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
Base class for all buildings in Simulator game modes.
class cCommodityNode
Represents a spice geyser in civilization stage, maybe it is also used elsewhere.
class cCreatureBase
The base class for all creatures in the Simulator.
class cCulturalTarget
class cEgg
Default model is 0x00000000!0xA76CD528, default mMaterialType is 5.
class cGameDataUFO
class cGamePlant
class cInteractiveOrnament
Static objects in a planet that the player can interact with, such as pickable objects, skeletons in creature stage,...
class cMovableDestructibleOrnament
class cOrnament
Used, among other things, for adventure objects (except pickable ones)
class cSpaceDefenseMissile
class cTribeHut
class cTribeTool
class cTurret
class cVehicle

Public static variables

static const uint32_t TYPE

Constructors, destructors, conversion operators

~cCombatant() virtual

Public functions

auto SetHealthPoints(float healthPoints) -> void
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 damage, uint32_t attackerPoliticalID, int, const Vector3&, cCombatant* pAttacker) -> int virtual
auto AddHostileUnit(cCombatant* combatant) -> void 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
auto func2Ch(bool) -> void virtual
auto func30h() -> Math::Vector3 virtual
auto func34h() -> uint32_t virtual
auto func38h() -> void 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.
auto func48h(int, int) -> void virtual
auto func4Ch(int) -> void virtual
auto SetTarget(cCombatant* target) -> void 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().

Public variables

bool field_8
bool field_9
eastl::map<int, int> field_0C
cCombatantPtr mpLastAttacker
float mMaxHealthPoints
ObjectPtr field_30
int field_34
float mHealthPoints
uint32_t mLastAttacker
float mArmorProbability
cCombatantPtr field_44
cCombatantPtr mpTarget
Vector3 field_4C
eastl::vector<Vector3> mAimPoints
bool field_6C
uint32_t field_70
Vector3 field_74
bool field_80
bool field_81
eastl::vector<cGonzagoTimer> field_84
cGonzagoTimer field_98
int field_B8
int field_BC
ObjectPtr field_C0
ObjectPtr 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.