44 * @return true if the chance worked out. |
44 * @return true if the chance worked out. |
45 */ |
45 */ |
46 bool Chance(uint out, uint max); |
46 bool Chance(uint out, uint max); |
47 }; |
47 }; |
48 |
48 |
49 #ifdef DEFINE_SQUIRREL_CLASS |
|
50 namespace SQConvert { |
|
51 /* Allow AIBase to be used as Squirrel parameter */ |
|
52 template <> AIBase *GetParam(ForceType<AIBase *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIBase *)instance; } |
|
53 template <> AIBase &GetParam(ForceType<AIBase &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBase *)instance; } |
|
54 template <> const AIBase *GetParam(ForceType<const AIBase *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIBase *)instance; } |
|
55 template <> const AIBase &GetParam(ForceType<const AIBase &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIBase *)instance; } |
|
56 }; // namespace SQConvert |
|
57 |
|
58 void SQAIBaseRegister(Squirrel *engine) { |
|
59 DefSQClass <AIBase> SQAIBase("AIBase"); |
|
60 SQAIBase.PreRegister(engine); |
|
61 SQAIBase.AddConstructor(engine); |
|
62 |
|
63 SQAIBase.DefSQStaticMethod(engine, &AIBase::GetClassName, "GetClassName", 1, "x"); |
|
64 |
|
65 SQAIBase.DefSQMethod(engine, &AIBase::Rand, "Rand", 1, "x"); |
|
66 SQAIBase.DefSQMethod(engine, &AIBase::RandRange, "RandRange", 2, "xi"); |
|
67 SQAIBase.DefSQMethod(engine, &AIBase::Chance, "Chance", 3, "xii"); |
|
68 |
|
69 SQAIBase.PostRegister(engine); |
|
70 } |
|
71 #endif /* DEFINE_SQUIRREL_CLASS */ |
|
72 |
|
73 #endif /* AI_BASE_HPP */ |
49 #endif /* AI_BASE_HPP */ |