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

Classes | Public Member Functions | Public Attributes | List of all members
CUnitType Class Reference

#include <unittype.h>

Classes

struct  _portrait_
 Icon to display for this unit. More...
 
struct  BoolFlags
 

Public Member Functions

Vec2i GetHalfTileSize () const
 
bool CanTransport () const
 
unittype.cpp - The unit types.
 CUnitType ()
 
 ~CUnitType ()
 
PixelSize GetPixelSize () const
 
bool CheckUserBoolFlags (const char *BoolFlags) const
 
bool CanMove () const
 
bool CanSelect (GroupSelectionMode mode=SELECTABLE_BY_RECTANGLE_ONLY) const
 

Public Attributes

std::string Ident
 
std::string Name
 Identifier. More...
 
int Slot
 Pretty name shown from the engine. More...
 
std::string File
 Type as number. More...
 
std::string ShadowFile
 Sprite files. More...
 
int Width
 Shadow file. More...
 
int Height
 Sprite width. More...
 
int OffsetX
 Sprite height. More...
 
int OffsetY
 Sprite horizontal offset. More...
 
int DrawLevel
 Sprite vertical offset. More...
 
int ShadowWidth
 Level to Draw UnitType at. More...
 
int ShadowHeight
 Shadow sprite width. More...
 
int ShadowOffsetX
 Shadow sprite height. More...
 
int ShadowOffsetY
 Shadow horizontal offset. More...
 
PixelPos MissileOffsets [UnitSides][MaxAttackPos]
 Shadow vertical offset. More...
 
CAnimations * Animations
 Attack offsets for missiles. More...
 
int StillFrame
 Animation scripts. More...
 
IconConfig Icon
 Still frame. More...
 
struct CUnitType::_portrait_ Portrait
 
MissileConfig Missile
 
MissileConfig Explosion
 Missile weapon. More...
 
MissileConfig Impact [ANIMATIONS_DEATHTYPES+2]
 Missile for unit explosion. More...
 
LuaCallback * DeathExplosion
 Missiles spawned if unit is hit(+shield) More...
 
LuaCallback * OnHit
 
LuaCallback * OnEachCycle
 lua function called when unit is hit More...
 
LuaCallback * OnEachSecond
 lua function called every cycle More...
 
LuaCallback * OnInit
 lua function called every second More...
 
int TeleportCost
 lua function called on unit init More...
 
LuaCallback * TeleportEffectIn
 mana used for teleportation More...
 
LuaCallback * TeleportEffectOut
 lua function to create effects before teleportation More...
 
std::string DamageType
 lua function to create effects after teleportation More...
 
std::string CorpseName
 DamageType (used for extra death animations and impacts) More...
 
CUnitType * CorpseType
 Corpse type name. More...
 
CConstruction * Construction
 Corpse unit-type. More...
 
int RepairHP
 What is shown in construction phase. More...
 
int RepairCosts [MaxCosts]
 Amount of HP per repair. More...
 
int TileWidth
 How much it costs to repair. More...
 
int TileHeight
 Tile size on map width. More...
 
int BoxWidth
 Tile size on map height. More...
 
int BoxHeight
 Selected box size width. More...
 
int BoxOffsetX
 Selected box size height. More...
 
int BoxOffsetY
 Selected box size horizontal offset. More...
 
int NumDirections
 Selected box size vertical offset. More...
 
int MinAttackRange
 Number of directions unit can face. More...
 
int ReactRangeComputer
 Minimal attack range. More...
 
int ReactRangePerson
 Reacts on enemy for computer. More...
 
int BurnPercent
 Reacts on enemy for person player. More...
 
int BurnDamageRate
 Burning percent. More...
 
int RepairRange
 HP burn rate per sec. More...
 
char * CanCastSpell
 Units repair range. More...
 
char * AutoCastActive
 Unit is able to use spells. More...
 
int AutoBuildRate
 Default value for autocast. More...
 
int RandomMovementProbability
 The rate at which the building builds itself. More...
 
int RandomMovementDistance
 Probability to move randomly. More...
 
int ClicksToExplode
 Quantity of tiles to move randomly. More...
 
