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

Implement CGib (#164)

* Implement CGib
* back compatibility + new line fix
This commit is contained in:
fl0werD 2020-05-27 05:54:09 +04:00 committed by GitHub
parent 46e1f0b5c6
commit 2e200bbd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 257 additions and 8 deletions

View File

@ -1,3 +1,3 @@
majorVersion=5
minorVersion=13
minorVersion=14
maintenanceVersion=0

View File

@ -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.

View File

@ -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,
};

View File

@ -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;
};

View File

@ -35,10 +35,11 @@
#include <cbase.h>
#include <gamerules.h>
#include <client.h>
#include <gib.h>
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 16
#define REGAMEDLL_API_VERSION_MINOR 17
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -461,13 +462,33 @@ typedef IHookChainClass<bool, class CBasePlayerWeapon, int, int, float, float, c
typedef IHookChainRegistryClass<bool, class CBasePlayerWeapon, int, int, float, float, const char *, const char *> IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload;
// CBasePlayer::DropIdlePlayer hook
typedef IHookChainClass<void, class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropIdlePlayer;
typedef IHookChainRegistryClass<void, class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer;
typedef IHookChainClass<void, CBasePlayer, const char *> IReGameHook_CBasePlayer_DropIdlePlayer;
typedef IHookChainRegistryClass<void, CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer;
// CreateWeaponBox hook
typedef IHookChain<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> IReGameHook_CreateWeaponBox;
typedef IHookChainRegistry<class CWeaponBox *, class CBasePlayerItem *, class CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> IReGameHookRegistry_CreateWeaponBox;
// SpawnHeadGib hook
typedef IHookChain<class CGib *, entvars_t *> IReGameHook_SpawnHeadGib;
typedef IHookChainRegistry<class CGib *, entvars_t *> IReGameHookRegistry_SpawnHeadGib;
// SpawnRandomGibs hook
typedef IHookChain<void, entvars_t *, int, int> IReGameHook_SpawnRandomGibs;
typedef IHookChainRegistry<void, entvars_t *, int, int> IReGameHookRegistry_SpawnRandomGibs;
// CGib::Spawn hook
typedef IHookChainClass<void, class CGib, const char *> IReGameHook_CGib_Spawn;
typedef IHookChainRegistryClass<void, class CGib, const char *> IReGameHookRegistry_CGib_Spawn;
// CGib::BounceGibTouch hook
typedef IHookChainClass<void, class CGib, CBaseEntity *> IReGameHook_CGib_BounceGibTouch;
typedef IHookChainRegistryClass<void, class CGib, CBaseEntity *> IReGameHookRegistry_CGib_BounceGibTouch;
// CGib::WaitTillLand hook
typedef IHookChainClass<void, class CGib> IReGameHook_CGib_WaitTillLand;
typedef IHookChainRegistryClass<void, class CGib> IReGameHookRegistry_CGib_WaitTillLand;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -584,6 +605,12 @@ public:
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 {

View File

@ -92,6 +92,7 @@
<ClInclude Include="..\include\cssdk\dlls\func_break.h" />
<ClInclude Include="..\include\cssdk\dlls\func_tank.h" />
<ClInclude Include="..\include\cssdk\dlls\gamerules.h" />
<ClInclude Include="..\include\cssdk\dlls\gib.h" />
<ClInclude Include="..\include\cssdk\dlls\healthkit.h" />
<ClInclude Include="..\include\cssdk\dlls\hintmessage.h" />
<ClInclude Include="..\include\cssdk\dlls\hookchains.h" />

View File

@ -720,6 +720,9 @@
<ClInclude Include="..\include\cssdk\dlls\API\CSPlayerWeapon.h">
<Filter>include\cssdk\dlls\API</Filter>
</ClInclude>
<ClInclude Include="..\include\cssdk\dlls\gib.h">
<Filter>include\cssdk\dlls</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">

View File

@ -1115,6 +1115,56 @@ bool IsPenetrableEntity(IReGameHook_IsPenetrableEntity *chain, Vector &vecSrc, V
return callForward<bool>(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<CGib>(callForward<size_t>(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<CGib>(_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<CGib>(_pthis), getPrivate<CBaseEntity>(_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<CGib>(_pthis));
};
callVoidForward(RG_CGib_WaitTillLand, original, indexOfEdict(pthis->pev));
}
int g_iClientStartSpeak, g_iClientStopSpeak;
void OnClientStartSpeak(size_t clientIndex)

View File

@ -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;

View File

@ -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()

View File

@ -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),

View File

@ -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

View File

@ -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,
};