_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
script_unittype.cpp File Reference
#include "stratagus.h"
#include "unittype.h"
#include "actions.h"
#include "animation.h"
#include "construct.h"
#include "editor.h"
#include "font.h"
#include "luacallback.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "sound.h"
#include "spells.h"
#include "ui.h"
#include "unit.h"
#include "unitsound.h"
#include "unit_manager.h"
#include "video.h"

script_unittype.cpp - The unit-type ccl functions.

CUnitTypeVar UnitTypeVar
 
static const char COWARD_KEY [] = "Coward"
 Variables for UnitType and unit. More...
 
static const char BUILDING_KEY [] = "Building"
 
static const char FLIP_KEY [] = "Flip"
 
static const char REVEALER_KEY [] = "Revealer"
 
static const char LANDUNIT_KEY [] = "LandUnit"
 
static const char AIRUNIT_KEY [] = "AirUnit"
 
static const char SEAUNIT_KEY [] = "SeaUnit"
 
static const char EXPLODEWHENKILLED_KEY [] = "ExplodeWhenKilled"
 
static const char VISIBLEUNDERFOG_KEY [] = "VisibleUnderFog"
 
static const char PERMANENTCLOAK_KEY [] = "PermanentCloak"
 
static const char DETECTCLOAK_KEY [] = "DetectCloak"
 
static const char ATTACKFROMTRANSPORTER_KEY [] = "AttackFromTransporter"
 
static const char VANISHES_KEY [] = "Vanishes"
 
static const char GROUNDATTACK_KEY [] = "GroundAttack"
 
static const char SHOREBUILDING_KEY [] = "ShoreBuilding"
 
static const char CANATTACK_KEY [] = "CanAttack"
 
static const char BUILDEROUTSIDE_KEY [] = "BuilderOutside"
 
static const char BUILDERLOST_KEY [] = "BuilderLost"
 
static const char CANHARVEST_KEY [] = "CanHarvest"
 
static const char HARVESTER_KEY [] = "Harvester"
 
static const char SELECTABLEBYRECTANGLE_KEY [] = "SelectableByRectangle"
 
static const char ISNOTSELECTABLE_KEY [] = "IsNotSelectable"
 
static const char DECORATION_KEY [] = "Decoration"
 
static const char INDESTRUCTIBLE_KEY [] = "Indestructible"
 
static const char TELEPORTER_KEY [] = "Teleporter"
 
static const char SHIELDPIERCE_KEY [] = "ShieldPiercing"
 
static const char SAVECARGO_KEY [] = "SaveCargo"
 
static const char NONSOLID_KEY [] = "NonSolid"
 
static const char WALL_KEY [] = "Wall"
 
static const char NORANDOMPLACING_KEY [] = "NoRandomPlacing"
 
static const char ORGANIC_KEY [] = "organic"
 
static const char SIDEATTACK_KEY [] = "SideAttack"
 
static const char NOFRIENDLYFIRE_KEY [] = "NoFriendlyFire"
 
static const char HITPOINTS_KEY [] = "HitPoints"
 
static const char BUILD_KEY [] = "Build"
 
static const char MANA_KEY [] = "Mana"
 
static const char TRANSPORT_KEY [] = "Transport"
 
static const char RESEARCH_KEY [] = "Research"
 
static const char TRAINING_KEY [] = "Training"
 
static const char UPGRADETO_KEY [] = "UpgradeTo"
 
static const char GIVERESOURCE_KEY [] = "GiveResource"
 
static const char CARRYRESOURCE_KEY [] = "CarryResource"
 
static const char XP_KEY [] = "Xp"
 
static const char KILL_KEY [] = "Kill"
 
static const char SUPPLY_KEY [] = "Supply"
 
static const char DEMAND_KEY [] = "Demand"
 
static const char ARMOR_KEY [] = "Armor"
 
static const char SIGHTRANGE_KEY [] = "SightRange"
 
static const char ATTACKRANGE_KEY [] = "AttackRange"
 
