_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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 AltFile
 Sprite files. More...
 
std::string ShadowFile
 Alternative 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...
 
char ShadowScale
 Shadow vertical offset. More...
 
char ShadowSpriteFrame
 Shadow scale-down factor. More...
 
PixelPos MissileOffsets [UnitSides][MaxAttackPos]
 
CAnimationsAnimations
 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...
 
LuaCallbackOnDeath
 Missiles spawned if unit is hit(+shield) More...
 
LuaCallbackOnHit
 lua function called when unit is about to die, receives x,y,unit More...
 
LuaCallbackOnEachCycle
 lua function called when unit is hit More...
 
LuaCallbackOnEachSecond
 lua function called every cycle More...
 
LuaCallbackOnInit
 lua function called every second More...
 
LuaCallbackOnReady
 lua function called on unit init More...
 
int TeleportCost
 lua function called when unit ready/built More...
 
LuaCallbackTeleportEffectIn
 mana used for teleportation More...
 
LuaCallbackTeleportEffectOut
 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...
 
CUnitTypeCorpseType
 Corpse type name. More...
 
CConstructionConstruction
 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
 
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 LandUnit: 1
 Flip image when facing left. 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 CanAttack: 1
 Building. More...
 
unsigned Neutral: 1
 Unit can attack. More...
 
unsigned SideAttack: 1
 Unit is neutral, used by the editor. More...
 
unsigned Skirmisher: 1
 Unit turns for attack (used for ships) More...
 
CUnitStats DefaultStat
 Unit will try to shoot from max range. More...
 
CUnitStats MapDefaultStat
 
std::vector< BoolFlagsBoolFlag
 
int CanStore [MaxCosts]
 
int GivesResource
 Resources that we can store here. More...
 
