OpenXcom  1.0
Open-source clone of the original X-Com
BattleUnit.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <vector>
21 #include <string>
22 #include <yaml-cpp/yaml.h>
23 #include "../Battlescape/Position.h"
24 #include "../Battlescape/BattlescapeGame.h"
25 #include "../Mod/RuleItem.h"
26 #include "../Mod/Unit.h"
27 #include "../Mod/MapData.h"
28 #include "Soldier.h"
29 #include "BattleItem.h"
30 
31 namespace OpenXcom
32 {
33 
34 class Tile;
35 class BattleItem;
36 class Unit;
37 class BattleAIState;
38 class SavedBattleGame;
39 class Node;
40 class Surface;
41 class RuleInventory;
42 class Soldier;
43 class Armor;
44 class SavedGame;
45 class Language;
46 class AIModule;
47 struct BattleUnitStatistics;
48 struct StatAdjustment;
49 
50 enum UnitStatus {STATUS_STANDING, STATUS_WALKING, STATUS_FLYING, STATUS_TURNING, STATUS_AIMING, STATUS_COLLAPSING, STATUS_DEAD, STATUS_UNCONSCIOUS, STATUS_PANICKING, STATUS_BERSERK, STATUS_IGNORE_ME};
51 enum UnitFaction {FACTION_PLAYER, FACTION_HOSTILE, FACTION_NEUTRAL};
52 enum UnitSide {SIDE_FRONT, SIDE_LEFT, SIDE_RIGHT, SIDE_REAR, SIDE_UNDER};
53 enum UnitBodyPart {BODYPART_HEAD, BODYPART_TORSO, BODYPART_RIGHTARM, BODYPART_LEFTARM, BODYPART_RIGHTLEG, BODYPART_LEFTLEG};
54 
60 {
61 private:
62  static const int SPEC_WEAPON_MAX = 3;
63 
64  UnitFaction _faction, _originalFaction;
65  UnitFaction _killedBy;
66  int _id;
67  Position _pos;
68  Tile *_tile;
69  Position _lastPos;
70  int _direction, _toDirection;
71  int _directionTurret, _toDirectionTurret;
72  int _verticalDirection;
73  Position _destination;
74  UnitStatus _status;
75  int _walkPhase, _fallPhase;
76  std::vector<BattleUnit *> _visibleUnits, _unitsSpottedThisTurn;
77  std::vector<Tile *> _visibleTiles;
78  int _tu, _energy, _health, _morale, _stunlevel;
79  bool _kneeled, _floating, _dontReselect;
80  int _currentArmor[5], _maxArmor[5];
81  int _fatalWounds[6];
82  int _fire;
83  std::vector<BattleItem*> _inventory;
84  BattleItem* _specWeapon[SPEC_WEAPON_MAX];
85  AIModule *_currentAIState;
86  bool _visible;
87  Surface *_cache[5];
88  bool _cacheInvalid;
89  int _expBravery, _expReactions, _expFiring, _expThrowing, _expPsiSkill, _expPsiStrength, _expMelee;
90  int improveStat(int exp) const;
91  int _motionPoints;
92  int _kills;
93  int _faceDirection; // used only during strafeing moves
94  bool _hitByFire, _hitByAnything;
95  int _moraleRestored;
96  int _coverReserve;
97  BattleUnit *_charging;
98  int _turnsSinceSpotted;
99  std::string _spawnUnit;
100  std::string _activeHand;
101  BattleUnitStatistics* _statistics;
102  int _murdererId; // used to credit the murderer with the kills that this unit got by blowing up on death
103  int _mindControllerID; // used to credit the mind controller with the kills of the mind controllee
104  UnitSide _fatalShotSide;
105  UnitBodyPart _fatalShotBodyPart;
106  std::string _murdererWeapon, _murdererWeaponAmmo;
107 
108  // static data
109  std::string _type;
110  std::string _rank;
111  std::string _race;
112  std::string _name;
113  UnitStats _stats;
114  int _standHeight, _kneelHeight, _floatHeight;
115  std::vector<int> _deathSound;
116  int _value, _aggroSound, _moveSound;
117  int _intelligence, _aggression;
118  SpecialAbility _specab;
119  Armor *_armor;
120  SoldierGender _gender;
121  Soldier *_geoscapeSoldier;
122  std::vector<int> _loftempsSet;
123  Unit *_unitRules;
124  int _rankInt;
125  int _turretType;
126  int _breathFrame;
127  bool _breathing;
128  bool _hidingForTurn, _floorAbove, _respawn;
129  MovementType _movementType;
130  std::vector<std::pair<Uint8, Uint8> > _recolor;
131  bool _capturable;
132 
134  void setRecolor(int basicLook, int utileLook, int rankLook);
135 public:
136  static const int MAX_SOLDIER_ID = 1000000;
138  BattleUnit(Soldier *soldier, int depth);
140  BattleUnit(Unit *unit, UnitFaction faction, int id, Armor *armor, StatAdjustment *adjustment, int depth);
142  ~BattleUnit();
144  void load(const YAML::Node& node);
146  YAML::Node save() const;
148  int getId() const;
150  void setPosition(Position pos, bool updateLastPos = true);
152  Position getPosition() const;
154  Position getLastPosition() const;
156  void setDirection(int direction);
158  void setFaceDirection(int direction);
160  int getDirection() const;
162  int getFaceDirection() const;
164  int getTurretDirection() const;
166  int getTurretToDirection() const;
168  int getVerticalDirection() const;
170  UnitStatus getStatus() const;
172  void startWalking(int direction, Position destination, Tile *tileBelowMe, bool cache);
174  void keepWalking(Tile *tileBelowMe, bool cache);
176  int getWalkingPhase() const;
178  int getDiagonalWalkingPhase() const;
180  Position getDestination() const;
182  void lookAt(Position point, bool turret = false);
184  void lookAt(int direction, bool force = false);
186  void turn(bool turret = false);
188  void abortTurn();
190  SoldierGender getGender() const;
192  UnitFaction getFaction() const;
194  void setCache(Surface *cache, int part = 0);
196  Surface *getCache(bool *invalid, int part = 0) const;
198  const std::vector<std::pair<Uint8, Uint8> > &getRecolor() const;
200  void kneel(bool kneeled);
202  bool isKneeled() const;
204  bool isFloating() const;
206  void aim(bool aiming);
208  int directionTo(Position point) const;
210  int getTimeUnits() const;
212  int getEnergy() const;
214  int getHealth() const;
216  int getMorale() const;
218  int damage(Position relative, int power, ItemDamageType type, bool ignoreArmor = false);
220  void healStun(int power);
222  int getStunlevel() const;
224  void knockOut(BattlescapeGame *battle);
226  void startFalling();
228  void keepFalling();
230  int getFallingPhase() const;
232  bool isOut() const;
234  int getActionTUs(BattleActionType actionType, BattleItem *item);
235  int getActionTUs(BattleActionType actionType, RuleItem *item);
237  bool spendTimeUnits(int tu);
239  bool spendEnergy(int tu);
241  void setTimeUnits(int tu);
243  bool addToVisibleUnits(BattleUnit *unit);
245  std::vector<BattleUnit*> *getVisibleUnits();
247  void clearVisibleUnits();
249  bool addToVisibleTiles(Tile *tile);
251  std::vector<Tile*> *getVisibleTiles();
253  void clearVisibleTiles();
255  int getFiringAccuracy(BattleActionType actionType, BattleItem *item);
257  int getAccuracyModifier(BattleItem *item = 0);
259  double getThrowingAccuracy();
261  void setArmor(int armor, UnitSide side);
263  int getArmor(UnitSide side) const;
265  int getMaxArmor(UnitSide side) const;
267  int getFatalWounds() const;
269  double getReactionScore();
271  void prepareNewTurn(bool fullProcess = true);
273  void moraleChange(int change);
275  void dontReselect();
277  void allowReselect();
279  bool reselectAllowed() const;
281  void setFire(int fire);
283  int getFire() const;
285  std::vector<BattleItem*> *getInventory();
287  void think(BattleAction *action);
289  AIModule *getAIModule() const;
291  void setAIModule(AIModule *ai);
293  void setVisible(bool flag);
295  bool getVisible() const;
297  void setTile(Tile *tile, Tile *tileBelow = 0);
299  Tile *getTile() const;
301  BattleItem *getItem(RuleInventory *slot, int x = 0, int y = 0) const;
303  BattleItem *getItem(const std::string &slot, int x = 0, int y = 0) const;
305  BattleItem *getMainHandWeapon(bool quickest = true) const;
309  bool checkAmmo();
311  bool isInExitArea(SpecialTileType stt = START_POINT) const;
312  bool liesInExitArea(Tile *tile, SpecialTileType stt = START_POINT) const;
314  int getHeight() const;
316  int getFloatHeight() const;
318  void addReactionExp();
320  void addFiringExp();
322  void addThrowingExp();
324  void addPsiSkillExp();
326  void addPsiStrengthExp();
328  void addMeleeExp();
330  void updateGeoscapeStats(Soldier *soldier) const;
332  bool postMissionProcedures(SavedGame *geoscape, UnitStats &statsDiff);
334  int getMiniMapSpriteIndex() const;
336  void setTurretType(int turretType);
338  int getTurretType() const;
340  int getFatalWound(int part) const;
342  void heal(int part, int woundAmount, int healthAmount);
344  void painKillers();
346  void stimulant (int energy, int stun);
348  int getMotionPoints() const;
350  Armor *getArmor() const;
352  std::string getName(Language *lang, bool debugAppendId = false) const;
356  int getStandHeight() const;
358  int getKneelHeight() const;
360  int getLoftemps(int entry = 0) const;
362  int getValue() const;
364  const std::vector<int> &getDeathSounds() const;
366  int getMoveSound() const;
368  bool isWoundable() const;
370  bool isFearable() const;
372  int getIntelligence() const;
374  int getAggression() const;
376  int getSpecialAbility() const;
378  void setRespawn(bool respawn);
380  bool getRespawn() const;
382  std::string getRankString() const;
384  Soldier *getGeoscapeSoldier() const;
386  void addKillCount();
388  std::string getType() const;
390  void setActiveHand(const std::string &slot);
392  std::string getActiveHand() const;
394  void convertToFaction(UnitFaction f);
396  void kill();
398  void instaKill();
400  std::string getSpawnUnit() const;
402  void setSpawnUnit(const std::string &spawnUnit);
404  int getAggroSound() const;
406  void setEnergy(int energy);
408  UnitFaction killedBy() const;
410  void killedBy(UnitFaction f);
412  void setCharging(BattleUnit *chargeTarget);
416  int getCarriedWeight(BattleItem *draggingItem = 0) const;
418  void setTurnsSinceSpotted (int turns);
420  int getTurnsSinceSpotted() const;
422  UnitFaction getOriginalFaction() const;
424  void invalidateCache();
425 
426  Unit *getUnitRules() const { return _unitRules; }
427 
428  Position lastCover;
430  std::vector<BattleUnit *> &getUnitsSpottedThisTurn();
432  void setRankInt(int rank);
434  int getRankInt() const;
436  void deriveRank();
438  bool checkViewSector(Position pos) const;
440  void adjustStats(const StatAdjustment &adjustment);
442  bool tookFireDamage() const;
444  void toggleFireDamage();
445  void setCoverReserve(int reserve);
446  int getCoverReserve() const;
448  bool isSelectable(UnitFaction faction, bool checkReselect, bool checkInventory) const;
450  bool hasInventory() const;
452  int getBreathFrame() const;
454  void breathe();
456  void setFloorAbove(bool floor);
458  bool getFloorAbove() const;
462  MovementType getMovementType() const;
464  bool isHiding() const {return _hidingForTurn; };
466  void setHiding(bool hiding) { _hidingForTurn = hiding; };
468  void goToTimeOut();
470  void setSpecialWeapon(SavedBattleGame *save, const Mod *mod);
472  BattleItem *getSpecialWeapon(BattleType type) const;
474  void recoverTimeUnits();
478  void setMurdererId(int id);
480  int getMurdererId() const;
482  void setFatalShotInfo(UnitSide side, UnitBodyPart bodypart);
484  UnitSide getFatalShotSide() const;
486  UnitBodyPart getFatalShotBodyPart() const;
488  std::string getMurdererWeapon() const;
490  void setMurdererWeapon(const std::string& weapon);
492  std::string getMurdererWeaponAmmo() const;
494  void setMurdererWeaponAmmo(const std::string& weaponAmmo);
496  void setMindControllerId(int id);
498  int getMindControllerId() const;
500  int getFiringXP() const;
502  void nerfFiringXP(int newXP);
504  bool getHitState();
506  void resetHitState();
508  bool getCapturable() const;
509 };
510 
511 }
void allowReselect()
Reselect this unit.
Definition: BattleUnit.cpp:1748
void addReactionExp()
Adds one to the reaction exp counter.
Definition: BattleUnit.cpp:2129
BattleUnit * getCharging()
Get the units we are charging towards.
Definition: BattleUnit.cpp:2735
int getAggression() const
Get the unit&#39;s aggression.
Definition: BattleUnit.cpp:2555
void setVisible(bool flag)
Set whether this unit is visible.
Definition: BattleUnit.cpp:1827
int getId() const
Gets the BattleUnit&#39;s ID.
Definition: BattleUnit.cpp:481
void prepareNewTurn(bool fullProcess=true)
Prepare for a new turn.
Definition: BattleUnit.cpp:1636
int getCarriedWeight(BattleItem *draggingItem=0) const
Get the carried weight in strength units.
Definition: BattleUnit.cpp:2745
void setMindControllerId(int id)
Set the unit mind controller&#39;s id.
Definition: BattleUnit.cpp:3270
void setMurdererWeapon(const std::string &weapon)
Set the unit murderer&#39;s weapon.
Definition: BattleUnit.cpp:3243
void setFloorAbove(bool floor)
Set the flag for "floor above me" meaning stop rendering bubbles.
Definition: BattleUnit.cpp:3025
BattleItem * getMainHandWeapon(bool quickest=true) const
Gets the item in the main hand.
Definition: BattleUnit.cpp:1963
UnitFaction killedBy() const
Get the faction that killed this unit.
Definition: BattleUnit.cpp:2708
std::string getSpawnUnit() const
Gets the unit&#39;s spawn unit.
Definition: BattleUnit.cpp:2590
void setAIModule(AIModule *ai)
Set AI Module.
Definition: BattleUnit.cpp:1805
Position getLastPosition() const
Gets the unit&#39;s position.
Definition: BattleUnit.cpp:510
int getRankInt() const
get the rank integer
Definition: BattleUnit.cpp:2815
const std::vector< int > & getDeathSounds() const
Get the unit&#39;s death sounds.
Definition: BattleUnit.cpp:2500
void setDirection(int direction)
Sets the unit&#39;s direction 0-7.
Definition: BattleUnit.cpp:529
Definition: BattlescapeGame.h:43
bool isOut() const
The unit is out - either dead or unconscious.
Definition: BattleUnit.cpp:1295
bool addToVisibleUnits(BattleUnit *unit)
Add unit to visible units.
Definition: BattleUnit.cpp:1415
int getSpecialAbility() const
Get the units&#39;s special ability.
Definition: BattleUnit.cpp:2564
void breathe()
Start breathing and/or update the breathing frame.
Definition: BattleUnit.cpp:2990
std::vector< BattleUnit * > * getVisibleUnits()
Get the list of visible units.
Definition: BattleUnit.cpp:1445
std::string getName(Language *lang, bool debugAppendId=false) const
Gets the unit&#39;s name.
Definition: BattleUnit.cpp:2417
std::vector< Tile * > * getVisibleTiles()
Get the list of visible tiles.
Definition: BattleUnit.cpp:1473
BattleItem * getGrenadeFromBelt() const
Gets a grenade from the belt, if any.
Definition: BattleUnit.cpp:2043
bool getRespawn() const
Get the units&#39;s respawn flag.
Definition: BattleUnit.cpp:2581
std::string getActiveHand() const
Get unit&#39;s active hand.
Definition: BattleUnit.cpp:2653
bool checkAmmo()
Reloads righthand weapon if needed.
Definition: BattleUnit.cpp:2059
int getMotionPoints() const
Get motion points for the motion scanner.
Definition: BattleUnit.cpp:2394
void deriveRank()
derive a rank integer based on rank string (for xcom soldiers ONLY)
Definition: BattleUnit.cpp:2824
bool reselectAllowed() const
Check whether reselecting this unit is allowed.
Definition: BattleUnit.cpp:1758
void turn(bool turret=false)
Turn to the destination direction.
Definition: BattleUnit.cpp:803
bool isFearable() const
Get whether the unit is affected by fear.
Definition: BattleUnit.cpp:2537
void aim(bool aiming)
Aim.
Definition: BattleUnit.cpp:979
int getAccuracyModifier(BattleItem *item=0)
Calculate accuracy modifier.
Definition: BattleUnit.cpp:1540
void setTile(Tile *tile, Tile *tileBelow=0)
Sets the unit&#39;s tile it&#39;s standing on.
Definition: BattleUnit.cpp:1854
UnitFaction getFaction() const
Gets the unit&#39;s faction.
Definition: BattleUnit.cpp:900
void stimulant(int energy, int stun)
Give stimulant to this unit.
Definition: BattleUnit.cpp:2380
void setMurdererId(int id)
Set the unit murderer&#39;s id.
Definition: BattleUnit.cpp:3187
The game data that gets written to disk when the game is saved.
Definition: SavedGame.h:99
void setFaceDirection(int direction)
Sets the unit&#39;s face direction (only used by strafing moves)
Definition: BattleUnit.cpp:541
double getReactionScore()
Get the current reaction score.
Definition: BattleUnit.cpp:1625
int getTurnsSinceSpotted() const
Set how many turns this unit will be exposed for.
Definition: BattleUnit.cpp:2770
void convertToFaction(UnitFaction f)
Convert&#39;s unit to a faction.
Definition: BattleUnit.cpp:2664
void heal(int part, int woundAmount, int healthAmount)
Heal one fatal wound.
Definition: BattleUnit.cpp:2342
int getFire() const
Get fire.
Definition: BattleUnit.cpp:1777
void nerfFiringXP(int newXP)
Artificially alter a unit&#39;s firing xp. (used for shotguns)
Definition: BattleUnit.cpp:3295
void clearVisibleUnits()
Clear visible units.
Definition: BattleUnit.cpp:1453
void setPosition(Position pos, bool updateLastPos=true)
Sets the unit&#39;s position.
Definition: BattleUnit.cpp:491
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
Definition: Unit.h:44
UnitBodyPart getFatalShotBodyPart() const
Get information on the unit&#39;s fatal shot&#39;s body part.
Definition: BattleUnit.cpp:3225
std::string getRankString() const
Get the units&#39;s rank string.
Definition: BattleUnit.cpp:2608
Soldier * getGeoscapeSoldier() const
Get the geoscape-soldier object.
Definition: BattleUnit.cpp:2617
std::string getMurdererWeaponAmmo() const
Get the unit murderer&#39;s weapon&#39;s ammo.
Definition: BattleUnit.cpp:3252
int getTurretToDirection() const
Gets the unit&#39;s turret To direction.
Definition: BattleUnit.cpp:578
int getKneelHeight() const
Get the unit&#39;s kneel height.
Definition: BattleUnit.cpp:2462
int getMaxArmor(UnitSide side) const
Get max armor value.
Definition: BattleUnit.cpp:1603
void keepFalling()
Increment the falling sequence.
Definition: BattleUnit.cpp:1263
void adjustStats(const StatAdjustment &adjustment)
adjust this unit&#39;s stats according to difficulty.
Definition: BattleUnit.cpp:2895
void setTimeUnits(int tu)
Set time units.
Definition: BattleUnit.cpp:1405
void setEnergy(int energy)
Sets the unit&#39;s energy level.
Definition: BattleUnit.cpp:2699
bool tookFireDamage() const
did this unit already take fire damage this turn? (used to avoid damaging large units multiple times...
Definition: BattleUnit.cpp:2922
void setMurdererWeaponAmmo(const std::string &weaponAmmo)
Set the unit murderer&#39;s weapon&#39;s ammo.
Definition: BattleUnit.cpp:3261
void startWalking(int direction, Position destination, Tile *tileBelowMe, bool cache)
Start the walkingPhase.
Definition: BattleUnit.cpp:608
bool hasInventory() const
Does this unit have an inventory?
Definition: BattleUnit.cpp:2971
bool postMissionProcedures(SavedGame *geoscape, UnitStats &statsDiff)
Check if unit eligible for squaddie promotion.
Definition: BattleUnit.cpp:2187
void setRankInt(int rank)
set the rank integer
Definition: BattleUnit.cpp:2806
void toggleFireDamage()
switch the state of the fire damage tracker.
Definition: BattleUnit.cpp:2930
bool isKneeled() const
Is kneeled?
Definition: BattleUnit.cpp:961
Surface * getCache(bool *invalid, int part=0) const
If this unit is cached on the battlescape.
Definition: BattleUnit.cpp:930
int damage(Position relative, int power, ItemDamageType type, bool ignoreArmor=false)
Do damage to the unit.
Definition: BattleUnit.cpp:1088
void recoverTimeUnits()
Recovers the unit&#39;s time units and energy.
Definition: BattleUnit.cpp:3141
void lookAt(Position point, bool turret=false)
Look at a certain point.
Definition: BattleUnit.cpp:752
bool getVisible() const
Get whether this unit is visible.
Definition: BattleUnit.cpp:1837
int getAggroSound() const
Gets the unit&#39;s aggro sound.
Definition: BattleUnit.cpp:2690
void setCoverReserve(int reserve)
Changes the amount of TUs reserved for cover.
Definition: BattleUnit.cpp:2939
void resetHitState()
reset the unit hit state.
Definition: BattleUnit.cpp:3311
int getMurdererId() const
Get the unit murderer&#39;s id.
Definition: BattleUnit.cpp:3196
void addThrowingExp()
Adds one to the throwing exp counter.
Definition: BattleUnit.cpp:2145
UnitFaction getOriginalFaction() const
Get this unit&#39;s original faction.
Definition: BattleUnit.cpp:2779
void setSpecialWeapon(SavedBattleGame *save, const Mod *mod)
Create special weapon for unit.
Definition: BattleUnit.cpp:3095
void kneel(bool kneeled)
Kneel down.
Definition: BattleUnit.cpp:951
void healStun(int power)
Heal stun level of the unit.
Definition: BattleUnit.cpp:1219
bool isWoundable() const
Get whether the unit is affected by fatal wounds.
Definition: BattleUnit.cpp:2527
void painKillers()
Give pain killers to this unit.
Definition: BattleUnit.cpp:2365
void load(const YAML::Node &node)
Loads the unit from YAML.
Definition: BattleUnit.cpp:316
Represents a specific type of item.
Definition: RuleItem.h:40
void setCharging(BattleUnit *chargeTarget)
Set the units we are charging towards.
Definition: BattleUnit.cpp:2726
bool getHitState()
Was this unit just hit?
Definition: BattleUnit.cpp:3303
Contains strings used throughout the game for localization.
Definition: Language.h:39
bool isInExitArea(SpecialTileType stt=START_POINT) const
Check if this unit is in the exit area.
Definition: BattleUnit.cpp:2101
double getThrowingAccuracy()
Calculate throwing accuracy.
Definition: BattleUnit.cpp:1569
void addPsiSkillExp()
Adds one to the psi skill exp counter.
Definition: BattleUnit.cpp:2153
int getHealth() const
Gets the unit&#39;s health.
Definition: BattleUnit.cpp:1066
bool getCapturable() const
Gets whether this unit can be captured alive (applies to aliens).
Definition: BattleUnit.cpp:3319
Represents a single item in the battlescape.
Definition: BattleItem.h:37
void addMeleeExp()
Adds one to the melee exp counter.
Definition: BattleUnit.cpp:2169
This class is used by the BattleUnit AI.
Definition: AIModule.h:40
std::string getType() const
Get unit type.
Definition: BattleUnit.cpp:2634
UnitSide getFatalShotSide() const
Get information on the unit&#39;s fatal shot&#39;s side.
Definition: BattleUnit.cpp:3216
int getTurretDirection() const
Gets the unit&#39;s turret direction.
Definition: BattleUnit.cpp:569
int getMorale() const
Gets the unit&#39;s bravery.
Definition: BattleUnit.cpp:1075
int getFloatHeight() const
Gets the unit floating elevation.
Definition: BattleUnit.cpp:2471
std::vector< BattleItem * > * getInventory()
Get the list of items in the inventory.
Definition: BattleUnit.cpp:1786
bool liesInExitArea(Tile *tile, SpecialTileType stt=START_POINT) const
Check if this unit lies (e.g.
Definition: BattleUnit.cpp:2112
int getDiagonalWalkingPhase() const
Gets the walking phase for diagonal walking.
Definition: BattleUnit.cpp:742
BattleUnitStatistics * getStatistics()
Get the unit&#39;s mission statistics.
Definition: BattleUnit.cpp:3178
void setTurretType(int turretType)
Set the turret type. -1 is no turret.
Definition: BattleUnit.cpp:2310
void setHiding(bool hiding)
Sets this unit is in hiding for a turn (or not).
Definition: BattleUnit.h:466
BattleItem * getItem(RuleInventory *slot, int x=0, int y=0) const
Gets the item in the specified slot.
Definition: BattleUnit.cpp:1896
UnitStats * getBaseStats()
Gets the unit&#39;s stats.
Definition: BattleUnit.cpp:2444
int getWalkingPhase() const
Gets the walking phase for animation and sound.
Definition: BattleUnit.cpp:733
void addPsiStrengthExp()
Adds one to the psi strength exp counter.
Definition: BattleUnit.cpp:2161
int getCoverReserve() const
Returns the amount of TUs reserved for cover.
Definition: BattleUnit.cpp:2948
void setArmor(int armor, UnitSide side)
Set armor value.
Definition: BattleUnit.cpp:1579
Represents a specific type of armor.
Definition: Armor.h:35
void setFire(int fire)
Set fire.
Definition: BattleUnit.cpp:1767
void setActiveHand(const std::string &slot)
Set the hand this unit is using;.
Definition: BattleUnit.cpp:2643
Represents a soldier hired by the player.
Definition: Soldier.h:48
Tile * getTile() const
Gets the unit&#39;s tile.
Definition: BattleUnit.cpp:1883
int getActionTUs(BattleActionType actionType, BattleItem *item)
Get the number of time units a certain action takes.
Definition: BattleUnit.cpp:1306
void addFiringExp()
Adds one to the firing exp counter.
Definition: BattleUnit.cpp:2137
void addKillCount()
Add a kill to the counter.
Definition: BattleUnit.cpp:2625
void goToTimeOut()
Puts the unit in the corner to think about what he&#39;s done.
Definition: BattleUnit.cpp:3075
int getTurretType() const
Get the turret type. -1 is no turret.
Definition: BattleUnit.cpp:2319
Basic element of which a battle map is build.
Definition: Tile.h:42
This struct holds some plain unit attribute data together.
Definition: Unit.h:30
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
int getMoveSound() const
Get the unit&#39;s move sound.
Definition: BattleUnit.cpp:2516
int getDirection() const
Gets the unit&#39;s direction.
Definition: BattleUnit.cpp:550
bool addToVisibleTiles(Tile *tile)
Add unit to visible tiles.
Definition: BattleUnit.cpp:1463
bool isHiding() const
Checks if this unit is in hiding for a turn.
Definition: BattleUnit.h:464
YAML::Node save() const
Saves the unit to YAML.
Definition: BattleUnit.cpp:382
int directionTo(Position point) const
Get direction to a certain point.
Definition: BattleUnit.cpp:1000
int getFiringXP() const
Get the unit&#39;s total firing xp for this mission.
Definition: BattleUnit.cpp:3287
const std::vector< std::pair< Uint8, Uint8 > > & getRecolor() const
Gets unit sprite recolors values.
Definition: BattleUnit.cpp:942
void setFatalShotInfo(UnitSide side, UnitBodyPart bodypart)
Set information on the unit&#39;s fatal shot.
Definition: BattleUnit.cpp:3206
BattleItem * getSpecialWeapon(BattleType type) const
Get special weapon.
Definition: BattleUnit.cpp:3126
int getStunlevel() const
Gets the unit&#39;s stun level.
Definition: BattleUnit.cpp:1225
void instaKill()
Set health to 0 and set status dead.
Definition: BattleUnit.cpp:2680
AIModule * getAIModule() const
Get AI Module.
Definition: BattleUnit.cpp:1818
void kill()
Set health to 0.
Definition: BattleUnit.cpp:2672
void clearVisibleTiles()
Clear visible tiles.
Definition: BattleUnit.cpp:1481
bool spendTimeUnits(int tu)
Spend time units if it can.
Definition: BattleUnit.cpp:1368
int getValue() const
Get the unit&#39;s value.
Definition: BattleUnit.cpp:2491
BattleItem * getMeleeWeapon()
Get any melee weapon we may be carrying, or a built in one.
Definition: BattleUnit.cpp:3043
int getFatalWound(int part) const
Get fatal wound amount of a body part.
Definition: BattleUnit.cpp:2329
void invalidateCache()
call this after the default copy constructor deletes the cache?
Definition: BattleUnit.cpp:2787
int getFiringAccuracy(BattleActionType actionType, BattleItem *item)
Calculate firing accuracy.
Definition: BattleUnit.cpp:1498
BattleUnit(Soldier *soldier, int depth)
Creates a BattleUnit from solder.
Definition: BattleUnit.cpp:49
Battlescape game - the core game engine of the battlescape game.
Definition: BattlescapeGame.h:68
void keepWalking(Tile *tileBelowMe, bool cache)
Increase the walkingPhase.
Definition: BattleUnit.cpp:652
int getStandHeight() const
Get the unit&#39;s stand height.
Definition: BattleUnit.cpp:2453
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:47
int getFatalWounds() const
Get total number of fatal wounds.
Definition: BattleUnit.cpp:1612
std::vector< BattleUnit * > & getUnitsSpottedThisTurn()
get the vector of units we&#39;ve seen this turn.
Definition: BattleUnit.cpp:2797
int getIntelligence() const
Get the unit&#39;s intelligence.
Definition: BattleUnit.cpp:2546
void setSpawnUnit(const std::string &spawnUnit)
Sets the unit&#39;s spawn unit.
Definition: BattleUnit.cpp:2599
Container for battle unit statistics.
Definition: BattleUnitStatistics.h:305
void moraleChange(int change)
Morale change.
Definition: BattleUnit.cpp:1726
int getFallingPhase() const
Get falling sequence.
Definition: BattleUnit.cpp:1285
void think(BattleAction *action)
Let AI do their thing.
Definition: BattleUnit.cpp:1795
int getEnergy() const
Gets the unit&#39;s stamina.
Definition: BattleUnit.cpp:1057
int getLoftemps(int entry=0) const
Get the unit&#39;s loft ID.
Definition: BattleUnit.cpp:2482
bool isSelectable(UnitFaction faction, bool checkReselect, bool checkInventory) const
Is this unit selectable?
Definition: BattleUnit.cpp:2961
Armor * getArmor() const
Gets the unit&#39;s armor.
Definition: BattleUnit.cpp:2404
Easy handling of X-Y-Z coordinates.
Definition: Position.h:28
bool spendEnergy(int tu)
Spend energy if it can.
Definition: BattleUnit.cpp:1386
~BattleUnit()
Cleans up the BattleUnit.
Definition: BattleUnit.cpp:300
UnitStatus getStatus() const
Gets the unit&#39;s status.
Definition: BattleUnit.cpp:596
bool getFloorAbove() const
Get the flag for "floor above me".
Definition: BattleUnit.cpp:3034
int getHeight() const
Gets the unit height taking into account kneeling/standing.
Definition: BattleUnit.cpp:2121
bool checkViewSector(Position pos) const
this function checks if a tile is visible, using maths.
Definition: BattleUnit.cpp:2846
MovementType getMovementType() const
Use this function to check the unit&#39;s movement type.
Definition: BattleUnit.cpp:3066
int getTimeUnits() const
Gets the unit&#39;s time units.
Definition: BattleUnit.cpp:1048
SoldierGender getGender() const
Gets the soldier&#39;s gender.
Definition: BattleUnit.cpp:891
void setTurnsSinceSpotted(int turns)
Set how many turns this unit will be exposed for.
Definition: BattleUnit.cpp:2761
Position getPosition() const
Gets the unit&#39;s position.
Definition: BattleUnit.cpp:501
int getMindControllerId() const
Get the unit mind controller&#39;s id.
Definition: BattleUnit.cpp:3279
void setRespawn(bool respawn)
Set the units&#39;s respawn flag.
Definition: BattleUnit.cpp:2573
void abortTurn()
Abort turning.
Definition: BattleUnit.cpp:882
void dontReselect()
Don&#39;t reselect this unit.
Definition: BattleUnit.cpp:1740
int getMiniMapSpriteIndex() const
Get the sprite index for the minimap.
Definition: BattleUnit.cpp:2273
bool isFloating() const
Is floating?
Definition: BattleUnit.cpp:970
int getBreathFrame() const
Is this unit breathing and if so what frame?
Definition: BattleUnit.cpp:2980
int getFaceDirection() const
Gets the unit&#39;s face direction (only used by strafing moves)
Definition: BattleUnit.cpp:560
int getVerticalDirection() const
Gets the unit&#39;s vertical direction.
Definition: BattleUnit.cpp:587
void knockOut(BattlescapeGame *battle)
Knocks the unit out instantly.
Definition: BattleUnit.cpp:1236
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
void updateGeoscapeStats(Soldier *soldier) const
Updates the stats of a Geoscape soldier.
Definition: BattleUnit.cpp:2174
std::string getMurdererWeapon() const
Get the unit murderer&#39;s weapon.
Definition: BattleUnit.cpp:3234
Definition: BaseInfoState.cpp:40
Represents the static data for a unit that is generated on the battlescape, this includes: HWPs...
Definition: Unit.h:57
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:42
void startFalling()
Start falling sequence.
Definition: BattleUnit.cpp:1253
Position getDestination() const
Gets the unit&#39;s destination when walking.
Definition: BattleUnit.cpp:519
void setCache(Surface *cache, int part=0)
Set the cached flag.
Definition: BattleUnit.cpp:910