static const char PIERCINGDAMAGE_KEY [] = "PiercingDamage"
 
static const char BASICDAMAGE_KEY [] = "BasicDamage"
 
static const char POSX_KEY [] = "PosX"
 
static const char POSY_KEY [] = "PosY"
 
static const char TARGETPOSX_KEY [] = "TargetPosX"
 
static const char TARGETPOSY_KEY [] = "TargetPosY"
 
static const char RADARRANGE_KEY [] = "RadarRange"
 
static const char RADARJAMMERRANGE_KEY [] = "RadarJammerRange"
 
static const char AUTOREPAIRRANGE_KEY [] = "AutoRepairRange"
 
static const char BLOODLUST_KEY [] = "Bloodlust"
 
static const char HASTE_KEY [] = "Haste"
 
static const char SLOW_KEY [] = "Slow"
 
static const char INVISIBLE_KEY [] = "Invisible"
 
static const char UNHOLYARMOR_KEY [] = "UnholyArmor"
 
static const char SLOT_KEY [] = "Slot"
 
static const char SHIELD_KEY [] = "ShieldPoints"
 
static const char POINTS_KEY [] = "Points"
 
static const char MAXHARVESTERS_KEY [] = "MaxHarvesters"
 
static const char POISON_KEY [] = "Poison"
 
static const char SHIELDPERMEABILITY_KEY [] = "ShieldPermeability"
 
static const char SHIELDPIERCING_KEY [] = "ShieldPiercing"
 
static const char ISALIVE_KEY [] = "IsAlive"
 
static const char PLAYER_KEY [] = "Player"
 
static const char PRIORITY_KEY [] = "Priority"
 
int GetSpriteIndex (const char *SpriteName)
 
unsigned CclGetResourceByName (lua_State *l)
 Get resource by name. More...
 
int ExtraDeathIndex (const char *death)
 Get the suitable animation frame depends of unit's damaged type. More...
 
static void ParseBuildingRules (lua_State *l, std::vector< CBuildRestriction * > &blist)
 
static void UpdateDefaultBoolFlags (CUnitType &type)
 
static int CclDefineUnitType (lua_State *l)
 
static int CclDefineUnitStats (lua_State *l)
 
CUnitTypeCclGetUnitType (lua_State *l)
 
static int CclUnitType (lua_State *l)
 
static int CclUnitTypeArray (lua_State *l)
 
static int CclGetUnitTypeIdent (lua_State *l)
 
static int CclGetUnitTypeName (lua_State *l)
 
static int CclSetUnitTypeName (lua_State *l)
 
static int CclGetUnitTypeData (lua_State *l)
 
void DefineVariableField (lua_State *l, CVariable *var, int lua_index)
 Cleanup unit-type module. More...
 
static int CclDefineVariables (lua_State *l)
 
static int CclDefineBoolFlags (lua_State *l)
 
static int CclDefineDecorations (lua_State *l)
 
static int CclDefineExtraDeathTypes (lua_State *l)
 
void UpdateUnitVariables (CUnit &unit)
 Update custom Variables with other variable (like Hp, ...) More...
 
void SetMapStat (std::string ident, std::string variable_key, int value, std::string variable_type)
 
void SetMapSound (std::string ident, std::string sound, std::string sound_type, std::string sound_subtype)
 
void UnitTypeCclRegister ()
 Access unit-type object. More...
 

Function Documentation

static int CclDefineBoolFlags ( lua_State *  l)
static

Define boolean flag.

Parameters
lLua state.
static int CclDefineDecorations ( lua_State *  l)
static

Define Decorations for user variables

Parameters
lLua state.
Todo:

modify Assert with luastate with User Error.

continue to add configuration.

static int CclDefineExtraDeathTypes ( lua_State *  l)
static

Define default extra death types.

Parameters
lLua state.
static int CclDefineUnitStats ( lua_State *  l)
static

Parse unit-stats.

Parameters
lLua state.
static int CclDefineUnitType ( lua_State *  l)
static

Parse unit-type.

