src/ai/core/ai_base.hpp
author truelight
Wed, 14 Mar 2007 20:22:07 +0000
branchnoai
changeset 9387 4255a0a2d272
parent 9362 3aebc515446a
child 9388 032008c3f6e3
permissions -rw-r--r--
(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 */