OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | List of all members
OpenXcom::BattleUnit Class Reference

Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about it's position, items carrying, stats, etc. More...

#include <BattleUnit.h>

Public Member Functions

 BattleUnit (Soldier *soldier, int depth)
 Creates a BattleUnit from solder. More...
 
 BattleUnit (Unit *unit, UnitFaction faction, int id, Armor *armor, StatAdjustment *adjustment, int depth)
 Creates a BattleUnit from unit. More...
 
 ~BattleUnit ()
 Cleans up the BattleUnit.
 
void load (const YAML::Node &node)
 Loads the unit from YAML. More...
 
YAML::Node save () const
 Saves the unit to YAML. More...
 
int getId () const
 Gets the BattleUnit's ID. More...
 
void setPosition (Position pos, bool updateLastPos=true)
 Sets the unit's position. More...
 
Position getPosition () const
 Gets the unit's position. More...
 
Position getLastPosition () const
 Gets the unit's position. More...
 
void setDirection (int direction)
 Sets the unit's direction 0-7. More...
 
void setFaceDirection (int direction)
 Sets the unit's face direction (only used by strafing moves) More...
 
int getDirection () const
 Gets the unit's direction. More...
 
int getFaceDirection () const
 Gets the unit's face direction (only used by strafing moves) More...
 
int getTurretDirection () const
 Gets the unit's turret direction. More...
 
int getTurretToDirection () const
 Gets the unit's turret To direction. More...
 
int getVerticalDirection () const
 Gets the unit's vertical direction. More...
 
UnitStatus getStatus () const
 Gets the unit's status. More...
 
void startWalking (int direction, Position destination, Tile *tileBelowMe, bool cache)
 Start the walkingPhase. More...
 
void keepWalking (Tile *tileBelowMe, bool cache)
 Increase the walkingPhase. More...
 
int getWalkingPhase () const
 Gets the walking phase for animation and sound. More...
 
int getDiagonalWalkingPhase () const
 Gets the walking phase for diagonal walking. More...
 
Position getDestination () const
 Gets the unit's destination when walking. More...
 
void lookAt (Position point, bool turret=false)
 Look at a certain point. More...
 
void lookAt (int direction, bool force=false)
 Look at a certain direction. More...
 
void turn (bool turret=false)
 Turn to the destination direction. More...
 
void abortTurn ()
 Abort turning. More...
 
SoldierGender getGender () const
 Gets the soldier's gender.
 
UnitFaction getFaction () const
 Gets the unit's faction. More...
 
void setCache (Surface *cache, int part=0)
 Set the cached flag. More...
 
SurfacegetCache (bool *invalid, int part=0) const
 If this unit is cached on the battlescape. More...
 
const std::vector< std::pair< Uint8, Uint8 > > & getRecolor () const
 Gets unit sprite recolors values. More...
 
void kneel (bool kneeled)
 Kneel down. More...
 
bool isKneeled () const
 Is kneeled? More...
 
bool isFloating () const
 Is floating? More...
 
void aim (bool aiming)
 Aim. More...
 
int directionTo (Position point) const
 Get direction to a certain point. More...
 
int getTimeUnits () const
 Gets the unit's time units. More...
 
int getEnergy () const
 Gets the unit's stamina. More...
 
int getHealth () const
 Gets the unit's health. More...
 
int getMorale () const
 Gets the unit's bravery. More...
 
int damage (Position relative, int power, ItemDamageType type, bool ignoreArmor=false)
 Do damage to the unit. More...
 
void healStun (int power)
 Heal stun level of the unit. More...
 
int getStunlevel () const
 Gets the unit's stun level.
 
void knockOut (BattlescapeGame *battle)
 Knocks the unit out instantly. More...
 
void startFalling ()
 Start falling sequence. More...
 
void keepFalling ()
 Increment the falling sequence. More...
 
int getFallingPhase () const
 Get falling sequence. More...
 
bool isOut () const
 The unit is out - either dead or unconscious. More...
 
int getActionTUs (BattleActionType actionType, BattleItem *item)
 Get the number of time units a certain action takes. More...
 
bool spendTimeUnits (int tu)
 Spend time units if it can. More...
 
bool spendEnergy (int tu)
 Spend energy if it can. More...
 
void setTimeUnits (int tu)
 Set time units. More...
 
bool addToVisibleUnits (BattleUnit *unit)
 Add unit to visible units. More...
 
std::vector< BattleUnit * > * getVisibleUnits ()
 Get the list of visible units. More...
 
void clearVisibleUnits ()
 Clear visible units.
 
bool addToVisibleTiles (Tile *tile)
 Add unit to visible tiles. More...
 
std::vector< Tile * > * getVisibleTiles ()
 Get the list of visible tiles. More...
 
void clearVisibleTiles ()
 Clear visible tiles.
 
int getFiringAccuracy (BattleActionType actionType, BattleItem *item)
 Calculate firing accuracy. More...
 
int getAccuracyModifier (BattleItem *item=0)
 Calculate accuracy modifier. More...
 
double getThrowingAccuracy ()
 Calculate throwing accuracy. More...
 
void setArmor (int armor, UnitSide side)
 Set armor value. More...
 
int getArmor (UnitSide side) const
 Get armor value. More...
 
int getMaxArmor (UnitSide side) const
 Get max armor value. More...
 
int getFatalWounds () const
 Get total number of fatal wounds. More...
 
double getReactionScore ()
 Get the current reaction score. More...
 
void prepareNewTurn (bool fullProcess=true)
 Prepare for a new turn.
 
void moraleChange (int change)
 Morale change. More...
 
void dontReselect ()
 Don't reselect this unit. More...
 
void allowReselect ()
 Reselect this unit. More...
 
bool reselectAllowed () const
 Check whether reselecting this unit is allowed. More...
 
void setFire (int fire)
 Set fire. More...
 
int getFire () const
 Get fire. More...
 
std::vector< BattleItem * > * getInventory ()
 Get the list of items in the inventory. More...
 
void think (BattleAction *action)
 Let AI do their thing. More...
 
AIModulegetAIModule () const
 Get AI Module. More...
 
void setAIModule (AIModule *ai)
 Set AI Module. More...
 
void setVisible (bool flag)
 Set whether this unit is visible. More...
 
bool getVisible () const
 Get whether this unit is visible. More...
 
void setTile (Tile *tile, Tile *tileBelow=0)
 Sets the unit's tile it's standing on. More...
 
TilegetTile () const
 Gets the unit's tile. More...
 
