2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-14 23:58:08 +03:00

Headers update, rename m_bHasSecondaryAttack, CSPlayer member additions (#293)

* Update CSEntity.h, CSPlayer.h, CSPlayerItem.h, regamedll_api.h
* SendDeathMessage interface to regamedll_api.h
* Update CSPlayerWeapon class, rename m_bHasSecondaryAttack
* Updated CSPlayerWeapon.h vfuncs and members
* Renamed bHasSecondaryAttack member to iStateSecondaryAttack and added compat to AMXX includes
* Added remaining CSPlayer members
* Added overload method for bool[]
This commit is contained in:
Francisco Muñoz 2023-11-26 01:12:14 -03:00 committed by GitHub
parent b281588ddf
commit 4c1932c2c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 384 additions and 15 deletions

View File

@ -1479,3 +1479,14 @@ enum GameEventType
EVENT_HOSTAGE_CALLED_FOR_HELP, // tell bots the hostage is talking (argumens: 1 = listener, 2 = NULL)
NUM_GAME_EVENTS,
};
/**
* Weapon secondary attack states
* For CCSPlayerWeapon::m_iStateSecondaryAttack
*/
enum SecondaryAtkState
{
WEAPON_SECONDARY_ATTACK_NONE = 0,
WEAPON_SECONDARY_ATTACK_SET,
WEAPON_SECONDARY_ATTACK_BLOCK
};

View File

@ -4816,6 +4816,54 @@ enum CCSPlayer_Members
* Set params: set_member(index, member, bool:value);
*/
m_bSpawnProtectionEffects,
/*
* Description: Player vertical jump height
* Member type: float
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
m_flJumpHeight,
/*
* Description: Player vertical jump height with longjump
* Member type: float
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
m_flLongJumpHeight,
/*
* Description: Player horizontal jump height with longjump
* Member type: float
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
m_flLongJumpForce,
/*
* Description: Player crouch maxspeed multiplier
* Member type: float
* Get params: Float:get_member(index, member);
* Set params: set_member(index, member, Float:value);
*/
m_flDuckSpeedMultiplier,
/*
* Description: How many unanswered kills this player has been dealt by each other player (0-31)
* Member type: int [32]
* Get params: get_member(index, member, element);
* Set params: set_member(index, member, value, element);
*/
m_iNumKilledByUnanswered,
/*
* Description: Array of state per other player whether player is dominating other players (0-31)
* Member type: bool [32]
* Get params: get_member(index, member, element);
* Set params: set_member(index, member, value, element);
*/
m_bPlayerDominated,
};
/**
@ -6238,12 +6286,12 @@ enum CMapInfo_Members
enum CCSPlayerWeapon_Members
{
/*
* Description: Can the weapon have secondary attack
* Member type: bool
* Description: Weapon secondary attack state
* Member type: enum SecondaryAtkState
* Get params: get_member(index, member);
* Set params: set_member(index, member, bool:value);
* Set params: set_member(index, member, SecondaryAtkState:value);
*/
m_Weapon_bHasSecondaryAttack = BEGIN_MEMBER_REGION(csplayerweapon),
m_Weapon_iStateSecondaryAttack = BEGIN_MEMBER_REGION(csplayerweapon),
/*
* Description: Basic damage that weapon deals before any multiplier, such as hitgroup, armor, distance and bullet penetration
@ -6254,6 +6302,9 @@ enum CCSPlayerWeapon_Members
m_Weapon_flBaseDamage,
};
// API compatibility
#define m_Weapon_bHasSecondaryAttack m_Weapon_iStateSecondaryAttack
/**
* CGib Members
*/

View File

@ -36,6 +36,7 @@ public:
CCSEntity() :
m_pContainingEntity(nullptr)
{
m_ucDmgPenetrationLevel = 0;
}
virtual ~CCSEntity() {}
@ -45,12 +46,14 @@ public:
public:
CBaseEntity *m_pContainingEntity;
unsigned char m_ucDmgPenetrationLevel; // penetration level of the damage caused by the inflictor
private:
#if defined(_MSC_VER)
#pragma region reserve_data_Region
#endif
int CCSEntity_Reserve[0x1000];
char CCSEntity_Reserve[0x3FFF];
virtual void func_reserve1() {};
virtual void func_reserve2() {};
virtual void func_reserve3() {};

