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

       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_unit.cpp File Reference

The unit ccl functions. More...

#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 CUnitCclGetUnit (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)


Detailed Description

The unit ccl functions.

Definition in file script_unit.cpp.


Function Documentation

static int CclCreateUnit ( lua_State *  l  )  [static]

Create a unit and place it on the map

Parameters:
l Lua state.
Returns:
Returns the slot number of the made unit.

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.

Parameters:
l Lua state.
Returns:
the resource id

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

Parameters:
l Lua state.
Returns:
The unit pointer

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

Parameters:
l Lua state.
Returns:
Array of units.

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.

Parameters:
l Lua state.
Returns:
The value of the variable of the unit.

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

Parameters:
l Lua state.
Returns:
Returns true if a unit was killed.

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

Parameters:
l Lua state.
Returns:
Returns the number of units killed.

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.

Parameters:
l Lua state.
Returns:
Returns the slot number of the made placed.

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]

static void CclParseBuilt ( lua_State *  l,
CUnit unit 
) [static]

static void CclParseHarvest ( lua_State *  l,
CUnit unit 
) [static]

Parse stored data for harvest order

Parameters:
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

Parameters:
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 
)

static void CclParseOrders ( lua_State *  l,
CUnit unit 
) [static]

Parse orders.

Parameters:
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

Parameters:
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

Parameters:
l Lua state.
Returns:
The old state of the flag

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

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

Parameters:
l Lua state.
Returns:
The new value of the unit.

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

Parameters:
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

Parameters:
l Lua state.
Todo:
Verify that vision table is always correct (transporter)
Todo:
(PlaceUnit() and host-info).

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   ) 


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