![]() |
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, 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... | |
Surface * | getCache (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... | |
AIModule * | getAIModule () 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... | |
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... | |
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... | |
Armor * | getArmor () const |
Gets the unit's armor. More... | |
std::string | getName (Language *lang, bool debugAppendId=false) const |
Gets the unit's name. More... | |
UnitStats * | getBaseStats () |
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... | |
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 | 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... | |
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 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... | |
BattleItem * | getMeleeWeapon () |
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... | |
BattleItem * | getSpecialWeapon (BattleType type) const |
Get special weapon. | |
void | recoverTimeUnits () |
Recovers the unit's time units and energy. More... | |
BattleUnitStatistics * | getStatistics () |
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). | |
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, |
int | depth | ||
) |
Creates a BattleUnit from solder.
Initializes a BattleUnit from a Soldier.
soldier | Pointer to the Soldier. |
depth | the depth of the battlefield (used to determine movement type in case of MT_FLOAT). |
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.
void OpenXcom::BattleUnit::abortTurn | ( | ) |
Abort turning.
Stops the turning towards the target direction.
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 StatAdjustment & | adjustment | ) |
adjust this unit's stats according to difficulty.
common function to adjust a unit's stats according to difficulty setting.
statAdjustment | the stat adjustment variables coefficient value. |
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.
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.
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 | ( | 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 | ( | 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
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.
AIModule * OpenXcom::BattleUnit::getAIModule | ( | ) | const |
Get AI Module.
Returns the current AI state.
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.
UnitStats * OpenXcom::BattleUnit::getBaseStats | ( | ) |
Gets the unit's stats.
Gets pointer to the unit's stats.
int OpenXcom::BattleUnit::getBreathFrame | ( | ) | const |
Is this unit breathing and if so what frame?
If this unit is breathing, what frame should be displayed?
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.
const std::vector< int > & OpenXcom::BattleUnit::getDeathSounds | ( | ) | const |
Get the unit's death sounds.
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.
UnitBodyPart OpenXcom::BattleUnit::getFatalShotBodyPart | ( | ) | const |
Get information on the unit's fatal shot's body part.
UnitSide OpenXcom::BattleUnit::getFatalShotSide | ( | ) | const |
Get information on the unit's fatal shot's side.
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.
bool OpenXcom::BattleUnit::getFloorAbove | ( | ) | const |
Get the flag for "floor above me".
Checks if the floor above flag has been set.
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.
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::getMaxArmor | ( | UnitSide | side | ) | const |
Get max armor value.
Get the max armor value of a certain armor side.
side | The side of the armor. |
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.
int OpenXcom::BattleUnit::getMindControllerId | ( | ) | const |
Get the unit mind controller's id.
Gets the unit mind controller's id.
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.
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.
int OpenXcom::BattleUnit::getMoveSound | ( | ) | const |
Get the unit's move sound.
int OpenXcom::BattleUnit::getMurdererId | ( | ) | const |
Get the unit murderer's id.
Gets the unit murderer's id.
std::string OpenXcom::BattleUnit::getMurdererWeapon | ( | ) | const |
Get the unit murderer's weapon.
Gets the unit murderer's weapon.
std::string OpenXcom::BattleUnit::getMurdererWeaponAmmo | ( | ) | const |
Get the unit murderer's weapon's ammo.
Gets the unit murderer's weapon's ammo.
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.
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.
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.
const std::vector< std::pair< Uint8, Uint8 > > & OpenXcom::BattleUnit::getRecolor | ( | ) | const |
Gets unit sprite recolors values.
Gets values used for recoloring sprites.
i | what value choose. |
bool OpenXcom::BattleUnit::getRespawn | ( | ) | const |
Get the units's respawn flag.
Gets this unit's respawn flag.
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.
BattleUnitStatistics * OpenXcom::BattleUnit::getStatistics | ( | ) |
Get the unit's mission statistics.
Get the unit's statistics.
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::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.
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.
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. |
void OpenXcom::BattleUnit::kill | ( | ) |
Set health to 0.
Set health to 0 - used when getting killed unconscious.
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. |
bool OpenXcom::BattleUnit::liesInExitArea | ( | Tile * | tile, |
SpecialTileType | stt = START_POINT |
||
) | const |
Check if this unit lies (e.g.
unconscious) in the exit area.
tile | Unit's location. |
stt | Type of exit tile to check for. |
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 | ( | 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::nerfFiringXP | ( | int | newXP | ) |
Artificially alter a unit's firing xp. (used for shotguns)
Artificially alter a unit's firing xp.
(used for shotguns)
void OpenXcom::BattleUnit::painKillers | ( | ) |
Give pain killers to this unit.
Restore soldier morale.
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. |
statsDiff | (out) The passed UnitStats struct will be filled with the stats differences. |
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.
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::setAIModule | ( | AIModule * | ai | ) |
Set AI Module.
Changes the current AI state.
aiState | Pointer to AI state. |
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::setFatalShotInfo | ( | UnitSide | side, |
UnitBodyPart | bodypart | ||
) |
Set information on the unit's fatal shot.
Set information on the unit's fatal blow.
UnitSide | unit's side that was shot. |
UnitBodyPart | unit's body part that was shot. |
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::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.
floor | is there a floor. |
void OpenXcom::BattleUnit::setMindControllerId | ( | int | id | ) |
Set the unit mind controller's id.
Sets the unit mind controller's id.
int | mind controller id. |
void OpenXcom::BattleUnit::setMurdererId | ( | int | id | ) |
Set the unit murderer's id.
Sets the unit murderer's id.
int | murderer id. |
void OpenXcom::BattleUnit::setMurdererWeapon | ( | const std::string & | weapon | ) |
Set the unit murderer's weapon.
Set the murderer's weapon.
string | murderer's weapon. |
void OpenXcom::BattleUnit::setMurdererWeaponAmmo | ( | const std::string & | weaponAmmo | ) |
Set the unit murderer's weapon's ammo.
Set the murderer's weapon's ammo.
string | murderer weapon ammo. |
void OpenXcom::BattleUnit::setPosition | ( | 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::setRespawn | ( | bool | respawn | ) |
Set the units's respawn flag.
Sets this unit to respawn (or not).
respawn | whether it should respawn. |
void OpenXcom::BattleUnit::setSpawnUnit | ( | const std::string & | spawnUnit | ) |
Sets the unit's spawn unit.
Set the unit that is spawned when this one dies.
spawnUnit | unit. |
void OpenXcom::BattleUnit::setSpecialWeapon | ( | SavedBattleGame * | save, |
const Mod * | mod | ||
) |
Create special weapon for unit.
Set special weapon that is handled outside inventory.
save |
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.
Initialises the falling sequence.
Occurs after death or stunned.
void OpenXcom::BattleUnit::startWalking | ( | int | direction, |
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. |