View File

@ -30,6 +30,7 @@
#include <API/CSPlayerItem.h>
#include <API/CSPlayerWeapon.h>
#include <utlarray.h>
enum WeaponInfiniteAmmoMode
{
@ -52,9 +53,21 @@ public:
m_bAutoBunnyHopping(false),
m_bMegaBunnyJumping(false),
m_bPlantC4Anywhere(false),
m_bSpawnProtectionEffects(false)
m_bSpawnProtectionEffects(false),
m_flJumpHeight(0),
m_flLongJumpHeight(0),
m_flLongJumpForce(0),
m_flDuckSpeedMultiplier(0),
m_iUserID(-1)
{
m_szModel[0] = '\0';
// Resets the kill history for this player
for (int i = 0; i < MAX_CLIENTS; i++)
{
m_iNumKilledByUnanswered[i] = 0;
m_bPlayerDominated[i] = false;
}
}
virtual bool IsConnected() const = 0;
@ -106,11 +119,6 @@ public:
virtual void OnSpawnEquip(bool addDefault = true, bool equipGame = true) = 0;
virtual void SetScoreboardAttributes(CBasePlayer *destination = nullptr) = 0;
void ResetVars();
void OnSpawn();
void OnKilled();
CBasePlayer *BasePlayer() const;
public:
@ -138,6 +146,23 @@ public:
bool m_bMegaBunnyJumping;
bool m_bPlantC4Anywhere;
bool m_bSpawnProtectionEffects;
double m_flJumpHeight;
double m_flLongJumpHeight;
double m_flLongJumpForce;
double m_flDuckSpeedMultiplier;
int m_iUserID;
struct CDamageRecord_t
{
float flDamage = 0.0f;
float flFlashDurationTime = 0.0f;
int userId = -1;
};
using DamageList_t = CUtlArray<CDamageRecord_t, MAX_CLIENTS>;
DamageList_t m_DamageList; // A unified array of recorded damage that includes giver and taker in each entry
DamageList_t &GetDamageList() { return m_DamageList; }
int m_iNumKilledByUnanswered[MAX_CLIENTS]; // [0-31] how many unanswered kills this player has been dealt by each other player
bool m_bPlayerDominated[MAX_CLIENTS]; // [0-31] array of state per other player whether player is dominating other players
};
// Inlines

View File

@ -39,6 +39,7 @@ public:
}
virtual void SetItemInfo(ItemInfo *pInfo) = 0;
virtual int GetItemInfo(ItemInfo *pInfo) = 0;
CBasePlayerItem *BasePlayerItem() const;

View File

@ -28,19 +28,33 @@
#pragma once
enum SecondaryAtkState : uint8_t
{
WEAPON_SECONDARY_ATTACK_NONE = 0,
WEAPON_SECONDARY_ATTACK_SET,
WEAPON_SECONDARY_ATTACK_BLOCK
};
class CBasePlayerWeapon;
class CCSPlayerWeapon: public CCSPlayerItem
{
DECLARE_CLASS_TYPES(CCSPlayerWeapon, CCSPlayerItem);
public:
CCSPlayerWeapon() :
m_bHasSecondaryAttack(false)
m_iStateSecondaryAttack(WEAPON_SECONDARY_ATTACK_NONE)
{
}
virtual BOOL DefaultDeploy(char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0) = 0;
virtual int DefaultReload(int iClipSize, int iAnim, float fDelay) = 0;
virtual bool DefaultShotgunReload(int iAnim, int iStartAnim, float fDelay, float fStartDelay, const char *pszReloadSound1 = nullptr, const char *pszReloadSound2 = nullptr) = 0;
virtual void KickBack(float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change) = 0;
virtual void SendWeaponAnim(int iAnim, int skiplocal = 0) = 0;
CBasePlayerWeapon *BasePlayerWeapon() const;
public:
bool m_bHasSecondaryAttack;
SecondaryAtkState m_iStateSecondaryAttack;
float m_flBaseDamage;
};

