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

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

The unit-type ccl functions. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "stratagus.h"
#include "video.h"
#include "map.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "animation.h"
#include "icons.h"
#include "missile.h"
#include "script.h"
#include "construct.h"
#include "spells.h"
#include "font.h"
#include "unit.h"
#include "unit_manager.h"
#include "player.h"
#include "luacallback.h"

Go to the source code of this file.

Classes

struct  LabelsStruct
struct  LabelsLaterStruct

Defines

#define MAGIC_FOR_NEW_UNITS   33
 How many percent of max mana for new units.

Functions

int GetSpriteIndex (const std::string &spriteName)
unsigned CclGetResourceByName (lua_State *l)
 < Get resource by name
static void ParseBuildingRules (lua_State *l, std::vector< CBuildRestriction * > &blist)
static int CclDefineUnitType (lua_State *l)
CUnitTypeCclGetUnitType (lua_State *l)
 Access unit-type object.
static void AddLabel (lua_State *l, CAnimation *anim, const std::string &name)
static CAnimationFindLabel (lua_State *l, const std::string &name)
static void FindLabelLater (lua_State *l, CAnimation **anim, const std::string &name)
static void FixLabels (lua_State *l)
static void ParseAnimationFrame (lua_State *l, const char *str, CAnimation *anim)
static CAnimationParseAnimation (lua_State *l, int idx)
static void AddAnimationToArray (CAnimation *anim)
static int CclDefineAnimations (lua_State *l)
void DefineVariableField (lua_State *l, CVariable *var, int lua_index)
 < Parse User Variables field.
int GetVariableIndex (const char *varname)
 Get index of the variable.
static int CclDefineVariables (lua_State *l)
static int CclDefineDecorations (lua_State *l)
void UpdateUnitVariables (const CUnit *unit)
void InitDefinedVariables ()
void UnitTypeCclRegister (void)
 Register ccl features.

Variables

CAnimationAnimationsArray [ANIMATIONS_MAXANIM]
int NumAnimations
 Hash table of all the animations.
std::map< std::string,
CAnimations * > 
AnimationMap
 Animation map.
CUnitTypeVar UnitTypeVar
 Variables for UnitType and unit.
static std::vector< LabelsStructLabels
static std::vector
< LabelsLaterStruct
LabelsLater


Detailed Description

The unit-type ccl functions.

Definition in file script_unittype.cpp.


Define Documentation

#define MAGIC_FOR_NEW_UNITS   33

How many percent of max mana for new units.

Definition at line 61 of file script_unittype.cpp.

Referenced by CclDefineUnitType().


Function Documentation

static void AddAnimationToArray ( CAnimation anim  )  [static]

Add animation to AnimationsArray

Definition at line 961 of file script_unittype.cpp.

References ANIMATIONS_MAXANIM, Assert, and NumAnimations.

Referenced by CclDefineAnimations().

static void AddLabel ( lua_State *  l,
CAnimation anim,
const std::string &  name 
) [static]

Add a label

Definition at line 761 of file script_unittype.cpp.

References LabelsStruct::Anim, Labels, and LabelsStruct::Name.

Referenced by ParseAnimationFrame().

static int CclDefineAnimations ( lua_State *  l  )  [static]

static int CclDefineDecorations ( lua_State *  l  )  [static]

static int CclDefineUnitType ( lua_State *  l  )  [static]

Parse unit-type.

Parameters:
l Lua state.

Definition at line 217 of file script_unittype.cpp.

