mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-27 07:05:38 +03:00
implement CGib (#536)
* implement CGib Move code part from basemonster.cpp to gib.cpp 3-rd party: Link entity to class (can hookable by HamSandwich amxx module) Add hooks for ReAPI
This commit is contained in:
parent
27c15c38f6
commit
bffb373539
@ -1,3 +1,3 @@
|
||||
majorVersion=5
|
||||
minorVersion=16
|
||||
minorVersion=17
|
||||
maintenanceVersion=0
|
||||
|
@ -170,6 +170,12 @@ GAMEHOOK_REGISTRY(CBasePlayer_DropIdlePlayer);
|
||||
|
||||
GAMEHOOK_REGISTRY(CreateWeaponBox);
|
||||
|
||||
GAMEHOOK_REGISTRY(SpawnHeadGib);
|
||||
GAMEHOOK_REGISTRY(SpawnRandomGibs);
|
||||
GAMEHOOK_REGISTRY(CGib_Spawn);
|
||||
GAMEHOOK_REGISTRY(CGib_BounceGibTouch);
|
||||
GAMEHOOK_REGISTRY(CGib_WaitTillLand);
|
||||
|
||||
int CReGameApi::GetMajorVersion() {
|
||||
return REGAMEDLL_API_VERSION_MAJOR;
|
||||
}
|
||||
|
@ -105,6 +105,16 @@
|
||||
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
|
||||
}
|
||||
|
||||
#define LINK_HOOK_GLOB_CLASS_VOID_CHAIN(className, functionName, args, ...)\
|
||||
void className::functionName args {\
|
||||
g_ReGameHookchains.m_##functionName.callChain(className::functionName##_OrigFunc, __VA_ARGS__);\
|
||||
}
|
||||
|
||||
#define LINK_HOOK_GLOB_CLASS_CHAIN(ret, className, functionName, args, ...)\
|
||||
ret className::functionName args {\
|
||||
return g_ReGameHookchains.m_##functionName.callChain(className::functionName##_OrigFunc, __VA_ARGS__);\
|
||||
}
|
||||
|
||||
#define LINK_HOOK_CUSTOM2_CHAIN(ret, customFuncName, functionName, args, ...)\
|
||||
ret functionName args {\
|
||||
return g_ReGameHookchains.m_##customFuncName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
|
||||
@ -137,6 +147,8 @@
|
||||
#define LINK_HOOK_VOID_CHAIN2(...)
|
||||
#define LINK_HOOK_CHAIN(...)
|
||||
#define LINK_HOOK_CHAIN2(...)
|
||||
#define LINK_HOOK_GLOB_CLASS_VOID_CHAIN(...)
|
||||
#define LINK_HOOK_GLOB_CLASS_CHAIN(...)
|
||||
|
||||
#endif // REGAMEDLL_API
|
||||
|
||||
@ -564,13 +576,33 @@ typedef IHookChainClassImpl<bool, CBasePlayerWeapon, int, int, float, float, con
|
||||
typedef IHookChainRegistryClassImpl<bool, CBasePlayerWeapon, int, int, float, float, const char *, const char *> CReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload;
|
||||
|
||||
// CBasePlayer::DropIdlePlayer hook
|
||||
typedef IHookChainClassImpl<void, CBasePlayer, const char *> CReGameHook_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainRegistryClassImpl<void, CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainClassImpl<void, class CBasePlayer, const char *> CReGameHook_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainRegistryClassImpl<void, class CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_DropIdlePlayer;
|
||||
|
||||
// CreateWeaponBox hook
|
||||
typedef IHookChainImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHook_CreateWeaponBox;
|
||||
typedef IHookChainRegistryImpl<CWeaponBox *, CBasePlayerItem *, CBasePlayer *, const char *, Vector &, Vector &, Vector &, float, bool> CReGameHookRegistry_CreateWeaponBox;
|
||||
|
||||
// SpawnHeadGib hook
|
||||
typedef IHookChainImpl<class CGib *, entvars_t *> CReGameHook_SpawnHeadGib;
|
||||
typedef IHookChainRegistryImpl<class CGib *, entvars_t *> CReGameHookRegistry_SpawnHeadGib;
|
||||
|
||||
// SpawnRandomGibs hook
|
||||
typedef IHookChainImpl<void, entvars_t *, int, int> CReGameHook_SpawnRandomGibs;
|
||||
typedef IHookChainRegistryImpl<void, entvars_t *, int, int> CReGameHookRegistry_SpawnRandomGibs;
|
||||
|
||||
// CGib::Spawn hook
|
||||
typedef IHookChainClassImpl<void, class CGib, const char *> CReGameHook_CGib_Spawn;
|
||||
typedef IHookChainRegistryClassImpl<void, class CGib, const char *> CReGameHookRegistry_CGib_Spawn;
|
||||
|
||||
// CGib::BounceGibTouch hook
|
||||
typedef IHookChainClassImpl<void, class CGib, CBaseEntity *> CReGameHook_CGib_BounceGibTouch;
|
||||
typedef IHookChainRegistryClassImpl<void, class CGib, CBaseEntity *> CReGameHookRegistry_CGib_BounceGibTouch;
|
||||
|
||||
// CGib::WaitTillLand hook
|
||||
typedef IHookChainClassImpl<void, class CGib> CReGameHook_CGib_WaitTillLand;
|
||||
typedef IHookChainRegistryClassImpl<void, class CGib> CReGameHookRegistry_CGib_WaitTillLand;
|
||||
|
||||
class CReGameHookchains: public IReGameHookchains {
|
||||
public:
|
||||
// CBasePlayer virtual
|
||||
@ -687,6 +719,12 @@ public:
|
||||
CReGameHookRegistry_CBasePlayer_DropIdlePlayer m_CBasePlayer_DropIdlePlayer;
|
||||
CReGameHookRegistry_CreateWeaponBox m_CreateWeaponBox;
|
||||
|
||||
CReGameHookRegistry_SpawnHeadGib m_SpawnHeadGib;
|
||||
CReGameHookRegistry_SpawnRandomGibs m_SpawnRandomGibs;
|
||||
CReGameHookRegistry_CGib_Spawn m_CGib_Spawn;
|
||||
CReGameHookRegistry_CGib_BounceGibTouch m_CGib_BounceGibTouch;
|
||||
CReGameHookRegistry_CGib_WaitTillLand m_CGib_WaitTillLand;
|
||||
|
||||
public:
|
||||
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
|
||||
virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache();
|
||||
@ -800,6 +838,12 @@ public:
|
||||
virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload();
|
||||
virtual IReGameHookRegistry_CBasePlayer_DropIdlePlayer *CBasePlayer_DropIdlePlayer();
|
||||
virtual IReGameHookRegistry_CreateWeaponBox *CreateWeaponBox();
|
||||
|
||||
virtual IReGameHookRegistry_SpawnHeadGib *SpawnHeadGib();
|
||||
virtual IReGameHookRegistry_SpawnRandomGibs *SpawnRandomGibs();
|
||||
virtual IReGameHookRegistry_CGib_Spawn *CGib_Spawn();
|
||||
virtual IReGameHookRegistry_CGib_BounceGibTouch *CGib_BounceGibTouch();
|
||||
virtual IReGameHookRegistry_CGib_WaitTillLand *CGib_WaitTillLand();
|
||||
};
|
||||
|
||||
extern CReGameHookchains g_ReGameHookchains;
|
||||
|
@ -368,32 +368,6 @@ void CBaseMonster::Killed(entvars_t *pevAttacker, int iGib)
|
||||
m_IdealMonsterState = MONSTERSTATE_DEAD;
|
||||
}
|
||||
|
||||
void CGib::WaitTillLand()
|
||||
{
|
||||
if (!IsInWorld())
|
||||
{
|
||||
UTIL_Remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pev->velocity == g_vecZero)
|
||||
{
|
||||
SetThink(&CBaseEntity::SUB_StartFadeOut);
|
||||
pev->nextthink = gpGlobals->time + m_lifeTime;
|
||||
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
if (m_bloodColor != DONT_BLEED)
|
||||
{
|
||||
CSoundEnt::InsertSound(bits_SOUND_MEAT, pev->origin, 384, 25);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->nextthink = gpGlobals->time + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CBaseMonster::TakeHealth(float flHealth, int bitsDamageType)
|
||||
{
|
||||
if (pev->takedamage == DAMAGE_NO)
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS(gib, CGib, CCSGib)
|
||||
|
||||
void CGib::LimitVelocity()
|
||||
{
|
||||
float length = pev->velocity.Length();
|
||||
@ -74,7 +76,9 @@ NOXREF void CGib::SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cG
|
||||
}
|
||||
}
|
||||
|
||||
void CGib::SpawnHeadGib(entvars_t *pevVictim)
|
||||
LINK_HOOK_GLOB_CLASS_CHAIN(CGib *, CGib, SpawnHeadGib, (entvars_t *pevVictim), pevVictim)
|
||||
|
||||
CGib *CGib::__API_HOOK(SpawnHeadGib)(entvars_t *pevVictim)
|
||||
{
|
||||
CGib *pGib = GetClassPtr<CCSGib>((CGib *)nullptr);
|
||||
|
||||
@ -132,9 +136,13 @@ void CGib::SpawnHeadGib(entvars_t *pevVictim)
|
||||
}
|
||||
|
||||
pGib->LimitVelocity();
|
||||
|
||||
return pGib;
|
||||
}
|
||||
|
||||
void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human)
|
||||
LINK_HOOK_GLOB_CLASS_VOID_CHAIN(CGib, SpawnRandomGibs, (entvars_t *pevVictim, int cGibs, int human), pevVictim, cGibs, human)
|
||||
|
||||
void CGib::__API_HOOK(SpawnRandomGibs)(entvars_t *pevVictim, int cGibs, int human)
|
||||
{
|
||||
for (int cSplat = 0; cSplat < cGibs; cSplat++)
|
||||
{
|
||||
@ -198,11 +206,14 @@ void CGib::SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human)
|
||||
pGib->pev->solid = SOLID_BBOX;
|
||||
UTIL_SetSize(pGib->pev, Vector(0, 0, 0), Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
pGib->LimitVelocity();
|
||||
}
|
||||
}
|
||||
|
||||
void CGib::BounceGibTouch(CBaseEntity *pOther)
|
||||
LINK_HOOK_CLASS_VOID_CHAIN(CGib, BounceGibTouch, (CBaseEntity *pOther), pOther)
|
||||
|
||||
void CGib::__API_HOOK(BounceGibTouch)(CBaseEntity *pOther)
|
||||
{
|
||||
if (pev->flags & FL_ONGROUND)
|
||||
{
|
||||
@ -260,7 +271,9 @@ void CGib::StickyGibTouch(CBaseEntity *pOther)
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
}
|
||||
|
||||
void CGib::Spawn(const char *szGibModel)
|
||||
LINK_HOOK_CLASS_VOID_CHAIN(CGib, Spawn, (const char *szGibModel), szGibModel)
|
||||
|
||||
void CGib::__API_HOOK(Spawn)(const char *szGibModel)
|
||||
{
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
|
||||
@ -292,3 +305,31 @@ void CGib::Spawn(const char *szGibModel)
|
||||
// how many blood decals this gib can place (1 per bounce until none remain).
|
||||
m_cBloodDecals = 5;
|
||||
}
|
||||
|
||||
LINK_HOOK_CLASS_VOID_CHAIN2(CGib, WaitTillLand)
|
||||
|
||||
void CGib::__API_HOOK(WaitTillLand)()
|
||||
{
|
||||
if (!IsInWorld())
|
||||
{
|
||||
UTIL_Remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pev->velocity == g_vecZero)
|
||||
{
|
||||
SetThink(&CBaseEntity::SUB_StartFadeOut);
|
||||
pev->nextthink = gpGlobals->time + m_lifeTime;
|
||||
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
if (m_bloodColor != DONT_BLEED)
|
||||
{
|
||||
CSoundEnt::InsertSound(bits_SOUND_MEAT, pev->origin, 384, 25);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->nextthink = gpGlobals->time + 0.5f;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public:
|
||||
virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; }
|
||||
|
||||
public:
|
||||
void Spawn_OrigFunc(const char *szGibModel);
|
||||
void BounceGibTouch_OrigFunc(CBaseEntity *pOther);
|
||||
void WaitTillLand_OrigFunc();
|
||||
|
||||
void Spawn(const char *szGibModel);
|
||||
void EXPORT BounceGibTouch(CBaseEntity *pOther);
|
||||
void EXPORT StickyGibTouch(CBaseEntity *pOther);
|
||||
@ -41,7 +45,10 @@ public:
|
||||
void LimitVelocity();
|
||||
|
||||
public:
|
||||
static void SpawnHeadGib(entvars_t *pevVictim);
|
||||
static CGib *SpawnHeadGib_OrigFunc(entvars_t *pevVictim);
|
||||
static void SpawnRandomGibs_OrigFunc(entvars_t *pevVictim, int cGibs, int human);
|
||||
|
||||
static CGib *SpawnHeadGib(entvars_t *pevVictim);
|
||||
static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human);
|
||||
static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs);
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
#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 +461,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, CBasePlayer, const char *> IReGameHook_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainRegistryClass<void, CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainClass<void, class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropIdlePlayer;
|
||||
typedef IHookChainRegistryClass<void, class 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 +604,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user