ResourceInfoResInfo [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...
 
CUnitSound MapSound
 Sounds for events. More...
 
int PoisonDrain
 Sounds for events, map-specific. More...
 
unsigned FieldFlags
 How much health is drained every second when poisoned. More...
 
unsigned MovementMask
 Unit map field flags. More...
 
CUnitStats Stats [PlayerMax]
 Unit check this map flags for move. More...
 
CPlayerColorGraphicSprite
 Unit status for each player. More...
 
CPlayerColorGraphicAltSprite
 Sprite images. More...
 
CGraphicShadowSprite
 Alternative 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

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::Transporter

Can transport units

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::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::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::ShieldPiercing

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

CUnitType::Sound

Sounds for events

CUnitType::Weapon

Current sound for weapon

Todo:
temporary solution

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

Constructor & Destructor Documentation

◆ CUnitType()

CUnitType::CUnitType ( )

◆ ~CUnitType()

CUnitType::~CUnitType ( )

Member Function Documentation

◆ CanMove()

bool CUnitType::CanMove ( ) const

◆ CanSelect()

bool CUnitType::CanSelect ( GroupSelectionMode  mode = SELECTABLE_BY_RECTANGLE_ONLY) const

◆ CanTransport()

bool CUnitType::CanTransport ( ) const
inline

◆ CheckUserBoolFlags()

bool CUnitType::CheckUserBoolFlags ( const char *  BoolFlags) const

◆ GetHalfTileSize()

Vec2i CUnitType::GetHalfTileSize ( ) const
inline

◆ GetPixelSize()

PixelSize CUnitType::GetPixelSize ( ) const

Member Data Documentation

◆ AiAdjacentRange

int CUnitType::AiAdjacentRange

How much this annoys the computer.

◆ AiBuildingRules

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

Rules list for building a building.

◆ AirUnit

unsigned CUnitType::AirUnit

Land animated.

◆ AltFile

std::string CUnitType::AltFile

Sprite files.

◆ AltSprite

CPlayerColorGraphic* CUnitType::AltSprite

Sprite images.

◆ Animations

CAnimations* CUnitType::Animations

Attack offsets for missiles.

◆ AnnoyComputerFactor

int CUnitType::AnnoyComputerFactor

Decay rate in 1/6 seconds.

◆ AutoBuildRate

int CUnitType::AutoBuildRate

Default value for autocast.

◆ AutoCastActive

char* CUnitType::AutoCastActive

Unit is able to use spells.

◆ BoardSize

int CUnitType::BoardSize

Number of Transporter slots.

◆ BoolFlag

std::vector<BoolFlags> CUnitType::BoolFlag

◆ BoxHeight

int CUnitType::BoxHeight

Selected box size width.

◆ BoxOffsetX

int CUnitType::BoxOffsetX

Selected box size height.

◆ BoxOffsetY

int CUnitType::BoxOffsetY

Selected box size horizontal offset.

◆ BoxWidth

int CUnitType::BoxWidth

Tile size on map height.

◆ Building

unsigned CUnitType::Building

Death explosion animated.

◆ BuildingRules

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

Resource information.

◆ BurnDamageRate

int CUnitType::BurnDamageRate

Burning percent.

◆ BurnPercent

int CUnitType::BurnPercent

Reacts on enemy for person player.

◆ ButtonLevelForTransporter

int CUnitType::ButtonLevelForTransporter

How much "cells" unit occupies inside transporter.

◆ CanAttack

unsigned CUnitType::CanAttack

Building.

◆ CanCastSpell

char* CUnitType::CanCastSpell

◆ CanStore

int CUnitType::CanStore[MaxCosts]

◆ CanTarget

int CUnitType::CanTarget

◆ ClicksToExplode

int CUnitType::ClicksToExplode

Quantity of tiles to move randomly.

◆ Construction

CConstruction* CUnitType::Construction

Corpse unit-type.

◆ CorpseName

std::string CUnitType::CorpseName

DamageType (used for extra death animations and impacts)

◆ CorpseType

CUnitType* CUnitType::CorpseType

Corpse type name.

◆ DamageType

std::string CUnitType::DamageType
mutable

lua function to create effects after teleportation

◆ DecayRate

int CUnitType::DecayRate

Land / fly / naval.

◆ DefaultStat

CUnitStats CUnitType::DefaultStat

Unit will try to shoot from max range.

◆ DrawLevel

int CUnitType::DrawLevel

Sprite vertical offset.

◆ ExplodeWhenKilled

unsigned CUnitType::ExplodeWhenKilled

Sea animated.

◆ Explosion

MissileConfig CUnitType::Explosion

Missile weapon.

◆ FieldFlags

unsigned CUnitType::FieldFlags

How much health is drained every second when poisoned.

◆ File

std::string CUnitType::File

Type as number.

◆ Flip

unsigned CUnitType::Flip

◆ GivesResource

int CUnitType::GivesResource

Resources that we can store here.

◆ Height

int CUnitType::Height

Sprite width.

◆ Icon

IconConfig CUnitType::Icon

Still frame.

◆ Ident

std::string CUnitType::Ident

◆ Impact

MissileConfig CUnitType::Impact[ANIMATIONS_DEATHTYPES+2]

Missile for unit explosion.

◆ LandUnit

unsigned CUnitType::LandUnit

Flip image when facing left.

◆ MapDefaultStat

CUnitStats CUnitType::MapDefaultStat

◆ MapSound

CUnitSound CUnitType::MapSound

Sounds for events.

◆ MaxOnBoard

int CUnitType::MaxOnBoard

Number of consecutive clicks until unit suicides.

◆ MinAttackRange

int CUnitType::MinAttackRange

Number of directions unit can face.

◆ Missile

MissileConfig CUnitType::Missile

◆ MissileOffsets

PixelPos CUnitType::MissileOffsets[UnitSides][MaxAttackPos]

If > 0, the shadow is a simple sprite without directions and this selects which frame to use

◆ MouseAction

int CUnitType::MouseAction

Min radius for AI build surroundings checking.

◆ MovementMask

unsigned CUnitType::MovementMask

Unit map field flags.

◆ Name

std::string CUnitType::Name

Identifier.

◆ Neutral

unsigned CUnitType::Neutral

Unit can attack.

◆ NeutralMinimapColorRGB

CColor CUnitType::NeutralMinimapColorRGB

Rules list for for AI to build a building.

◆ NumDirections

int CUnitType::NumDirections

Selected box size vertical offset.

◆ OffsetX

int CUnitType::OffsetX

Sprite height.

◆ OffsetY

int CUnitType::OffsetY

Sprite horizontal offset.

◆ OnDeath

LuaCallback* CUnitType::OnDeath

Missiles spawned if unit is hit(+shield)

◆ OnEachCycle

LuaCallback* CUnitType::OnEachCycle

lua function called when unit is hit

◆ OnEachSecond

LuaCallback* CUnitType::OnEachSecond

lua function called every cycle

◆ OnHit

LuaCallback* CUnitType::OnHit

lua function called when unit is about to die, receives x,y,unit

◆ OnInit

LuaCallback* CUnitType::OnInit

lua function called every second

◆ OnReady

LuaCallback* CUnitType::OnReady

lua function called on unit init

◆ PoisonDrain

int CUnitType::PoisonDrain

Sounds for events, map-specific.

◆ Portrait

struct CUnitType::_portrait_ CUnitType::Portrait

◆ RandomMovementDistance

int CUnitType::RandomMovementDistance

Probability to move randomly.

◆ RandomMovementProbability

int CUnitType::RandomMovementProbability

The rate at which the building builds itself.

◆ ReactRangeComputer

int CUnitType::ReactRangeComputer

Minimal attack range.

◆ ReactRangePerson

int CUnitType::ReactRangePerson

Reacts on enemy for computer.

◆ RepairCosts

int CUnitType::RepairCosts[MaxCosts]

Amount of HP per repair.

◆ RepairHP

int CUnitType::RepairHP

What is shown in construction phase.

◆ RepairRange

int CUnitType::RepairRange

HP burn rate per sec.

◆ ResInfo

ResourceInfo* CUnitType::ResInfo[MaxCosts]

The resource this unit gives.

◆ SeaUnit

unsigned CUnitType::SeaUnit

Air animated.

◆ ShadowFile

std::string CUnitType::ShadowFile

Alternative sprite files.

◆ ShadowHeight

int CUnitType::ShadowHeight

Shadow sprite width.

◆ ShadowOffsetX

int CUnitType::ShadowOffsetX

Shadow sprite height.

◆ ShadowOffsetY

int CUnitType::ShadowOffsetY

Shadow horizontal offset.

◆ ShadowScale

char CUnitType::ShadowScale

Shadow vertical offset.

◆ ShadowSprite

CGraphic* CUnitType::ShadowSprite

Alternative sprite images.

◆ ShadowSpriteFrame

char CUnitType::ShadowSpriteFrame

Shadow scale-down factor.

◆ ShadowWidth

int CUnitType::ShadowWidth

Level to Draw UnitType at.

◆ SideAttack

unsigned CUnitType::SideAttack

Unit is neutral, used by the editor.

◆ Skirmisher

unsigned CUnitType::Skirmisher

Unit turns for attack (used for ships)

◆ Slot

int CUnitType::Slot

Pretty name shown from the engine.

◆ Sound

CUnitSound CUnitType::Sound

Minimap Color for Neutral Units.

◆ Sprite

CPlayerColorGraphic* CUnitType::Sprite

Unit status for each player.

◆ StartingResources

int CUnitType::StartingResources

On which button level game will show units inside transporter.

◆ Stats

CUnitStats CUnitType::Stats[PlayerMax]

Unit check this map flags for move.

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

◆ StillFrame

int CUnitType::StillFrame

Animation scripts.

◆ TeleportCost

int CUnitType::TeleportCost

lua function called when unit ready/built

◆ TeleportEffectIn

LuaCallback* CUnitType::TeleportEffectIn

mana used for teleportation

◆ TeleportEffectOut

LuaCallback* CUnitType::TeleportEffectOut

lua function to create effects before teleportation

◆ TileHeight

int CUnitType::TileHeight

Tile size on map width.

◆ TileWidth

int CUnitType::TileWidth

How much it costs to repair.

◆ UnitType

UnitTypeType CUnitType::UnitType

originally only visual effect, we do more with this!

Amount of Resources on build

◆ Width

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.