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

CUnitType Class Reference

#include <unittype.h>

List of all members.


Public Member Functions

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

Public Attributes

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

Classes

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

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

Vec2i CUnitType::GetHalfTileSize (  )  const [inline]

PixelSize CUnitType::GetPixelSize (  )  const

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

Shadow sprite image.

bool CUnitType::CanTransport (  )  const [inline]

bool CUnitType::CanMove (  )  const

bool CUnitType::CanSelect ( GroupSelectionMode  mode = SELECTABLE_BY_RECTANGLE_ONLY  )  const [inline]


Member Data Documentation

std::string CUnitType::Ident

std::string CUnitType::Name

Identifier.

Pretty name shown from the engine.

std::string CUnitType::File

Type as number.

std::string CUnitType::ShadowFile

Sprite files.

Shadow file.

Sprite width.

Sprite height.

Sprite horizontal offset.

Sprite vertical offset.

Level to Draw UnitType at.

Shadow sprite width.

Shadow sprite height.

Shadow horizontal offset.

PixelPos CUnitType::MissileOffsets[UnitSides][MaxAttackPos]

Shadow vertical offset.

Attack offsets for missiles.

Icon to display for this unit.

MissileConfig CUnitType::Impact[ANIMATIONS_DEATHTYPES+2]

Missile for unit explosion.

Missiles spawned if unit is hit(+shield).

lua function called when unit is hit

lua function called every cycle

std::string CUnitType::DamageType

lua function called every second

std::string CUnitType::CorpseName

DamageType (used for extra death animations and impacts).

Corpse type name.

What is shown in construction phase.

int CUnitType::RepairCosts[MaxCosts]

Amount of HP per repair.

How much it costs to repair.

Tile size on map width.

Tile size on map height.

Selected box size width.

Selected box size height.

Number of directions unit can face.

Minimal attack range.

Reacts on enemy for computer.

Reacts on enemy for person player.

Priority value / AI Treatment.

Burning percent.

HP burn rate per sec.

Units repair range.

Unit is able to use spells.

Default value for autocast.

The rate at which the building builds itself.

Probability to move randomly.

Number of consecutive clicks until unit suicides.

Number of Transporter slots.

originally only visual effect, we do more with this!

Amount of Resources on build

Land / fly / naval.

Decay rate in 1/6 seconds.

How much this annoys the computer.

unsigned CUnitType::Flip

Flip image when facing left.

reveal the fog of war

Land animated.

Air animated.

Sea animated.

Death explosion animated.

Building.

Unit is visible under fog of war.

Is only visible by CloakDetectors.

Can see Cloaked units.

Unit will only attack if instructed.

Can attack from transporter.

Corpes & destroyed places.

Can do command ground attack.

Building must be build on coast.

Unit can attack.

The builder stays outside during the build.

The builder is lost after the build.

Resource can be harvested.

unit is a resource harvester.

Unit is neutral, used by the editor.

Selectable with mouse rectangle.

Unit should not be selected during game.

Unit is a decoration (act as tile).

Unit is indestructible (take no damage).

Can teleport other units.

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

Unit unloads his passengers after death.

unsigned CUnitType::Wall

Unit can be entered by other units.

Use special logic for Direction field.

int CUnitType::CanStore[MaxCosts]

Resources that we can store here.

The resource this unit gives.

Resource information.

Rules list for building a building.

Rules list for for AI to build a building.

Minimap Color for Neutral Units.

Sounds for events.

Food supply.

Food demand.

Gives player an improved income.

Unit map field flags.

Unit check this map flags for move.

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

Unit status for each player.


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.