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

src/include/unittype.h File Reference

#include <SDL.h>
#include <vector>
#include <algorithm>
#include "upgrade_structs.h"
#include "util.h"
#include "unitsound.h"
#include "icons.h"
#include "animation.h"
#include "vec2i.h"

Go to the source code of this file.


Classes

class  MissileConfig
class  ResourceInfo
class  CVariable
class  CDecoVar
class  CDecoVarBar
class  CDecoVarText
class  CDecoVarSpriteBar
 Sprite contains frame from full (left)to empty state (right). More...
class  CDecoVarStaticSprite
 use to show specific frame in a sprite. More...
class  CBuildRestriction
class  CBuildRestrictionAnd
class  CBuildRestrictionAddOn
struct  CBuildRestrictionAddOn::functor
class  CBuildRestrictionOnTop
struct  CBuildRestrictionOnTop::functor
class  CBuildRestrictionDistance
class  CUnitType
struct  CUnitType::_portrait_
 Icon to display for this unit. More...
struct  CUnitType::BoolFlags
 Array of user defined variables. More...
class  CUnitTypeVar
 Orc wall. More...
struct  CUnitTypeVar::CKeys< SIZE >
struct  CUnitTypeVar::CKeys< SIZE >::DataKey
struct  CUnitTypeVar::CBoolKeys
struct  CUnitTypeVar::CVariableKeys

unittype.h - The unit-types headerfile.

enum  GroupSelectionMode { SELECTABLE_BY_RECTANGLE_ONLY = 0, NON_SELECTABLE_BY_RECTANGLE_ONLY, SELECT_ALL }
enum  {
  COWARD_INDEX = 0, BUILDING_INDEX, FLIP_INDEX, REVEALER_INDEX,
  LANDUNIT_INDEX, AIRUNIT_INDEX, SEAUNIT_INDEX, EXPLODEWHENKILLED_INDEX,
  VISIBLEUNDERFOG_INDEX, PERMANENTCLOAK_INDEX, DETECTCLOAK_INDEX, ATTACKFROMTRANSPORTER_INDEX,
  VANISHES_INDEX, GROUNDATTACK_INDEX, SHOREBUILDING_INDEX, CANATTACK_INDEX,
  BUILDEROUTSIDE_INDEX, BUILDERLOST_INDEX, CANHARVEST_INDEX, HARVESTER_INDEX,
  SELECTABLEBYRECTANGLE_INDEX, ISNOTSELECTABLE_INDEX, DECORATION_INDEX, INDESTRUCTIBLE_INDEX,
  TELEPORTER_INDEX, SHIELDPIERCE_INDEX, SAVECARGO_INDEX, NBARALREADYDEFINED
}
enum  {
  HP_INDEX = 0, BUILD_INDEX, MANA_INDEX, TRANSPORT_INDEX,
  RESEARCH_INDEX, TRAINING_INDEX, UPGRADINGTO_INDEX, GIVERESOURCE_INDEX,
  CARRYRESOURCE_INDEX, XP_INDEX, KILL_INDEX, SUPPLY_INDEX,
  DEMAND_INDEX, ARMOR_INDEX, SIGHTRANGE_INDEX, ATTACKRANGE_INDEX,
  PIERCINGDAMAGE_INDEX, BASICDAMAGE_INDEX, POSX_INDEX, POSY_INDEX,
  RADAR_INDEX, RADARJAMMER_INDEX, AUTOREPAIRRANGE_INDEX, BLOODLUST_INDEX,
  HASTE_INDEX, SLOW_INDEX, INVISIBLE_INDEX, UNHOLYARMOR_INDEX,
  SLOT_INDEX, SHIELD_INDEX, POINTS_INDEX, MAXHARVESTERS_INDEX,
  NVARALREADYDEFINED
}
enum  UnitTypeType { UnitTypeLand, UnitTypeFly, UnitTypeNaval }
enum  DistanceTypeType {
  Equal, NotEqual, LessThan, LessThanEqual,
  GreaterThan, GreaterThanEqual
}
std::vector< CUnitType * > UnitTypes
CUnitTypeUnitTypeHumanWall
 All unit-types.
CUnitTypeUnitTypeOrcWall
 Human wall.
CUnitTypeVar UnitTypeVar
 Animation map.
CUnitTypeUnitTypeByIdent (const std::string &ident)
 Update unit stats.
CUnitTypeCclGetUnitType (lua_State *l)
void UnitTypeCclRegister ()
 Access unit-type object.
void UpdateStats (int reset_to_default)
 Register ccl features.
void SaveUnitTypes (CFile *file)
 Get unit-type by ident.
CUnitTypeNewUnitTypeSlot (const std::string &ident)
 Save the unit-type table.
void DrawUnitType (const CUnitType &type, CPlayerColorGraphic *sprite, int player, int frame, int x, int y)
 Draw the sprite frame of unit-type.
void InitUnitTypes (int reset_player_stats)
void LoadUnitTypeSprite (CUnitType &unittype)
 Init unit-type table.
void LoadUnitTypes ()
 Load the sprite for a unittype.
void CleanUnitTypes ()
 Load the unit-type data.
