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

A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Controller is the identity that stays. More...

#include <Pawn.hpp>

Inheritance diagram for VoltMod::Pawn:

Public Member Functions

bool IsAlive () const
bool IsOnGround () const
Vector EyePosition () const
Vector EyeForward () const
void Slay () const
bool Godmode () const
void SetGodmode (bool on) const
void SetVelocity (Vector velocity) const
bool Heal (int amount) const
Entity GiveItem (std::string_view item) const
Entity GiveKnife () const
bool StripWeapons (bool removeSuit=true) const
std::vector< Entity > Weapons () const
void SelectWeapon (const Entity &weapon) const
void RemoveWeapon (const Entity &weapon) const
Entity ActiveWeapon () const
void HoldFire (int tick) const
void HoldFire (const Clock &clock) const
void HoldCrouch (float amount=1.0f) const
void ReleaseCrouch () const
VoltMod::ObserverMode ObserverMode () const
Status SetObserverMode (VoltMod::ObserverMode mode) const
std::string ModelName () const
VoltMod::Controller Controller () const
int Slot () const
 Entity () noexcept
 Entity (EntitySystem &entities, CEntityInstance *raw) noexcept
 Entity (const Entity &)=default
Public Member Functions inherited from VoltMod::Entity
 Entity () noexcept
 Entity (EntitySystem &entities, CEntityInstance *raw) noexcept
 Entity (const Entity &)=default
Entity & operator= (const Entity &)=delete
 operator bool () const noexcept
CEntityInstance * Raw () const noexcept
int Index () const
EntityRef Ref () const
std::string_view ClassName () const
Pawn AsPawn () const
std::optional< WeaponData > FindWeaponData () const
Vector Origin () const
QAngle Angles () const
void Teleport (std::optional< Vector > origin, std::optional< QAngle > angles, std::optional< Vector > velocity) const
Schema::MoveType_t MoveType () const
void SetMoveType (Schema::MoveType_t type) const
void Spawn (KeyValues &values) const
void AcceptInput (std::string_view input, std::string_view value={}, const Entity &activator={}) const
void Remove () const
void RemoveAfter (float seconds) const
void SetParent (const Entity &parent, std::string_view attachment={}) const
void ClearParent () const
void StopEffect (bool immediately) const
void EmitSound (std::string_view soundEvent, float volume=1.0f) const
void EmitSound (std::string_view soundEvent, IRecipientFilter &recipients, float volume=1.0f) const
void EmitSoundTo (std::string_view soundEvent, int slot, float volume=1.0f) const
void StopSound (std::string_view soundEvent) const
void SetModel (std::string_view path) const
void Follow (const Entity &parent, bool copyBones) const
void SetScale (float scale) const
void SetRender (Schema::RenderMode_t mode, Color color) const
void SetVisible (bool visible, uint8_t alpha=0) const
void PlayAnimation (std::string_view animation, std::string_view idle={}) const
void LoopAnimation (std::string_view animation) const
void SetPlaybackRate (float rate) const
void SetSkin (int skin) const
void SetBodygroup (std::string_view group, int value) const

Additional Inherited Members

Protected Attributes inherited from VoltMod::Entity
EntitySystem * _sys = nullptr
CEntityInstance * _e = nullptr

Detailed Description

A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Controller is the identity that stays.

Definition at line 34 of file Pawn.hpp.

Member Function Documentation

◆ ActiveWeapon()

Entity VoltMod::Pawn::ActiveWeapon ( ) const

The weapon in hand; falsy when there is none.

Definition at line 171 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::Schema::CPlayer_WeaponServices::ActiveWeapon(), and Entity().

Referenced by VoltMod::FireHold::Hold(), HoldFire(), and VoltMod::FireHold::Release().

◆ Controller()

VoltMod::Controller VoltMod::Pawn::Controller ( ) const

The owning player's controller.

Definition at line 278 of file Pawn.cpp.

References VoltMod::Entity::_sys, and Slot().

◆ Entity() [1/3]

VoltMod::Entity::Entity ( )
inlinenoexcept

Definition at line 47 of file Entity.hpp.

Referenced by ActiveWeapon(), GiveItem(), GiveKnife(), RemoveWeapon(), SelectWeapon(), Slot(), and Weapons().

◆ Entity() [2/3]

VoltMod::Entity::Entity ( const Entity & )
default

◆ Entity() [3/3]

VoltMod::Entity::Entity ( EntitySystem & entities,
CEntityInstance * raw )
inlinenoexcept

Prefer runtime.Entities lookups over building one by hand.

Definition at line 50 of file Entity.hpp.

◆ EyeForward()

Vector VoltMod::Pawn::EyeForward ( ) const

The unit vector the player aims along.

Definition at line 40 of file Pawn.cpp.

References VoltMod::AngleToForward().

Referenced by VoltMod::Trace::FromEyes().

◆ EyePosition()

Vector VoltMod::Pawn::EyePosition ( ) const

Where shots start: the origin plus the view offset.

Definition at line 35 of file Pawn.cpp.

References VoltMod::Entity::Origin().

Referenced by VoltMod::Trace::FromEyes().

◆ GiveItem()

Entity VoltMod::Pawn::GiveItem ( std::string_view item) const

Give an item by class name, such as "weapon_ak47". A weapon the pawn's team cannot buy is given through a same-frame team swap. The given item; falsy when the engine refused it.

Definition at line 70 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::Schema::View::Base(), Entity(), VoltMod::None, VoltMod::Opposite(), and VoltMod::Log::Warn().

