_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#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] |
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 * | OnDeath |
Missiles spawned if unit is hit(+shield) More... | |
LuaCallback * | OnHit |
lua function called when unit is about to die, receives x,y,unit More... | |
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... | |
LuaCallback * | OnReady |
lua function called on unit init More... | |
int | TeleportCost |
lua function called when unit ready/built 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 |
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< 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... | |
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... | |
CPlayerColorGraphic * | Sprite |
Unit status for each player. More... | |
CPlayerColorGraphic * | AltSprite |
Sprite images. More... | |
CGraphic * | ShadowSprite |
Alternative sprite images. More... | |
Base structure of unit-type
#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:
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".
Pretty name shown by the engine. The name should be shorter than 17 characters and no word can be longer than 8 characters.
Path file name of the sprite file.
Path file name of shadow sprite file.
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.
Animation scripts for the different actions. Currently the animations still, move, attack and die are supported.
Icon to display for this unit-type. Contains configuration and run time variable.
Configuration and run time variable of the missile weapon.
Configuration and run time variable of the missile explosion. This is the explosion that happens if unit is set to ExplodeWhenKilled
Corpse unit-type name, should only be used during setup.
Corpse unit-type pointer, only this should be used during run time. Many unit-types can share the same corpse.
What is shown in construction phase.
CUnitType::SightRange
Sight range
CUnitType::_HitPoints
Maximum hit points
CUnitType::_Costs[MaxCosts]
How many resources needed
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.
Tile size on map width
Tile size on map height
Selected box size width
Selected box size height
Number of directions the unit can face
Minimal attack range
Reacts on enemy for computer
Reacts on enemy for person player
CUnitType::Priority
Priority value / AI Treatment
The burning limit in percents. If the unit has lees than this it will start to burn.
Burn rate in HP per second
Land / fly / naval
Decay rate in 1/6 seconds
CUnitType::AnnoyComputerFactor
How much this annoys the computer
Right click action
CUnitType::Points
How many points you get for unit. Used in the final score table.
Which units can it attack
Land animated
Air animated
Sea animated
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.
If this is non-zero, then after that many clicks the unit will commit suicide. Doesn't work with resource workers/resources.
Unit is a Building
CUnitType::Transporter
Can transport units
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)
This equals to the resource Id of the resource given or 0 (TimeCost) for other buildings.
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.
What resource types we can store here.
Unit is able to use spells
Unit is able to attack.
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)
CUnitType::ShieldPiercing
Can directly damage shield-protected units, without shield damaging.
Sounds for events
CUnitType::Weapon
Current sound for weapon
Flags that are set, if a unit enters a map field or cleared, if a unit leaves a map field.
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.
Unit status for each player
CUnitType::Type
Type as number
Sprite images
Shadow sprite images
CUnitType::CUnitType | ( | ) |
CUnitType::~CUnitType | ( | ) |
bool CUnitType::CanMove | ( | ) | const |
bool CUnitType::CanSelect | ( | GroupSelectionMode | mode = SELECTABLE_BY_RECTANGLE_ONLY | ) | const |
|
inline |
bool CUnitType::CheckUserBoolFlags | ( | const char * | BoolFlags | ) | const |
|
inline |
PixelSize CUnitType::GetPixelSize | ( | ) | const |
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.
std::string CUnitType::AltFile |
Sprite files.
CPlayerColorGraphic* CUnitType::AltSprite |
Sprite images.
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.
|
mutable |
lua function to create effects after teleportation
int CUnitType::DecayRate |
Land / fly / naval.
CUnitStats CUnitType::DefaultStat |
Unit will try to shoot from max range.
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] |
If > 0, the shadow is a simple sprite without directions and this selects which frame to use
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::OnDeath |
Missiles spawned if unit is hit(+shield)
LuaCallback* CUnitType::OnEachCycle |
lua function called when unit is hit
LuaCallback* CUnitType::OnEachSecond |
lua function called every cycle
LuaCallback* CUnitType::OnHit |
lua function called when unit is about to die, receives x,y,unit
LuaCallback* CUnitType::OnInit |
lua function called every second
LuaCallback* CUnitType::OnReady |
lua function called on unit init
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 |
Alternative sprite files.
int CUnitType::ShadowHeight |
Shadow sprite width.
int CUnitType::ShadowOffsetX |
Shadow sprite height.
int CUnitType::ShadowOffsetY |
Shadow horizontal offset.
char CUnitType::ShadowScale |
Shadow vertical offset.
CGraphic* CUnitType::ShadowSprite |
Alternative sprite images.
char CUnitType::ShadowSpriteFrame |
Shadow scale-down factor.
int CUnitType::ShadowWidth |
Level to Draw UnitType at.
unsigned CUnitType::SideAttack |
Unit is neutral, used by the editor.
unsigned CUnitType::Skirmisher |
Unit turns for attack (used for ships)
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.
int CUnitType::StillFrame |
Animation scripts.
int CUnitType::TeleportCost |
lua function called when unit ready/built
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.