_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
script_ai.cpp File Reference
#include "stratagus.h"
#include "ai.h"
#include "ai_local.h"
#include "interface.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"
#include "upgrade.h"

Functions

script_ai.cpp - The AI ccl functions.
static void AiHelperInsert (std::vector< std::vector< CUnitType * > > &table, unsigned int n, CUnitType &base)
 
static std::vector< CUnitType * > getUnitTypeFromString (const std::string &list)
 
static std::vector< CUnitType * > getReparableUnits ()
 
static std::vector< CUnitType * > getSupplyUnits ()
 
static std::vector< CUnitType * > getRefineryUnits ()
 
static void InitAiHelper (AiHelper &aiHelper)
 
static int CclDefineAiHelper (lua_State *l)
 
static CAiTypeGetAiTypesByName (const char *name)
 
static int CclDefineAi (lua_State *l)
 
static void InsertUnitTypeRequests (CUnitType *type, int count)
 
static AiRequestTypeFindInUnitTypeRequests (const CUnitType *type)
 
static int FindInUpgradeToRequests (const CUnitType *type)
 
static void InsertUpgradeToRequests (CUnitType *type)
 
static void InsertResearchRequests (CUpgrade *upgrade)
 
static int CclAiGetRace (lua_State *l)
 
static int CclAiGetSleepCycles (lua_State *l)
 
static int CclAiDebug (lua_State *l)
 
static int CclAiDebugPlayer (lua_State *l)
 
static int CclAiNeed (lua_State *l)
 
static int CclAiSet (lua_State *l)
 
static int CclAiWait (lua_State *l)
 
static int CclAiForce (lua_State *l)
 
static int CclAiForceRole (lua_State *l)
 
static int CclAiReleaseForce (lua_State *l)
 
static int CclAiCheckForce (lua_State *l)
 
static int CclAiWaitForce (lua_State *l)
 
static int CclAiAttackWithForce (lua_State *l)
 
static int CclAiWaitForces (lua_State *l)
 
static int CclAiAttackWithForces (lua_State *l)
 
static int CclAiSleep (lua_State *l)
 
static int CclAiResearch (lua_State *l)
 
static int CclAiUpgradeTo (lua_State *l)
 
static int CclAiPlayer (lua_State *l)
 
static int CclAiSetReserve (lua_State *l)
 
static int CclAiSetCollect (lua_State *l)
 
static int CclAiSetBuildDepots (lua_State *l)
 
static int CclAiDump (lua_State *l)
 
static void CclParseBuildQueue (lua_State *l, PlayerAi *ai, int offset)
 
static int CclDefineAiPlayer (lua_State *l)
 
void AiCclRegister ()
 Save the AI state. More...
 

Function Documentation

void AiCclRegister ( )

Save the AI state.

Register CCL features for unit-type.

static void AiHelperInsert ( std::vector< std::vector< CUnitType * > > &  table,
unsigned int  n,
CUnitType base 
)
static

Insert new unit-type element.

Parameters
tableTable with elements.
nIndex to insert new into table
baseBase type to insert into table.
static int CclAiAttackWithForce ( lua_State *  l)
static

Attack with force.

Parameters
lLua state.
static int CclAiAttackWithForces ( lua_State *  l)
static

Attack with forces.

Parameters
lLua state.
static int CclAiCheckForce ( lua_State *  l)
static

Check if a force ready.

Parameters
lLua state.
static int CclAiDebug ( lua_State *  l)
static

Set debugging flag of AI script

Parameters
lLua state
Returns
Number of return values
static int CclAiDebugPlayer ( lua_State *  l)
static

Activate AI debugging for the given player(s) Player can be a number for a specific player "self" for current human player (ai me) "none" to disable

Parameters
lLua State
Returns
Number of return values
static int CclAiDump ( lua_State *  l)
static

Dump some AI debug information.

Parameters
lLua state.
static int CclAiForce ( lua_State *  l)
static

Define a force, a groups of units.

Parameters
lLua state.
static int CclAiForceRole ( lua_State *  l)
static

Define the role of a force.

