(svn r9252) [NoAI] -Codechange: rename Random and RandomRange to a non-conflicting name, especially because the sematics differ with respect to the core Random and RandomRange.
/* $Id$ */
/** @file ai_base.hpp declaration of class for AIBase class */
#ifndef AI_BASE_HPP
#define AI_BASE_HPP
#include "ai_object.hpp"
/**
* Implementation of some basic function
*
* @note The random functions are not called Random and RandomRange, because
* when including them the RANDOM_DEBUG stuff messes with their names.
* However, because in MP we cannot use Random because that will cause
* desyncs (AIs are ran locally, not on all clients). This means that
* we use InteractiveRandom in MP, thus the whole random debugging is
* pointless for the AIs. Therefor the random functions are called
* differently.
*/
class AIBase : public AIObject {
public:
/**
* Get a random value.
* @return A random value between 0 and MAX(uint32)
*/
uint32 Rand();
/**
* Get a random value in a range.
* @param max The maximum value it will return.
* @return A random value between 0 .. max.
*/
uint RandRange(uint max);
/**
* 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 DEFINE_SQUIRREL_CLASS
void SQAIBaseRegister(Squirrel *engine) {
DefSQClass <AIBase> SQAIBase("AIBase");
SQAIBase.PreRegister(engine);
SQAIBase.AddConstructor(engine);
SQAIBase.DefSQFunction(engine, &AIBase::Rand, "Rand");
SQAIBase.DefSQFunction(engine, &AIBase::RandRange, "RandRange");
SQAIBase.DefSQFunction(engine, &AIBase::Chance, "Chance");
SQAIBase.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */
#endif /* AI_BASE_HPP */