OpenXcom
1.0
Open-source clone of the original X-Com
|
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, UnitFaction faction) | |
Creates a BattleUnit. More... | |
BattleUnit (Unit *unit, UnitFaction faction, int id, Armor *armor, int diff) | |
Initializes a BattleUnit from a Unit (non-player) object. 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 (const Position &pos, bool updateLastPos=true) |
Sets the unit's position. More... | |
const Position & | getPosition () const |
Gets the unit's position. More... | |
const 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, const 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... | |
const Position & | getDestination () const |
Gets the unit's destination when walking. More... | |
void | lookAt (const 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... | |
Surface * | getCache (bool *invalid, int part=0) const |
If this unit is cached on the battlescape. 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 (const 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 (const 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 | getFatalWounds () const |
Get total number of fatal wounds. More... | |
double | getReactionScore () |
Get the current reaction score. More... | |
void | prepareNewTurn () |
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... | |
BattleAIState * | getCurrentAIState () const |
Get current AI state. More... | |
void | setAIState (BattleAIState *aiState) |
Set next AI State. 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... | |
Tile * | getTile () const |
Gets the unit's tile. More... | |
BattleItem * | getItem (RuleInventory *slot, int x=0, int y=0) const |
Gets the item in the specified slot. More... | |
BattleItem * | getItem (const std::string &slot, int x=0, int y=0) const |
Gets the item in the specified slot. More... | |
BattleItem * | getMainHandWeapon (bool quickest=true) const |
Gets the item in the main hand. More... | |
BattleItem * | getGrenadeFromBelt () 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... | |
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. More... | |
void | addPsiExp () |
Adds one to the psi exp counter. More... | |
void | addMeleeExp () |
Adds one to the melee exp counter. More... | |
void | updateGeoscapeStats (Soldier *soldier) |
Updates the stats of a Geoscape soldier. | |
bool | postMissionProcedures (SavedGame *geoscape) |
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... | |
Armor * | getArmor () const |
Gets the unit's armor. More... | |
std::wstring | getName (Language *lang, bool debugAppendId=false) const |
Gets the unit's name. More... | |
UnitStats * | getStats () |
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... | |
int | getDeathSound () const |
Get the unit's death sound. 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 | setSpecialAbility (SpecialAbility specab) |
Set the units's special ability. More... | |
std::string | getRankString () const |
Get the units's rank string. More... | |
Soldier * | getGeoscapeSoldier () 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 | instaKill () |
Set health to 0 and set status dead. More... | |
std::string | getSpawnUnit () const |
Gets the unit's spawn unit. More... | |
void | setSpawnUnit (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... | |
void | halveArmor () |
Halve the unit's armor values. 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... | |
BattleUnit * | getCharging () |
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 int diff) |
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... | |
Public Attributes | |
bool | _hidingForTurn |
scratch value for AI's left hand to tell its right hand what's up... | |
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about it's position, items carrying, stats, etc.
OpenXcom::BattleUnit::BattleUnit | ( | Soldier * | soldier, |
UnitFaction | faction | ||
) |
Creates a BattleUnit.
Initializes a BattleUnit from a Soldier.
soldier | Pointer to the Soldier. |
faction | Which faction the units belongs to. |
OpenXcom::BattleUnit::BattleUnit | ( | Unit * | unit, |
UnitFaction | faction, | ||
int | id, | ||
Armor * | armor, | ||
int | diff | ||
) |
Initializes a BattleUnit from a Unit (non-player) object.
void OpenXcom::BattleUnit::abortTurn | ( | ) |
Abort turning.
Stops the turning towards the target direction.
void OpenXcom::BattleUnit::addMeleeExp | ( | ) |
Adds one to the melee exp counter.
Adds one to the firing exp counter.
void OpenXcom::BattleUnit::addPsiExp | ( | ) |
Adds one to the psi exp counter.
Adds one to the firing exp counter.
void OpenXcom::BattleUnit::addThrowingExp | ( | ) |
Adds one to the throwing exp counter.
Adds one to the firing exp counter.
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.
tile |
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.
unit |
void OpenXcom::BattleUnit::adjustStats | ( | const int | diff | ) |
adjust this unit's stats according to difficulty.
common function to adjust a unit's stats according to difficulty setting.
diff | difficulty level (for stat adjustement). |
void OpenXcom::BattleUnit::aim | ( | bool | aiming | ) |
Aim.
(shows the right hand sprite and weapon holding)
aiming | true/false |
void OpenXcom::BattleUnit::allowReselect | ( | ) |
Reselect this unit.
Mark this unit as reselectable.
bool OpenXcom::BattleUnit::checkAmmo | ( | ) |
Reloads righthand weapon if needed.
Check if we have ammo and reload if needed (used for AI).
bool OpenXcom::BattleUnit::checkViewSector | ( | Position | pos | ) | const |
this function checks if a tile is visible, using maths.
pos | the position to check against |
void OpenXcom::BattleUnit::convertToFaction | ( | UnitFaction | f | ) |
Convert's unit to a faction.
Converts unit to another faction (original faction is still stored).
f | faction. |
int OpenXcom::BattleUnit::damage | ( | const Position & | relative, |
int | power, | ||
ItemDamageType | type, | ||
bool | ignoreArmor = false |
||
) |
Do damage to the unit.
Do an amount of damage.
relative | The relative position of which part of armor and/or bodypart is hit. |
power | The amount of damage to inflict. |
type | The type of damage being inflicted. |
ignoreArmor | Should the damage ignore armor resistance? |
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).
int OpenXcom::BattleUnit::directionTo | ( | const Position & | point | ) | const |
Get direction to a certain point.
Returns the direction from this unit to a given point.
point | given position. |
void OpenXcom::BattleUnit::dontReselect | ( | ) |
Don't reselect this unit.
Mark this unit as not reselectable.
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)
item | the item we are shooting right now. |
int OpenXcom::BattleUnit::getActionTUs | ( | BattleActionType | actionType, |
BattleItem * | item | ||
) |
Get the number of time units a certain action takes.
actionType | |
item |
std::string OpenXcom::BattleUnit::getActiveHand | ( | ) | const |
Get unit's active hand.
int OpenXcom::BattleUnit::getAggression | ( | ) | const |
Get the unit's aggression.
int OpenXcom::BattleUnit::getAggroSound | ( | ) | const |
Gets the unit's aggro sound.
Get sound to play when unit aggros.
int OpenXcom::BattleUnit::getArmor | ( | UnitSide | side | ) | const |
Get armor value.
Get the armor value of a certain armor side.
side | The side of the armor. |
Armor * OpenXcom::BattleUnit::getArmor | ( | ) | const |
Gets the unit's armor.
Surface * OpenXcom::BattleUnit::getCache | ( | bool * | invalid, |
int | part = 0 |
||
) | const |
int OpenXcom::BattleUnit::getCarriedWeight | ( | BattleItem * | draggingItem = 0 | ) | const |
Get the carried weight in strength units.
Get the units carried weight in strength units.
draggingItem | item to ignore |
BattleUnit * OpenXcom::BattleUnit::getCharging | ( | ) |
Get the units we are charging towards.
int OpenXcom::BattleUnit::getCoverReserve | ( | ) | const |
Returns the amount of TUs reserved for cover.
BattleAIState * OpenXcom::BattleUnit::getCurrentAIState | ( | ) | const |
Get current AI state.
Returns the current AI state.
int OpenXcom::BattleUnit::getDeathSound | ( | ) | const |
Get the unit's death sound.
const Position & OpenXcom::BattleUnit::getDestination | ( | ) | const |
int OpenXcom::BattleUnit::getDiagonalWalkingPhase | ( | ) | const |
Gets the walking phase for diagonal walking.
int OpenXcom::BattleUnit::getDirection | ( | ) | const |
Gets the unit's direction.
Gets the BattleUnit's (horizontal) direction.
int OpenXcom::BattleUnit::getEnergy | ( | ) | const |
Gets the unit's stamina.
Returns the soldier's amount of energy.
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.
UnitFaction OpenXcom::BattleUnit::getFaction | ( | ) | const |
Gets the unit's faction.
Returns the unit's faction.
int OpenXcom::BattleUnit::getFallingPhase | ( | ) | const |
Get falling sequence.
Returns the phase of the falling sequence.
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.
part | The body part (in the range 0-5) |
int OpenXcom::BattleUnit::getFatalWounds | ( | ) | const |
Get total number of fatal wounds.
Get total amount of fatal wounds this unit has.
int OpenXcom::BattleUnit::getFire | ( | ) | const |
Get fire.
Get the amount of turns this unit is on fire.
0 = no fire.
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)
actionType | |
item |
int OpenXcom::BattleUnit::getFloatHeight | ( | ) | const |
Gets the unit floating elevation.
Get the unit's floating elevation.
Soldier * OpenXcom::BattleUnit::getGeoscapeSoldier | ( | ) | const |
Get the geoscape-soldier object.
BattleItem * OpenXcom::BattleUnit::getGrenadeFromBelt | ( | ) | const |
Gets a grenade from the belt, if any.
Get a grenade from the belt (used for AI)
int OpenXcom::BattleUnit::getHealth | ( | ) | const |
Gets the unit's health.
Returns the soldier's amount of health.
int OpenXcom::BattleUnit::getHeight | ( | ) | const |
Gets the unit height taking into account kneeling/standing.
int OpenXcom::BattleUnit::getId | ( | ) | const |
int OpenXcom::BattleUnit::getIntelligence | ( | ) | const |
Get the unit's intelligence.
Get the number of turns an AI unit remembers a soldier's position.
std::vector< BattleItem * > * OpenXcom::BattleUnit::getInventory | ( | ) |
Get the list of items in the inventory.
Get the pointer to the vector of inventory items.
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.
slot | Inventory slot. |
x | X position in slot. |
y | Y position in slot. |
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.
slot | Inventory slot. |
x | X position in slot. |
y | Y position in slot. |
int OpenXcom::BattleUnit::getKneelHeight | ( | ) | const |
Get the unit's kneel height.
const Position & OpenXcom::BattleUnit::getLastPosition | ( | ) | const |
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.
entry | Unit tile |
BattleItem * OpenXcom::BattleUnit::getMainHandWeapon | ( | bool | quickest = true | ) | const |
Gets the item in the main hand.
Get the "main hand weapon" from the unit.
quickest | Whether to get the quickest weapon, default true |
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
int OpenXcom::BattleUnit::getMorale | ( | ) | const |
Gets the unit's bravery.
Returns the soldier's amount of morale.
int OpenXcom::BattleUnit::getMotionPoints | ( | ) | const |
Get motion points for the motion scanner.
More points is a larger blip on the scanner.
int OpenXcom::BattleUnit::getMoveSound | ( | ) | const |
Get the unit's move sound.
std::wstring 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.
lang | Pointer to language. |
debugAppendId | Append unit ID to name for debug purposes. |
UnitFaction OpenXcom::BattleUnit::getOriginalFaction | ( | ) | const |
Get this unit's original faction.
Get this unit's original Faction.
const Position & OpenXcom::BattleUnit::getPosition | ( | ) | const |
int OpenXcom::BattleUnit::getRankInt | ( | ) | const |
get the rank integer
Return the numeric version of the unit's rank.
std::string OpenXcom::BattleUnit::getRankString | ( | ) | const |
Get the units's rank string.
double OpenXcom::BattleUnit::getReactionScore | ( | ) |
Get the current reaction score.
Little formula to calculate reaction score.
std::string OpenXcom::BattleUnit::getSpawnUnit | ( | ) | const |
Gets the unit's spawn unit.
Get the unit that is spawned when this one dies.
int OpenXcom::BattleUnit::getSpecialAbility | ( | ) | const |
Get the units's special ability.
Returns the unit's special ability.
int OpenXcom::BattleUnit::getStandHeight | ( | ) | const |
Get the unit's stand height.
UnitStats * OpenXcom::BattleUnit::getStats | ( | ) |
Gets the unit's stats.
Gets pointer to the unit's stats.
UnitStatus OpenXcom::BattleUnit::getStatus | ( | ) | const |
Gets the unit's status.
double OpenXcom::BattleUnit::getThrowingAccuracy | ( | ) |
Calculate throwing accuracy.
int OpenXcom::BattleUnit::getTimeUnits | ( | ) | const |
Gets the unit's time units.
Returns the soldier's amount of time units.
int OpenXcom::BattleUnit::getTurnsSinceSpotted | ( | ) | const |
Set how many turns this unit will be exposed for.
Get how long since this unit was exposed.
int OpenXcom::BattleUnit::getTurretDirection | ( | ) | const |
int OpenXcom::BattleUnit::getTurretToDirection | ( | ) | const |
Gets the unit's turret To direction.
Gets the BattleUnit's turret To direction.
int OpenXcom::BattleUnit::getTurretType | ( | ) | const |
Get the turret type. -1 is no turret.
Get the turret type.
-1 is no turret.
std::string OpenXcom::BattleUnit::getType | ( | ) | const |
Get unit type.
std::vector< BattleUnit * > & OpenXcom::BattleUnit::getUnitsSpottedThisTurn | ( | ) |
get the vector of units we've seen this turn.
Get the list of units spotted this turn.
int OpenXcom::BattleUnit::getValue | ( | ) | const |
Get the unit's value.
Used for score at debriefing.
int OpenXcom::BattleUnit::getVerticalDirection | ( | ) | const |
Gets the unit's vertical direction.
Gets the BattleUnit's vertical direction.
This is when going up or down.
bool OpenXcom::BattleUnit::getVisible | ( | ) | const |
Get whether this unit is visible.
std::vector< Tile * > * OpenXcom::BattleUnit::getVisibleTiles | ( | ) |
Get the list of visible tiles.
Get the pointer to the vector of visible tiles.
std::vector< BattleUnit * > * OpenXcom::BattleUnit::getVisibleUnits | ( | ) |
Get the list of visible units.
Get the pointer to the vector of visible units.
int OpenXcom::BattleUnit::getWalkingPhase | ( | ) | const |
Gets the walking phase for animation and sound.
void OpenXcom::BattleUnit::halveArmor | ( | ) |
Halve the unit's armor values.
Halve this unit's armor values (for beginner mode)
bool OpenXcom::BattleUnit::hasInventory | ( | ) | const |
Does this unit have an inventory?
Checks if this unit has an inventory.
Large units and/or terror units don't have inventories.
void OpenXcom::BattleUnit::heal | ( | int | part, |
int | woundAmount, | ||
int | healthAmount | ||
) |
Heal one fatal wound.
Heal a fatal wound of the soldier.
part | the body part to heal |
woundAmount | the amount of fatal wound healed |
healthAmount | The amount of health to add to soldier health |
void OpenXcom::BattleUnit::healStun | ( | int | power | ) |
Heal stun level of the unit.
Do an amount of stun recovery.
power |
void OpenXcom::BattleUnit::instaKill | ( | ) |
Set health to 0 and set status dead.
Set health to 0 and set status dead - used when getting zombified.
void OpenXcom::BattleUnit::invalidateCache | ( | ) |
call this after the default copy constructor deletes the cache?
invalidate cache; call after copying object :(
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.
bool OpenXcom::BattleUnit::isFloating | ( | ) | const |
Is floating?
Is floating? A unit is floating when there is no ground under him/her.
bool OpenXcom::BattleUnit::isInExitArea | ( | SpecialTileType | stt = START_POINT | ) | const |
Check if this unit is in the exit area.
stt | Type of exit tile to check for. |
bool OpenXcom::BattleUnit::isKneeled | ( | ) | const |
Is kneeled?
Is kneeled down?
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.
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.
faction | The faction to compare with. |
checkReselect | Check if the unit is reselectable. |
checkInventory | Check if the unit has an inventory. |
bool OpenXcom::BattleUnit::isWoundable | ( | ) | const |
Get whether the unit is affected by fatal wounds.
Normally only soldiers are affected by fatal wounds.
void OpenXcom::BattleUnit::keepFalling | ( | ) |
Increment the falling sequence.
Advances the phase of falling sequence.
void OpenXcom::BattleUnit::keepWalking | ( | Tile * | tileBelowMe, |
bool | cache | ||
) |
Increase the walkingPhase.
This will increment the walking phase.
tileBelowMe | Pointer to tile currently below the unit. |
cache | Refresh the unit cache. |
UnitFaction OpenXcom::BattleUnit::killedBy | ( | ) | const |
Get the faction that killed this unit.
Get the faction the unit was killed by.
void OpenXcom::BattleUnit::killedBy | ( | UnitFaction | f | ) |
Set the faction that killed this unit.
Set the faction the unit was killed by.
f | faction |
void OpenXcom::BattleUnit::kneel | ( | bool | kneeled | ) |
Kneel down.
kneeled | to kneel or to stand up |
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.
battle | Pointer to the battlescape game. |
void OpenXcom::BattleUnit::load | ( | const YAML::Node & | node | ) |
Loads the unit from YAML.
Loads the unit from a YAML file.
node | YAML node. |
void OpenXcom::BattleUnit::lookAt | ( | const Position & | point, |
bool | turret = false |
||
) |
Look at a certain point.
Look at a point.
point | Position to look at. |
turret | True to turn the turret, false to turn the unit. |
void OpenXcom::BattleUnit::lookAt | ( | int | direction, |
bool | force = false |
||
) |
Look at a certain direction.
Look at a direction.
direction | Direction to look at. |
force | True to reset the direction, false to animate to it. |
void OpenXcom::BattleUnit::moraleChange | ( | int | change | ) |
Morale change.
Morale change with bounds check.
change | can be positive or negative |
void OpenXcom::BattleUnit::painKillers | ( | ) |
Give pain killers to this unit.
Restore soldier morale.
bool OpenXcom::BattleUnit::postMissionProcedures | ( | SavedGame * | geoscape | ) |
Check if unit eligible for squaddie promotion.
If yes, promote the unit. Increase the mission counter. Calculate the experience increases.
geoscape | Pointer to geoscape save. |
bool OpenXcom::BattleUnit::reselectAllowed | ( | ) | const |
Check whether reselecting this unit is allowed.
YAML::Node OpenXcom::BattleUnit::save | ( | ) | const |
Saves the unit to YAML.
Saves the soldier to a YAML file.
void OpenXcom::BattleUnit::setActiveHand | ( | const std::string & | hand | ) |
Set the hand this unit is using;.
Set unit's active hand.
hand | active hand. |
void OpenXcom::BattleUnit::setAIState | ( | BattleAIState * | aiState | ) |
void OpenXcom::BattleUnit::setArmor | ( | int | armor, |
UnitSide | side | ||
) |
Set armor value.
Set the armor value of a certain armor side.
armor | Amount of armor. |
side | The side of the armor. |
void OpenXcom::BattleUnit::setCache | ( | Surface * | cache, |
int | part = 0 |
||
) |
Set the cached flag.
Sets the unit's cache flag.
cache | Pointer to cache surface to use, NULL to redraw from scratch. |
part | Unit part to cache. |
void OpenXcom::BattleUnit::setCharging | ( | BattleUnit * | chargeTarget | ) |
Set the units we are charging towards.
chargeTarget | Charge Target |
void OpenXcom::BattleUnit::setCoverReserve | ( | int | reserve | ) |
Changes the amount of TUs reserved for cover.
reserve | time units. |
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.
direction | new horizontal direction |
void OpenXcom::BattleUnit::setEnergy | ( | int | energy | ) |
Sets the unit's energy level.
Set a specific number of energy.
energy | energy. |
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.
direction | new face direction |
void OpenXcom::BattleUnit::setFire | ( | int | fire | ) |
Set fire.
Set the amount of turns this unit is on fire.
0 = no fire.
fire | : amount of turns this tile is on fire. |
void OpenXcom::BattleUnit::setPosition | ( | const Position & | pos, |
bool | updateLastPos = true |
||
) |
Sets the unit's position.
Changes the BattleUnit's position.
pos | position |
updateLastPos | refresh last stored position |
void OpenXcom::BattleUnit::setRankInt | ( | int | rank | ) |
set the rank integer
Change the numeric version of the unit's rank.
rank | unit rank, 0 = lowest |
void OpenXcom::BattleUnit::setSpawnUnit | ( | std::string | spawnUnit | ) |
Sets the unit's spawn unit.
Set the unit that is spawned when this one dies.
spawnUnit | unit. |
void OpenXcom::BattleUnit::setSpecialAbility | ( | SpecialAbility | specab | ) |
Set the units's special ability.
Changes the unit's special ability.
specab | special ability. |
Sets the unit's tile it's standing on.
tile | Pointer to tile. |
tileBelow | Pointer to tile below. |
void OpenXcom::BattleUnit::setTimeUnits | ( | int | tu | ) |
Set time units.
Set a specific number of timeunits.
tu |
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.
turns | number of turns |
void OpenXcom::BattleUnit::setTurretType | ( | int | turretType | ) |
Set the turret type. -1 is no turret.
Set the turret type.
-1 is no turret.
turretType |
void OpenXcom::BattleUnit::setVisible | ( | bool | flag | ) |
Set whether this unit is visible.
flag |
bool OpenXcom::BattleUnit::spendEnergy | ( | int | tu | ) |
Spend energy if it can.
Return false if it can't.
tu |
bool OpenXcom::BattleUnit::spendTimeUnits | ( | int | tu | ) |
Spend time units if it can.
Return false if it can't.
tu |
void OpenXcom::BattleUnit::startFalling | ( | ) |
Start falling sequence.
Intialises the falling sequence.
Occurs after death or stunned.
void OpenXcom::BattleUnit::startWalking | ( | int | direction, |
const Position & | destination, | ||
Tile * | tileBelowMe, | ||
bool | cache | ||
) |
Start the walkingPhase.
Initialises variables to start walking.
direction | Which way to walk. |
destination | The position we should end up on. |
tileBelowMe | Which tile is currently below the unit. |
cache | Update cache? |
void OpenXcom::BattleUnit::stimulant | ( | int | energy, |
int | s | ||
) |
Give stimulant to this unit.
Restore soldier energy and reduce stun level.
energy | The amount of energy to add |
s | The amount of stun level to reduce |
void OpenXcom::BattleUnit::think | ( | BattleAction * | action | ) |
Let AI do their thing.
action | AI action. |
void OpenXcom::BattleUnit::toggleFireDamage | ( | ) |
switch the state of the fire damage tracker.
toggle the state of the fire damage tracking boolean.
bool OpenXcom::BattleUnit::tookFireDamage | ( | ) | const |
did this unit already take fire damage this turn? (used to avoid damaging large units multiple times.)
void OpenXcom::BattleUnit::turn | ( | bool | turret = false | ) |
Turn to the destination direction.
Advances the turning towards the target direction.
turret | True to turn the turret, false to turn the unit. |