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

src/ai/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_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 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 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.

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:
table Table with elements.
n Index to insert new into table
base Base type to insert into table.

static int CclAiAttackWithForce ( lua_State *  l  )  [static]

Attack with force.

Parameters:
l Lua state.

static int CclAiAttackWithForces ( lua_State *  l  )  [static]

Attack with forces.

Parameters:
l Lua state.

static int CclAiCheckForce ( lua_State *  l  )  [static]

Check if a force ready.

Parameters:
l Lua state.

static int CclAiDebug ( lua_State *  l  )  [static]

Set debugging flag of AI script

Parameters:
l Lua 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:
l Lua State
Returns:
Number of return values

static int CclAiDump ( lua_State *  l  )  [static]

Dump some AI debug informations.

Parameters:
l Lua state.

static int CclAiForce ( lua_State *  l  )  [static]

Define a force, a groups of units.

Parameters:
l Lua state.

static int CclAiForceRole ( lua_State *  l  )  [static]

Define the role of a force.

Parameters:
l Lua state.

static int CclAiGetRace ( lua_State *  l  )  [static]

Get the race of the current AI player.

Parameters:
l Lua state.

static int CclAiGetSleepCycles ( lua_State *  l  )  [static]

Get the number of cycles to sleep.

Parameters:
l Lua state
Returns:
Number of return values

static int CclAiNeed ( lua_State *  l  )  [static]

Need a unit.

Parameters:
l Lua state.
Returns:
Number of return values

static int CclAiPlayer ( lua_State *  l  )  [static]

Return the player of the running AI.

Parameters:
l Lua state.
Returns:
Player number of the AI.

static int CclAiResearch ( lua_State *  l  )  [static]

Research an upgrade.

Parameters:
l Lua state.

static int CclAiSet ( lua_State *  l  )  [static]

Set the number of units.

Parameters:
l Lua state
Returns:
Number of return values

static int CclAiSetCollect ( lua_State *  l  )  [static]

Set AI player resource collect percent.

Parameters:
l Lua state.

static int CclAiSetReserve ( lua_State *  l  )  [static]

Set AI player resource reserve.

Parameters:
l Lua state.
Returns:
Old resource vector

static int CclAiSleep ( lua_State *  l  )  [static]

Sleep n cycles.

Parameters:
l Lua state.

static int CclAiUpgradeTo ( lua_State *  l  )  [static]

Upgrade an unit to an new unit-type.

Parameters:
l Lua state.

static int CclAiWait ( lua_State *  l  )  [static]

Wait for a unit.

Parameters:
l Lua State.
Returns:
Number of return values

static int CclAiWaitForce ( lua_State *  l  )  [static]

Wait for a force ready.

Parameters:
l Lua state.

static int CclAiWaitForces ( lua_State *  l  )  [static]

Wait for a forces ready.

Parameters:
l Lua state.

static int CclDefineAi ( lua_State *  l  )  [static]

Define an AI engine.

Parameters:
l Lua state.
Returns:
FIXME: docu

static int CclDefineAiHelper ( lua_State *  l  )  [static]

Define helper for AI.

Parameters:
l Lua 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:
l Lua state.

static void CclParseBuildQueue ( lua_State *  l,
PlayerAi ai,
int  offset 
) [static]

Parse AiBuildQueue builing list

Parameters:
l Lua state.
ai PlayerAi pointer which should be filled with the data.

static AiRequestType* FindInUnitTypeRequests ( const CUnitType type  )  [static]

Find unit-type in request table.

Parameters:
type Unit-type to be found.

static int FindInUpgradeToRequests ( const CUnitType type  )  [static]

Find unit-type in upgrade-to table.

Parameters:
type Unit-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:
aiHelper variable to initialise.
Todo:
missing Equiv initialisation.

static void InsertResearchRequests ( CUpgrade upgrade  )  [static]

Append unit-type to request table.

Parameters:
upgrade Upgrade to be appended.

static void InsertUnitTypeRequests ( CUnitType type,
int  count 
) [static]

Append unit-type to request table.

Parameters:
type Unit-type to be appended.
count How many unit-types to build.

static void InsertUpgradeToRequests ( CUnitType type  )  [static]

Append unit-type to request table.

Parameters:
type Unit-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.