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

       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"

unittype.h File Reference

The unit-types headerfile. More...

#include "SDL.h"
#include <vector>
#include "upgrade_structs.h"
#include "unitsound.h"
#include "icons.h"

Go to the source code of this file.

Classes

class  MissileConfig
class  CVariable
class  CDecoVar
class  CDecoVarSpriteBar
 Sprite contains frame from full (left)to empty state (right). More...
class  CBuildRestriction
class  CBuildRestrictionAnd
class  CBuildRestrictionAddOn
class  CBuildRestrictionOnTop
class  CBuildRestrictionDistance
class  CUnitType
class  CUnitTypeVar

Defines

#define MouseActionNone   0
 Nothing.
#define MouseActionAttack   1
 Attack.
#define MouseActionMove   2
 Move.
#define MouseActionHarvest   3
 Harvest resources.
#define MouseActionSpellCast   5
 Cast the first spell known.
#define MouseActionSail   6
 Sail.
#define CanTargetLand   1
 Can attack land units.
#define CanTargetSea   2
 Can attack sea units.
#define CanTargetAir   4
 Can attack air units.

Enumerations

enum  {
  HP_INDEX, BUILD_INDEX, MANA_INDEX, TRANSPORT_INDEX,
  TRAINING_INDEX, GIVERESOURCE_INDEX, KILL_INDEX, ARMOR_INDEX,
  SIGHTRANGE_INDEX, ATTACKRANGE_INDEX, PIERCINGDAMAGE_INDEX, BASICDAMAGE_INDEX,
  POSX_INDEX, POSY_INDEX, RADAR_INDEX, RADARJAMMER_INDEX,
  AUTOREPAIRRANGE_INDEX, SLOT_INDEX, NVARALREADYDEFINED
}
enum  UnitTypeType { UnitTypeLand, UnitTypeFly, UnitTypeNaval }
enum  DistanceTypeType {
  Equal, NotEqual, LessThan, LessThanEqual,
  GreaterThan, GreaterThanEqual
}

Functions

CUnitTypeUnitTypeByIdent (const std::string &ident)
 Get unit-type by ident.
CUnitTypeCclGetUnitType (lua_State *l)
 Access unit-type object.
void UnitTypeCclRegister (void)
 Register ccl features.
void UpdateStats (int reset_to_default)
 Update unit stats.
int GetVariableIndex (const char *VarName)
 Get index of the variable.
CUnitTypeNewUnitTypeSlot (const std::string &ident)
 Draw the sprite frame of unit-type.
void DrawUnitType (const CUnitType *type, CPlayerColorGraphic *sprite, int player, int frame, int x, int y)
void InitUnitTypes (int reset_player_stats)
 Init unit-type table.
void LoadUnitTypeSprite (CUnitType *unittype)
 Load the sprite for a unittype.
void LoadUnitTypes (void)
 Load the unit-type data.
void CleanUnitTypes (void)
 Cleanup unit-type module.
void DefineVariableField (lua_State *l, CVariable *var, int lua_index)
 < Parse User Variables field.
void UpdateUnitVariables (const CUnit *unit)

Variables

std::vector< CUnitType * > UnitTypes
 All unit-types.
CUnitTypeVar UnitTypeVar
 Variables for UnitType and unit.


Detailed Description

The unit-types headerfile.

Definition in file unittype.h.


Define Documentation

#define CanTargetAir   4

Can attack air units.

Definition at line 650 of file unittype.h.

Referenced by CanTarget(), and CclDefineUnitType().

#define CanTargetLand   1

Can attack land units.

Definition at line 648 of file unittype.h.

Referenced by CanTarget(), and CclDefineUnitType().

#define CanTargetSea   2

Can attack sea units.

Definition at line 649 of file unittype.h.

Referenced by CanTarget(), and CclDefineUnitType().

#define MouseActionAttack   1

Attack.

Definition at line 641 of file unittype.h.

Referenced by CclDefineUnitType(), and DoRightButton().