int MaxOnBoard
 Number of consecutive clicks until unit suicides. More...
 
int BoardSize
 Number of Transporter slots. More...
 
int ButtonLevelForTransporter
 How much "cells" unit occupies inside transporter. More...
 
int StartingResources
 On which button level game will show units inside transporter. More...
 
UnitTypeType UnitType
 originally only visual effect, we do more with this! More...
 
int DecayRate
 Land / fly / naval. More...
 
int AnnoyComputerFactor
 Decay rate in 1/6 seconds. More...
 
int AiAdjacentRange
 How much this annoys the computer. More...
 
int MouseAction
 Min radius for AI build surroundings checking. More...
 
int CanTarget
 
unsigned Flip: 1
 
unsigned Revealer: 1
 Flip image when facing left. More...
 
unsigned LandUnit: 1
 reveal the fog of war More...
 
unsigned AirUnit: 1
 Land animated. More...
 
unsigned SeaUnit: 1
 Air animated. More...
 
unsigned ExplodeWhenKilled: 1
 Sea animated. More...
 
unsigned Building: 1
 Death explosion animated. More...
 
unsigned VisibleUnderFog: 1
 Building. More...
 
unsigned PermanentCloak: 1
 Unit is visible under fog of war. More...
 
unsigned DetectCloak: 1
 Is only visible by CloakDetectors. More...
 
unsigned Coward: 1
 Can see Cloaked units. More...
 
unsigned AttackFromTransporter: 1
 Unit will only attack if instructed. More...
 
unsigned Vanishes: 1
 Can attack from transporter. More...
 
unsigned GroundAttack: 1
 Corpes & destroyed places. More...
 
unsigned ShoreBuilding: 1
 Can do command ground attack. More...
 
unsigned CanAttack: 1
 Building must be build on coast. More...
 
unsigned BuilderOutside: 1
 Unit can attack. More...
 
unsigned BuilderLost: 1
 The builder stays outside during the build. More...
 
unsigned CanHarvest: 1
 The builder is lost after the build. More...
 
unsigned Harvester: 1
 Resource can be harvested. More...
 
unsigned Neutral: 1
 unit is a resource harvester. More...
 
unsigned SelectableByRectangle: 1
 Unit is neutral, used by the editor. More...
 
unsigned IsNotSelectable: 1
 Selectable with mouse rectangle. More...
 
unsigned Decoration: 1
 Unit should not be selected during game. More...
 
unsigned Indestructible: 1
 Unit is a decoration (act as tile). More...
 
unsigned Teleporter: 1
 Unit is indestructible (take no damage). More...
 
unsigned SaveCargo: 1
 Can teleport other units. More...
 
unsigned NonSolid: 1
 Unit unloads his passengers after death. More...
 
unsigned Wall: 1
 Unit can be entered by other units. More...
 
unsigned NoRandomPlacing: 1
 Use special logic for Direction field. More...
 
unsigned Organic: 1
 Don't use random frame rotation. More...
 
unsigned SideAttack: 1
 Organic unit (used for death coil spell) More...
 
CUnitStats DefaultStat
 Unit turns for attack (used for ships) More...
 
std::vector< BoolFlags > BoolFlag
 
int CanStore [MaxCosts]
 
int GivesResource
 Resources that we can store here. More...
 
ResourceInfo * ResInfo [MaxCosts]
 The resource this unit gives. More...
 
std::vector< CBuildRestriction * > BuildingRules
 Resource information. More...
 
std::vector< CBuildRestriction * > AiBuildingRules
 Rules list for building a building. More...
 
CColor NeutralMinimapColorRGB
 Rules list for for AI to build a building. More...
 
CUnitSound Sound
 Minimap Color for Neutral Units. More...
 
int Supply
 Sounds for events. More...
 
int Demand
 Food supply. More...
 
int PoisonDrain
 Food demand. More...
 
int ImproveIncomes [MaxCosts]
 How much health is drained every second when poisoned. More...
 
unsigned FieldFlags
 Gives player an improved income. More...
 
unsigned MovementMask
 Unit map field flags. More...
 