References _C_, CUnitSound::Acknowledgement, CUnitType::AirUnit, CUnitType::Animations, AnimationsByIdent(), CUnitType::AnnoyComputerFactor, CUnitType::AttackFromTransporter, ATTACKRANGE_INDEX, SpellType::AutoCast, CUnitType::AutoCastActive, CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitType::BuilderLost, CUnitType::BuilderOutside, CUnitType::Building, CUnitType::BuildingRules, CUnitType::BurnDamageRate, CUnitType::BurnPercent, CUnitType::CanAttack, CUnitType::CanCastSpell, CUnitType::CanHarvestFrom, CUnitType::CanTarget, CanTargetAir, CanTargetLand, CanTargetSea, CUnitType::CanTransport, CUnitType::Construction, ConstructionByIdent(), CUnitType::CorpseName, CUnitType::CorpseType, CUnitType::Coward, CUnitSound::Dead, CUnitType::DeathExplosion, DebugPrint, CUnitType::DecayRate, CUnitType::Decoration, DefineVariableField(), CUnitType::DrawLevel, CVariable::Enable, CUnitType::ExplodeWhenKilled, CUnitType::Explosion, CUnitType::File, CUnitType::Flip, GetVariableIndex(), CUnitType::GroundAttack, CUnitSound::Harvest, CUnitType::Harvester, CUnitType::Height, CUnitSound::Help, HP_INDEX, IconConfig::Icon, CUnitType::Icon, CVariable::Increase, CUnitType::Indestructible, CUnitType::IsNotSelectable, CUnitType::LandUnit, LuaCheckArgs, LuaError, LuaToBoolean(), LuaToNumber(), LuaToString(), MAGIC_FOR_NEW_UNITS, MANA_INDEX, CVariable::Max, CUnitType::MaxOnBoard, CUnitType::MinAttackRange, MissileConfig::Missile, CUnitType::Missile, CUnitType::MouseAction, MouseActionAttack, MouseActionHarvest, MouseActionMove, MouseActionNone, MouseActionSail, MouseActionSpellCast, SoundConfig::Name, MissileConfig::Name, IconConfig::Name, CUnitType::Name, CUnitType::Neutral, CUnitType::NeutralMinimapColorRGB, NewUnitTypeSlot(), CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnitType::Organic, ParseBuildingRules(), CUnitType::Points, CUnitType::Priority, CUnitType::ProductionEfficiency, CUnitType::ReactRangeComputer, CUnitType::ReactRangePerson, CUnitSound::Ready, CUnitSound::Repair, CUnitType::RepairHP, CUnitType::RepairRange, CUnitType::Revealer, CUnitType::SeaUnit, CUnitType::SelectableByRectangle, CUnitSound::Selected, CUnitType::SetEnergyProductionRate(), CUnitType::SetEnergyStorageCapacity(), CUnitType::SetEnergyValue(), CUnitType::SetMagmaProductionRate(), CUnitType::SetMagmaStorageCapacity(), CUnitType::SetMagmaValue(), CUnitType::SetMaxEnergyUtilizationRate(), CUnitType::SetMaxMagmaUtilizationRate(), CUnitType::ShadowFile, CUnitType::ShadowHeight, CUnitType::ShadowOffsetX, CUnitType::ShadowOffsetY, CUnitType::ShadowWidth, CUnitType::ShoreBuilding, SpellType::Slot, CUnitType::Sound, SpellTypeByIdent(), SpellTypeTable, CUnitType::TileHeight, CUnitType::TileWidth, CUnitType::UnitType, UnitTypeByIdent(), UnitTypeFly, UnitTypeLand, UnitTypeNaval, CVariable::Value, CUnitType::Vanishes, CUnitType::Variable, CUnitType::VisibleUnderFog, and CUnitType::Width.

Referenced by UnitTypeCclRegister().

static int CclDefineVariables ( lua_State *  l  )  [static]

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.

CUnitType* CclGetUnitType ( lua_State *  l  ) 

Access unit-type object.

Access unit-type object

Parameters:
l Lua state.

Definition at line 737 of file script_unittype.cpp.

References _lua_user_data_::Data, data, LuaError, LuaToString(), LuaUnitType, _lua_user_data_::Type, and UnitTypeByIdent().

Referenced by CclAiForce(), CclAiNeed(), CclAiSet(), CclAiWait(), CclCreateUnit(), CclIfNearUnit(), CclIfRescuedNearUnit(), and TriggerGetUnitType().

void DefineVariableField ( lua_State *  l,
CVariable var,
int  lua_index 
)

< Parse User Variables field.

Define the field of the UserDefined variables.

Parameters:
l Lua state.
var Variable to set.
lua_index Index of the table where are the infos

Definition at line 1042 of file script_unittype.cpp.

References _C_, CVariable::Enable, CVariable::Increase, LuaError, LuaToBoolean(), LuaToNumber(), LuaToString(), CVariable::Max, and CVariable::Value.

Referenced by CclDefineUnitType(), CclDefineVariables(), and CclUnit().

static CAnimation* FindLabel ( lua_State *  l,
const std::string &  name 
) [static]

Find a label

Definition at line 772 of file script_unittype.cpp.

References _C_, int(), Labels, and LuaError.

Referenced by FixLabels().

static void FindLabelLater ( lua_State *  l,
CAnimation **  anim,
const std::string &  name 
) [static]

Find a label later

Definition at line 786 of file script_unittype.cpp.

References LabelsLaterStruct::Anim, LabelsLater, and LabelsLaterStruct::Name.

Referenced by ParseAnimationFrame().

static void FixLabels ( lua_State *  l  )  [static]

Fix labels

Definition at line 797 of file script_unittype.cpp.

References FindLabel(), int(), and LabelsLater.

Referenced by ParseAnimation().

int GetSpriteIndex ( const std::string &  spriteName  ) 

Return the index of the sprite.

Parameters:
spriteName Name of the sprite.
Returns:
Index of the sprite. -1 if not found.

Definition at line 197 of file unit_draw.cpp.

References int(), and DecoSpriteType::Name.

Referenced by CclDefineDecorations(), and CclDefineSprites().

int GetVariableIndex ( const char *  varname  ) 

Get index of the variable.

Return the index of the variable.

Parameters:
varname Name of the variable.
Returns:
Index of the variable, -1 if not found.

Definition at line 1074 of file script_unittype.cpp.

References CUnitTypeVar::NumberVariable, and CUnitTypeVar::VariableName.

Referenced by CclDefineDecorations(), CclDefineUnitType(), CclDefineVariables(), CclGetUnitVariable(), CclSetUnitVariable(), CclSpellAction(), CclSpellCondition(), and CclUnit().

void InitDefinedVariables (  ) 

Define already variables, useful for drawing now.

Definition at line 1351 of file script_unittype.cpp.

References new_strdup(), CUnitTypeVar::NumberVariable, NVARALREADYDEFINED, CUnitTypeVar::Variable, and CUnitTypeVar::VariableName.

Referenced by EditorMainLoop(), and UnitTypeCclRegister().

static CAnimation* ParseAnimation ( lua_State *  l,
int  idx 
) [static]

Parse an animation

Definition at line 924 of file script_unittype.cpp.

References FixLabels(), Labels, LabelsLater, LuaError, LuaToString(), CAnimation::Next, and ParseAnimationFrame().

Referenced by CclDefineAnimations().

static void ParseAnimationFrame ( lua_State *  l,
const char *  str,
CAnimation anim 
) [static]

static void ParseBuildingRules ( lua_State *  l,
std::vector< CBuildRestriction * > &  blist 
) [static]

void UnitTypeCclRegister ( void   ) 

Register ccl features.

Register CCL features for unit-type.

Definition at line 1371 of file script_unittype.cpp.

References CclDefineAnimations(), CclDefineDecorations(), CclDefineUnitType(), CclDefineVariables(), InitDefinedVariables(), and Lua.

Referenced by InitCcl().

void UpdateUnitVariables ( const CUnit unit  ) 


Variable Documentation

std::map<std::string, CAnimations *> AnimationMap

Animation map.

Definition at line 70 of file script_unittype.cpp.

Referenced by AnimationsByIdent(), CclDefineAnimations(), and CleanUnitTypes().

CAnimation* AnimationsArray[ANIMATIONS_MAXANIM]

Definition at line 67 of file script_unittype.cpp.

Referenced by CclUnit(), CleanUnitTypes(), and SaveUnit().

std::vector<LabelsStruct> Labels [static]

Definition at line 78 of file script_unittype.cpp.

Referenced by AddLabel(), CclSetTitleScreens(), FindLabel(), and ParseAnimation().

std::vector<LabelsLaterStruct> LabelsLater [static]

Definition at line 84 of file script_unittype.cpp.

Referenced by FindLabelLater(), FixLabels(), and ParseAnimation().

Hash table of all the animations.

Definition at line 68 of file script_unittype.cpp.

Referenced by AddAnimationToArray(), CleanUnitTypes(), and SaveUnit().


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