Simulator::cCombatant class

Any object that has hit points and can combat other units.

This class acts more as a container of different variables (like the target combatant, number of hit points, etc), and therefore it barely has any combat logic on it. The combat logic is managed externally, by the cCombatSimulator class.

Combatants can only fight with other combatants, and can only attack one of them at a time. To do so, use the SetTarget() method. If the class has no target, it won't attack anyone.

Several attributes can be saved into the game data:

  • mHealthPoints
  • mMaxHealthPoints
  • mLastAttacker
  • mArmorProbability

Derived classes

class cBuilding
class cCommodityNode
class cCreatureBase
class cGameDataUFO
class cInteractiveOrnament
class cOrnament
class cVehicle

Public static variables

static const uint32_t TYPE

Constructors, destructors, conversion operators

~cCombatant() virtual

Public functions

void SetHealthPoints(float healthPoints)
auto GetWeaponRange() -> float
Returns the maximum range of this combatant's weapon.
auto Write(void* arg_0) -> bool virtual
auto ToSpatialObject() -> cSpatialObject* pure virtual
Returns the cSpatialObject that corresponds to this combatant.
auto ToGameData() -> cGameData* pure virtual
Returns the cGameData that corresponds to this combatant.
auto GetPoliticalID() -> uint32_t pure virtual
Returns this object political ID, used to identify the cGameData.
auto GetWeapon() -> cSpaceToolData* virtual
Returns the weapon tool used by this combatant. This is only available for vehicles.
auto func18h(float, int, int, int, int) -> int virtual
void AddHostileUnit(cCombatant* combatant) virtual
auto func20h() -> Math::Vector3 virtual
auto GetRandomAimIndex() -> int virtual
Generates a random index that allows to select from the existing aim points.
auto func28h(int) -> Math::Vector3 virtual
void func2Ch(bool) virtual
auto func30h() -> Math::Vector3 virtual
auto func34h() -> uint32_t virtual
void func38h() virtual
auto func3Ch() -> bool virtual
auto IsInWeaponRange(cCombatant* other) -> bool virtual
Returns true if the other combatant is inside the maximum range of this combatant's weapon.
auto IsWeaponCharged(int = 0) -> bool virtual
Returns true if the weapon has enough ammo (if it uses ammo) and is not recharging.
void func48h(int, int) virtual
void func4Ch(int) virtual
void SetTarget(cCombatant* target) virtual
Sets the target combatant; if it is not nullptr, this object will start attacking the given combatant.
auto GetTarget() -> cCombatant* virtual
Returns the current target, that is, the combatant that this class is attacking, or nullptr if the class is not in combat.
auto GetMaxHitPoints() -> float virtual
auto Cast(uint32_t type) -> void* virtual
Same as Object::Cast(uint32_t)
auto AddRef() -> int pure virtual
Same as Object::AddRef().
auto Release() -> int pure virtual
Same as Object::Release().

Protected variables

bool field_8
bool field_9
map<int, int> field_0C
intrusive_ptr<cCombatant> field_28
float mMaxHealthPoints
intrusive_ptr<Object> field_30
int field_34
float mHealthPoints
int mLastAttacker
float mArmorProbability
intrusive_ptr<cCombatant> field_44
intrusive_ptr<cCombatant> mpTarget
Vector3 field_4C
vector<Vector3> mAimPoints
bool field_6C
uint32_t field_70
Vector3 field_74
bool field_80
bool field_81
vector<cGonzagoTimer> field_84
cGonzagoTimer field_98
int field_B8
int field_BC
intrusive_ptr<Object> field_C0
intrusive_ptr<Object> field_C4

Function documentation

float Simulator::cCombatant::GetWeaponRange()

Returns the maximum range of this combatant's weapon.

If this combatant does not use weapon tools, returns 0.

bool Simulator::cCombatant::IsInWeaponRange(cCombatant* other) virtual

Returns true if the other combatant is inside the maximum range of this combatant's weapon.

If this combatant does not use weapon tools, returns false.

bool Simulator::cCombatant::IsWeaponCharged(int = 0) virtual

Returns true if the weapon has enough ammo (if it uses ammo) and is not recharging.

If this combatant does not use weapon tools, returns false.

void Simulator::cCombatant::SetTarget(cCombatant* target) virtual

Sets the target combatant; if it is not nullptr, this object will start attacking the given combatant.

Parameters
target The new target combatant.

There can only be one target at a time.