CUnitStats Stats [PlayerMax]
 Unit check this map flags for move. More...
 
CPlayerColorGraphic * Sprite
 Unit status for each player. More...
 
CGraphic * ShadowSprite
 Sprite images. More...
 

Detailed Description

Base structure of unit-type

Todo:
n0body: AutoBuildRate not implemented.

#include "unittype.h"

This class contains the information that is shared between all units of the same type and determins if a unit is a building, a person, ...

The unit-type class members:

CUnitType::Ident

Unique identifier of the unit-type, used to reference it in config files and during startup. As convention they start with "unit-" fe. "unit-farm".

Note
Don't use this member in game, use instead the pointer to this structure. See UnitTypeByIdent().

CUnitType::Name

Pretty name shown by the engine. The name should be shorter than 17 characters and no word can be longer than 8 characters.

CUnitType::File

Path file name of the sprite file.

CUnitType::ShadowFile

Path file name of shadow sprite file.

CUnitType::DrawLevel

The Level/Order to draw this type of unit in. 0-255 usually.

CUnitType::Width CUnitType::Height

Size of a sprite frame in pixels. All frames of a sprite have the same size. Also all sprites (tilesets) must have the same size.

CUnitType::ShadowWidth CUnitType::ShadowHeight

Size of a shadow sprite frame in pixels. All frames of a sprite have the same size. Also all sprites (tilesets) must have the same size.

CUnitType::ShadowOffsetX CUnitType::ShadowOffsetY

Vertical offset to draw the shadow in pixels.

CUnitType::Animations

Animation scripts for the different actions. Currently the animations still, move, attack and die are supported.

See also
CAnimations
CAnimation

CUnitType::Icon

Icon to display for this unit-type. Contains configuration and run time variable.

Note
This icon can be used for training, but isn't used.

CUnitType::Missile

Configuration and run time variable of the missile weapon.

Note
It is planned to support more than one weapons. And the sound of the missile should be used as fire sound.

CUnitType::Explosion

Configuration and run time variable of the missile explosion. This is the explosion that happens if unit is set to ExplodeWhenKilled

CUnitType::CorpseName

Corpse unit-type name, should only be used during setup.

CUnitType::CorpseType

Corpse unit-type pointer, only this should be used during run time. Many unit-types can share the same corpse.

Todo:
continue this documentation

CUnitType::Construction

What is shown in construction phase.

CUnitType::SightRange

Sight range

CUnitType::_HitPoints

Maximum hit points

CUnitType::_Costs[MaxCosts]

How many resources needed

CUnitType::RepairHP

The HP given to a unit each cycle it's repaired. If zero, unit cannot be repaired

CUnitType::RepairCosts[MaxCosts]

Costs per repair cycle to fix a unit.

CUnitType::TileWidth

Tile size on map width

CUnitType::TileHeight

Tile size on map height

CUnitType::BoxWidth

Selected box size width

CUnitType::BoxHeight

Selected box size height

CUnitType::NumDirections

Number of directions the unit can face

CUnitType::MinAttackRange

Minimal attack range

CUnitType::ReactRangeComputer

Reacts on enemy for computer

CUnitType::ReactRangePerson

Reacts on enemy for person player

CUnitType::Priority

Priority value / AI Treatment

CUnitType::BurnPercent

The burning limit in percents. If the unit has lees than this it will start to burn.

CUnitType::BurnDamageRate

Burn rate in HP per second

CUnitType::UnitType

Land / fly / naval

Note
original only visual effect, we do more with this!

CUnitType::DecayRate

Decay rate in 1/6 seconds

CUnitType::AnnoyComputerFactor

How much this annoys the computer

Todo:
not used

CUnitType::MouseAction

Right click action

CUnitType::Points

How many points you get for unit. Used in the final score table.

CUnitType::CanTarget

Which units can it attack

Unit::Revealer

A special unit used to reveal the map for a time. This unit has active sight even when Removed. It's used for Reveal map type of spells.

CUnitType::LandUnit

Land animated

CUnitType::AirUnit

Air animated

CUnitType::SeaUnit

Sea animated

CUnitType::ExplodeWhenKilled

Death explosion animated

