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

script_ai.cpp File Reference
#include "network.h"
#include "net_lowlevel.h"
#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 CclAiPendingBuildCount (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)
 
static int CclAiProcessorSetup (lua_State *l)
 
static CTCPSocketAiProcessorSendState (lua_State *l, char prefix)
 
static int CclAiProcessorStep (lua_State *l)
 
static int CclAiProcessorEnd (lua_State *l)
 
void AiCclRegister ()
 Save the AI state. More...
 

Function Documentation

◆ AiCclRegister()

void AiCclRegister ( )

Save the AI state.

Register CCL features for unit-type.

◆ AiHelperInsert()

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.

◆ AiProcessorSendState()

static CTCPSocket* AiProcessorSendState ( lua_State *  l,
char  prefix 
)
static

◆ CclAiAttackWithForce()

static int CclAiAttackWithForce ( lua_State *  l)
static

Description

Attack with one single force.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiForce(1,{"unit-footman", 3}) end, function() return AiWaitForce(1) end, – Attack with Force 1 function() return AiAttackWithForce(1) end,
function() return AiForce(2,{"unit-footman",5}) end, function() return AiWaitForce(2) end, – Attack with Force 2 function() return AiAttackWithForce(2) end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiAttackWithForces()

static int CclAiAttackWithForces ( lua_State *  l)
static

Description

Attack with forces.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiNeed("unit-elven-lumber-mill") end, function() return AiWait("unit-elven-lumber-mill") end, function() return AiForce(1,{"unit-footman", 2}) end, function() return AiForce(2,{"unit-archer",1}) end, function() return AiForce(3,{"unit-archer",1,"unit-footman",3}) end, – Wait all three forces to be ready function() return AiWaitForces({1,2,3}) end, – Attack with all three forces function() return AiAttackWithForces({1,2,3}) end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiCheckForce()

static int CclAiCheckForce ( lua_State *  l)
static

Check if a force ready.

Parameters
lLua state.

◆ CclAiDebug()

static int CclAiDebug ( lua_State *  l)
static

Set debugging flag of AI script

Parameters
lLua state
Returns
Number of return values

◆ CclAiDebugPlayer()

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

◆ CclAiDump()

static int CclAiDump ( lua_State *  l)
static

Description

Dump some AI debug information.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(3600) end, – Get the information from all the A.I players function() return AiDump() end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiWait("unit-peasant") end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiForce()

static int CclAiForce ( lua_State *  l)
static

Description

Define a force, a groups of units.

Parameters
lLua state.

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the instructions forever. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, – Tell to the A.I that it needs a Town Hall. function() return AiNeed("unit-town-hall") end, – Wait until the Town Hall has been built. function() return AiWait("unit-town-hall") end, – Tell to the A.I that it needs 4 peasants function() return AiSet("unit-peasant",4) end, – Tell to the A.I that it needs a Barracks. function() return AiNeed("unit-human-barracks") end, – Tell to the A.I that it needs a Lumbermill. function() return AiNeed("unit-elven-lumber-mill") end, – Wait until the Barracks has been built. function() return AiWait("unit-human-barracks") end, – Wait until the Lumbermill has been built. function() return AiWait("unit-elven-lumber-mill") end, – Specify the force number 1 made only of 3 footmen function() return AiForce(1,{"unit-footman", 3}) end, – Specify the force number 2 made only of 2 archers function() return AiForce(2,{"unit-archer", 2}) end, – Specify the force number 3 made of 2 footmen and 1 archer function() return AiForce(3,{"unit-footman", 2, "unit-archer", 1}) end, – Wait for all three forces function() return AiWaitForce(1) end, function() return AiWaitForce(2) end, function() return AiWaitForce(3) end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiForceRole()

static int CclAiForceRole ( lua_State *  l)
static

Description

Define the role of a force.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiNeed("unit-elven-lumber-mill") end, – Force 1 has the role of attacker function() return AiForceRole(1,"<u>attack</u>") end, – Force 2 has the role of defender function() return AiForceRole(2,"<u>defend</u>") end, function() return AiForce(1,{"unit-footman", 3}) end, function() return AiForce(2,{"unit-archer", 2}) end, function() return AiWaitForce(1) end, function() return AiWaitForce(2) end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiGetRace()

static int CclAiGetRace ( lua_State *  l)
static

Get the race of the current AI player.

Parameters
lLua state.

◆ CclAiGetSleepCycles()

static int CclAiGetSleepCycles ( lua_State *  l)
static

Description

