(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
-Update: SQNoAI does now exactly what NoAI does
/* $Id$ */
/** @file declaration of class for AIBase class */
#ifndef AI_BASE_HPP
#define AI_BASE_HPP
#include "ai_object.hpp"
class AIBase: public AIObject {
public:
/**
* Get a random value.
* @return A random value between 0 and MAX(uint32)
*/
#if defined(RANDOM_DEBUG)
uint32 DoRandom(int line, const char *file);
#else
uint32 Random();
#endif
/**
* Get a random value in a range.
* @param max The maximum value it will return.
* @return A random value between 0 .. max.
*/
#if defined(RANDOM_DEBUG)
uint DoRandomRange(uint max, int line, const char *file);
#else
uint RandomRange(uint max);
#endif
/**
* Take a chance of 'out' out of 'max'.
* @param out How many times is should return true.
* @param max What the max value of 'out' can be.
* @return True if the chance worked out.
*/
bool Chance(uint out, uint max);
};
#ifdef SQUIRREL_CLASS
void SQAIBaseRegister(HSQUIRRELVM vm) {
DefSQClass <AIBase> SQAIBase("AIBase");
SQAIBase.PreRegister(vm);
SQAIBase.DefSQFunction(vm, &AIBase::Random, "Random");
SQAIBase.DefSQFunction(vm, &AIBase::RandomRange, "RandomRange");
SQAIBase.DefSQFunction(vm, &AIBase::Chance, "Chance");
SQAIBase.PostRegister(vm);
}
#endif /* SQUIRREL_CLASS */
#endif /* AI_BASE_HPP */