Parameters
lLua state.
static int CclAiGetRace ( lua_State *  l)
static

Get the race of the current AI player.

Parameters
lLua state.
static int CclAiGetSleepCycles ( lua_State *  l)
static

Get the number of cycles to sleep.

Parameters
lLua state
Returns
Number of return values
static int CclAiNeed ( lua_State *  l)
static

Need a unit.

Parameters
lLua state.
Returns
Number of return values
static int CclAiPlayer ( lua_State *  l)
static

Return the player of the running AI.

Parameters
lLua state.
Returns
Player number of the AI.
static int CclAiReleaseForce ( lua_State *  l)
static

Release force.

Parameters
lLua state.
static int CclAiResearch ( lua_State *  l)
static

Research an upgrade.

Parameters
lLua state.
static int CclAiSet ( lua_State *  l)
static

Set the number of units.

Parameters
lLua state
Returns
Number of return values
static int CclAiSetBuildDepots ( lua_State *  l)
static

Set AI player build.

Parameters
lLua state.
static int CclAiSetCollect ( lua_State *  l)
static

Set AI player resource collect percent.

Parameters
lLua state.
static int CclAiSetReserve ( lua_State *  l)
static

Set AI player resource reserve.

Parameters
lLua state.
Returns
Old resource vector
static int CclAiSleep ( lua_State *  l)
static

Sleep n cycles.

Parameters
lLua state.
static int CclAiUpgradeTo ( lua_State *  l)
static

Upgrade an unit to an new unit-type.

Parameters
lLua state.
static int CclAiWait ( lua_State *  l)
static

Wait for a unit.

Parameters
lLua State.
Returns
Number of return values
static int CclAiWaitForce ( lua_State *  l)
static

Wait for a force ready.

Parameters
lLua state.
static int CclAiWaitForces ( lua_State *  l)
static

Wait for a forces ready.

Parameters
lLua state.
static int CclDefineAi ( lua_State *  l)
static

Define an AI engine.

Parameters
lLua state.
Returns
FIXME: docu
static int CclDefineAiHelper ( lua_State *  l)
static

Define helper for AI.

Parameters
lLua state.
Todo:
FIXME: the first unit could be a list see ../doc/ccl/ai.html
static int CclDefineAiPlayer ( lua_State *  l)
static

Define an AI player.

Parameters
lLua state.
static void CclParseBuildQueue ( lua_State *  l,
PlayerAi ai,
int  offset 
)
static

Parse AiBuildQueue builing list

Parameters
lLua state.
aiPlayerAi pointer which should be filled with the data.
static AiRequestType* FindInUnitTypeRequests ( const CUnitType type)
static

Find unit-type in request table.

Parameters
typeUnit-type to be found.
static int FindInUpgradeToRequests ( const CUnitType type)
static

Find unit-type in upgrade-to table.

Parameters
typeUnit-type to be found.
static CAiType* GetAiTypesByName ( const char *  name)
static
static std::vector<CUnitType *> getRefineryUnits ( )
static

Get sorted list of unittype with CanHarvest not null.

Note
Better (MaxOnBoard / cost) first.
static std::vector<CUnitType *> getReparableUnits ( )
static

Get list of unittype which can be repared.

static std::vector<CUnitType *> getSupplyUnits ( )
static

Get sorted list of unittype with Supply not null.

Note
Better (supply / cost) first.
static std::vector<CUnitType *> getUnitTypeFromString ( const std::string &  list)
static

Transform list of unit separed with coma to a true list.

static void InitAiHelper ( AiHelper aiHelper)
static

Init AiHelper.

Parameters
aiHelpervariable to initialise.
Todo:
missing Equiv initialisation.
static void InsertResearchRequests ( CUpgrade upgrade)
static

Append unit-type to request table.

Parameters
upgradeUpgrade to be appended.
static void InsertUnitTypeRequests ( CUnitType type,
int  count 
)
static

Append unit-type to request table.

Parameters
typeUnit-type to be appended.
countHow many unit-types to build.
static void InsertUpgradeToRequests ( CUnitType type)
static

Append unit-type to request table.

Parameters
typeUnit-type to be appended.
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.