VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Damage Class Reference

Every entity's damage, from CBaseEntity::TakeDamageOld, and a way to deal it. More...

#include <Damage.hpp>

Public Member Functions

 Damage (EntitySystem &entities, const Bindings &bindings, Interfaces &interfaces, GameEvents &events)
 Damage (const Damage &)=delete
Damage & operator= (const Damage &)=delete
Status Available () const
void Apply (const Entity &victim, const DamageInfo &info)

Public Attributes

Event< DamageHit & > Before

Detailed Description

Every entity's damage, from CBaseEntity::TakeDamageOld, and a way to deal it.

The hook sits where the function starts, so it sees players, props and anything else that takes damage, including hits from Apply. It installs on the first Before subscription.

_damage = runtime.Damage.Before += [this](VoltMod::DamageHit& hit) {
if (IsStructure(hit.Victim.Ref()))
hit.Blocked = HitStructure(hit.Victim.Ref(), hit.Attacker, hit.Amount);
};
runtime.Damage.Apply(bot, {.Attacker = owner.Ref(), .Inflictor = turret, .Amount = 25,
constexpr uint32_t DamageBullet
Definition Damage.hpp:24

Game-thread only.

Definition at line 79 of file Damage.hpp.

Constructor & Destructor Documentation

◆ Damage() [1/2]

VoltMod::Damage::Damage ( EntitySystem & entities,
const Bindings & bindings,
Interfaces & interfaces,
GameEvents & events )

entities resolves the refs, bindings supplies the two damage functions, interfaces the event manager and events each client's listener. All must outlive this service; the Runtime declares them above.

Definition at line 37 of file Damage.cpp.

Referenced by Damage(), and operator=().

◆ Damage() [2/2]

VoltMod::Damage::Damage ( const Damage & )
delete

References Damage().

Member Function Documentation

◆ Apply()

◆ Available()

Status VoltMod::Damage::Available ( ) const

Why damage cannot be hooked or dealt: a damage signature did not bind.

Definition at line 79 of file Damage.cpp.

References VoltMod::Error::Unsupported().

Referenced by Apply().

◆ operator=()

Damage & VoltMod::Damage::operator= ( const Damage & )
delete

References Damage().

Member Data Documentation

◆ Before

Event<DamageHit&> VoltMod::Damage::Before

Raised before the engine applies a hit.

Definition at line 94 of file Damage.hpp.


The documentation for this class was generated from the following files: