19 #ifndef OPENXCOM_UNIT_H
20 #define OPENXCOM_UNIT_H
23 #include <yaml-cpp/yaml.h>
28 enum SpecialAbility { SPECAB_NONE = 0, SPECAB_EXPLODEONDEATH, SPECAB_BURNFLOOR, SPECAB_RESPAWN };
34 int tu, stamina, health, bravery, reactions, firing, throwing, strength, psiStrength, psiSkill, melee;
36 UnitStats() : tu(0), stamina(0), health(0), bravery(0), reactions(0), firing(0), throwing(0), strength(0), psiStrength(0), psiSkill(0), melee(0) {};
37 UnitStats(
int tu_,
int stamina_,
int health_,
int bravery_,
int reactions_,
int firing_,
int throwing_,
int strength_,
int psiStrength_,
int psiSkill_,
int melee_) : tu(tu_), stamina(stamina_), health(health_), bravery(bravery_), reactions(reactions_), firing(firing_), throwing(throwing_), strength(strength_), psiStrength(psiStrength_), psiSkill(psiSkill_), melee(melee_) {};
38 UnitStats& operator+=(
const UnitStats& stats) { tu += stats.tu; stamina += stats.stamina; health += stats.health; bravery += stats.bravery; reactions += stats.reactions; firing += stats.firing; throwing += stats.throwing; strength += stats.strength; psiStrength += stats.psiStrength; psiSkill += stats.psiSkill; melee += stats.melee;
return *
this; }
39 UnitStats operator+(
const UnitStats& stats)
const {
return UnitStats(tu + stats.tu, stamina + stats.stamina, health + stats.health, bravery + stats.bravery, reactions + stats.reactions, firing + stats.firing, throwing + stats.throwing, strength + stats.strength, psiStrength + stats.psiStrength, psiSkill + stats.psiSkill, melee + stats.melee); }
40 UnitStats& operator-=(
const UnitStats& stats) { tu -= stats.tu; stamina -= stats.stamina; health -= stats.health; bravery -= stats.bravery; reactions -= stats.reactions; firing -= stats.firing; throwing -= stats.throwing; strength -= stats.strength; psiStrength -= stats.psiStrength; psiSkill -= stats.psiSkill; melee -= stats.melee;
return *
this; }
41 UnitStats operator-(
const UnitStats& stats)
const {
return UnitStats(tu - stats.tu, stamina - stats.stamina, health - stats.health, bravery - stats.bravery, reactions - stats.reactions, firing - stats.firing, throwing - stats.throwing, strength - stats.strength, psiStrength - stats.psiStrength, psiSkill - stats.psiSkill, melee - stats.melee); }
42 UnitStats operator-()
const {
return UnitStats(-tu, -stamina, -health, -bravery, -reactions, -firing, -throwing, -strength, -psiStrength, -psiSkill, -melee); }
43 void merge(
const UnitStats& stats) { tu = (stats.tu ? stats.tu : tu); stamina = (stats.stamina ? stats.stamina : stamina); health = (stats.health ? stats.health : health); bravery = (stats.bravery ? stats.bravery : bravery); reactions = (stats.reactions ? stats.reactions : reactions); firing = (stats.firing ? stats.firing : firing); throwing = (stats.throwing ? stats.throwing : throwing); strength = (stats.strength ? stats.strength : strength); psiStrength = (stats.psiStrength ? stats.psiStrength : psiStrength); psiSkill = (stats.psiSkill ? stats.psiSkill : psiSkill); melee = (stats.melee ? stats.melee : melee); };
58 int _standHeight, _kneelHeight, _floatHeight;
59 int _value, _deathSound, _aggroSound, _moveSound;
60 int _intelligence, _aggression, _energyRecovery;
61 SpecialAbility _specab;
62 std::string _spawnUnit;
66 Unit(
const std::string &type);
70 void load(
const YAML::Node& node,
int modIndex);
105 int getEnergyRecovery()
const;
113 struct convert<OpenXcom::UnitStats>
119 node[
"stamina"] = rhs.stamina;
120 node[
"health"] = rhs.health;
121 node[
"bravery"] = rhs.bravery;
122 node[
"reactions"] = rhs.reactions;
123 node[
"firing"] = rhs.firing;
124 node[
"throwing"] = rhs.throwing;
125 node[
"strength"] = rhs.strength;
126 node[
"psiStrength"] = rhs.psiStrength;
127 node[
"psiSkill"] = rhs.psiSkill;
128 node[
"melee"] = rhs.melee;
137 rhs.tu = node[
"tu"].as<
int>(rhs.tu);
138 rhs.stamina = node[
"stamina"].as<
int>(rhs.stamina);
139 rhs.health = node[
"health"].as<
int>(rhs.health);
140 rhs.bravery = node[
"bravery"].as<
int>(rhs.bravery);
141 rhs.reactions = node[
"reactions"].as<
int>(rhs.reactions);
142 rhs.firing = node[
"firing"].as<
int>(rhs.firing);
143 rhs.throwing = node[
"throwing"].as<
int>(rhs.throwing);
144 rhs.strength = node[
"strength"].as<
int>(rhs.strength);
145 rhs.psiStrength = node[
"psiStrength"].as<
int>(rhs.psiStrength);
146 rhs.psiSkill = node[
"psiSkill"].as<
int>(rhs.psiSkill);
147 rhs.melee = node[
"melee"].as<
int>(rhs.melee);
void load(const YAML::Node &node, int modIndex)
Loads the unit data from YAML.
Definition: Unit.cpp:47
int getIntelligence() const
Gets the intelligence. This is the number of turns AI remembers your troop positions.
Definition: Unit.cpp:192
Unit(const std::string &type)
Creates a blank unit ruleset.
Definition: Unit.cpp:28
int getValue() const
Gets the value - for score calculation.
Definition: Unit.cpp:165
int getAggroSound() const
Gets the unit's war cry.
Definition: Unit.cpp:228
int getAggression() const
Gets the aggression. Determines the chance of revenge and taking cover.
Definition: Unit.cpp:201
std::string getSpawnUnit() const
Gets the unit's spawn unit.
Definition: Unit.cpp:219
std::string getRank() const
Gets the alien rank.
Definition: Unit.cpp:156
std::string getRace() const
Gets the alien race type.
Definition: Unit.cpp:147
~Unit()
Cleans up the unit ruleset.
Definition: Unit.cpp:37
This struct holds some plain unit attribute data together.
Definition: Unit.h:32
std::string getArmor() const
Gets the armor type.
Definition: Unit.cpp:138
int getFloatHeight() const
Gets the unit's float elevation.
Definition: Unit.cpp:129
int getDeathSound() const
Gets the death sound id.
Definition: Unit.cpp:174
bool isLivingWeapon() const
Checks if this unit has a built in weapon.
Definition: Unit.cpp:237
int getSpecialAbility() const
Gets the alien's special ability.
Definition: Unit.cpp:210
UnitStats * getStats()
Gets the unit's stats.
Definition: Unit.cpp:102
int getMoveSound() const
Gets the move sound id.
Definition: Unit.cpp:183
int getStandHeight() const
Gets the unit's height when standing.
Definition: Unit.cpp:111
std::string getType() const
Gets the unit's type.
Definition: Unit.cpp:93
int getKneelHeight() const
Gets the unit's height when kneeling.
Definition: Unit.cpp:120
Represents the static data for a unit that is generated on the battlescape, this includes: HWPs...
Definition: Unit.h:50