CUnitType::RandomMovementProbability

When the unit is idle this is the probability that it will take a step in a random direction, in percents.

CUnitType::ClicksToExplode

If this is non-zero, then after that many clicks the unit will commit suicide. Doesn't work with resource workers/resources.

CUnitType::Building

Unit is a Building

CUnitType::VisibleUnderFog

Unit is visible under fog of war.

CUnitType::PermanentCloak

Unit is permanently cloaked.

CUnitType::DetectCloak

These units can detect Cloaked units.

CUnitType::Coward

Unit is a coward, and acts defensively. it will not attack at will and auto-casters will not buff it(bloodlust).

CUnitType::Transporter

Can transport units

CUnitType::AttackFromTransporter

Units inside this transporter can attack with missiles.

CUnitType::MaxOnBoard

Maximum units on board (for transporters), and resources

CUnitType::StartingResources Amount of Resources a unit has when It's Built

CUnitType::DamageType Unit's missile damage type (used for extra death animations)

CUnitType::GivesResource

This equals to the resource Id of the resource given or 0 (TimeCost) for other buildings.

CUnitType::CanHarvest

Resource can be harvested. It's false for things like oil patches.

Todo:
crappy name.

CUnitType::Harvester

Unit is a resource worker. Faster than examining ResInfo

CUnitType::ResInfo[MaxCosts]

Information about resource harvesting. If NULL, it can't harvest it.

CUnitType::NeutralMinimapColorRGB

Says what color a unit will have when it's neutral and is displayed on the minimap.

CUnitType::CanStore[MaxCosts]

What resource types we can store here.

CUnitType::Vanishes

Corpes & destroyed places

CUnitType::GroundAttack

Can do command ground attack

CUnitType::ShoreBuilding

Building must be build on coast

CUnitType::CanCastSpell

Unit is able to use spells

CUnitType::CanAttack

Unit is able to attack.

CUnitType::RepairRange

Unit can repair buildings. It will use the actack animation. It will heal 4 points for every repair cycle, and cost 1 of each resource, alternatively(1 cycle wood, 1 cycle gold)

Todo:
The above should be more configurable. If units have a repair range, they can repair, and this is the distance.

CUnitType::BuilderOutside

Only valid for buildings. When building the worker will remain outside inside the building.

Warning
Workers that can build buildings with the
BuilderOutside flag must have the CanRepair flag.

CUnitType::BuilderLost

Only valid for buildings without the BuilderOutside flag. The worker is lost when the building is completed.

CUnitType::SelectableByRectangle

Selectable with mouse rectangle

CUnitType::Teleporter

Can teleport other units.

CUnitType::ShieldPiercing

Can directly damage shield-protected units, without shield damaging.

CUnitType::SaveCargo

Unit unloads his passengers after death.

CUnitType::Sound

Sounds for events

CUnitType::Weapon

Current sound for weapon

Todo:
temporary solution

CUnitType::Supply

How much food does this unit supply.

CUnitType::Demand

Food demand

CUnitType::ImproveIncomes[MaxCosts]

Gives the player an improved income.

CUnitType::FieldFlags

Flags that are set, if a unit enters a map field or cleared, if a unit leaves a map field.

CUnitType::MovementMask

Movement mask, this value is and'ed to the map field flags, to see if a unit can enter or placed on the map field.

CUnitType::Stats[PlayerMax]

Unit status for each player

Todo:
This stats should? be moved into the player struct

CUnitType::Type

Type as number

Todo:
Should us a general name f.e. Slot here?

CUnitType::Sprite

Sprite images

CUnitType::ShadowSprite

Shadow sprite images

CUnitType::PlayerColorSprite

Sprite images of the player colors. This image is drawn over CUnitType::Sprite. Used with OpenGL only.

Constructor & Destructor Documentation

CUnitType::CUnitType ( )
CUnitType::~CUnitType ( )

Member Function Documentation