View File

@ -614,6 +614,14 @@ typedef IHookChainRegistryClass<void, CBasePlayerWeapon, float, float, float, fl
typedef IHookChainClass<void, CBasePlayerWeapon, int, int> IReGameHook_CBasePlayerWeapon_SendWeaponAnim;
typedef IHookChainRegistryClass<void, CBasePlayerWeapon, int, int> IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim;
// CHalfLifeMultiplay::SendDeathMessage hook
typedef IHookChain<void, class CBaseEntity *, class CBasePlayer *, class CBasePlayer *, struct entvars_s *, const char *, int, int> IReGameHook_CSGameRules_SendDeathMessage;
typedef IHookChainRegistry<void, class CBaseEntity *, class CBasePlayer *, class CBasePlayer *, struct entvars_s *, const char *, int, int> IReGameHookRegistry_CSGameRules_SendDeathMessage;
// CBasePlayer::PlayerDeathThink hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_PlayerDeathThink;
typedef IHookChainRegistryClass<void, class CBasePlayer> IReGameHookRegistry_CBasePlayer_PlayerDeathThink;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -771,6 +779,9 @@ public:
virtual IReGameHookRegistry_CBasePlayerWeapon_ItemPostFrame *CBasePlayerWeapon_ItemPostFrame() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_KickBack *CBasePlayerWeapon_KickBack() = 0;
virtual IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim *CBasePlayerWeapon_SendWeaponAnim() = 0;
virtual IReGameHookRegistry_CSGameRules_SendDeathMessage *CSGameRules_SendDeathMessage() = 0;
virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0;
};
struct ReGameFuncs_t {

View File

@ -0,0 +1,235 @@
/*
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
*/
#pragma once
// A growable array class that maintains a free list and keeps elements
// in the same location
#include "tier0/platform.h"
#include "tier0/dbg.h"
#define FOR_EACH_ARRAY(vecName, iteratorName)\
for (int iteratorName = 0; (vecName).IsUtlArray && iteratorName < (vecName).Count(); iteratorName++)
#define FOR_EACH_ARRAY_BACK(vecName, iteratorName)\
for (int iteratorName = (vecName).Count() - 1; (vecName).IsUtlArray && iteratorName >= 0; iteratorName--)
template <class T, size_t MAX_SIZE>
class CUtlArray
{
public:
typedef T ElemType_t;
enum { IsUtlArray = true }; // Used to match this at compiletime
CUtlArray();
CUtlArray(T *pMemory, size_t count);
~CUtlArray();
CUtlArray<T, MAX_SIZE> &operator=(const CUtlArray<T, MAX_SIZE> &other);
CUtlArray(CUtlArray const &vec);
// element access
T &operator[](int i);
const T &operator[](int i) const;
T &Element(int i);
const T &Element(int i) const;
T &Random();
const T &Random() const;
T *Base();
const T *Base() const;
// Returns the number of elements in the array, NumAllocated() is included for consistency with UtlVector
int Count() const;
int NumAllocated() const;
// Is element index valid?
bool IsValidIndex(int i) const;
static int InvalidIndex();
void CopyArray(const T *pArray, size_t count);
void Clear();
void RemoveAll();
void Swap(CUtlArray< T, MAX_SIZE> &vec);
// Finds an element (element needs operator== defined)
int Find(const T &src) const;
void FillWithValue(const T &src);
bool HasElement(const T &src) const;
protected:
T m_Memory[MAX_SIZE];
};
// Constructor
template <typename T, size_t MAX_SIZE>
inline CUtlArray<T, MAX_SIZE>::CUtlArray()
{
}
template <typename T, size_t MAX_SIZE>
inline CUtlArray<T, MAX_SIZE>::CUtlArray(T *pMemory, size_t count)
{
CopyArray(pMemory, count);
}
// Destructor
template <typename T, size_t MAX_SIZE>
inline CUtlArray<T, MAX_SIZE>::~CUtlArray()
{
}
template <typename T, size_t MAX_SIZE>
inline CUtlArray<T, MAX_SIZE> &CUtlArray<T, MAX_SIZE>::operator=(const CUtlArray<T, MAX_SIZE> &other)
{
if (this != &other)
{
for (size_t n = 0; n < MAX_SIZE; n++)
m_Memory[n] = other.m_Memory[n];
}
return *this;
}
template <typename T, size_t MAX_SIZE>
inline CUtlArray<T, MAX_SIZE>::CUtlArray(CUtlArray const &vec)
{
for (size_t n = 0; n < MAX_SIZE; n++)
m_Memory[n] = vec.m_Memory[n];
}
template <typename T, size_t MAX_SIZE>
inline T *CUtlArray<T, MAX_SIZE>::Base()
{
return &m_Memory[0];
}
template <typename T, size_t MAX_SIZE>
inline const T *CUtlArray<T, MAX_SIZE>::Base() const
{
return &m_Memory[0];
}
// Element access
template <typename T, size_t MAX_SIZE>
inline T &CUtlArray<T, MAX_SIZE>::operator[](int i)
{
Assert(IsValidIndex(i));
return m_Memory[i];
}
template <typename T, size_t MAX_SIZE>
inline const T &CUtlArray<T, MAX_SIZE>::operator[](int i) const
{
Assert(IsValidIndex(i));
return m_Memory[i];
}
template <typename T, size_t MAX_SIZE>
inline T &CUtlArray<T, MAX_SIZE>::Element(int i)
{
Assert(IsValidIndex(i));
return m_Memory[i];
}
template <typename T, size_t MAX_SIZE>
inline const T &CUtlArray<T, MAX_SIZE>::Element(int i) const
{
Assert(IsValidIndex(i));
return m_Memory[i];
}
// Count
template <typename T, size_t MAX_SIZE>
inline int CUtlArray<T, MAX_SIZE>::Count() const
{
return (int)MAX_SIZE;
}
template <typename T, size_t MAX_SIZE>
inline int CUtlArray<T, MAX_SIZE>::NumAllocated() const
{
return (int)MAX_SIZE;
}
// Is element index valid?
template <typename T, size_t MAX_SIZE>
inline bool CUtlArray<T, MAX_SIZE>::IsValidIndex(int i) const
{
return (i >= 0) && (i < MAX_SIZE);
}
// Returns in invalid index
template <typename T, size_t MAX_SIZE>
inline int CUtlArray<T, MAX_SIZE>::InvalidIndex()
{
return -1;
}
template <typename T, size_t MAX_SIZE>
void CUtlArray<T, MAX_SIZE>::CopyArray(const T *pArray, size_t count)
{
Assert(count < MAX_SIZE);
for (size_t n = 0; n < count; n++)
m_Memory[n] = pArray[n];
}
template <typename T, size_t MAX_SIZE>
void CUtlArray<T, MAX_SIZE>::Clear()
{
Q_memset(m_Memory, 0, MAX_SIZE * sizeof(T));
}
template <typename T, size_t MAX_SIZE>
void CUtlArray<T, MAX_SIZE>::RemoveAll()
{
Clear();
}
template <typename T, size_t MAX_SIZE>
void CUtlArray<T, MAX_SIZE>::Swap(CUtlArray< T, MAX_SIZE> &vec)
{
for (size_t n = 0; n < MAX_SIZE; n++)
SWAP(m_Memory[n], vec.m_Memory[n]);
}
// Finds an element (element needs operator== defined)
template <typename T, size_t MAX_SIZE>
int CUtlArray<T, MAX_SIZE>::Find(const T &src) const
{
for (int i = 0; i < Count(); i++)
{
if (Element(i) == src)
return i;
}
return -1;
}
template <typename T, size_t MAX_SIZE>
void CUtlArray<T, MAX_SIZE>::FillWithValue(const T &src)
{
for (int i = 0; i < Count(); i++)
Element(i) = src;
}
template <typename T, size_t MAX_SIZE>
bool CUtlArray<T, MAX_SIZE>::HasElement(const T &src) const
{
return (Find(src) >= 0);
}

View File

@ -190,6 +190,7 @@
<ClInclude Include="..\include\cssdk\pm_shared\pm_shared.h" />
<ClInclude Include="..\include\cssdk\public\FileSystem.h" />
<ClInclude Include="..\include\cssdk\public\interface.h" />
<ClInclude Include="..\include\cssdk\public\utlarray.h" />
<ClInclude Include="..\include\cssdk\public\utlmemory.h" />
<ClInclude Include="..\include\cssdk\public\utlvector.h" />
<ClInclude Include="..\include\metamod\dllapi.h" />

View File

@ -582,6 +582,9 @@
<ClInclude Include="..\include\cssdk\public\interface.h">
<Filter>include\cssdk\public</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\public\utlarray.h">
<Filter>include\cssdk\public</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\public\utlmemory.h">
<Filter>include\cssdk\public</Filter>
</ClInclude>

View File

@ -112,6 +112,7 @@ inline MType getMemberType(MONSTERSTATE) { return MEMBER_INTEGER; }
inline MType getMemberType(ArmorType) { return MEMBER_INTEGER; }
inline MType getMemberType(ArmouryItemPack) { return MEMBER_INTEGER; }
inline MType getMemberType(InfoMapBuyParam) { return MEMBER_INTEGER; }
inline MType getMemberType(SecondaryAtkState) { return MEMBER_INTEGER; }
inline MType getMemberType(netadrtype_t) { return MEMBER_INTEGER; }
inline MType getMemberType(TraceResult) { return MEMBER_TRACERESULT; }
@ -120,6 +121,7 @@ inline MType getMemberType(short) { return MEMBER_SHORT; }
inline MType getMemberType(unsigned short) { return MEMBER_SHORT; }
inline MType getMemberType(bool) { return MEMBER_BOOL; }
inline MType getMemberType(bool*) { return MEMBER_BOOL; }
inline MType getMemberType(CUnifiedSignals) { return MEMBER_SIGNALS; }
inline MType getMemberType(RebuyStruct) { return MEBMER_REBUYSTRUCT; }
@ -764,6 +766,12 @@ member_t memberlist_csplayer[] = {
CSPL_MEMBERS(m_bMegaBunnyJumping),
CSPL_MEMBERS(m_bPlantC4Anywhere),
CSPL_MEMBERS(m_bSpawnProtectionEffects),
CSPL_MEMBERS(m_flJumpHeight),
CSPL_MEMBERS(m_flLongJumpHeight),
CSPL_MEMBERS(m_flLongJumpForce),
CSPL_MEMBERS(m_flDuckSpeedMultiplier),
CSPL_MEMBERS(m_iNumKilledByUnanswered),
CSPL_MEMBERS(m_bPlayerDominated),
};
member_t memberlist_baseitem[] = {
@ -1039,7 +1047,7 @@ member_t memberlist_mapinfo[] = {
};
member_t memberlist_csplayerweapon[] = {
CSPLWPN_MEMBERS(bHasSecondaryAttack),
CSPLWPN_MEMBERS(iStateSecondaryAttack),
CSPLWPN_MEMBERS(flBaseDamage),
};

View File

@ -759,6 +759,12 @@ enum CSPlayer_Members
m_bMegaBunnyJumping,
m_bPlantC4Anywhere,
m_bSpawnProtectionEffects,
m_flJumpHeight,
m_flLongJumpHeight,
m_flLongJumpForce,
m_flDuckSpeedMultiplier,
m_iNumKilledByUnanswered,
m_bPlayerDominated,
};
enum CBasePlayerItem_Members
@ -1071,7 +1077,7 @@ enum MapInfo_Members
enum CSPlayerWeapon_Members
{
m_Weapon_bHasSecondaryAttack = BEGIN_MEMBER_REGION(csplayerweapon),
m_Weapon_iStateSecondaryAttack = BEGIN_MEMBER_REGION(csplayerweapon),
m_Weapon_flBaseDamage,
};