src/ai/api/ai_settings.hpp
author truelight
Sun, 25 Mar 2007 16:10:40 +0000
branchnoai
changeset 9529 5f26f4bc574b
parent 9526 a4ad60ba03be
child 9530 5b93bc87cc5e
permissions -rw-r--r--
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
-Add: added GetClassName() to all API functions (needed to do the thing above ;))
/* $Id$ */

/** @file ai_settings.hpp everything to change AI settings */

#ifndef AI_SETTINGS_HPP
#define AI_SETTINGS_HPP

#include "ai_object.hpp"

/**
 * Class that handles all AI settings related functions.
 */
class AISettings : public AIObject {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AISettings"; }

	/**
	 * Change the minimum amount of time the AI should be put in suspend mode
	 *   when you execute a command. Normally in SP this is 1, and in MP it is
	 *   what ever delay the server has been programmed to delay commands
	 *   (normally between 1 and 5). To give a more 'real' effect to your AI,
	 *   you can control that number here.
	 * @param ticks the minimum amount of ticks to wait.
	 * @pre ticks should be positive. Too big values will influence performance of the AI.
	 * @note If the number is lower then the MP setting, the MP setting wins.
	 */
	void SetCommandDelay(uint ticks);
};

#ifdef DEFINE_SQUIRREL_CLASS
namespace SQConvert {
	/* Allow AISettings to be used as Squirrel parameter */
	template <> AISettings *GetParam(ForceType<AISettings *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISettings *)instance; }
}; // namespace SQConvert

void SQAISettingsRegister(Squirrel *engine) {
	DefSQClass <AISettings> SQAISettings("AISettings");
	SQAISettings.PreRegister(engine);
	SQAISettings.AddConstructor(engine);

	SQAISettings.DefSQFunction(engine, &AISettings::SetCommandDelay, "SetCommandDelay");

	SQAISettings.PostRegister(engine);
}
#endif /* DEFINE_SQUIRREL_CLASS */

#endif /* AI_SETTINGS_HPP */