BattleItemgetItem (RuleInventory *slot, int x=0, int y=0) const
 Gets the item in the specified slot. More...
 
BattleItemgetItem (const std::string &slot, int x=0, int y=0) const
 Gets the item in the specified slot. More...
 
BattleItemgetMainHandWeapon (bool quickest=true) const
 Gets the item in the main hand. More...
 
BattleItemgetGrenadeFromBelt () const
 Gets a grenade from the belt, if any. More...
 
bool checkAmmo ()
 Reloads righthand weapon if needed. More...
 
bool isInExitArea (SpecialTileType stt=START_POINT) const
 Check if this unit is in the exit area. More...
 
bool liesInExitArea (Tile *tile, SpecialTileType stt=START_POINT) const
 Check if this unit lies (e.g. More...
 
int getHeight () const
 Gets the unit height taking into account kneeling/standing. More...
 
int getFloatHeight () const
 Gets the unit floating elevation. More...
 
void addReactionExp ()
 Adds one to the reaction exp counter.
 
void addFiringExp ()
 Adds one to the firing exp counter.
 
void addThrowingExp ()
 Adds one to the throwing exp counter.
 
void addPsiSkillExp ()
 Adds one to the psi skill exp counter.
 
void addPsiStrengthExp ()
 Adds one to the psi strength exp counter.
 
void addMeleeExp ()
 Adds one to the melee exp counter.
 
void updateGeoscapeStats (Soldier *soldier) const
 Updates the stats of a Geoscape soldier.
 
bool postMissionProcedures (SavedGame *geoscape, UnitStats &statsDiff)
 Check if unit eligible for squaddie promotion. More...
 
int getMiniMapSpriteIndex () const
 Get the sprite index for the minimap. More...
 
void setTurretType (int turretType)
 Set the turret type. -1 is no turret. More...
 
int getTurretType () const
 Get the turret type. -1 is no turret. More...
 
int getFatalWound (int part) const
 Get fatal wound amount of a body part. More...
 
void heal (int part, int woundAmount, int healthAmount)
 Heal one fatal wound. More...
 
void painKillers ()
 Give pain killers to this unit. More...
 
void stimulant (int energy, int stun)
 Give stimulant to this unit. More...
 
int getMotionPoints () const
 Get motion points for the motion scanner. More...
 
ArmorgetArmor () const
 Gets the unit's armor. More...
 
std::string getName (Language *lang, bool debugAppendId=false) const
 Gets the unit's name. More...
 
UnitStatsgetBaseStats ()
 Gets the unit's stats. More...
 
int getStandHeight () const
 Get the unit's stand height. More...
 
int getKneelHeight () const
 Get the unit's kneel height. More...
 
int getLoftemps (int entry=0) const
 Get the unit's loft ID. More...
 
int getValue () const
 Get the unit's value. More...
 
const std::vector< int > & getDeathSounds () const
 Get the unit's death sounds. More...
 
int getMoveSound () const
 Get the unit's move sound. More...
 
bool isWoundable () const
 Get whether the unit is affected by fatal wounds. More...
 
bool isFearable () const
 Get whether the unit is affected by fear. More...
 
int getIntelligence () const
 Get the unit's intelligence. More...
 
int getAggression () const
 Get the unit's aggression. More...
 
int getSpecialAbility () const
 Get the units's special ability. More...
 
void setRespawn (bool respawn)
 Set the units's respawn flag. More...
 
bool getRespawn () const
 Get the units's respawn flag. More...
 
std::string getRankString () const
 Get the units's rank string. More...
 
SoldiergetGeoscapeSoldier () const
 Get the geoscape-soldier object. More...
 
void addKillCount ()
 Add a kill to the counter.
 
std::string getType () const
 Get unit type. More...
 
void setActiveHand (const std::string &slot)
 Set the hand this unit is using;. More...
 
std::string getActiveHand () const
 Get unit's active hand. More...
 
void convertToFaction (UnitFaction f)
 Convert's unit to a faction. More...
 
void kill ()
 Set health to 0. More...
 
void instaKill ()
 Set health to 0 and set status dead. More...
 
std::string getSpawnUnit () const
 Gets the unit's spawn unit. More...
 
void setSpawnUnit (const std::string &spawnUnit)
 Sets the unit's spawn unit. More...
 
int getAggroSound () const
 Gets the unit's aggro sound. More...
 
void setEnergy (int energy)
 Sets the unit's energy level. More...
 
UnitFaction killedBy () const
 Get the faction that killed this unit. More...
 
void killedBy (UnitFaction f)
 Set the faction that killed this unit. More...
 
void setCharging (BattleUnit *chargeTarget)
 Set the units we are charging towards. More...
 
BattleUnitgetCharging ()
 Get the units we are charging towards. More...
 
int getCarriedWeight (BattleItem *draggingItem=0) const
 Get the carried weight in strength units. More...
 
void setTurnsSinceSpotted (int turns)
 Set how many turns this unit will be exposed for. More...
 
int getTurnsSinceSpotted () const
 Set how many turns this unit will be exposed for. More...
 
UnitFaction getOriginalFaction () const
 Get this unit's original faction. More...
 
void invalidateCache ()
 call this after the default copy constructor deletes the cache? More...
 
std::vector< BattleUnit * > & getUnitsSpottedThisTurn ()
 get the vector of units we've seen this turn. More...
 
void setRankInt (int rank)
 set the rank integer More...
 
int getRankInt () const
 get the rank integer More...
 
void deriveRank ()
 derive a rank integer based on rank string (for xcom soldiers ONLY) More...
 
bool checkViewSector (Position pos) const
 this function checks if a tile is visible, using maths. More...
 
void adjustStats (const StatAdjustment &adjustment)
 adjust this unit's stats according to difficulty. More...
 
bool tookFireDamage () const
 did this unit already take fire damage this turn? (used to avoid damaging large units multiple times.) More...
 
void toggleFireDamage ()
 switch the state of the fire damage tracker. More...
 
void setCoverReserve (int reserve)
 Changes the amount of TUs reserved for cover. More...
 
int getCoverReserve () const
 Returns the amount of TUs reserved for cover. More...
 
bool isSelectable (UnitFaction faction, bool checkReselect, bool checkInventory) const
 Is this unit selectable? More...
 
bool hasInventory () const
 Does this unit have an inventory? More...
 
int getBreathFrame () const
 Is this unit breathing and if so what frame? More...
 
void breathe ()
 Start breathing and/or update the breathing frame. More...
 
void setFloorAbove (bool floor)
 Set the flag for "floor above me" meaning stop rendering bubbles. More...
 
bool getFloorAbove () const
 Get the flag for "floor above me". More...
 
BattleItemgetMeleeWeapon ()
 Get any melee weapon we may be carrying, or a built in one. More...
 
MovementType getMovementType () const
 Use this function to check the unit's movement type. More...
 
bool isHiding () const
 Checks if this unit is in hiding for a turn.
 
void setHiding (bool hiding)
 Sets this unit is in hiding for a turn (or not).
 
void goToTimeOut ()
 Puts the unit in the corner to think about what he's done. More...
 
void setSpecialWeapon (SavedBattleGame *save, const Mod *mod)
 Create special weapon for unit. More...
 
BattleItemgetSpecialWeapon (BattleType type) const
 Get special weapon.
 
void recoverTimeUnits ()
 Recovers the unit's time units and energy. More...
 
BattleUnitStatisticsgetStatistics ()
 Get the unit's mission statistics. More...
 
void setMurdererId (int id)
 Set the unit murderer's id. More...
 
int getMurdererId () const
 Get the unit murderer's id. More...
 
void setFatalShotInfo (UnitSide side, UnitBodyPart bodypart)
 Set information on the unit's fatal shot. More...
 
UnitSide getFatalShotSide () const
 Get information on the unit's fatal shot's side. More...
 
UnitBodyPart getFatalShotBodyPart () const
 Get information on the unit's fatal shot's body part. More...
 
std::string getMurdererWeapon () const
 Get the unit murderer's weapon. More...
 
void setMurdererWeapon (const std::string &weapon)
 Set the unit murderer's weapon. More...
 
std::string getMurdererWeaponAmmo () const
 Get the unit murderer's weapon's ammo. More...
 
void setMurdererWeaponAmmo (const std::string &weaponAmmo)
 Set the unit murderer's weapon's ammo. More...
 
void setMindControllerId (int id)
 Set the unit mind controller's id. More...
 
int getMindControllerId () const
 Get the unit mind controller's id. More...
 
int getFiringXP () const
 Get the unit's total firing xp for this mission.
 
void nerfFiringXP (int newXP)
 Artificially alter a unit's firing xp. (used for shotguns) More...
 
bool getHitState ()
 Was this unit just hit?
 
void resetHitState ()
 reset the unit hit state.
 
bool getCapturable () const
 Gets whether this unit can be captured alive (applies to aliens).
 

Detailed Description

Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about it's position, items carrying, stats, etc.

Constructor & Destructor Documentation

◆ BattleUnit() [1/2]

OpenXcom::BattleUnit::BattleUnit ( Soldier soldier,
int  depth 
)

Creates a BattleUnit from solder.

Initializes a BattleUnit from a Soldier.

Parameters
soldierPointer to the Soldier.
depththe depth of the battlefield (used to determine movement type in case of MT_FLOAT).

◆ BattleUnit() [2/2]

OpenXcom::BattleUnit::BattleUnit ( Unit unit,
UnitFaction  faction,
int  id,
Armor armor,
StatAdjustment adjustment,
int  depth 
)

Creates a BattleUnit from unit.

Initializes a BattleUnit from a Unit (non-player) object.

Parameters
unitPointer to Unit object.
factionWhich faction the units belongs to.
idUnique unit ID.
armorPointer to unit Armor.
diffdifficulty level (for stat adjustment).
depththe depth of the battlefield (used to determine movement type in case of MT_FLOAT).

Member Function Documentation

◆ abortTurn()

void OpenXcom::BattleUnit::abortTurn ( )

Abort turning.

Stops the turning towards the target direction.

◆ addToVisibleTiles()

bool OpenXcom::BattleUnit::addToVisibleTiles ( Tile tile)

Add unit to visible tiles.

Add this unit to the list of visible tiles.

Returns true if this is a new one.

Parameters
tile
Returns

◆ addToVisibleUnits()

bool OpenXcom::BattleUnit::addToVisibleUnits ( BattleUnit unit)

Add unit to visible units.

Add this unit to the list of visible units.

Returns true if this is a new one.

Parameters
unit
Returns

◆ adjustStats()

void OpenXcom::BattleUnit::adjustStats ( const StatAdjustment adjustment)

adjust this unit's stats according to difficulty.

common function to adjust a unit's stats according to difficulty setting.

Parameters
statAdjustmentthe stat adjustment variables coefficient value.

◆ aim()

void OpenXcom::BattleUnit::aim ( bool  aiming)

Aim.

(shows the right hand sprite and weapon holding)

Parameters
aimingtrue/false

◆ allowReselect()

void OpenXcom::BattleUnit::allowReselect ( )

Reselect this unit.

Mark this unit as reselectable.

◆ breathe()

void OpenXcom::BattleUnit::breathe ( )

Start breathing and/or update the breathing frame.

Decides if we should start producing bubbles, and/or updates which bubble frame we are on.

◆ checkAmmo()

bool OpenXcom::BattleUnit::checkAmmo ( )

Reloads righthand weapon if needed.

Check if we have ammo and reload if needed (used for AI).

Returns
Do we have ammo?

◆ checkViewSector()

bool OpenXcom::BattleUnit::checkViewSector ( Position  pos) const

this function checks if a tile is visible, using maths.

Parameters
posthe position to check against
Returns
what the maths decide

◆ convertToFaction()

void OpenXcom::BattleUnit::convertToFaction ( UnitFaction  f)

Convert's unit to a faction.

Converts unit to another faction (original faction is still stored).

Parameters
ffaction.

◆ damage()

int OpenXcom::BattleUnit::damage ( Position  relative,
int  power,
ItemDamageType  type,
bool  ignoreArmor = false 
)

Do damage to the unit.

Do an amount of damage.

Parameters
relativeThe relative position of which part of armor and/or bodypart is hit.
powerThe amount of damage to inflict.
typeThe type of damage being inflicted.
ignoreArmorShould the damage ignore armor resistance?
Returns
damage done after adjustment

◆ deriveRank()

void OpenXcom::BattleUnit::deriveRank ( )

derive a rank integer based on rank string (for xcom soldiers ONLY)

Derive the numeric unit rank from the string rank (for soldier units).

◆ directionTo()

int OpenXcom::BattleUnit::directionTo ( Position  point) const

Get direction to a certain point.

Returns the direction from this unit to a given point.

0 <-> y = -1, x = 0 1 <-> y = -1, x = 1 3 <-> y = 1, x = 1 5 <-> y = 1, x = -1 7 <-> y = -1, x = -1

Parameters
pointgiven position.
Returns
direction.

◆ dontReselect()

void OpenXcom::BattleUnit::dontReselect ( )

Don't reselect this unit.

Mark this unit as not reselectable.

◆ getAccuracyModifier()

int OpenXcom::BattleUnit::getAccuracyModifier ( BattleItem item = 0)

Calculate accuracy modifier.

To calculate firing accuracy.

Takes health and fatal wounds into account. Formula = accuracyStat * woundsPenalty(% health) * critWoundsPenalty (-10%/wound)

Parameters
itemthe item we are shooting right now.
Returns
modifier

◆ getActionTUs()

int OpenXcom::BattleUnit::getActionTUs ( BattleActionType  actionType,
BattleItem item 
)

Get the number of time units a certain action takes.

Parameters
actionType
item
Returns
TUs

◆ getActiveHand()

std::string OpenXcom::BattleUnit::getActiveHand ( ) const

Get unit's active hand.

Returns
active hand.

◆ getAggression()

int OpenXcom::BattleUnit::getAggression ( ) const

Get the unit's aggression.

Returns
aggression.

◆ getAggroSound()

int OpenXcom::BattleUnit::getAggroSound ( ) const

Gets the unit's aggro sound.

Get sound to play when unit aggros.

Returns
sound

◆ getAIModule()

AIModule * OpenXcom::BattleUnit::getAIModule ( ) const

Get AI Module.

Returns the current AI state.

Returns
Pointer to AI state.

◆ getArmor() [1/2]

int OpenXcom::BattleUnit::getArmor ( UnitSide  side) const

Get armor value.

Get the armor value of a certain armor side.

Parameters
sideThe side of the armor.
Returns
Amount of armor.

◆ getArmor() [2/2]

Armor * OpenXcom::BattleUnit::getArmor ( ) const

Gets the unit's armor.

Returns
Pointer to armor.

◆ getBaseStats()

UnitStats * OpenXcom::BattleUnit::getBaseStats ( )

Gets the unit's stats.

Gets pointer to the unit's stats.

Returns
stats Pointer to the unit's stats.

◆ getBreathFrame()

int OpenXcom::BattleUnit::getBreathFrame ( ) const

Is this unit breathing and if so what frame?

If this unit is breathing, what frame should be displayed?

Returns
frame number.

◆ getCache()

Surface * OpenXcom::BattleUnit::getCache ( bool *  invalid,
int  part = 0 
) const

If this unit is cached on the battlescape.

Check if the unit is still cached in the Map cache.

When the unit changes it needs to be re-cached.

Parameters
invalidGet if the cache is invalid.
partUnit part to check.
Returns
Pointer to cache surface used.

◆ getCarriedWeight()

int OpenXcom::BattleUnit::getCarriedWeight ( BattleItem draggingItem = 0) const

Get the carried weight in strength units.

Get the units carried weight in strength units.

Parameters
draggingItemitem to ignore
Returns
weight

◆ getCharging()

BattleUnit * OpenXcom::BattleUnit::getCharging ( )

Get the units we are charging towards.

Returns
Charge Target

◆ getCoverReserve()

int OpenXcom::BattleUnit::getCoverReserve ( ) const

Returns the amount of TUs reserved for cover.

Returns
time units.

◆ getDeathSounds()

const std::vector< int > & OpenXcom::BattleUnit::getDeathSounds ( ) const

Get the unit's death sounds.

Returns
List of sound IDs.

◆ getDestination()

Position OpenXcom::BattleUnit::getDestination ( ) const

Gets the unit's destination when walking.

Gets the BattleUnit's destination.

Returns
destination

◆ getDiagonalWalkingPhase()

int OpenXcom::BattleUnit::getDiagonalWalkingPhase ( ) const

Gets the walking phase for diagonal walking.

Returns
phase this will be 0 or 8

◆ getDirection()

int OpenXcom::BattleUnit::getDirection ( ) const

Gets the unit's direction.

Gets the BattleUnit's (horizontal) direction.

Returns
horizontal direction

◆ getEnergy()

int OpenXcom::BattleUnit::getEnergy ( ) const

Gets the unit's stamina.

Returns the soldier's amount of energy.

Returns
Energy.

◆ getFaceDirection()

int OpenXcom::BattleUnit::getFaceDirection ( ) const

Gets the unit's face direction (only used by strafing moves)

Gets the BattleUnit's (horizontal) face direction.

Used only during strafing moves.

Returns
face direction

◆ getFaction()

UnitFaction OpenXcom::BattleUnit::getFaction ( ) const

Gets the unit's faction.

Returns the unit's faction.

Returns
Faction. (player, hostile or neutral)

◆ getFallingPhase()

int OpenXcom::BattleUnit::getFallingPhase ( ) const

Get falling sequence.

Returns the phase of the falling sequence.

Returns
phase

◆ getFatalShotBodyPart()

UnitBodyPart OpenXcom::BattleUnit::getFatalShotBodyPart ( ) const

Get information on the unit's fatal shot's body part.

Returns
UnitBodyPart fatal shot's body part.

◆ getFatalShotSide()

UnitSide OpenXcom::BattleUnit::getFatalShotSide ( ) const

Get information on the unit's fatal shot's side.

Returns
UnitSide fatal shot's side.

◆ getFatalWound()

int OpenXcom::BattleUnit::getFatalWound ( int  part) const

Get fatal wound amount of a body part.

Get the amount of fatal wound for a body part.

Parameters
partThe body part (in the range 0-5)
Returns
The amount of fatal wound of a body part

◆ getFatalWounds()

int OpenXcom::BattleUnit::getFatalWounds ( ) const

Get total number of fatal wounds.

Get total amount of fatal wounds this unit has.

Returns
Number of fatal wounds.

◆ getFire()

int OpenXcom::BattleUnit::getFire ( ) const

Get fire.

Get the amount of turns this unit is on fire.

0 = no fire.

Returns
fire : amount of turns this tile is on fire.

◆ getFiringAccuracy()

int OpenXcom::BattleUnit::getFiringAccuracy ( BattleActionType  actionType,
BattleItem item 
)

Calculate firing accuracy.

Formula = accuracyStat * weaponAccuracy * kneelingbonus(1.15) * one-handPenalty(0.8) * woundsPenalty(% health) * critWoundsPenalty (-10%/wound)

Parameters
actionType
item
Returns
firing Accuracy

◆ getFloatHeight()

int OpenXcom::BattleUnit::getFloatHeight ( ) const

Gets the unit floating elevation.

Get the unit's floating elevation.

Returns
The unit's elevation over the ground in voxels, when flying.

◆ getFloorAbove()

bool OpenXcom::BattleUnit::getFloorAbove ( ) const

Get the flag for "floor above me".

Checks if the floor above flag has been set.

Returns
if we're under cover.

◆ getGeoscapeSoldier()

Soldier * OpenXcom::BattleUnit::getGeoscapeSoldier ( ) const

Get the geoscape-soldier object.

Returns
soldier.

◆ getGrenadeFromBelt()

BattleItem * OpenXcom::BattleUnit::getGrenadeFromBelt ( ) const

Gets a grenade from the belt, if any.

Get a grenade from the belt (used for AI)

Returns
Pointer to item.

◆ getHealth()

int OpenXcom::BattleUnit::getHealth ( ) const

Gets the unit's health.

Returns the soldier's amount of health.

Returns
Health.

◆ getHeight()

int OpenXcom::BattleUnit::getHeight ( ) const

Gets the unit height taking into account kneeling/standing.

Returns
Unit's height.

◆ getId()

int OpenXcom::BattleUnit::getId ( ) const

Gets the BattleUnit's ID.

Returns the BattleUnit's unique ID.

Returns
Unique ID.

◆ getIntelligence()

int OpenXcom::BattleUnit::getIntelligence ( ) const

Get the unit's intelligence.

Get the number of turns an AI unit remembers a soldier's position.

Returns
intelligence.

◆ getInventory()

std::vector< BattleItem * > * OpenXcom::BattleUnit::getInventory ( )

Get the list of items in the inventory.

Get the pointer to the vector of inventory items.

Returns
pointer to vector.

◆ getItem() [1/2]

BattleItem * OpenXcom::BattleUnit::getItem ( RuleInventory slot,
int  x = 0,
int  y = 0 
) const

Gets the item in the specified slot.

Checks if there's an inventory item in the specified inventory position.

Parameters
slotInventory slot.
xX position in slot.
yY position in slot.
Returns
Item in the slot, or NULL if none.

◆ getItem() [2/2]

BattleItem * OpenXcom::BattleUnit::getItem ( const std::string &  slot,
int  x = 0,
int  y = 0 
) const

Gets the item in the specified slot.

Checks if there's an inventory item in the specified inventory position.

Parameters
slotInventory slot.
xX position in slot.
yY position in slot.
Returns
Item in the slot, or NULL if none.

◆ getKneelHeight()

int OpenXcom::BattleUnit::getKneelHeight ( ) const

Get the unit's kneel height.

Returns
The unit's height in voxels, when kneeling.

◆ getLastPosition()

Position OpenXcom::BattleUnit::getLastPosition ( ) const

Gets the unit's position.

Gets the BattleUnit's position.

Returns
position

◆ getLoftemps()

int OpenXcom::BattleUnit::getLoftemps ( int  entry = 0) const

Get the unit's loft ID.

Get the unit's loft ID, one per unit tile.

Each tile only has one loft, as it is repeated over the entire height of the unit.

Parameters
entryUnit tile
Returns
The unit's line of fire template ID.

◆ getMainHandWeapon()

BattleItem * OpenXcom::BattleUnit::getMainHandWeapon ( bool  quickest = true) const

Gets the item in the main hand.

Get the "main hand weapon" from the unit.

Parameters
quickestWhether to get the quickest weapon, default true
Returns
Pointer to item.

◆ getMaxArmor()

int OpenXcom::BattleUnit::getMaxArmor ( UnitSide  side) const

Get max armor value.

Get the max armor value of a certain armor side.

Parameters
sideThe side of the armor.
Returns
Amount of armor.

◆ getMeleeWeapon()

BattleItem * OpenXcom::BattleUnit::getMeleeWeapon ( )

Get any melee weapon we may be carrying, or a built in one.

Get the name of any melee weapon we may be carrying, or a built in one.

Returns
the name .

◆ getMindControllerId()

int OpenXcom::BattleUnit::getMindControllerId ( ) const

Get the unit mind controller's id.

Gets the unit mind controller's id.

Returns
int mind controller id.

◆ getMiniMapSpriteIndex()

int OpenXcom::BattleUnit::getMiniMapSpriteIndex ( ) const

Get the sprite index for the minimap.

Get the unit's minimap sprite index.

Used to display the unit on the minimap

Returns
the unit minimap index

◆ getMorale()

int OpenXcom::BattleUnit::getMorale ( ) const

Gets the unit's bravery.

Returns the soldier's amount of morale.

Returns
Morale.

◆ getMotionPoints()

int OpenXcom::BattleUnit::getMotionPoints ( ) const

Get motion points for the motion scanner.

More points is a larger blip on the scanner.

Returns
points.

◆ getMovementType()

MovementType OpenXcom::BattleUnit::getMovementType ( ) const

Use this function to check the unit's movement type.

use this instead of checking the rules of the armor.

◆ getMoveSound()

int OpenXcom::BattleUnit::getMoveSound ( ) const

Get the unit's move sound.

Returns
id.

◆ getMurdererId()

int OpenXcom::BattleUnit::getMurdererId ( ) const

Get the unit murderer's id.

Gets the unit murderer's id.

Returns
int murderer id.

◆ getMurdererWeapon()

std::string OpenXcom::BattleUnit::getMurdererWeapon ( ) const

Get the unit murderer's weapon.

Gets the unit murderer's weapon.

Returns
int murderer weapon.

◆ getMurdererWeaponAmmo()

std::string OpenXcom::BattleUnit::getMurdererWeaponAmmo ( ) const

Get the unit murderer's weapon's ammo.

Gets the unit murderer's weapon's ammo.

Returns
int murderer weapon ammo.

◆ getName()

std::string OpenXcom::BattleUnit::getName ( Language lang,
bool  debugAppendId = false 
) const

Gets the unit's name.

Get unit's name.

An aliens name is the translation of it's race and rank. hence the language pointer needed.

Parameters
langPointer to language.
debugAppendIdAppend unit ID to name for debug purposes.
Returns
name Widecharstring of the unit's name.

◆ getOriginalFaction()

UnitFaction OpenXcom::BattleUnit::getOriginalFaction ( ) const

Get this unit's original faction.

Get this unit's original Faction.

Returns
original faction

◆ getPosition()

Position OpenXcom::BattleUnit::getPosition ( ) const

Gets the unit's position.

Gets the BattleUnit's position.

Returns
position

◆ getRankInt()

int OpenXcom::BattleUnit::getRankInt ( ) const

get the rank integer

Return the numeric version of the unit's rank.

Returns
unit rank, 0 = lowest

◆ getRankString()

std::string OpenXcom::BattleUnit::getRankString ( ) const

Get the units's rank string.

Returns
rank.

◆ getReactionScore()

double OpenXcom::BattleUnit::getReactionScore ( )

Get the current reaction score.

Little formula to calculate reaction score.

Returns
Reaction score.

◆ getRecolor()

const std::vector< std::pair< Uint8, Uint8 > > & OpenXcom::BattleUnit::getRecolor ( ) const

Gets unit sprite recolors values.

Gets values used for recoloring sprites.

Parameters
iwhat value choose.
Returns
Pairs of value, where first is color group to replace and second is new color group with shade.

◆ getRespawn()

bool OpenXcom::BattleUnit::getRespawn ( ) const

Get the units's respawn flag.

Gets this unit's respawn flag.

◆ getSpawnUnit()

std::string OpenXcom::BattleUnit::getSpawnUnit ( ) const

Gets the unit's spawn unit.

Get the unit that is spawned when this one dies.

Returns
unit.

◆ getSpecialAbility()

int OpenXcom::BattleUnit::getSpecialAbility ( ) const

Get the units's special ability.

Returns the unit's special ability.

Returns
special ability.

◆ getStandHeight()

int OpenXcom::BattleUnit::getStandHeight ( ) const

Get the unit's stand height.

Returns
The unit's height in voxels, when standing up.

◆ getStatistics()

BattleUnitStatistics * OpenXcom::BattleUnit::getStatistics ( )

Get the unit's mission statistics.

Get the unit's statistics.

Returns
BattleUnitStatistics statistics.

◆ getStatus()

UnitStatus OpenXcom::BattleUnit::getStatus ( ) const

Gets the unit's status.

Returns
the unit's status

◆ getThrowingAccuracy()

double OpenXcom::BattleUnit::getThrowingAccuracy ( )

Calculate throwing accuracy.

Returns
throwing Accuracy

◆ getTile()

Tile * OpenXcom::BattleUnit::getTile ( ) const

Gets the unit's tile.

Returns
Tile

◆ getTimeUnits()

int OpenXcom::BattleUnit::getTimeUnits ( ) const

Gets the unit's time units.

Returns the soldier's amount of time units.

Returns
Time units.

◆ getTurnsSinceSpotted()

int OpenXcom::BattleUnit::getTurnsSinceSpotted ( ) const

Set how many turns this unit will be exposed for.

Get how long since this unit was exposed.

Returns
number of turns

◆ getTurretDirection()

int OpenXcom::BattleUnit::getTurretDirection ( ) const

Gets the unit's turret direction.

Gets the BattleUnit's turret direction.

Returns
direction

◆ getTurretToDirection()

int OpenXcom::BattleUnit::getTurretToDirection ( ) const

Gets the unit's turret To direction.

Gets the BattleUnit's turret To direction.

Returns
toDirectionTurret

◆ getTurretType()

int OpenXcom::BattleUnit::getTurretType ( ) const

Get the turret type. -1 is no turret.

Get the turret type.

-1 is no turret.

Returns
type

◆ getType()

std::string OpenXcom::BattleUnit::getType ( ) const

Get unit type.

Returns
unit type.

◆ getUnitsSpottedThisTurn()

std::vector< BattleUnit * > & OpenXcom::BattleUnit::getUnitsSpottedThisTurn ( )

get the vector of units we've seen this turn.

Get the list of units spotted this turn.

Returns
List of units.

◆ getValue()

int OpenXcom::BattleUnit::getValue ( ) const

Get the unit's value.

Used for score at debriefing.

Returns
value score

◆ getVerticalDirection()

int OpenXcom::BattleUnit::getVerticalDirection ( ) const

Gets the unit's vertical direction.

Gets the BattleUnit's vertical direction.

This is when going up or down.

Returns
direction

◆ getVisible()

bool OpenXcom::BattleUnit::getVisible ( ) const

Get whether this unit is visible.

Returns
flag

◆ getVisibleTiles()

std::vector< Tile * > * OpenXcom::BattleUnit::getVisibleTiles ( )

Get the list of visible tiles.

Get the pointer to the vector of visible tiles.

Returns
pointer to vector.

◆ getVisibleUnits()

std::vector< BattleUnit * > * OpenXcom::BattleUnit::getVisibleUnits ( )

Get the list of visible units.

Get the pointer to the vector of visible units.

Returns
pointer to vector.

◆ getWalkingPhase()

int OpenXcom::BattleUnit::getWalkingPhase ( ) const

Gets the walking phase for animation and sound.

Returns
phase will always go from 0-7

◆ goToTimeOut()

void OpenXcom::BattleUnit::goToTimeOut ( )

Puts the unit in the corner to think about what he's done.

Elevates the unit to grand galactic inquisitor status, meaning they will NOT take part in the current battle.

◆ hasInventory()

bool OpenXcom::BattleUnit::hasInventory ( ) const

Does this unit have an inventory?

Checks if this unit has an inventory.

Large units and/or terror units generally don't have inventories.

Returns
True if an inventory is available, false otherwise.

◆ heal()

void OpenXcom::BattleUnit::heal ( int  part,
int  woundAmount,
int  healthAmount 
)

Heal one fatal wound.

Heal a fatal wound of the soldier.

Parameters
partthe body part to heal
woundAmountthe amount of fatal wound healed
healthAmountThe amount of health to add to soldier health

◆ healStun()

void OpenXcom::BattleUnit::healStun ( int  power)

Heal stun level of the unit.

Do an amount of stun recovery.

Parameters
power

◆ instaKill()

void OpenXcom::BattleUnit::instaKill ( )

Set health to 0 and set status dead.

Set health to 0 and set status dead - used when getting zombified.

◆ invalidateCache()

void OpenXcom::BattleUnit::invalidateCache ( )

call this after the default copy constructor deletes the cache?

invalidate cache; call after copying object :(

◆ isFearable()

bool OpenXcom::BattleUnit::isFearable ( ) const

Get whether the unit is affected by fear.

Get whether the unit is affected by morale loss.

Normally only small units are affected by morale loss.

Returns
Is the unit affected by morale?

◆ isFloating()

bool OpenXcom::BattleUnit::isFloating ( ) const

Is floating?

Is floating? A unit is floating when there is no ground under him/her.

Returns
true/false

◆ isInExitArea()

bool OpenXcom::BattleUnit::isInExitArea ( SpecialTileType  stt = START_POINT) const

Check if this unit is in the exit area.

Parameters
sttType of exit tile to check for.
Returns
Is in the exit area?

◆ isKneeled()

bool OpenXcom::BattleUnit::isKneeled ( ) const

Is kneeled?

Is kneeled down?

Returns
true/false

◆ isOut()

bool OpenXcom::BattleUnit::isOut ( ) const

The unit is out - either dead or unconscious.

Returns whether the soldier is out of combat, dead or unconscious.

A soldier that is out, cannot perform any actions, cannot be selected, but it's still a unit.

Returns
flag if out or not.

◆ isSelectable()

bool OpenXcom::BattleUnit::isSelectable ( UnitFaction  faction,
bool  checkReselect,
bool  checkInventory 
) const

Is this unit selectable?

Checks if this unit can be selected.

Only alive units belonging to the faction can be selected.

Parameters
factionThe faction to compare with.
checkReselectCheck if the unit is reselectable.
checkInventoryCheck if the unit has an inventory.
Returns
True if the unit can be selected, false otherwise.

◆ isWoundable()

bool OpenXcom::BattleUnit::isWoundable ( ) const

Get whether the unit is affected by fatal wounds.

Normally only soldiers are affected by fatal wounds.

Returns
Is the unit affected by wounds?

◆ keepFalling()

void OpenXcom::BattleUnit::keepFalling ( )

Increment the falling sequence.

Advances the phase of falling sequence.

◆ keepWalking()

void OpenXcom::BattleUnit::keepWalking ( Tile tileBelowMe,
bool  cache 
)

Increase the walkingPhase.

This will increment the walking phase.

Parameters
tileBelowMePointer to tile currently below the unit.
cacheRefresh the unit cache.

◆ kill()

void OpenXcom::BattleUnit::kill ( )

Set health to 0.

Set health to 0 - used when getting killed unconscious.

◆ killedBy() [1/2]

UnitFaction OpenXcom::BattleUnit::killedBy ( ) const

Get the faction that killed this unit.

Get the faction the unit was killed by.

Returns
faction

◆ killedBy() [2/2]

void OpenXcom::BattleUnit::killedBy ( UnitFaction  f)

Set the faction that killed this unit.

Set the faction the unit was killed by.

Parameters
ffaction

◆ kneel()

void OpenXcom::BattleUnit::kneel ( bool  kneeled)

Kneel down.

Parameters
kneeledto kneel or to stand up

◆ knockOut()

void OpenXcom::BattleUnit::knockOut ( BattlescapeGame battle)

Knocks the unit out instantly.

Raises a unit's stun level sufficiently so that the unit is ready to become unconscious.

Used when another unit falls on top of this unit. Zombified units first convert to their spawn unit.

Parameters
battlePointer to the battlescape game.

◆ liesInExitArea()

bool OpenXcom::BattleUnit::liesInExitArea ( Tile tile,
SpecialTileType  stt = START_POINT 
) const

Check if this unit lies (e.g.

unconscious) in the exit area.

Parameters
tileUnit's location.
sttType of exit tile to check for.
Returns
Is in the exit area?

◆ load()

void OpenXcom::BattleUnit::load ( const YAML::Node &  node)

Loads the unit from YAML.

Loads the unit from a YAML file.

Parameters
nodeYAML node.

◆ lookAt() [1/2]

void OpenXcom::BattleUnit::lookAt ( Position  point,
bool  turret = false 
)

Look at a certain point.

Look at a point.

Parameters
pointPosition to look at.
turretTrue to turn the turret, false to turn the unit.

◆ lookAt() [2/2]

void OpenXcom::BattleUnit::lookAt ( int  direction,
bool  force = false 
)

Look at a certain direction.

Look at a direction.

Parameters
directionDirection to look at.
forceTrue to reset the direction, false to animate to it.

◆ moraleChange()

void OpenXcom::BattleUnit::moraleChange ( int  change)

Morale change.

Morale change with bounds check.

Parameters
changecan be positive or negative

◆ nerfFiringXP()

void OpenXcom::BattleUnit::nerfFiringXP ( int  newXP)

Artificially alter a unit's firing xp. (used for shotguns)

Artificially alter a unit's firing xp.

(used for shotguns)

◆ painKillers()

void OpenXcom::BattleUnit::painKillers ( )

Give pain killers to this unit.

Restore soldier morale.

◆ postMissionProcedures()

bool OpenXcom::BattleUnit::postMissionProcedures ( SavedGame geoscape,
UnitStats statsDiff 
)

Check if unit eligible for squaddie promotion.

If yes, promote the unit. Increase the mission counter. Calculate the experience increases.

Parameters
geoscapePointer to geoscape save.
statsDiff(out) The passed UnitStats struct will be filled with the stats differences.
Returns
True if the soldier was eligible for squaddie promotion.

◆ recoverTimeUnits()

void OpenXcom::BattleUnit::recoverTimeUnits ( )

Recovers the unit's time units and energy.

Recovers a unit's TUs and energy, taking a number of factors into consideration.

◆ reselectAllowed()

bool OpenXcom::BattleUnit::reselectAllowed ( ) const

Check whether reselecting this unit is allowed.

Returns
bool

◆ save()

YAML::Node OpenXcom::BattleUnit::save ( ) const

Saves the unit to YAML.

Saves the soldier to a YAML file.

Returns
YAML node.

◆ setActiveHand()

void OpenXcom::BattleUnit::setActiveHand ( const std::string &  hand)

Set the hand this unit is using;.

Set unit's active hand.

Parameters
handactive hand.

◆ setAIModule()

void OpenXcom::BattleUnit::setAIModule ( AIModule ai)

Set AI Module.

Changes the current AI state.

Parameters
aiStatePointer to AI state.

◆ setArmor()

void OpenXcom::BattleUnit::setArmor ( int  armor,
UnitSide  side 
)

Set armor value.

Set the armor value of a certain armor side.

Parameters
armorAmount of armor.
sideThe side of the armor.

◆ setCache()

void OpenXcom::BattleUnit::setCache ( Surface cache,
int  part = 0 
)

Set the cached flag.

Sets the unit's cache flag.

Parameters
cachePointer to cache surface to use, NULL to redraw from scratch.
partUnit part to cache.

◆ setCharging()

void OpenXcom::BattleUnit::setCharging ( BattleUnit chargeTarget)

Set the units we are charging towards.

Parameters
chargeTargetCharge Target

◆ setCoverReserve()

void OpenXcom::BattleUnit::setCoverReserve ( int  reserve)

Changes the amount of TUs reserved for cover.

Parameters
reservetime units.

◆ setDirection()

void OpenXcom::BattleUnit::setDirection ( int  direction)

Sets the unit's direction 0-7.

Changes the BattleUnit's (horizontal) direction.

Only used for initial unit placement.

Parameters
directionnew horizontal direction

◆ setEnergy()

void OpenXcom::BattleUnit::setEnergy ( int  energy)

Sets the unit's energy level.

Set a specific number of energy.

Parameters
energyenergy.

◆ setFaceDirection()

void OpenXcom::BattleUnit::setFaceDirection ( int  direction)

Sets the unit's face direction (only used by strafing moves)

Changes the BattleUnit's (horizontal) face direction.

Only used for strafing moves.

Parameters
directionnew face direction

◆ setFatalShotInfo()

void OpenXcom::BattleUnit::setFatalShotInfo ( UnitSide  side,
UnitBodyPart  bodypart 
)

Set information on the unit's fatal shot.

Set information on the unit's fatal blow.

Parameters
UnitSideunit's side that was shot.
UnitBodyPartunit's body part that was shot.

◆ setFire()

void OpenXcom::BattleUnit::setFire ( int  fire)

Set fire.

Set the amount of turns this unit is on fire.

0 = no fire.

Parameters
fire: amount of turns this tile is on fire.

◆ setFloorAbove()

void OpenXcom::BattleUnit::setFloorAbove ( bool  floor)

Set the flag for "floor above me" meaning stop rendering bubbles.

Sets the flag for "this unit is under cover" meaning don't draw bubbles.

Parameters
flooris there a floor.

◆ setMindControllerId()

void OpenXcom::BattleUnit::setMindControllerId ( int  id)

Set the unit mind controller's id.

Sets the unit mind controller's id.

Parameters
intmind controller id.

◆ setMurdererId()

void OpenXcom::BattleUnit::setMurdererId ( int  id)

Set the unit murderer's id.

Sets the unit murderer's id.

Parameters
intmurderer id.

◆ setMurdererWeapon()

void OpenXcom::BattleUnit::setMurdererWeapon ( const std::string &  weapon)

Set the unit murderer's weapon.

Set the murderer's weapon.

Parameters
stringmurderer's weapon.

◆ setMurdererWeaponAmmo()

void OpenXcom::BattleUnit::setMurdererWeaponAmmo ( const std::string &  weaponAmmo)

Set the unit murderer's weapon's ammo.

Set the murderer's weapon's ammo.

Parameters
stringmurderer weapon ammo.

◆ setPosition()

void OpenXcom::BattleUnit::setPosition ( Position  pos,
bool  updateLastPos = true 
)

Sets the unit's position.

Changes the BattleUnit's position.

Parameters
posposition
updateLastPosrefresh last stored position

◆ setRankInt()

void OpenXcom::BattleUnit::setRankInt ( int  rank)

set the rank integer

Change the numeric version of the unit's rank.

Parameters
rankunit rank, 0 = lowest

◆ setRespawn()

void OpenXcom::BattleUnit::setRespawn ( bool  respawn)

Set the units's respawn flag.

Sets this unit to respawn (or not).

Parameters
respawnwhether it should respawn.

◆ setSpawnUnit()

void OpenXcom::BattleUnit::setSpawnUnit ( const std::string &  spawnUnit)

Sets the unit's spawn unit.

Set the unit that is spawned when this one dies.

Parameters
spawnUnitunit.

◆ setSpecialWeapon()

void OpenXcom::BattleUnit::setSpecialWeapon ( SavedBattleGame save,
const Mod mod 
)

Create special weapon for unit.

Set special weapon that is handled outside inventory.

Parameters
save

◆ setTile()

void OpenXcom::BattleUnit::setTile ( Tile tile,
Tile tileBelow = 0 
)

Sets the unit's tile it's standing on.

Parameters
tilePointer to tile.
tileBelowPointer to tile below.

◆ setTimeUnits()

void OpenXcom::BattleUnit::setTimeUnits ( int  tu)

Set time units.

Set a specific number of timeunits.

Parameters
tu

◆ setTurnsSinceSpotted()

void OpenXcom::BattleUnit::setTurnsSinceSpotted ( int  turns)

Set how many turns this unit will be exposed for.

Set how long since this unit was last exposed.

Parameters
turnsnumber of turns

◆ setTurretType()

void OpenXcom::BattleUnit::setTurretType ( int  turretType)

Set the turret type. -1 is no turret.

Set the turret type.

-1 is no turret.

Parameters
turretType

◆ setVisible()

void OpenXcom::BattleUnit::setVisible ( bool  flag)

Set whether this unit is visible.

Parameters
flag

◆ spendEnergy()

bool OpenXcom::BattleUnit::spendEnergy ( int  tu)

Spend energy if it can.

Return false if it can't.

Parameters
tu
Returns
flag if it could spend the time units or not.

◆ spendTimeUnits()

bool OpenXcom::BattleUnit::spendTimeUnits ( int  tu)

Spend time units if it can.

Return false if it can't.

Parameters
tu
Returns
flag if it could spend the time units or not.

◆ startFalling()

void OpenXcom::BattleUnit::startFalling ( )

Start falling sequence.

Initialises the falling sequence.

Occurs after death or stunned.

◆ startWalking()

void OpenXcom::BattleUnit::startWalking ( int  direction,
Position  destination,
Tile tileBelowMe,
bool  cache 
)

Start the walkingPhase.

Initialises variables to start walking.

Parameters
directionWhich way to walk.
destinationThe position we should end up on.
tileBelowMeWhich tile is currently below the unit.
cacheUpdate cache?

◆ stimulant()

void OpenXcom::BattleUnit::stimulant ( int  energy,
int  s 
)

Give stimulant to this unit.

Restore soldier energy and reduce stun level.

Parameters
energyThe amount of energy to add
sThe amount of stun level to reduce

◆ think()

void OpenXcom::BattleUnit::think ( BattleAction action)

Let AI do their thing.

Parameters
actionAI action.

◆ toggleFireDamage()

void OpenXcom::BattleUnit::toggleFireDamage ( )

switch the state of the fire damage tracker.

toggle the state of the fire damage tracking boolean.

◆ tookFireDamage()

bool OpenXcom::BattleUnit::tookFireDamage ( ) const

did this unit already take fire damage this turn? (used to avoid damaging large units multiple times.)

Returns
ow it burns

◆ turn()

void OpenXcom::BattleUnit::turn ( bool  turret = false)

Turn to the destination direction.

Advances the turning towards the target direction.

Parameters
turretTrue to turn the turret, false to turn the unit.

The documentation for this class was generated from the following files: