____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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.h"
#include "unit_manager.h"
#include "unit_cache.h"
#include "unittype.h"
#include "animation.h"
#include "upgrade.h"
#include "player.h"
#include "script.h"
#include "spells.h"
#include "pathfinder.h"
#include "map.h"
#include "trigger.h"
#include "actions.h"
#include "construct.h"
Go to the source code of this file.
Functions | |
| unsigned | CclGetResourceByName (lua_State *l) |
| < Get resource by name | |
| static int | CclSetBuildingCapture (lua_State *l) |
| static CUnit * | CclGetUnit (lua_State *l) |
| void | CclParseOrder (lua_State *l, COrder *order) |
| < Parse order | |
| static void | CclParseOrders (lua_State *l, CUnit *unit) |
| static void | CclParseBuilt (lua_State *l, CUnit *unit) |
| static void | CclParseTrain (lua_State *l, CUnit *unit) |
| static void | CclParseHarvest (lua_State *l, CUnit *unit) |
| static void | CclParseMove (lua_State *l, CUnit *unit) |
| static int | CclUnit (lua_State *l) |
| static int | CclMoveUnit (lua_State *l) |
| static int | CclCreateUnit (lua_State *l) |
| static int | CclSetResourcesHeld (lua_State *l) |
| static int | CclOrderUnit (lua_State *l) |
| static int | CclKillUnit (lua_State *l) |
| static int | CclKillUnitAt (lua_State *l) |
| static int | CclGetUnits (lua_State *l) |
| static int | CclGetUnitVariable (lua_State *l) |
| static int | CclSetUnitVariable (lua_State *l) |
| static int | CclSlotUsage (lua_State *l) |
| void | UnitCclRegister (void) |
Definition in file script_unit.cpp.
| static int CclCreateUnit | ( | lua_State * | l | ) | [static] |
Create a unit and place it on the map
| l | Lua state. |
Definition at line 815 of file script_unit.cpp.
References CUnitType::Building, CanBuildUnitType(), CclGetUnitType(), DebugPrint, DropOutOnSide(), LuaCheckArgs, LuaError, LuaToNumber(), MakeUnit(), NoUnitP, CUnit::Place(), PlayerNobody, Players, CUnit::Slot, SyncRand(), TriggerGetPlayer(), CUnit::Type, UnitCanBeAt(), UpdateForNewUnit(), CUnit::X, and CUnit::Y.
Referenced by UnitCclRegister().
| unsigned CclGetResourceByName | ( | lua_State * | l | ) |
< Get resource by name
Get the resource ID from a SCM object.
| l | Lua state. |
Definition at line 99 of file script_unittype.cpp.
References _C_, DefaultResourceNames, LuaError, LuaToString(), and MaxCosts.
| static CUnit* CclGetUnit | ( | lua_State * | l | ) | [static] |
Get a unit pointer
| l | Lua state. |
Definition at line 87 of file script_unit.cpp.
References int(), LuaToNumber(), and UnitSlots.
Referenced by CclGetUnitVariable(), CclMoveUnit(), CclSetResourcesHeld(), and CclSetUnitVariable().
| static int CclGetUnits | ( | lua_State * | l | ) | [static] |
Get a player's units
| l | Lua state. |
Definition at line 1124 of file script_unit.cpp.
References LuaCheckArgs, NumUnits, Players, CPlayer::TotalNumUnits, TriggerGetPlayer(), and Units.
Referenced by UnitCclRegister().
| static int CclGetUnitVariable | ( | lua_State * | l | ) | [static] |
Get the value of the unit variable.
| l | Lua state. |
Definition at line 1155 of file script_unit.cpp.
References _C_, CclGetUnit(), GetVariableIndex(), LuaCheckArgs, LuaError, LuaToString(), CVariable::Value, and CUnit::Variable.
Referenced by UnitCclRegister().
| static int CclKillUnit | ( | lua_State * | l | ) | [static] |
Kill a unit
| l | Lua state. |
Definition at line 1014 of file script_unit.cpp.
References ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, LetUnitDie(), LuaCheckArgs, NumUnits, Players, CPlayer::TotalNumUnits, TriggerGetPlayer(), TriggerGetUnitType(), CUnit::Type, CPlayer::Units, and Units.
Referenced by UnitCclRegister().
| static int CclKillUnitAt | ( | lua_State * | l | ) | [static] |
Kill a unit at a location
| l | Lua state. |
Definition at line 1059 of file script_unit.cpp.
References ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, CPlayer::Index, LetUnitDie(), LuaCheckArgs, LuaError, LuaToNumber(), CUnit::Player, CUnitCache::Select(), TriggerGetPlayer(), TriggerGetUnitType(), CUnit::Type, UnitCache, and UnitMax.
Referenced by UnitCclRegister().
| static int CclMoveUnit | ( | lua_State * | l | ) | [static] |
Move a unit on map.
| l | Lua state. |
Definition at line 774 of file script_unit.cpp.
References CclGetUnit(), DropOutOnSide(), LuaCheckArgs, LuaToNumber(), CUnit::Place(), SyncRand(), UnitCanBeAt(), CUnit::X, and CUnit::Y.
Referenced by UnitCclRegister().
| static int CclOrderUnit | ( | lua_State * | l | ) | [static] |
Order a unit
| l | Lua state. |
Definition at line 912 of file script_unit.cpp.
References _C_, ALL_BUILDINGS, ALL_FOODUNITS, ANY_UNIT, CUnitType::Building, CommandAttack(), CommandMove(), CommandPatrolUnit(), CPlayer::Index, LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), CUnit::Player, CUnitCache::Select(), TargetOnMap(), TriggerGetPlayer(), TriggerGetUnitType(), CUnit::Type, UnitCache, and UnitMax.
Referenced by UnitCclRegister().
| static void CclParseBuilt | ( | lua_State * | l, | |
| CUnit * | unit | |||
| ) | [static] |
Parse built
| l | Lua state. | |
| unit | Unit pointer which should be filled with the data. |
Definition at line 256 of file script_unit.cpp.
References _C_, Assert, CUnit::_order_data_::Built, CUnit::_order_data_::_order_built_::Cancel, CUnitType::Construction, CUnit::Data, CUnit::_order_data_::_order_built_::Frame, CConstruction::Frames, LuaError, LuaToNumber(), LuaToString(), CConstructionFrame::Next, CUnit::_order_data_::_order_built_::Progress, CUnit::Type, UnitSlots, and CUnit::_order_data_::_order_built_::Worker.
Referenced by CclUnit().
| static void CclParseHarvest | ( | lua_State * | l, | |
| CUnit * | unit | |||
| ) | [static] |
Parse stored data for harvest order
| l | Lua state. | |
| unit | Unit pointer which should be filled with the data. |
Definition at line 343 of file script_unit.cpp.
References _C_, CUnit::_order_data_::_order_harvest_::CurrentProduction, CUnit::Data, CUnit::_order_data_::Harvest, LuaError, LuaToNumber(), LuaToString(), and MaxCosts.
Referenced by CclUnit().
| static void CclParseMove | ( | lua_State * | l, | |
| CUnit * | unit | |||
| ) | [static] |
Parse stored data for move order
| l | Lua state. | |
| unit | Unit pointer which should be filled with the data. |
Definition at line 381 of file script_unit.cpp.
References _C_, CUnit::Data, CUnit::_order_data_::_order_move_::Fast, CUnit::_order_data_::_order_move_::Length, LuaError, LuaToNumber(), LuaToString(), CUnit::_order_data_::Move, and CUnit::_order_data_::_order_move_::Path.
Referenced by CclUnit().
| void CclParseOrder | ( | lua_State * | l, | |
| COrder * | order | |||
| ) |
< Parse order
Parse order
| l | Lua state. | |
| order | OUT: resulting order. |
Definition at line 98 of file script_unit.cpp.
References _C_, COrder::Action, COrder::Arg1, DebugPrint, COrder::Goal, COrder::Height, LuaError, LuaToNumber(), LuaToString(), COrder::MinRange, COrder::Patrol, COrder::Range, COrder::Spell, SpellTypeByIdent(), COrder::Type, UnitActionAttack, UnitActionAttackGround, UnitActionBoard, UnitActionBuild, UnitActionBuilt, UnitActionDie, UnitActionFollow, UnitActionMove, UnitActionNone, UnitActionPatrol, UnitActionRepair, UnitActionResource, UnitActionSpellCast, UnitActionStandGround, UnitActionStill, UnitActionTrain, UnitActionUnload, UnitSlots, UnitTypeByIdent(), COrder::Width, COrder::X, and COrder::Y.
Referenced by CclDefineAiPlayer(), CclParseOrders(), and CclUnit().
| static void CclParseOrders | ( | lua_State * | l, | |
| CUnit * | unit | |||
| ) | [static] |
Parse orders.
| l | Lua state. | |
| unit | Unit pointer which should get the orders. |
Definition at line 234 of file script_unit.cpp.
References CclParseOrder(), CUnit::OrderCount, and CUnit::Orders.
Referenced by CclUnit().
| static void CclParseTrain | ( | lua_State * | l, | |
| CUnit * | unit | |||
| ) | [static] |
Parse stored data for train order
| l | Lua state. | |
| unit | Unit pointer which should be filled with the data. |
Definition at line 312 of file script_unit.cpp.
References _C_, CUnit::Data, LuaError, LuaToNumber(), LuaToString(), CUnit::_order_data_::_order_train_::Ticks, and CUnit::_order_data_::Train.
Referenced by CclUnit().
| static int CclSetBuildingCapture | ( | lua_State * | l | ) | [static] |
Set capture buildings
| l | Lua state. |
Definition at line 73 of file script_unit.cpp.
References EnableBuildingCapture, LuaCheckArgs, and LuaToBoolean().
Referenced by UnitCclRegister().
| static int CclSetResourcesHeld | ( | lua_State * | l | ) | [static] |
Set resources held by a unit
| l | Lua state. |
Definition at line 879 of file script_unit.cpp.
References CclGetUnit(), CYCLES_PER_SECOND, LuaCheckArgs, LuaError, LuaToNumber(), MaxCosts, and CUnit::ResourcesHeld.
Referenced by UnitCclRegister().
| static int CclSetUnitVariable | ( | lua_State * | l | ) | [static] |
Set the value of the unit variable.
| l | Lua state. |
Definition at line 1181 of file script_unit.cpp.
References _C_, CclGetUnit(), GetVariableIndex(), LuaCheckArgs, LuaError, LuaToNumber(), LuaToString(), CVariable::Max, CVariable::Value, and CUnit::Variable.
Referenced by UnitCclRegister().
| static int CclSlotUsage | ( | lua_State * | l | ) | [static] |
Get the usage of unit slots during load to allocate memory
| l | Lua state. |
Definition at line 1211 of file script_unit.cpp.
References _C_, Assert, LuaError, LuaToNumber(), LuaToString(), CUnit::Refs, CUnitManager::ReleaseUnit(), CUnit::Slot, UnitManager, UnitSlotFree, and UnitSlots.
Referenced by UnitCclRegister().
| static int CclUnit | ( | lua_State * | l | ) | [static] |
Parse unit
| l | Lua state. |
Definition at line 429 of file script_unit.cpp.
References _C_, CUnit::AddInContainer(), CUnit::_unit_anim_::Anim, CUnit::Anim, AnimationsArray, Assert, CUnit::AssignToPlayer(), CUnit::Attacked, CUnit::AutoCastSpell, CUnit::AutoRepair, CUnit::Blink, CUnit::BoardCount, CUnit::Boarded, CUnit::Burning, CUnit::_unit_seen_::ByPlayer, CclParseBuilt(), CclParseHarvest(), CclParseMove(), CclParseOrder(), CclParseOrders(), CclParseTrain(), CUnit::_unit_seen_::CFrame, CUnit::Colors, CUnit::_unit_seen_::Constructed, CUnit::Constructed, CUnitType::Construction, CUnit::_unit_anim_::CurrAnim, CUnit::CurrentSightRange, DebugPrint, DefineVariableField(), CUnit::_unit_seen_::Destroyed, CUnit::Destroyed, CUnit::Direction, CUnit::_unit_seen_::Frame, CUnit::Frame, CConstruction::Frames, GetVariableIndex(), CUnit::Goal, CUnit::GroupId, CUnit::Init(), int(), CUnit::_unit_seen_::IX, CUnit::IX, CUnit::_unit_seen_::IY, CUnit::IY, CUnit::LastGroup, LuaError, LuaToNumber(), LuaToString(), MapMarkTileSight, MapMarkUnitSight(), MapSight(), MaxCosts, CUnit::Moving, CUnit::NewOrder, CConstructionFrame::Next, CUnit::Next, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, CUnit::Player, PlayerMax, Players, CUnit::ProductionEfficiency, CUnit::ReCast, CUnit::Refs, CUnit::Removed, CUnit::RescuedFrom, CUnit::ResourcesHeld, CUnitType::Revealer, CUnit::SavedOrder, CUnit::Seen, CUnit::Selected, SpellType::Slot, CUnitType::Slot, CUnit::Slot, SpellTypeByIdent(), SpellTypeTable, CUnit::State, CUnit::_unit_seen_::State, CUnitType::Stats, CUnit::Stats, CUnit::SubAction, CUnit::TTL, CUnit::Type, CUnit::_unit_seen_::Type, CUnit::_unit_anim_::Unbreakable, UnitActionBuilt, CPlayer::UnitColors, UnitNotSeen, UnitSlots, UnitTypeByIdent(), CPlayer::UnitTypesCount, UpdateForNewUnit(), CUnit::Variable, CUnit::_unit_anim_::Wait, CUnit::Wait, CUnit::_unit_seen_::X, CUnit::X, CUnit::_unit_seen_::Y, CUnit::Y, and y.
Referenced by UnitCclRegister().
| void UnitCclRegister | ( | void | ) |
Register CCL features for unit.
Definition at line 1252 of file script_unit.cpp.
References CclCreateUnit(), CclGetUnits(), CclGetUnitVariable(), CclKillUnit(), CclKillUnitAt(), CclMoveUnit(), CclOrderUnit(), CclSetBuildingCapture(), CclSetResourcesHeld(), CclSetUnitVariable(), CclSlotUsage(), CclUnit(), and Lua.
Referenced by InitCcl().
1.5.6