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
 
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
 
bool StripWeapons (bool removeSuit=true) const
 
std::vector< Entity > Weapons () const
 
void SelectWeapon (const Entity &weapon) const
 
void RemoveWeapon (const Entity &weapon) const
 
void HoldFire (int tick) 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
 
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 EmitSound (std::string_view soundEvent, float volume=1.0f) const
 
void EmitSound (std::string_view soundEvent, IRecipientFilter &recipients, float volume=1.0f) const
 
void StopSound (std::string_view soundEvent) const
 
void SetModel (std::string_view path) 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
 

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 18 of file Pawn.hpp.

Member Function Documentation

◆ Controller()

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

The owning player's controller.

Definition at line 213 of file Pawn.cpp.

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

Referenced by VoltMod::ObserverTarget().

◆ Entity() [1/3]

VoltMod::Entity::Entity ( )
inlinenoexcept

Definition at line 36 of file Entity.hpp.

◆ 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 39 of file Entity.hpp.

◆ EyePosition()

Vector VoltMod::Pawn::EyePosition ( ) const

Where shots start: the origin plus the view offset.

Definition at line 24 of file Pawn.cpp.

References VoltMod::Entity::Origin().

◆ 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 54 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Bindings(), VoltMod::Bindings::GiveNamedItem, VoltMod::None, VoltMod::Opposite(), VoltMod::ReadFile(), and VoltMod::Log::Warn().

◆ Godmode()

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

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

Definition at line 40 of file Pawn.hpp.

References VoltMod::ReadFile().

◆ 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 42 of file Pawn.cpp.

References IsAlive(), and VoltMod::ReadFile().

◆ HoldFire()

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 151 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Get(), VoltMod::ReadFile(), and VoltMod::Schema::CBasePlayerWeapon::SetNextPrimaryAttackTick().

◆ IsAlive()

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

Definition at line 29 of file Pawn.hpp.

References VoltMod::Entity::_e, and VoltMod::ReadFile().

Referenced by Heal(), and RemoveWeapon().

◆ IsOnGround()

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

Definition at line 31 of file Pawn.hpp.

References VoltMod::ReadFile().

◆ ModelName()

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

Current model path; empty when unavailable.

Definition at line 201 of file Pawn.cpp.

References VoltMod::Schema::View::Base(), and VoltMod::ReadFile().

◆ ObserverMode()

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

Definition at line 183 of file Pawn.cpp.

References VoltMod::None, and VoltMod::ReadFile().

◆ 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 139 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Get(), IsAlive(), VoltMod::ReadFile(), 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 122 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Bindings(), VoltMod::ReadFile(), VoltMod::Bindings::SelectItem, and Weapons().

Referenced by RemoveWeapon().

◆ SetGodmode()

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

Definition at line 29 of file Pawn.cpp.

References VoltMod::ReadFile().

◆ SetObserverMode()

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

Definition at line 189 of file Pawn.cpp.

References VoltMod::Error::NotReady(), and VoltMod::ReadFile().

◆ 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 34 of file Pawn.cpp.

References VoltMod::ReadFile().

◆ Slay()

void VoltMod::Pawn::Slay ( ) const

Does nothing when the CommitSuicide index did not bind.

Definition at line 170 of file Pawn.cpp.

References VoltMod::Entity::_e, VoltMod::Entity::_sys, VoltMod::EntitySystem::Bindings(), and VoltMod::Bindings::CommitSuicide.

◆ Slot()

int VoltMod::Pawn::Slot ( ) const

◆ StripWeapons()

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

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

Definition at line 91 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Bindings(), VoltMod::ReadFile(), and VoltMod::Bindings::RemoveAllItems.

◆ Weapons()

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

The carried weapons, knife and grenades included.

Definition at line 102 of file Pawn.cpp.

References VoltMod::Entity::_sys, VoltMod::EntitySystem::Get(), and VoltMod::ReadFile().

Referenced by SelectWeapon().


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