____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

script_ai.cpp File Reference

The AI ccl functions. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "unit_manager.h"
#include "unittype.h"
#include "upgrade.h"
#include "script.h"
#include "ai.h"
#include "pathfinder.h"
#include "ai_local.h"
#include "player.h"
#include "interface.h"

Go to the source code of this file.

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 void InitAiHelper (AiHelper &aiHelper)
static int CclDefineAiHelper (lua_State *l)
static int CclDefineAi (lua_State *l)
static void InsertUnitTypeRequests (CUnitType *type, int count)
static AiRequestTypeFindInUnitTypeRequests (const CUnitType *type)
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 CclAiSleep (lua_State *l)
static int CclAiPlayer (lua_State *l)
static int CclAiDump (lua_State *l)
static int DefaultResourceNumber (const char *name)
static int CclDefineAiPlayer (lua_State *l)
void AiCclRegister (void)
 Register ccl features.


Detailed Description

The AI ccl functions.

Definition in file script_ai.cpp.


Function Documentation

void AiCclRegister ( void   ) 

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.

Definition at line 58 of file script_ai.cpp.

References Assert.

Referenced by CclDefineAiHelper(), and InitAiHelper().

static int CclAiAttackWithForce ( lua_State *  l  )  [static]

Attack with force.

Parameters:
l Lua state.

Definition at line 699 of file script_ai.cpp.

References _C_, AI_MAX_FORCES, AiAttackWithForce(), LuaCheckArgs, LuaError, and LuaToNumber().

Referenced by AiCclRegister().

static int CclAiCheckForce ( lua_State *  l  )  [static]

Check if a force ready.

Parameters:
l Lua state.

Definition at line 648 of file script_ai.cpp.

References AI_MAX_FORCES, AiPlayer, AiForce::Completed, PlayerAi::Force, LuaCheckArgs, and LuaToNumber().

Referenced by AiCclRegister().

static int CclAiDebug ( lua_State *  l  )  [static]

Set debugging flag of AI script

Parameters:
l Lua state
Returns:
Number of return values

Definition at line 378 of file script_ai.cpp.

References AiPlayer, LuaCheckArgs, LuaToBoolean(), and PlayerAi::ScriptDebug.

Referenced by AiCclRegister().

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

Definition at line 395 of file script_ai.cpp.

References CPlayer::Index, LuaToNumber(), LuaToString(), NumPlayers, Players, and ThisPlayer.

Referenced by AiCclRegister().

static int CclAiDump ( lua_State *  l  )  [static]

static int CclAiForce ( lua_State *  l  )  [static]

static int CclAiForceRole ( lua_State *  l  )  [static]

Define the role of a force.

Parameters:
l Lua state.

Definition at line 620 of file script_ai.cpp.

References _C_, AI_MAX_FORCES, AiForceRoleAttack, AiForceRoleDefend, AiPlayer, PlayerAi::Force, LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), and AiForce::Role.

Referenced by AiCclRegister().

static int CclAiGetSleepCycles ( lua_State *  l  )  [static]

Get the number of cycles to sleep.

Parameters:
l Lua state
Returns:
Number of return values

Definition at line 362 of file script_ai.cpp.

References AiSleepCycles, and LuaCheckArgs.

Referenced by AiCclRegister().

static int CclAiNeed ( lua_State *  l  )  [static]

Need a unit.

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

Definition at line 443 of file script_ai.cpp.

References CclGetUnitType(), InsertUnitTypeRequests(), and LuaCheckArgs.

Referenced by AiCclRegister().

static int CclAiPlayer ( lua_State *  l  )  [static]

Return the player of the running AI.

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

Definition at line 747 of file script_ai.cpp.

References AiPlayer, CPlayer::Index, LuaCheckArgs, and PlayerAi::Player.

Referenced by AiCclRegister().

static int CclAiSet ( lua_State *  l  )  [static]

Set the number of units.

Parameters:
l Lua state
Returns:
Number of return values

Definition at line 459 of file script_ai.cpp.

References CclGetUnitType(), AiRequestType::Count, FindInUnitTypeRequests(), InsertUnitTypeRequests(), LuaCheckArgs, and LuaToNumber().

Referenced by AiCclRegister().

static int CclAiSleep ( lua_State *  l  )  [static]

Sleep n cycles.

Parameters:
l Lua state.

Definition at line 720 of file script_ai.cpp.

References AiPlayer, GameCycle, LuaCheckArgs, LuaToNumber(), and PlayerAi::SleepCycles.

Referenced by AiCclRegister().

static int CclAiWait ( lua_State *  l  )  [static]

Wait for a unit.

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

Definition at line 486 of file script_ai.cpp.

References _C_, AiHelpers, AiPlayer, CclGetUnitType(), AiRequestType::Count, DebugPrint, AiHelper::Equiv, FindInUnitTypeRequests(), CUnitType::Ident, int(), LuaCheckArgs, PlayerAi::Player, CUnitType::Slot, and CPlayer::UnitTypesCount.

Referenced by AiCclRegister().

static int CclAiWaitForce ( lua_State *  l  )  [static]

Wait for a force ready.

Parameters:
l Lua state.

Definition at line 670 of file script_ai.cpp.

References _C_, AI_MAX_FORCES, AiCleanForces(), AiPlayer, Assert, AiForce::Completed, PlayerAi::Force, LuaCheckArgs, LuaError, and LuaToNumber().

Referenced by AiCclRegister().

static int CclDefineAi ( lua_State *  l  )  [static]

Define an AI engine.

Parameters:
l Lua state.

Definition at line 258 of file script_ai.cpp.

References _C_, AiTypes, CAiType::Class, DebugPrint, int(), LuaCheckArgs, LuaError, LuaToString(), CAiType::Name, and CAiType::Script.

Referenced by AiCclRegister().

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

Definition at line 176 of file script_ai.cpp.

References _C_, AiHelperInsert(), AiHelpers, AiNewUnitTypeEquiv(), AiHelper::Equiv, InitAiHelper(), LuaError, LuaToString(), CUnitType::Slot, and UnitTypeByIdent().

Referenced by AiCclRegister().

static int CclDefineAiPlayer ( lua_State *  l  )  [static]

static int DefaultResourceNumber ( const char *  name  )  [static]

Get the default resource number

Parameters:
name Resource name.
Returns:
The number of the resource in DefaultResourceNames

Definition at line 820 of file script_ai.cpp.

References Assert, DefaultResourceNames, and MaxCosts.

Referenced by CclDefineAiPlayer().

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

Find unit-type in request table.

Parameters:
type Unit-type to be found.

Definition at line 339 of file script_ai.cpp.

References AiPlayer, and PlayerAi::UnitTypeRequests.

Referenced by CclAiSet(), and CclAiWait().

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

Get list of unittype which can be repared.

Definition at line 106 of file script_ai.cpp.

References CUnitType::RepairHP, and UnitTypes.

Referenced by InitAiHelper().

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

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

Definition at line 80 of file script_ai.cpp.

References Assert, UnitTypeByIdent(), and UnitTypes.

Referenced by InitAiHelper().

static void InitAiHelper ( AiHelper aiHelper  )  [static]

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.

Definition at line 324 of file script_ai.cpp.

References AiPlayer, AiRequestType::Count, AiRequestType::Type, and PlayerAi::UnitTypeRequests.

Referenced by CclAiNeed(), and CclAiSet().


Generated on Sat Feb 21 00:28:18 2009 for Bos Wars by  doxygen 1.5.6