diff --git a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc index 149baeed..17a0bf57 100644 --- a/reapi/extra/amxmodx/scripting/include/cssdk_const.inc +++ b/reapi/extra/amxmodx/scripting/include/cssdk_const.inc @@ -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 +}; diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index a4a34e8e..9749df4e 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -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 */ diff --git a/reapi/include/cssdk/dlls/API/CSEntity.h b/reapi/include/cssdk/dlls/API/CSEntity.h index 8f03b7c2..4f321515 100644 --- a/reapi/include/cssdk/dlls/API/CSEntity.h +++ b/reapi/include/cssdk/dlls/API/CSEntity.h @@ -36,6 +36,7 @@ class CCSEntity CCSEntity() : m_pContainingEntity(nullptr) { + m_ucDmgPenetrationLevel = 0; } virtual ~CCSEntity() {} @@ -45,12 +46,14 @@ class CCSEntity 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() {}; diff --git a/reapi/include/cssdk/dlls/API/CSPlayer.h b/reapi/include/cssdk/dlls/API/CSPlayer.h index b12aa230..3495ee29 100644 --- a/reapi/include/cssdk/dlls/API/CSPlayer.h +++ b/reapi/include/cssdk/dlls/API/CSPlayer.h @@ -30,6 +30,7 @@ #include #include +#include enum WeaponInfiniteAmmoMode { @@ -52,9 +53,21 @@ class CCSPlayer: public CCSMonster 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 @@ class CCSPlayer: public CCSMonster 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 @@ class CCSPlayer: public CCSMonster 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; + 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 diff --git a/reapi/include/cssdk/dlls/API/CSPlayerItem.h b/reapi/include/cssdk/dlls/API/CSPlayerItem.h index 74abc0b2..e4bec454 100644 --- a/reapi/include/cssdk/dlls/API/CSPlayerItem.h +++ b/reapi/include/cssdk/dlls/API/CSPlayerItem.h @@ -39,6 +39,7 @@ class CCSPlayerItem: public CCSAnimating } virtual void SetItemInfo(ItemInfo *pInfo) = 0; + virtual int GetItemInfo(ItemInfo *pInfo) = 0; CBasePlayerItem *BasePlayerItem() const; diff --git a/reapi/include/cssdk/dlls/API/CSPlayerWeapon.h b/reapi/include/cssdk/dlls/API/CSPlayerWeapon.h index 70317c93..837347c4 100644 --- a/reapi/include/cssdk/dlls/API/CSPlayerWeapon.h +++ b/reapi/include/cssdk/dlls/API/CSPlayerWeapon.h @@ -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; }; diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index d3531fec..5d5d4861 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -614,6 +614,14 @@ typedef IHookChainRegistryClass IReGameHook_CBasePlayerWeapon_SendWeaponAnim; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_SendWeaponAnim; +// CHalfLifeMultiplay::SendDeathMessage hook +typedef IHookChain IReGameHook_CSGameRules_SendDeathMessage; +typedef IHookChainRegistry IReGameHookRegistry_CSGameRules_SendDeathMessage; + +// CBasePlayer::PlayerDeathThink hook +typedef IHookChainClass IReGameHook_CBasePlayer_PlayerDeathThink; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PlayerDeathThink; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -771,6 +779,9 @@ class IReGameHookchains { 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 { diff --git a/reapi/include/cssdk/public/utlarray.h b/reapi/include/cssdk/public/utlarray.h new file mode 100644 index 00000000..6bdb4136 --- /dev/null +++ b/reapi/include/cssdk/public/utlarray.h @@ -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 CUtlArray +{ +public: + typedef T ElemType_t; + enum { IsUtlArray = true }; // Used to match this at compiletime + + CUtlArray(); + CUtlArray(T *pMemory, size_t count); + ~CUtlArray(); + + CUtlArray &operator=(const CUtlArray &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 +inline CUtlArray::CUtlArray() +{ +} + +template +inline CUtlArray::CUtlArray(T *pMemory, size_t count) +{ + CopyArray(pMemory, count); +} + +// Destructor +template +inline CUtlArray::~CUtlArray() +{ +} + +template +inline CUtlArray &CUtlArray::operator=(const CUtlArray &other) +{ + if (this != &other) + { + for (size_t n = 0; n < MAX_SIZE; n++) + m_Memory[n] = other.m_Memory[n]; + } + + return *this; +} + +template +inline CUtlArray::CUtlArray(CUtlArray const &vec) +{ + for (size_t n = 0; n < MAX_SIZE; n++) + m_Memory[n] = vec.m_Memory[n]; +} + +template +inline T *CUtlArray::Base() +{ + return &m_Memory[0]; +} + +template +inline const T *CUtlArray::Base() const +{ + return &m_Memory[0]; +} + +// Element access +template +inline T &CUtlArray::operator[](int i) +{ + Assert(IsValidIndex(i)); + return m_Memory[i]; +} + +template +inline const T &CUtlArray::operator[](int i) const +{ + Assert(IsValidIndex(i)); + return m_Memory[i]; +} + +template +inline T &CUtlArray::Element(int i) +{ + Assert(IsValidIndex(i)); + return m_Memory[i]; +} + +template +inline const T &CUtlArray::Element(int i) const +{ + Assert(IsValidIndex(i)); + return m_Memory[i]; +} + +// Count +template +inline int CUtlArray::Count() const +{ + return (int)MAX_SIZE; +} + +template +inline int CUtlArray::NumAllocated() const +{ + return (int)MAX_SIZE; +} + +// Is element index valid? +template +inline bool CUtlArray::IsValidIndex(int i) const +{ + return (i >= 0) && (i < MAX_SIZE); +} + +// Returns in invalid index +template +inline int CUtlArray::InvalidIndex() +{ + return -1; +} + +template +void CUtlArray::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 +void CUtlArray::Clear() +{ + Q_memset(m_Memory, 0, MAX_SIZE * sizeof(T)); +} + +template +void CUtlArray::RemoveAll() +{ + Clear(); +} + +template +void CUtlArray::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 +int CUtlArray::Find(const T &src) const +{ + for (int i = 0; i < Count(); i++) + { + if (Element(i) == src) + return i; + } + + return -1; +} + +template +void CUtlArray::FillWithValue(const T &src) +{ + for (int i = 0; i < Count(); i++) + Element(i) = src; +} + +template +bool CUtlArray::HasElement(const T &src) const +{ + return (Find(src) >= 0); +} diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 4573b111..41b87982 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -190,6 +190,7 @@ + diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index 41448a5c..501a60fc 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -582,6 +582,9 @@ include\cssdk\public + + include\cssdk\public + include\cssdk\public diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index b7777ad6..fb6ea887 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -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), }; diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h index d54c6aad..017dadc0 100644 --- a/reapi/src/member_list.h +++ b/reapi/src/member_list.h @@ -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, };