void DefineVariableField (lua_State *l, CVariable *var, int lua_index)
 Cleanup unit-type module.
void UpdateUnitVariables (const CUnit &unit)
 Update custom Variables with other variable (like Hp, ...).

Defines

#define MouseActionNone   0
 Right click action.
#define MouseActionAttack   1
#define MouseActionMove   2
#define MouseActionHarvest   3
#define MouseActionSpellCast   5
#define MouseActionSail   6
#define CanTargetLand   1
 Which units can it attack.
#define CanTargetSea   2
#define CanTargetAir   4

Define Documentation

#define CanTargetAir   4

#define CanTargetLand   1

Which units can it attack.

#define CanTargetSea   2

#define MouseActionAttack   1

#define MouseActionHarvest   3

#define MouseActionMove   2

#define MouseActionNone   0

Right click action.

#define MouseActionSail   6

#define MouseActionSpellCast   5


Enumeration Type Documentation

anonymous enum

Enumerator:
COWARD_INDEX 
BUILDING_INDEX 
FLIP_INDEX 
REVEALER_INDEX 
LANDUNIT_INDEX 
AIRUNIT_INDEX 
SEAUNIT_INDEX 
EXPLODEWHENKILLED_INDEX 
VISIBLEUNDERFOG_INDEX 
PERMANENTCLOAK_INDEX 
DETECTCLOAK_INDEX 
ATTACKFROMTRANSPORTER_INDEX 
VANISHES_INDEX 
GROUNDATTACK_INDEX 
SHOREBUILDING_INDEX 
CANATTACK_INDEX 
BUILDEROUTSIDE_INDEX 
BUILDERLOST_INDEX 
CANHARVEST_INDEX 
HARVESTER_INDEX 
SELECTABLEBYRECTANGLE_INDEX 
ISNOTSELECTABLE_INDEX 
DECORATION_INDEX 
INDESTRUCTIBLE_INDEX 
TELEPORTER_INDEX 
SHIELDPIERCE_INDEX 
SAVECARGO_INDEX 
NBARALREADYDEFINED 

anonymous enum

Enumerator:
HP_INDEX 
BUILD_INDEX 
MANA_INDEX 
TRANSPORT_INDEX 
RESEARCH_INDEX 
TRAINING_INDEX 
UPGRADINGTO_INDEX 
GIVERESOURCE_INDEX 
CARRYRESOURCE_INDEX 
XP_INDEX 
KILL_INDEX 
SUPPLY_INDEX 
DEMAND_INDEX 
ARMOR_INDEX 
SIGHTRANGE_INDEX 
ATTACKRANGE_INDEX 
PIERCINGDAMAGE_INDEX 
BASICDAMAGE_INDEX 
POSX_INDEX 
POSY_INDEX 
RADAR_INDEX 
RADARJAMMER_INDEX 
AUTOREPAIRRANGE_INDEX 
BLOODLUST_INDEX 
HASTE_INDEX 
SLOW_INDEX 
INVISIBLE_INDEX 
UNHOLYARMOR_INDEX 
SLOT_INDEX 
SHIELD_INDEX 
POINTS_INDEX 
MAXHARVESTERS_INDEX 
NVARALREADYDEFINED 

Enumerator:
Equal 
NotEqual 
LessThan 
LessThanEqual 
GreaterThan 
GreaterThanEqual 

Enumerator:
SELECTABLE_BY_RECTANGLE_ONLY 
NON_SELECTABLE_BY_RECTANGLE_ONLY 
SELECT_ALL 

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

Unit lives on water


Function Documentation

CUnitType* CclGetUnitType ( lua_State *  l  ) 

Access unit-type object

Parameters:
l Lua state.

void CleanUnitTypes (  ) 

Load the unit-type data.

Cleanup the unit-type module.

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

Cleanup unit-type module.

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

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

Draw the sprite frame of unit-type.

Allocate an empty unit-type slot

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.

void InitUnitTypes ( int  reset_player_stats  ) 

Init unit types.

void LoadUnitTypes (  ) 

Load the sprite for a unittype.

Load the graphics for the unit-types.

void LoadUnitTypeSprite ( CUnitType type  ) 

Init unit-type table.

Loads the Sprite for a unit type

Parameters:
type type of unit to load

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

Save the unit-type table.

Allocate an empty unit-type slot.

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

void SaveUnitTypes ( CFile file  ) 

Get unit-type by ident.

Save state of the unit-type table to file.

Parameters:
file Output file.

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

Update unit stats.

Find unit-type by identifier.

Parameters:
ident The unit-type identifier.
Returns:
Unit-type pointer.

void UnitTypeCclRegister (  ) 

Access unit-type object.

Register CCL features for unit-type.

void UpdateStats ( int  reset  ) 

Register ccl features.

Update the player stats for changed unit types.

Parameters:
reset indicates wether default value should be set to each stat (level, upgrades)

void UpdateUnitVariables ( const CUnit unit  ) 

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

Update unit variables which are not user defined.


Variable Documentation

All unit-types.

Todo:
this hardcoded unit-types must be removed!!
Next unit type are used hardcoded in the source.

Todo:
find a way to make it configurable!

Human wall.

std::vector<CUnitType *> UnitTypes

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.