bool CUnitType::CanMove ( ) const
bool CUnitType::CanSelect ( GroupSelectionMode  mode = SELECTABLE_BY_RECTANGLE_ONLY) const
bool CUnitType::CanTransport ( ) const
inline
bool CUnitType::CheckUserBoolFlags ( const char *  BoolFlags) const
Vec2i CUnitType::GetHalfTileSize ( ) const
inline
PixelSize CUnitType::GetPixelSize ( ) const

Member Data Documentation

int CUnitType::AiAdjacentRange

How much this annoys the computer.

std::vector<CBuildRestriction *> CUnitType::AiBuildingRules

Rules list for building a building.

unsigned CUnitType::AirUnit

Land animated.

CAnimations* CUnitType::Animations

Attack offsets for missiles.

int CUnitType::AnnoyComputerFactor

Decay rate in 1/6 seconds.

unsigned CUnitType::AttackFromTransporter

Unit will only attack if instructed.

int CUnitType::AutoBuildRate

Default value for autocast.

char* CUnitType::AutoCastActive

Unit is able to use spells.

int CUnitType::BoardSize

Number of Transporter slots.

std::vector<BoolFlags> CUnitType::BoolFlag
int CUnitType::BoxHeight

Selected box size width.

int CUnitType::BoxOffsetX

Selected box size height.

int CUnitType::BoxOffsetY

Selected box size horizontal offset.

int CUnitType::BoxWidth

Tile size on map height.

unsigned CUnitType::BuilderLost

The builder stays outside during the build.

unsigned CUnitType::BuilderOutside

Unit can attack.

unsigned CUnitType::Building

Death explosion animated.

std::vector<CBuildRestriction *> CUnitType::BuildingRules

Resource information.

int CUnitType::BurnDamageRate

Burning percent.

int CUnitType::BurnPercent

Reacts on enemy for person player.

int CUnitType::ButtonLevelForTransporter

How much "cells" unit occupies inside transporter.

unsigned CUnitType::CanAttack

Building must be build on coast.

char* CUnitType::CanCastSpell

Units repair range.

unsigned CUnitType::CanHarvest

The builder is lost after the build.

int CUnitType::CanStore[MaxCosts]
int CUnitType::CanTarget
int CUnitType::ClicksToExplode

Quantity of tiles to move randomly.

CConstruction* CUnitType::Construction

Corpse unit-type.

std::string CUnitType::CorpseName

DamageType (used for extra death animations and impacts)

CUnitType* CUnitType::CorpseType

Corpse type name.

unsigned CUnitType::Coward

Can see Cloaked units.

std::string CUnitType::DamageType
mutable

lua function to create effects after teleportation

LuaCallback* CUnitType::DeathExplosion

Missiles spawned if unit is hit(+shield)

int CUnitType::DecayRate

Land / fly / naval.

unsigned CUnitType::Decoration

Unit should not be selected during game.

CUnitStats CUnitType::DefaultStat

Unit turns for attack (used for ships)

int CUnitType::Demand

Food supply.

unsigned CUnitType::DetectCloak

Is only visible by CloakDetectors.

int CUnitType::DrawLevel

Sprite vertical offset.

unsigned CUnitType::ExplodeWhenKilled

Sea animated.

MissileConfig CUnitType::Explosion

Missile weapon.

unsigned CUnitType::FieldFlags

Gives player an improved income.

std::string CUnitType::File

Type as number.

unsigned CUnitType::Flip
int CUnitType::GivesResource

Resources that we can store here.

unsigned CUnitType::GroundAttack

Corpes & destroyed places.

unsigned CUnitType::Harvester

Resource can be harvested.

int CUnitType::Height

Sprite width.

IconConfig CUnitType::Icon

Still frame.

std::string CUnitType::Ident
MissileConfig CUnitType::Impact[ANIMATIONS_DEATHTYPES+2]

Missile for unit explosion.

int CUnitType::ImproveIncomes[MaxCosts]

How much health is drained every second when poisoned.

unsigned CUnitType::Indestructible

Unit is a decoration (act as tile).

unsigned CUnitType::IsNotSelectable

Selectable with mouse rectangle.

unsigned CUnitType::LandUnit

reveal the fog of war

int CUnitType::MaxOnBoard

Number of consecutive clicks until unit suicides.

int CUnitType::MinAttackRange