Parameters
lLua state.
static int CclDefineVariables ( lua_State *  l)
static

Define user variables.

Parameters
lLua state.
unsigned CclGetResourceByName ( lua_State *  l)

Get resource by name.

Get the resource ID from a SCM object.

Parameters
lLua state.
Returns
the resource id
CUnitType* CclGetUnitType ( lua_State *  l)

Access unit-type object

Parameters
lLua state.
static int CclGetUnitTypeData ( lua_State *  l)
static

Get unit type data.

Parameters
lLua state.
static int CclGetUnitTypeIdent ( lua_State *  l)
static

Get the ident of the unit-type structure.

Parameters
lLua state.
Returns
The identifier of the unit-type.
static int CclGetUnitTypeName ( lua_State *  l)
static

Get the name of the unit-type structure.

Parameters
lLua state.
Returns
The name of the unit-type.
static int CclSetUnitTypeName ( lua_State *  l)
static

Set the name of the unit-type structure.

Parameters
lLua state.
Returns
The name of the unit-type.
static int CclUnitType ( lua_State *  l)
static

Get unit-type structure.

Parameters
lLua state.
Returns
Unit-type structure.
static int CclUnitTypeArray ( lua_State *  l)
static

Get all unit-type structures.

Parameters
lLua state.
Returns
An array of all unit-type structures.
void DefineVariableField ( lua_State *  l,
CVariable var,
int  lua_index 
)

Cleanup unit-type module.

Define the field of the UserDefined variables.

Parameters
lLua state.
varVariable to set.
lua_indexIndex of the table where are the infos
int ExtraDeathIndex ( const char *  death)

Get the suitable animation frame depends of unit's damaged type.

Find the index of a extra death type

int GetSpriteIndex ( const char *  SpriteName)

Return the index of the sprite named SpriteName.

Parameters
SpriteNameName of the sprite.
Returns
Index of the sprite. -1 if not found.
static void ParseBuildingRules ( lua_State *  l,
std::vector< CBuildRestriction * > &  blist 
)
static

Parse BuildingRules

Parameters
lLua state.
blistBuildingRestriction to fill in
void SetMapSound ( std::string  ident,
std::string  sound,
std::string  sound_type,
std::string  sound_subtype 
)

Set the map sound for a unit type

Parameters
identUnit type ident
sound_typeType of the sound
soundThe sound to be set for that type
void SetMapStat ( std::string  ident,
std::string  variable_key,
int  value,
std::string  variable_type 
)

Set the map default stat for a unit type

Parameters
identUnit type ident
variable_keyKey of the desired variable
valueValue to set to
variable_typeType to be modified (i.e. "Value", "Max", etc.); alternatively, resource type if variable_key equals "Costs"
void UnitTypeCclRegister ( )

Access unit-type object.

Register CCL features for unit-type.

static void UpdateDefaultBoolFlags ( CUnitType type)
static
void UpdateUnitVariables ( CUnit unit)

Update custom Variables with other variable (like Hp, ...)

Update unit variables which are not user defined.

Variable Documentation

const char AIRUNIT_KEY[] = "AirUnit"
static
const char ARMOR_KEY[] = "Armor"
static
const char ATTACKFROMTRANSPORTER_KEY[] = "AttackFromTransporter"
static
const char ATTACKRANGE_KEY[] = "AttackRange"
static
const char AUTOREPAIRRANGE_KEY[] = "AutoRepairRange"
static
const char BASICDAMAGE_KEY[] = "BasicDamage"
static
const char BLOODLUST_KEY[] = "Bloodlust"
static
const char BUILD_KEY[] = "Build"
static
const char BUILDERLOST_KEY[] = "BuilderLost"
static
const char BUILDEROUTSIDE_KEY[] = "BuilderOutside"
static
const char BUILDING_KEY[] = "Building"
static
const char CANATTACK_KEY[] = "CanAttack"
static
const char CANHARVEST_KEY[] = "CanHarvest"
static
const char CARRYRESOURCE_KEY[] = "CarryResource"
static
const char COWARD_KEY[] = "Coward"
static