#define MouseActionHarvest   3

Harvest resources.

Definition at line 643 of file unittype.h.

Referenced by CclDefineUnitType(), and DoRightButton().

#define MouseActionMove   2

Move.

Definition at line 642 of file unittype.h.

Referenced by CclDefineUnitType(), and DoRightButton().

#define MouseActionNone   0

Nothing.

Definition at line 640 of file unittype.h.

Referenced by CclDefineUnitType().

#define MouseActionSail   6

Sail.

Definition at line 645 of file unittype.h.

Referenced by CclDefineUnitType(), and DoRightButton().

#define MouseActionSpellCast   5

Cast the first spell known.

Definition at line 644 of file unittype.h.

Referenced by CclDefineUnitType(), and DoRightButton().


Enumeration Type Documentation

anonymous enum

Enumerator:
HP_INDEX 
BUILD_INDEX 
MANA_INDEX 
TRANSPORT_INDEX 
TRAINING_INDEX 
GIVERESOURCE_INDEX 
KILL_INDEX 
ARMOR_INDEX 
SIGHTRANGE_INDEX 
ATTACKRANGE_INDEX 
PIERCINGDAMAGE_INDEX 
BASICDAMAGE_INDEX 
POSX_INDEX 
POSY_INDEX 
RADAR_INDEX 
RADARJAMMER_INDEX 
AUTOREPAIRRANGE_INDEX 
SLOT_INDEX 
NVARALREADYDEFINED 

Definition at line 421 of file unittype.h.

Enumerator:
Equal 
NotEqual 
LessThan 
LessThanEqual 
GreaterThan 
GreaterThanEqual 

Definition at line 494 of file unittype.h.

Enumerator:
UnitTypeLand  Unit lives on land.
UnitTypeFly  Unit lives in air.
UnitTypeNaval  Unit lives on water.

Definition at line 488 of file unittype.h.


Function Documentation

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 CleanUnitTypes ( void   ) 

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

< Parse User Variables field.

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

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().

void DrawUnitType ( const CUnitType type,
CPlayerColorGraphic sprite,
int  player,
int  frame,
int  x,
int  y 
)

Draw unit-type on map.

Parameters:
type Unit-type pointer.
sprite Sprite to use for drawing
player Player number for color substitution.
frame Animation frame of unit-type.
x Screen X pixel postion to draw unit-type.
y Screen Y pixel postion to draw unit-type.
Todo:
Do screen position caculation in high level. Better way to handle in x mirrored sprites.

Definition at line 297 of file unittype.cpp.

References CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), CUnitType::Flip, CUnitType::Height, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, and CUnitType::Width.

Referenced by CUnit::Draw(), DrawBuildingCursor(), and DrawStartLocations().

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 InitUnitTypes ( int  reset_player_stats  ) 

void LoadUnitTypes ( void   ) 

void LoadUnitTypeSprite ( CUnitType type  ) 

CUnitType* NewUnitTypeSlot ( const std::string &  ident  ) 

Draw the sprite frame of unit-type.

Allocate an empty unit-type slot

Allocate an empty unit-type slot.

Parameters:
ident Identifier to identify the slot (malloced by caller!).
Returns:
New allocated (zeroed) unit-type pointer.

Definition at line 264 of file unittype.cpp.

References ExitFatal(), CUnitType::Ident, CUnitTypeVar::NumberVariable, CUnitType::Slot, UnitTypeMap, UnitTypes, UnitTypeVar, CUnitTypeVar::Variable, and CUnitType::Variable.

Referenced by CclDefineUnitType().

CUnitType * UnitTypeByIdent ( const std::string &  ident  ) 

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 UpdateStats ( int  reset  ) 

void UpdateUnitVariables ( const CUnit unit  ) 

Update unit variables which are not user defined.

Definition at line 1250 of file script_unittype.cpp.

Referenced by DrawDecoration(), and DrawUnitInfo().


Variable Documentation

std::vector<CUnitType *> UnitTypes


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