Number of directions unit can face.

MissileConfig CUnitType::Missile
PixelPos CUnitType::MissileOffsets[UnitSides][MaxAttackPos]

Shadow vertical offset.

int CUnitType::MouseAction

Min radius for AI build surroundings checking.

unsigned CUnitType::MovementMask

Unit map field flags.

std::string CUnitType::Name

Identifier.

unsigned CUnitType::Neutral

unit is a resource harvester.

CColor CUnitType::NeutralMinimapColorRGB

Rules list for for AI to build a building.

unsigned CUnitType::NonSolid

Unit unloads his passengers after death.

unsigned CUnitType::NoRandomPlacing

Use special logic for Direction field.

int CUnitType::NumDirections

Selected box size vertical offset.

int CUnitType::OffsetX

Sprite height.

int CUnitType::OffsetY

Sprite horizontal offset.

LuaCallback* CUnitType::OnEachCycle

lua function called when unit is hit

LuaCallback* CUnitType::OnEachSecond

lua function called every cycle

LuaCallback* CUnitType::OnHit
LuaCallback* CUnitType::OnInit

lua function called every second

unsigned CUnitType::Organic

Don't use random frame rotation.

unsigned CUnitType::PermanentCloak

Unit is visible under fog of war.

int CUnitType::PoisonDrain

Food demand.

struct CUnitType::_portrait_ CUnitType::Portrait
int CUnitType::RandomMovementDistance

Probability to move randomly.

int CUnitType::RandomMovementProbability

The rate at which the building builds itself.

int CUnitType::ReactRangeComputer

Minimal attack range.

int CUnitType::ReactRangePerson

Reacts on enemy for computer.

int CUnitType::RepairCosts[MaxCosts]

Amount of HP per repair.

int CUnitType::RepairHP

What is shown in construction phase.

int CUnitType::RepairRange

HP burn rate per sec.

ResourceInfo* CUnitType::ResInfo[MaxCosts]

The resource this unit gives.

unsigned CUnitType::Revealer

Flip image when facing left.

unsigned CUnitType::SaveCargo

Can teleport other units.

unsigned CUnitType::SeaUnit

Air animated.

unsigned CUnitType::SelectableByRectangle

Unit is neutral, used by the editor.

std::string CUnitType::ShadowFile

Sprite files.

int CUnitType::ShadowHeight

Shadow sprite width.

int CUnitType::ShadowOffsetX

Shadow sprite height.

int CUnitType::ShadowOffsetY

Shadow horizontal offset.

CGraphic* CUnitType::ShadowSprite

Sprite images.

int CUnitType::ShadowWidth

Level to Draw UnitType at.

unsigned CUnitType::ShoreBuilding

Can do command ground attack.

unsigned CUnitType::SideAttack

Organic unit (used for death coil spell)

int CUnitType::Slot

Pretty name shown from the engine.

CUnitSound CUnitType::Sound

Minimap Color for Neutral Units.

CPlayerColorGraphic* CUnitType::Sprite

Unit status for each player.

int CUnitType::StartingResources

On which button level game will show units inside transporter.

CUnitStats CUnitType::Stats[PlayerMax]

Unit check this map flags for move.

Todo:
This stats should? be moved into the player struct
int CUnitType::StillFrame

Animation scripts.

int CUnitType::Supply

Sounds for events.

int CUnitType::TeleportCost

lua function called on unit init

LuaCallback* CUnitType::TeleportEffectIn

mana used for teleportation

LuaCallback* CUnitType::TeleportEffectOut

lua function to create effects before teleportation

unsigned CUnitType::Teleporter

Unit is indestructible (take no damage).

int CUnitType::TileHeight

Tile size on map width.

int CUnitType::TileWidth

How much it costs to repair.

UnitTypeType CUnitType::UnitType

originally only visual effect, we do more with this!

Amount of Resources on build

unsigned CUnitType::Vanishes

Can attack from transporter.

unsigned CUnitType::VisibleUnderFog

Building.

unsigned CUnitType::Wall

Unit can be entered by other units.

int CUnitType::Width

Shadow file.


The documentation for this class was generated from the following files:
(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.