author | rubidium |
Sat, 14 Apr 2007 20:38:10 +0000 | |
branch | noai |
changeset 9594 | 5009a30f320a |
parent 9541 | 4bb34cea7fad |
child 9596 | 8af5a1399842 |
permissions | -rw-r--r-- |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
2 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
3 |
/** @file ai_settings.hpp everything to change AI settings */ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
4 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
5 |
#ifndef AI_SETTINGS_HPP |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
6 |
#define AI_SETTINGS_HPP |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
7 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
8 |
#include "ai_object.hpp" |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
9 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
10 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
11 |
* Class that handles all AI settings related functions. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
12 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
13 |
class AISettings : public AIObject { |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
14 |
public: |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
15 |
/** |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
16 |
* The name of the class, needed by several sub-processes. |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
17 |
*/ |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
18 |
static const char *GetClassName() { return "AISettings"; } |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
19 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
20 |
/** |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
21 |
* Change the minimum amount of time the AI should be put in suspend mode |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
22 |
* when you execute a command. Normally in SP this is 1, and in MP it is |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
23 |
* what ever delay the server has been programmed to delay commands |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
24 |
* (normally between 1 and 5). To give a more 'real' effect to your AI, |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
25 |
* you can control that number here. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
26 |
* @param ticks the minimum amount of ticks to wait. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
27 |
* @pre ticks should be positive. Too big values will influence performance of the AI. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
28 |
* @note If the number is lower then the MP setting, the MP setting wins. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
29 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
30 |
void SetCommandDelay(uint ticks); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
31 |
}; |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
32 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
33 |
#ifdef DEFINE_SQUIRREL_CLASS |
9524
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9520
diff
changeset
|
34 |
namespace SQConvert { |
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9520
diff
changeset
|
35 |
/* Allow AISettings to be used as Squirrel parameter */ |
9594
5009a30f320a
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
rubidium
parents:
9541
diff
changeset
|
36 |
template <> AISettings *GetParam(ForceType<AISettings *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISettings *)instance; } |
5009a30f320a
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
rubidium
parents:
9541
diff
changeset
|
37 |
template <> AISettings &GetParam(ForceType<AISettings &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISettings *)instance; } |
5009a30f320a
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
rubidium
parents:
9541
diff
changeset
|
38 |
template <> const AISettings *GetParam(ForceType<const AISettings *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISettings *)instance; } |
5009a30f320a
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
rubidium
parents:
9541
diff
changeset
|
39 |
template <> const AISettings &GetParam(ForceType<const AISettings &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISettings *)instance; } |
9524
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9520
diff
changeset
|
40 |
}; // namespace SQConvert |
283d23931bb4
(svn r9444) [NoAI] -Codechange: allow all API-class-instances to be used as parameters in Squirrel.
rubidium
parents:
9520
diff
changeset
|
41 |
|
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
42 |
void SQAISettingsRegister(Squirrel *engine) { |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
43 |
DefSQClass <AISettings> SQAISettings("AISettings"); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
44 |
SQAISettings.PreRegister(engine); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
45 |
SQAISettings.AddConstructor(engine); |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
9524
diff
changeset
|
46 |
|
9541
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
47 |
SQAISettings.DefSQStaticMethod(engine, &AISettings::GetClassName, "GetClassName", 1, "x"); |
9532
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9530
diff
changeset
|
48 |
|
9541
4bb34cea7fad
(svn r9463) [NoAI] -Codechange: update squirrel export script to generate the correct amount and type of parameters, so that can be checked.
rubidium
parents:
9532
diff
changeset
|
49 |
SQAISettings.DefSQMethod(engine, &AISettings::SetCommandDelay, "SetCommandDelay", 2, "xi"); |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
9524
diff
changeset
|
50 |
|
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
51 |
SQAISettings.PostRegister(engine); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
52 |
} |
9520
f7cf8bea10db
(svn r9440) [NoAI] -Codechange: use the identifier used for the #ifdef in the #endif not something that looks like the identifier.
rubidium
parents:
9452
diff
changeset
|
53 |
#endif /* DEFINE_SQUIRREL_CLASS */ |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
54 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
diff
changeset
|
55 |
#endif /* AI_SETTINGS_HPP */ |