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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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...
 
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...
 
LuaCallbackDeathExplosion
 Missiles spawned if unit is hit(+shield) More...
 
LuaCallbackOnHit
 
LuaCallbackOnEachCycle
 lua function called when unit is hit More...
 
LuaCallbackOnEachSecond
 lua function called every cycle More...
 
LuaCallbackOnInit
 lua function called every second More...
 
int TeleportCost
 lua function called on unit init 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...
 
CUnitStats DefaultStat
 Unit turns for attack (used for ships) 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...
 
CGraphicShadowSprite
 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

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.

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

char* CUnitType::CanCastSpell
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.

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.

CUnitStats CUnitType::DefaultStat

Unit turns for attack (used for ships)

int CUnitType::DrawLevel

Sprite vertical offset.

unsigned CUnitType::ExplodeWhenKilled

Sea animated.

MissileConfig CUnitType::Explosion

Missile weapon.

unsigned CUnitType::FieldFlags

How much health is drained every second when poisoned.

std::string CUnitType::File

Type as number.

unsigned CUnitType::Flip
int CUnitType::GivesResource

Resources that we can store here.

int CUnitType::Height

Sprite width.

IconConfig CUnitType::Icon

Still frame.

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

Missile for unit explosion.

unsigned CUnitType::LandUnit

Flip image when facing left.

CUnitStats CUnitType::MapDefaultStat
CUnitSound CUnitType::MapSound

Sounds for events.

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 can attack.

CColor CUnitType::NeutralMinimapColorRGB

Rules list for for AI to build a building.

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

int CUnitType::PoisonDrain

Sounds for events, map-specific.

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

Air animated.

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

Unit is neutral, used by the editor.

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

lua function called on unit init

LuaCallback* CUnitType::TeleportEffectIn

mana used for teleportation

LuaCallback* CUnitType::TeleportEffectOut

lua function to create effects before teleportation

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

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.