Variables for UnitType and unit.

const char DECORATION_KEY[] = "Decoration"
static
const char DEMAND_KEY[] = "Demand"
static
const char DETECTCLOAK_KEY[] = "DetectCloak"
static
const char EXPLODEWHENKILLED_KEY[] = "ExplodeWhenKilled"
static
const char FLIP_KEY[] = "Flip"
static
const char GIVERESOURCE_KEY[] = "GiveResource"
static
const char GROUNDATTACK_KEY[] = "GroundAttack"
static
const char HARVESTER_KEY[] = "Harvester"
static
const char HASTE_KEY[] = "Haste"
static
const char HITPOINTS_KEY[] = "HitPoints"
static
const char INDESTRUCTIBLE_KEY[] = "Indestructible"
static
const char INVISIBLE_KEY[] = "Invisible"
static
const char ISALIVE_KEY[] = "IsAlive"
static
const char ISNOTSELECTABLE_KEY[] = "IsNotSelectable"
static
const char KILL_KEY[] = "Kill"
static
const char LANDUNIT_KEY[] = "LandUnit"
static
const char MANA_KEY[] = "Mana"
static
const char MAXHARVESTERS_KEY[] = "MaxHarvesters"
static
const char NOFRIENDLYFIRE_KEY[] = "NoFriendlyFire"
static
const char NONSOLID_KEY[] = "NonSolid"
static
const char NORANDOMPLACING_KEY[] = "NoRandomPlacing"
static
const char ORGANIC_KEY[] = "organic"
static
const char PERMANENTCLOAK_KEY[] = "PermanentCloak"
static
const char PIERCINGDAMAGE_KEY[] = "PiercingDamage"
static
const char PLAYER_KEY[] = "Player"
static
const char POINTS_KEY[] = "Points"
static
const char POISON_KEY[] = "Poison"
static
const char POSX_KEY[] = "PosX"
static
const char POSY_KEY[] = "PosY"
static
const char PRIORITY_KEY[] = "Priority"
static
const char RADARJAMMERRANGE_KEY[] = "RadarJammerRange"
static
const char RADARRANGE_KEY[] = "RadarRange"
static
const char RESEARCH_KEY[] = "Research"
static
const char REVEALER_KEY[] = "Revealer"
static
const char SAVECARGO_KEY[] = "SaveCargo"
static
const char SEAUNIT_KEY[] = "SeaUnit"
static
const char SELECTABLEBYRECTANGLE_KEY[] = "SelectableByRectangle"
static
const char SHIELD_KEY[] = "ShieldPoints"
static
const char SHIELDPERMEABILITY_KEY[] = "ShieldPermeability"
static
const char SHIELDPIERCE_KEY[] = "ShieldPiercing"
static
const char SHIELDPIERCING_KEY[] = "ShieldPiercing"
static
const char SHOREBUILDING_KEY[] = "ShoreBuilding"
static
const char SIDEATTACK_KEY[] = "SideAttack"
static
const char SIGHTRANGE_KEY[] = "SightRange"
static
const char SLOT_KEY[] = "Slot"
static
const char SLOW_KEY[] = "Slow"
static
const char SUPPLY_KEY[] = "Supply"
static
const char TARGETPOSX_KEY[] = "TargetPosX"
static
const char TARGETPOSY_KEY[] = "TargetPosY"
static
const char TELEPORTER_KEY[] = "Teleporter"
static
const char TRAINING_KEY[] = "Training"
static
const char TRANSPORT_KEY[] = "Transport"
static
const char UNHOLYARMOR_KEY[] = "UnholyArmor"
static
CUnitTypeVar UnitTypeVar
const char UPGRADETO_KEY[] = "UpgradeTo"
static
const char VANISHES_KEY[] = "Vanishes"
static
const char VISIBLEUNDERFOG_KEY[] = "VisibleUnderFog"
static
const char WALL_KEY[] = "Wall"
static
const char XP_KEY[] = "Xp"
static
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.