Referenced by GiveKnife().

◆ GiveKnife()

Entity VoltMod::Pawn::GiveKnife ( ) const

Give the default knife of the pawn's team: "weapon_knife" is the CT one.

Definition at line 107 of file Pawn.cpp.

References Entity(), GiveItem(), and VoltMod::T.

◆ Godmode()

bool VoltMod::Pawn::Godmode ( ) const
inline

The FL_GODMODE flag, which is what makes a CS2 pawn take no damage.

Definition at line 59 of file Pawn.hpp.

◆ Heal()

bool VoltMod::Pawn::Heal ( int amount) const

Add amount health, up to MaxHealth. False when nothing changed, such as a dead pawn.

Definition at line 58 of file Pawn.cpp.

References IsAlive().

◆ HoldCrouch()

void VoltMod::Pawn::HoldCrouch ( float amount = 1.0f) const

◆ HoldFire() [1/2]

void VoltMod::Pawn::HoldFire ( const Clock & clock) const

HoldFire until HoldFireTick; call it every frame to hold fire.

Definition at line 194 of file Pawn.cpp.

References HoldFire(), and VoltMod::HoldFireTick().

◆ HoldFire() [2/2]

void VoltMod::Pawn::HoldFire ( int tick) const

Keep the weapon in hand from either attack before engine tick tick. A weapon switched to later is not covered, so call it every frame to hold fire for a while.

Definition at line 177 of file Pawn.cpp.

References ActiveWeapon(), VoltMod::Schema::CBasePlayerWeapon::NextPrimaryAttackTick(), VoltMod::Schema::CBasePlayerWeapon::NextSecondaryAttackTick(), VoltMod::Entity::Raw(), VoltMod::Schema::CBasePlayerWeapon::SetNextPrimaryAttackTick(), and VoltMod::Schema::CBasePlayerWeapon::SetNextSecondaryAttackTick().

Referenced by HoldFire().

◆ IsAlive()

bool VoltMod::Pawn::IsAlive ( ) const
inline

◆ IsOnGround()

bool VoltMod::Pawn::IsOnGround ( ) const
inline

Definition at line 47 of file Pawn.hpp.

◆ ModelName()

std::string VoltMod::Pawn::ModelName ( ) const

Current model path; empty when unavailable.

Definition at line 266 of file Pawn.cpp.

References VoltMod::Schema::CModelState::ModelName(), and VoltMod::Schema::CSkeletonInstance::ModelState().

Referenced by VoltMod::GlowVision::Refresh().

◆ ObserverMode()

VoltMod::ObserverMode VoltMod::Pawn::ObserverMode ( ) const

◆ ReleaseCrouch()

void VoltMod::Pawn::ReleaseCrouch ( ) const

◆ RemoveWeapon()

void VoltMod::Pawn::RemoveWeapon ( const Entity & weapon) const

Remove weapon through the engine's input queue, so it is safe inside a death event. A weapon in a live pawn's hand is first swapped for the one held before it.

Definition at line 159 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::Schema::CPlayer_WeaponServices::ActiveWeapon(), Entity(), IsAlive(), VoltMod::Schema::CPlayer_WeaponServices::LastWeapon(), VoltMod::Entity::Ref(), VoltMod::Entity::RemoveAfter(), and SelectWeapon().

◆ SelectWeapon()

void VoltMod::Pawn::SelectWeapon ( const Entity & weapon) const

Draw weapon. Does nothing for a weapon the pawn does not carry, or when the SelectItem index did not bind.

Definition at line 143 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::Schema::View::Base(), Entity(), VoltMod::Entity::Raw(), VoltMod::Entity::Ref(), and Weapons().

Referenced by RemoveWeapon().

◆ SetGodmode()

void VoltMod::Pawn::SetGodmode ( bool on) const

Definition at line 45 of file Pawn.cpp.

◆ SetObserverMode()

Status VoltMod::Pawn::SetObserverMode ( VoltMod::ObserverMode mode) const

◆ SetVelocity()

void VoltMod::Pawn::SetVelocity ( Vector velocity) const

Set the pawn's velocity and lift it off the ground this tick, so the engine keeps the velocity. SetAbsVelocity alone leaves a grounded pawn grounded.

Definition at line 50 of file Pawn.cpp.

◆ Slay()

void VoltMod::Pawn::Slay ( ) const

Does nothing when the CommitSuicide index did not bind.

Definition at line 235 of file Pawn.cpp.

References VoltMod::Entity::_e, and VoltMod::Entity::_sys.

◆ Slot()

int VoltMod::Pawn::Slot ( ) const

The owning player's slot, or -1. Constant time.

Definition at line 283 of file Pawn.cpp.

References VoltMod::Entity::_sys, Entity(), VoltMod::Entity::Index(), and VoltMod::IsValidSlot().

Referenced by Controller(), and VoltMod::HookTeleport().

◆ StripWeapons()

bool VoltMod::Pawn::StripWeapons ( bool removeSuit = true) const

Remove every weapon, and with removeSuit the armor and defuse kit too.

Definition at line 112 of file Pawn.cpp.

References VoltMod::Entity::_sys, and VoltMod::Schema::View::Base().

◆ Weapons()

std::vector< Entity > VoltMod::Pawn::Weapons ( ) const

The carried weapons, knife and grenades included.

Definition at line 123 of file Pawn.cpp.

References VoltMod::Entity::_sys, Entity(), and VoltMod::Schema::CPlayer_WeaponServices::MyWeapons().

Referenced by SelectWeapon().


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