Get the number of cycles to sleep.

Parameters
lLua state
Returns
Number of return values

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the instructions forever. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { – Get the number of cycles to sleep. function() return AiSleep(AiGetSleepCycles()) end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiNeed()

static int CclAiNeed ( lua_State *  l)
static

Description

Need a unit.

Parameters
lLua state.
Returns
Number of return values

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the instructions forever. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, – Tell to the A.I that it needs a Town Hall. function() return AiNeed("unit-town-hall") end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiPendingBuildCount()

static int CclAiPendingBuildCount ( lua_State *  l)
static

Get number of active build requests for a unit type.

Parameters
lLua State.
Returns
Number of return values

◆ CclAiPlayer()

static int CclAiPlayer ( lua_State *  l)
static

Return the player of the running AI.

Parameters
lLua state.
Returns
Player number of the AI.

◆ CclAiProcessorEnd()

static int CclAiProcessorEnd ( lua_State *  l)
static

◆ CclAiProcessorSetup()

static int CclAiProcessorSetup ( lua_State *  l)
static

AiProcessorSetup(host, port, number_of_state_variables, number_of_actions)

Connect to an AI agent running at host:port, that will consume number_of_state_variables every step and select one of number_of_actions.

◆ CclAiProcessorStep()

static int CclAiProcessorStep ( lua_State *  l)
static

AiProcessorStep(handle, reward_since_last_call, table_of_state_variables)

◆ CclAiReleaseForce()

static int CclAiReleaseForce ( lua_State *  l)
static

Release force.

Parameters
lLua state.

◆ CclAiResearch()

static int CclAiResearch ( lua_State *  l)
static

Description

Research an upgrade.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { – Get the number of cycles to sleep function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiNeed("unit-elven-lumber-mill") end, function() return AiWait("unit-elven-lumber-mill") end, function() return AiForce(1,{"unit-footman", 1, "unit-archer", 2}) end, function() return AiWaitForce(1) end, – Upgrade the archers arrow. function() return AiResearch("upgrade-arrow1") end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiSet()

static int CclAiSet ( lua_State *  l)
static

Description

Set the number of units.

Parameters
lLua state
Returns
Number of return values

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the instructions forever. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, – Tell to the A.I that it needs a Town Hall. function() return AiNeed("unit-town-hall") end, – Wait until the town-hall has been built. function() return AiWait("unit-town-hall") end, – Tell to the A.I that it needs 4 peasants function() return AiSet("unit-peasant",4) end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiSetBuildDepots()

static int CclAiSetBuildDepots ( lua_State *  l)
static

Set AI player build.

Parameters
lLua state.

◆ CclAiSetCollect()

static int CclAiSetCollect ( lua_State *  l)
static

Description

Set AI player resource collect percent.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, – The peasants will focus only on gathering gold function() return AiSetCollect({0,100,0,0,0,0,0}) end, function() return AiSet("unit-peasant",4) end, function() return AiWait("unit-peasant") end, function() return AiSleep(1800) end, – The peasants will now focus 50% on gathering gold and 50% on gathering lumber function() return AiSetCollect({0,50,50,0,0,0,0}) end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiSetReserve()

static int CclAiSetReserve ( lua_State *  l)
static

Set AI player resource reserve.

Parameters
lLua state.
Returns
Old resource vector

◆ CclAiSleep()

static int CclAiSleep ( lua_State *  l)
static

Description

Sleep for n cycles.

Parameters
lLua state.

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { – Get the number of cycles to sleep function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, – Sleep for 1 in game minute function() return AiSleep(1800) end, function() return AiNeed("unit-human-blacksmith") end, function() return AiWait("unit-human-blacksmith") end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiUpgradeTo()

static int CclAiUpgradeTo ( lua_State *  l)
static

Description

Upgrade an unit to an new unit-type.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiNeed("unit-elven-lumber-mill") end, function() return AiWait("unit-elven-lumber-mill") end, function() return AiSleep(1800) end, – Upgrade the Town Hall to Keep function() return AiUpgradeTo("unit-keep") end, function() return AiWait("unit-keep") end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiWait()

static int CclAiWait ( lua_State *  l)
static

Description

Wait for a unit.

Parameters
lLua State.
Returns
Number of return values

Example:

local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the instructions forever. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, – Tell to the A.I that it needs a Town Hall. function() return AiNeed("unit-town-hall") end, – Wait until the Town Hall has been built. function() return AiWait("unit-town-hall") end, – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiWaitForce()

static int CclAiWaitForce ( lua_State *  l)
static

Description

Wait for a force ready.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiForce(1,{"unit-footman", 3}) end, – Wait until force 1 is completed function() return AiWaitForce(1) end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclAiWaitForces()

static int CclAiWaitForces ( lua_State *  l)
static

Description

Wait for a forces ready.

Parameters
lLua state.

Example:

local simple_ai_loop = { function() return AiSleep(9000) end, function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
local simple_ai = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed("unit-town-hall") end, function() return AiWait("unit-town-hall") end, function() return AiSet("unit-peasant",4) end, function() return AiNeed("unit-human-barracks") end, function() return AiWait("unit-human-barracks") end, function() return AiNeed("unit-elven-lumber-mill") end, function() return AiWait("unit-elven-lumber-mill") end, function() return AiForce(1,{"unit-footman", 2}) end, function() return AiForce(2,{"unit-archer",1}) end, function() return AiForce(3,{"unit-archer",1,"unit-footman",3}) end, – Wait all three forces to be ready function() return AiWaitForces({1,2,3}) end, function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclDefineAi()

static int CclDefineAi ( lua_State *  l)
static

Description

Define an AI engine.

Parameters
lLua state.
Returns
FIXME: docu

Example:

– Those instructions will be executed forever local simple_ai_loop = { – Sleep for 5 in game minutes function() return AiSleep(9000) end, – Repeat the functions from start. function() stratagus.gameData.AIState.loop_index[1 + AiPlayer()] = 0; return false; end, }
– The initial instructions the A.I has to execute local simple_ai = { function() return AiSleep(1800) end, – Sleep for 1 in game minute function() return AiNeed("unit-town-hall") end, – One Town Hall is needed function() return AiWait("unit-town-hall") end, – Wait until the Town Hall is completed function() return AiSet("unit-peasant", 4) end, – Make 4 peasants – Basic buildings function() return AiSet("unit-farm", 4) end, – Make 4 farms function() return AiWait("unit-farm") end, – Wait until all 4 farms are build. function() return AiNeed("unit-human-barracks") end, – Need a Barracks function() return AiWait("unit-human-barracks") end, – Wait until the Barracks has been built – Defense force for the base function() return AiForce(1, {"unit-footman", 3}) end, – Make a force of 3 footmen function() return AiWaitForce(1) end, – Wait until the 3 footmen are trained function() return AiForceRole(1,"defend") end, – Make this force as a defense force – Execute the instructions in simple_ai_loop function() return AiLoop(simple_ai_loop, stratagus.gameData.AIState.loop_index) end, }
– function that calls the instructions in simple_ai inside DefineAi function custom_ai() return AiLoop(simple_ai,stratagus.gameData.AIState.index) end – Make an A.I for the human race that calls the function custom_ai DefineAi("example_ai","human","class_ai",custom_ai)

◆ CclDefineAiHelper()

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

◆ CclDefineAiPlayer()

static int CclDefineAiPlayer ( lua_State *  l)
static

Define an AI player.

Parameters
lLua state.

◆ CclParseBuildQueue()

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.

◆ FindInUnitTypeRequests()

static AiRequestType* FindInUnitTypeRequests ( const CUnitType type)
static

Find unit-type in request table.

Parameters
typeUnit-type to be found.

◆ FindInUpgradeToRequests()

static int FindInUpgradeToRequests ( const CUnitType type)
static

Find unit-type in upgrade-to table.

Parameters
typeUnit-type to be found.

◆ GetAiTypesByName()

static CAiType* GetAiTypesByName ( const char *  name)
static

◆ getRefineryUnits()

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

Get sorted list of unittype with CanHarvest not null.

Note
Better (MaxOnBoard / cost) first.

◆ getReparableUnits()

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

Get list of unittype which can be repared.

◆ getSupplyUnits()

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

Get sorted list of unittype with Supply not null.

Note
Better (supply / cost) first.

◆ getUnitTypeFromString()

static std::vector<CUnitType *> getUnitTypeFromString ( const std::string &  list)
static

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

◆ InitAiHelper()

static void InitAiHelper ( AiHelper aiHelper)
static

Init AiHelper.

Parameters
aiHelpervariable to initialise.
Todo:
missing Equiv initialisation.

◆ InsertResearchRequests()

static void InsertResearchRequests ( CUpgrade upgrade)
static

Append unit-type to request table.

Parameters
upgradeUpgrade to be appended.

◆ InsertUnitTypeRequests()

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.

◆ InsertUpgradeToRequests()

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.