____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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"
#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 AiRequestType * | FindInUnitTypeRequests (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. | |
Definition in file script_ai.cpp.
| void AiCclRegister | ( | void | ) |
Register ccl features.
Register CCL features for unit-type.
Definition at line 1169 of file script_ai.cpp.
References CclAiAttackWithForce(), CclAiCheckForce(), CclAiDebug(), CclAiDebugPlayer(), CclAiDump(), CclAiForce(), CclAiForceRole(), CclAiGetSleepCycles(), CclAiNeed(), CclAiPlayer(), CclAiSet(), CclAiSleep(), CclAiWait(), CclAiWaitForce(), CclDefineAi(), CclDefineAiHelper(), CclDefineAiPlayer(), and Lua.
Referenced by InitCcl().
| static void AiHelperInsert | ( | std::vector< std::vector< CUnitType * > > & | table, | |
| unsigned int | n, | |||
| CUnitType * | base | |||
| ) | [static] |
Insert new unit-type element.
| 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.
| 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.
| 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
| l | Lua state |
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
| l | Lua State |
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] |
Dump some AI debug informations.
| l | Lua state. |
Definition at line 759 of file script_ai.cpp.
References AI_MAX_FORCES, AiPlayer, AiForce::Attacking, AiForce::Completed, PlayerAi::Force, CUnitType::Ident, CPlayer::Index, int(), LuaCheckArgs, AiBuildQueue::Made, PlayerAi::Player, PlayerAi::Script, AiUnitType::Type, AiBuildQueue::Type, PlayerAi::UnitTypeBuilt, PlayerAi::UnitTypeRequests, AiForce::UnitTypes, AiUnitType::Want, and AiBuildQueue::Want.
Referenced by AiCclRegister().
| static int CclAiForce | ( | lua_State * | l | ) | [static] |
Define a force, a groups of units.
| l | Lua state. |
Definition at line 546 of file script_ai.cpp.
References _C_, AI_MAX_FORCES, AiAssignFreeUnitsToForce(), AiPlayer, CclGetUnitType(), PlayerAi::Force, int(), LuaCheckArgs, LuaError, LuaToNumber(), CUnitType::Slot, AiUnitType::Type, UnitTypeEquivs, AiForce::UnitTypes, UnitTypes, and AiUnitType::Want.
Referenced by AiCclRegister().
| static int CclAiForceRole | ( | lua_State * | l | ) | [static] |
Define the role of a force.
| 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.
| l | Lua state |
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.
| l | Lua state. |
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.
| l | Lua state. |
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.
| l | Lua state |
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.
| 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.
| l | Lua State. |
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.
| 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.
| 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.
| l | Lua state. |
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] |
Define an AI player.
| l | Lua state. |
Definition at line 839 of file script_ai.cpp.
References _C_, CPlayer::Ai, AiForceRoleAttack, AiForceRoleDefend, PlayerAi::AiType, AiTypes, Assert, AiForce::Attacking, CclParseOrder(), AiForce::Completed, DebugPrint, DefaultResourceNumber(), AiForce::Defending, PlayerAi::FirstExplorationRequest, PlayerAi::Force, AiForce::GoalX, AiForce::GoalY, int(), PlayerAi::LastCanNotMoveGameCycle, PlayerAi::LastExplorationGameCycle, PlayerAi::LastRepairBuilding, LuaError, LuaToBoolean(), LuaToNumber(), LuaToString(), AiBuildQueue::Made, AiExplorationRequest::Mask, AiForce::MustTransport, CAiType::Name, PlayerAi::Needed, PlayerAi::NeededMask, AiTransportRequest::Order, PlayerAi::Player, PlayerMax, Players, AiForce::Role, CAiType::Script, PlayerAi::Script, PlayerAi::ScriptDebug, PlayerAi::SleepCycles, AiForce::State, PlayerAi::TransportRequests, PlayerAi::TriedRepairWorkers, AiBuildQueue::Type, AiUnitType::Type, AiTransportRequest::Unit, AiForce::Units, UnitSlots, PlayerAi::UnitTypeBuilt, UnitTypeByIdent(), PlayerAi::UnitTypeRequests, AiForce::UnitTypes, AiBuildQueue::Want, AiUnitType::Want, AiExplorationRequest::X, AiExplorationRequest::Y, and y.
Referenced by AiCclRegister().
| static int DefaultResourceNumber | ( | const char * | name | ) | [static] |
Get the default resource number
| name | Resource name. |
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.
| 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] |
Init AiHelper.
| aiHelper | variable to initialise. |
Definition at line 127 of file script_ai.cpp.
References ButtonAction::Action, AiHelperInsert(), AiHelper::Build, ButtonBuild, ButtonRepair, ButtonTrain, getReparableUnits(), getUnitTypeFromString(), int(), AiHelper::Repair, CUnitType::Slot, AiHelper::Train, UnitButtonTable, ButtonAction::UnitMask, UnitTypeByIdent(), and ButtonAction::ValueStr.
Referenced by CclDefineAiHelper().
| static void InsertUnitTypeRequests | ( | CUnitType * | type, | |
| int | count | |||
| ) | [static] |
Append unit-type to request table.
| 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().
1.5.6