_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "stratagus.h"
#include "unit.h"
#include "actions.h"
#include "animation.h"
#include "commands.h"
#include "construct.h"
#include "interface.h"
#include "map.h"
#include "netconnect.h"
#include "network.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
#include "spells.h"
#include "trigger.h"
#include "unit_find.h"
#include "unit_manager.h"
#include "unittype.h"
#include "upgrade.h"
Classes | |
class | HasSameUnitTypeAs |
Functions | |
script_unit.cpp - The unit ccl functions. | |
unsigned | CclGetResourceByName (lua_State *l) |
Get resource by name. More... | |
static int | CclSetTrainingQueue (lua_State *l) |
static int | CclSetBuildingCapture (lua_State *l) |
static int | CclSetRevealAttacker (lua_State *l) |
static int | CclResourcesMultiBuildersMultiplier (lua_State *l) |
static CUnit * | CclGetUnit (lua_State *l) |
CUnit * | CclGetUnitFromRef (lua_State *l) |
For saving lua state. More... | |
static void | CclParseOrders (lua_State *l, CUnit &unit) |
static int | CclUnit (lua_State *l) |
static int | CclMoveUnit (lua_State *l) |
static int | CclRemoveUnit (lua_State *l) |
static int | CclCreateUnit (lua_State *l) |
static int | CclTransformUnit (lua_State *l) |
static int | CclDamageUnit (lua_State *l) |
static int | CclSetResourcesHeld (lua_State *l) |
static int | CclSetTeleportDestination (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 | CclGetUnitsAroundUnit (lua_State *l) |
static int | CclGetUnitBoolFlag (lua_State *l) |
static int | CclGetUnitVariable (lua_State *l) |
static int | CclSetUnitVariable (lua_State *l) |
static int | CclSlotUsage (lua_State *l) |
static int | CclSelectSingleUnit (lua_State *l) |
static int | CclFindNextResource (lua_State *l) |
static int | CclEnableSimplifiedAutoTargeting (lua_State *l) |
void | UnitCclRegister () |
register CCL units features More... | |
|
static |
Description
Create a unit and place it on the map
l | Lua state. |
Example:
CreateUnit("unit-human-transport", 1, {94, 0})
|
static |
Description
Damages unit, additionally using another unit as first's attacker
l | Lua state. |
Example:
– Make a grunt for player 5 grunt = CreateUnit("unit-grunt", 5, {58, 8}) – Damage the grunt with 15 points DamageUnit(-1,grunt,15)
|
static |
Enable/disable simplified auto targeting
l | Lua state. |
|
static |
Find the next reachable resource unit that gives resource starting from a worker. Optional third argument is the range to search.
l | Lua state. |
Example:
peon = CreateUnit("unit-peon", 5, {58, 8}) goldmine = FindNextResource(peon, 0)
unsigned CclGetResourceByName | ( | lua_State * | l | ) |
Get resource by name.
Get the resource ID from a SCM object.
l | Lua state. |
|
static |
Get a unit pointer
l | Lua state. |
|
static |
Get the value of the unit bool-flag.
l | Lua state. |
CUnit* CclGetUnitFromRef | ( | lua_State * | l | ) |
For saving lua state.
Get a unit pointer from ref string
l | Lua state. |
|
static |
Description
Get a player's units
l | Lua state. |
Example:
– Get units from player 0 units = GetUnits(0) for i, id_unit in ipairs(units) do print(id_unit) end
|
static |
Description
Get a player's units in rectangle box specified with 2 coordinates
l | Lua state. |
Example:
circlePower = CreateUnit("unit-circle-of-power", 15, {59, 4}) – Get the units near the circle of power. unitsOnCircle = GetUnitsAroundUnit(circle,1,true)
|
static |
Description
Get the value of the unit variable.
l | Lua state. |
Example:
– Make a grunt for player 5 grunt = CreateUnit("unit-grunt", 5, {58, 8}) – Take the name of the unit unit_name = GetUnitVariable(grunt,"Name") – Take the player number based on the unit player_type = GetUnitVariable(grunt,"PlayerType") – Take the value of the armor armor_value = GetUnitVariable(grunt,"Armor") – Show the message in the game. AddMessage(unit_name .. " " .. player_type .. " " .. armor_value)
|
static |
Description
Kill a unit
l | Lua state. |
Example:
– Kills an ogre controlled by player 3 KillUnit("unit-ogre", 3)
|
static |
Description
Kill a unit at a location
l | Lua state. |
Example:
– Kill 8 peasants controlled by player 7 from position {27,1} to {34,5} KillUnitAt("unit-peasant",7,8,{27,1},{34,5})
|
static |
Move a unit on map.
l | Lua state. |
Example:
– Create the unit footman = CreateUnit("unit-footman", 0, {7, 4}) – Move the unit to position 20 (x) and 10 (y) MoveUnit(footman,{20,10})
|
static |
Description
Order a unit
l | Lua state. |
OrderUnit(player, unit-type, start_loc, dest_loc, order)
Example:
– Move transport from position x=94,y=0 to x=80,y=9 OrderUnit(1,"unit-human-transport",{94,0},{80,9},"move")
Parse orders.
l | Lua state. |
unit | Unit pointer which should get the orders. |
|
static |
Description
Remove unit from the map.
l | Lua state. |
Example:
ogre = CreateUnit("unit-ogre", 0, {24, 89}) AddTrigger(
function() return (GameCycle > 150) end,
function()
<strong>RemoveUnit</strong>(ogre)
return false end -- end of function
)</code></div>
|
static |
Set cost multiplier to RepairCost for buildings additional workers helping (0 = no additional cost)
l | Lua state. |
Example:
– No cost ResourcesMultiBuildersMultiplier(0) – Each builder helping will cost 1 resource ResourcesMultiBuildersMultiplier(1) – Each builder helping will cost 10 resource ResourcesMultiBuildersMultiplier(10)
|
static |
Description
Select a single unit
l | Lua state. |
Example:
– Make the hero unit Grom Hellscream for player 5 grom = CreateUnit("unit-beast-cry", 5, {58, 8}) – Select only the unit Grom Hellscream SelectSingleUnit(grom)
|
static |
Set capture buildings
l | Lua state. |
Example:
SetBuildingCapture(true) SetBuildingCapture(false)
|
static |
Set resources held by a unit
l | Lua state. |
|
static |
Set reveal attacker
l | Lua state. |
Example:
SetRevealAttacker(true) SetRevealAttacker(false)
|
static |
Set teleport deastination for teleporter unit
l | Lua state. |
|
static |
Description
Set training queue
l | Lua state. |
Example:
– Training queue available. Train multiple units. SetTrainingQueue(true) – Train one unit at a time. SetTrainingQueue(false)
|
static |
Description
Set the value of the unit variable.
l | Lua state. |
Example:
– Create a blacksmith for player 2 blacksmith = CreateUnit("unit-human-blacksmith", 2, {66, 71}) – Specify the amount of hit points to assign to the blacksmith SetUnitVariable(blacksmith,"HitPoints",344) – Set the blacksmiths color to the color of player 4 SetUnitVariable(blacksmith,"Color",4)
|
static |
Get the usage of unit slots during load to allocate memory
l | Lua state. |
|
static |
Description
'Upgrade' a unit in place to a unit of different type.
l | Lua state. |
Example:
– Make a peon for player 5 peon = CreateUnit("unit-peon", 5, {58, 9}) – The peon will be trasformed into a Grunt TransformUnit(peon,"unit-grunt")
|
static |
Parse unit
l | Lua state. |
Verify that vision table is always correct (transporter)
(PlaceUnit() and host-info).
Example:
footman = CreateUnit("unit-footman", 0, {0, 1}) – The unit will appear selected Unit(footman,{"selected"}) – The unit will be considered destroyed Unit(footman,{"destroyed"}) – The unit will be considered removed Unit(footman,{"removed"}) – The unit will be considered as a summoned unit Unit(footman,{"summoned",500}) – The unit will face on south Unit(footman,{"direction",0}) – The unit will be displayed with his 3rd frame Unit(footman,{"frame", 3}) – The footman will have a high sight Unit(footman,{"current-sight-range",9}) – Change the unit color to be the ones from player 1 Unit(footman,{"rescued-from",1})
void UnitCclRegister | ( | ) |
register CCL units features
Register CCL features for unit.