diff --git a/gradle.properties b/gradle.properties index b08fc23c..e6c302fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=13 +minorVersion=14 maintenanceVersion=0 diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index 7fdcdfbe..8a48a916 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -23,7 +23,8 @@ enum hooks_tables_e ht_rechecker, ht_grenade, ht_weaponbox, - ht_weapon + ht_weapon, + ht_gib }; enum members_tables_e @@ -75,7 +76,8 @@ enum members_tables_e mt_shield, mt_rebuystruct, mt_mapinfo, - mt_csplayerweapon + mt_csplayerweapon, + mt_gib }; // Is like FNullEnt @@ -137,7 +139,7 @@ enum HookChain * * @return Returns a hook handle. Use EnableHookChain/DisableHookChain to toggle the forward on or off */ -native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon}:function_id, const callback[], post = 0); +native HookChain:RegisterHookChain({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib}:function_id, const callback[], post = 0); /* * Stops a hook from triggering. diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 9c596f09..8c590699 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -382,6 +382,19 @@ enum GamedllFunc * Params: (Float:vecSrc[3], Float:vecEnd[3], index, entity) */ RG_IsPenetrableEntity, + + /* + * Description: - + * Return type: CGib * (Entity index of gib) + * Params: (pevVictim) + */ + RG_SpawnHeadGib, + + /* + * Description: - + * Params: (int cGibs, int human) + */ + RG_SpawnRandomGibs, }; /** @@ -804,6 +817,30 @@ enum GamedllFunc_CBasePlayerWeapon RG_CBasePlayerWeapon_DefaultShotgunReload, }; +/** +* GamedllFunc CGib +*/ +enum GamedllFunc_CGib +{ + /* + * Description: - + * Params: (const this, const szGibModel[]) + */ + RG_CGib_Spawn = BEGIN_FUNC_REGION(gib), + + /* + * Description: - + * Params: (const this, pOther) + */ + RG_CGib_BounceGibTouch, + + /* + * Description: - + * Params: (const this) + */ + RG_CGib_WaitTillLand, +}; + /** * GamedllFunc CSGameRules */ @@ -5903,3 +5940,41 @@ enum CCSPlayerWeapon_Members */ m_Weapon_flBaseDamage, }; + +/** +* CGib Members +*/ +enum CGib_Members +{ + /* + * Description: - + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_Gib_bloodColor = BEGIN_MEMBER_REGION(gib), + + /* + * Description: - + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_Gib_cBloodDecals, + + /* + * Description: - + * Member type: int + * Get params: get_member(index, member); + * Set params: set_member(index, member, value); + */ + m_Gib_material, + + /* + * Description: - + * Member type: float + * Get params: Float:get_member(index, member); + * Set params: set_member(index, member, Float:value); + */ + m_Gib_lifeTime, +}; diff --git a/reapi/include/cssdk/dlls/gib.h b/reapi/include/cssdk/dlls/gib.h new file mode 100644 index 00000000..34557032 --- /dev/null +++ b/reapi/include/cssdk/dlls/gib.h @@ -0,0 +1,41 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +class CGib : public CBaseEntity +{ +public: + virtual int ObjectCaps() = 0; + +public: + int m_bloodColor; + int m_cBloodDecals; + int m_material; + float m_lifeTime; +}; diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index b20ddd99..59b86472 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -35,10 +35,11 @@ #include #include #include +#include #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 16 +#define REGAMEDLL_API_VERSION_MINOR 17 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -461,13 +462,33 @@ typedef IHookChainClass IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload; // CBasePlayer::DropIdlePlayer hook -typedef IHookChainClass IReGameHook_CBasePlayer_DropIdlePlayer; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropIdlePlayer; +typedef IHookChainClass IReGameHook_CBasePlayer_DropIdlePlayer; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropIdlePlayer; // CreateWeaponBox hook typedef IHookChain IReGameHook_CreateWeaponBox; typedef IHookChainRegistry IReGameHookRegistry_CreateWeaponBox; +// SpawnHeadGib hook +typedef IHookChain IReGameHook_SpawnHeadGib; +typedef IHookChainRegistry IReGameHookRegistry_SpawnHeadGib; + +// SpawnRandomGibs hook +typedef IHookChain IReGameHook_SpawnRandomGibs; +typedef IHookChainRegistry IReGameHookRegistry_SpawnRandomGibs; + +// CGib::Spawn hook +typedef IHookChainClass IReGameHook_CGib_Spawn; +typedef IHookChainRegistryClass IReGameHookRegistry_CGib_Spawn; + +// CGib::BounceGibTouch hook +typedef IHookChainClass IReGameHook_CGib_BounceGibTouch; +typedef IHookChainRegistryClass IReGameHookRegistry_CGib_BounceGibTouch; + +// CGib::WaitTillLand hook +typedef IHookChainClass IReGameHook_CGib_WaitTillLand; +typedef IHookChainRegistryClass IReGameHookRegistry_CGib_WaitTillLand; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -584,6 +605,12 @@ class IReGameHookchains { virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload() = 0; virtual IReGameHookRegistry_CBasePlayer_DropIdlePlayer *CBasePlayer_DropIdlePlayer() = 0; virtual IReGameHookRegistry_CreateWeaponBox *CreateWeaponBox() = 0; + + virtual IReGameHookRegistry_SpawnHeadGib *SpawnHeadGib() = 0; + virtual IReGameHookRegistry_SpawnRandomGibs *SpawnRandomGibs() = 0; + virtual IReGameHookRegistry_CGib_Spawn *CGib_Spawn() = 0; + virtual IReGameHookRegistry_CGib_BounceGibTouch *CGib_BounceGibTouch() = 0; + virtual IReGameHookRegistry_CGib_WaitTillLand *CGib_WaitTillLand() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 5cc0a5a9..7a945355 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -92,6 +92,7 @@ + diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index cc963463..62fb42f7 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -720,6 +720,9 @@ include\cssdk\dlls\API + + include\cssdk\dlls + diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 23b15d3e..bd0d1196 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1115,6 +1115,56 @@ bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, V return callForward(RG_IsPenetrableEntity, original, getAmxVector(vecSrcCopy), getAmxVector(vecEndCopy), indexOfEdict(pevAttacker), indexOfEdict(pHit)); } +CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim) +{ + auto original = [chain](int _pevVictim) + { + return indexOfPDataAmx(chain->callNext(PEV(_pevVictim))); + }; + + return getPrivate(callForward(RG_SpawnHeadGib, original, indexOfEdict(pevVictim))); +} + +void SpawnRandomGibs(IReGameHook_SpawnRandomGibs *chain, entvars_t *pevVictim, int cGibs, int human) +{ + auto original = [chain](int _pevVictim, int _cGibs, int _human) + { + chain->callNext(PEV(_pevVictim), _cGibs, _human); + }; + + callVoidForward(RG_SpawnRandomGibs, original, indexOfEdict(pevVictim), cGibs, human); +} + +void CGib_Spawn(IReGameHook_CGib_Spawn *chain, CGib *pthis, const char *szGibModel) +{ + auto original = [chain](int _pthis, const char *_szGibModel) + { + chain->callNext(getPrivate(_pthis), _szGibModel); + }; + + callVoidForward(RG_CGib_Spawn, original, indexOfEdict(pthis->pev), szGibModel); +} + +void CGib_BounceGibTouch(IReGameHook_CGib_BounceGibTouch *chain, CGib *pthis, CBaseEntity *pOther) +{ + auto original = [chain](int _pthis, int _pOther) + { + chain->callNext(getPrivate(_pthis), getPrivate(_pOther)); + }; + + callVoidForward(RG_CGib_BounceGibTouch, original, indexOfEdict(pthis->pev), indexOfEdict(pOther->pev)); +} + +void CGib_WaitTillLand(IReGameHook_CGib_WaitTillLand *chain, CGib *pthis) +{ + auto original = [chain](int _pthis) + { + chain->callNext(getPrivate(_pthis)); + }; + + callVoidForward(RG_CGib_WaitTillLand, original, indexOfEdict(pthis->pev)); +} + int g_iClientStartSpeak, g_iClientStopSpeak; void OnClientStartSpeak(size_t clientIndex) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 5b26575d..bb0274d5 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -338,6 +338,8 @@ CGrenade *ThrowFlashbang(IReGameHook_ThrowFlashbang *chain, entvars_t *pevOwner, CGrenade *ThrowSmokeGrenade(IReGameHook_ThrowSmokeGrenade *chain, entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity, float time, unsigned short usEvent); CGrenade *PlantBomb(IReGameHook_PlantBomb *chain, entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity); bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, Vector &vecEnd, entvars_t *pevAttacker, edict_t *pHit); +CGib *SpawnHeadGib(IReGameHook_SpawnHeadGib *chain, entvars_t *pevVictim); +void SpawnRandomGibs(IReGameHook_SpawnRandomGibs *chain, entvars_t *pevVictim, int cGibs, int human); // regamedll functions - player void CBasePlayer_Spawn(IReGameHook_CBasePlayer_Spawn *chain, CBasePlayer *pthis); @@ -432,6 +434,11 @@ void CGrenade_ExplodeFlashbang(IReGameHook_CGrenade_ExplodeFlashbang *chain, CGr void CGrenade_ExplodeSmokeGrenade(IReGameHook_CGrenade_ExplodeSmokeGrenade *chain, CGrenade *pthis); void CGrenade_ExplodeBomb(IReGameHook_CGrenade_ExplodeBomb *chain, CGrenade *pthis, TraceResult *ptr, int bitsDamageType); +// regamedll functions - gib +void CGib_Spawn(IReGameHook_CGib_Spawn *chain, CGib *pthis, const char *szGibModel); +void CGib_BounceGibTouch(IReGameHook_CGib_BounceGibTouch *chain, CGib *pthis, CBaseEntity *pOther); +void CGib_WaitTillLand(IReGameHook_CGib_WaitTillLand *chain, CGib *pthis); + extern int g_iClientStartSpeak; extern int g_iClientStopSpeak; diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 354e9a16..040f2f4e 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -99,6 +99,8 @@ hook_t hooklist_gamedll[] = { DLL(ThrowSmokeGrenade), DLL(PlantBomb), DLL(IsPenetrableEntity), + DLL(SpawnHeadGib), + DLL(SpawnRandomGibs), }; hook_t hooklist_animating[] = { @@ -205,6 +207,12 @@ hook_t hooklist_weapon[] = { DLL(CBasePlayerWeapon_DefaultShotgunReload), }; +hook_t hooklist_gib[] = { + DLL(CGib_Spawn), + DLL(CGib_BounceGibTouch), + DLL(CGib_WaitTillLand), +}; + #define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }} hook_t hooklist_rechecker[] = { RCHECK(FileConsistencyProcess, _AMXX), @@ -229,6 +237,7 @@ hook_t* hooklist_t::getHookSafe(size_t hook) CASE(grenade) CASE(weaponbox) CASE(weapon) + CASE(gib) } return nullptr; @@ -247,6 +256,7 @@ void hooklist_t::clear() FOREACH_CLEAR(grenade); FOREACH_CLEAR(weaponbox); FOREACH_CLEAR(weapon); + FOREACH_CLEAR(gib); } void hook_t::clear() diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index a3849fec..9997ad63 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -34,6 +34,7 @@ extern hook_t hooklist_rechecker[]; extern hook_t hooklist_grenade[]; extern hook_t hooklist_weaponbox[]; extern hook_t hooklist_weapon[]; +extern hook_t hooklist_gib[]; enum { @@ -59,6 +60,7 @@ struct hooklist_t CASE(grenade) CASE(weaponbox) CASE(weapon) + CASE(gib) } #undef CASE @@ -79,7 +81,8 @@ struct hooklist_t ht_rechecker, ht_grenade, ht_weaponbox, - ht_weapon + ht_weapon, + ht_gib, }; }; @@ -117,6 +120,9 @@ enum GamedllFunc RG_PlantBomb, RG_IsPenetrableEntity, + RG_SpawnHeadGib, + RG_SpawnRandomGibs, + // [...] }; @@ -245,6 +251,15 @@ enum GamedllFunc_CSGameRules // [...] }; +enum GamedllFunc_CGib +{ + RG_CGib_Spawn = BEGIN_FUNC_REGION(gib), + RG_CGib_BounceGibTouch, + RG_CGib_WaitTillLand, + + // [...] +}; + enum ReCheckerFunc { RC_FileConsistencyProcess = BEGIN_FUNC_REGION(rechecker), diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index e9c008ea..bc0e2654 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -67,6 +67,7 @@ #define REBUYSTRUCT_MEMBERS(mx) CLASS_MEMBERS(RebuyStruct, mx, mx) #define MAPINFO_MEMBERS(mx) CLASS_MEMBERS_PREF(CMapInfo, mx, m_MapInfo_##mx, m_) #define CSPLWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CCSPlayerWeapon, mx, m_Weapon_##mx, m_) +#define GIB_MEMBERS(mx) CLASS_MEMBERS_PREF(CGib, mx, m_Gib_##mx, m_) inline MType getMemberType(float*) { return MEMBER_FLOAT; } inline MType getMemberType(float) { return MEMBER_FLOAT; } @@ -1019,6 +1020,13 @@ member_t memberlist_csplayerweapon[] = { CSPLWPN_MEMBERS(flBaseDamage), }; +member_t memberlist_gib[] = { + GIB_MEMBERS(bloodColor), + GIB_MEMBERS(cBloodDecals), + GIB_MEMBERS(material), + GIB_MEMBERS(lifeTime), +}; + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // #ifdef __GNUC__ @@ -1081,6 +1089,7 @@ member_t *memberlist_t::operator[](size_t members) const CASE(rebuystruct) CASE(mapinfo) CASE(csplayerweapon) + CASE(gib) } #undef CASE diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h index 3ef4e59b..caf8a865 100644 --- a/reapi/src/member_list.h +++ b/reapi/src/member_list.h @@ -82,6 +82,7 @@ struct memberlist_t mt_rebuystruct, mt_mapinfo, mt_csplayerweapon, + mt_gib, }; }; @@ -1053,3 +1054,11 @@ enum CSPlayerWeapon_Members m_Weapon_bHasSecondaryAttack = BEGIN_MEMBER_REGION(csplayerweapon), m_Weapon_flBaseDamage, }; + +enum CGib_Members +{ + m_Gib_bloodColor = BEGIN_MEMBER_REGION(gib), + m_Gib_cBloodDecals, + m_Gib_material, + m_Gib_lifeTime, +};