API: Implemented PlantBomb Closes #589

API: Bump minor version
This commit is contained in:
s1lentq 2021-01-04 22:22:45 +07:00
parent 6fc1c2ff84
commit 15328fd764
4 changed files with 23 additions and 12 deletions

View File

@ -1,3 +1,3 @@
majorVersion=5
minorVersion=19
minorVersion=20
maintenanceVersion=0

View File

@ -38,6 +38,10 @@ const char *EXT_FUNC Cmd_Argv_api(int i) {
return CMD_ARGV_(i);
}
CGrenade *PlantBomb_api(entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity) {
return CGrenade::ShootSatchelCharge(pevOwner, vecStart, vecVelocity);
}
ReGameFuncs_t g_ReGameApiFuncs = {
&CREATE_NAMED_ENTITY,
@ -54,7 +58,9 @@ ReGameFuncs_t g_ReGameApiFuncs = {
&RemoveEntityHashValue,
Cmd_Argc_api,
Cmd_Argv_api
Cmd_Argv_api,
PlantBomb_api
};
GAMEHOOK_REGISTRY(CBasePlayer_Spawn);

View File

@ -1202,7 +1202,11 @@ CGrenade *CGrenade::__API_HOOK(ShootSatchelCharge)(entvars_t *pevOwner, VectorRe
UTIL_SetOrigin(pGrenade->pev, vecStart);
pGrenade->pev->velocity = g_vecZero;
pGrenade->pev->angles = vecAngles;
if (pevOwner)
pGrenade->pev->owner = ENT(pevOwner);
else
pGrenade->pev->owner = nullptr;
// Detonate in "time" seconds
pGrenade->SetThink(&CGrenade::C4Think);
@ -1211,7 +1215,7 @@ CGrenade *CGrenade::__API_HOOK(ShootSatchelCharge)(entvars_t *pevOwner, VectorRe
#ifdef REGAMEDLL_FIXES
TraceResult tr;
UTIL_TraceLine(vecStart, vecStart + Vector(0, 0, -8192), ignore_monsters, ENT(pevOwner), &tr);
UTIL_TraceLine(vecStart, vecStart + Vector(0, 0, -8192), ignore_monsters, pGrenade->pev->owner, &tr);
pGrenade->pev->oldorigin = (tr.flFraction == 1.0) ? vecStart : tr.vecEndPos;
pGrenade->pev->nextthink = gpGlobals->time + 0.01f;
@ -1235,16 +1239,16 @@ CGrenade *CGrenade::__API_HOOK(ShootSatchelCharge)(entvars_t *pevOwner, VectorRe
pGrenade->pev->friction = 0.9f;
pGrenade->m_bJustBlew = false;
edict_t *pEntCurBombTarget = nullptr;
if (pevOwner)
{
CBasePlayer *pOwner = CBasePlayer::Instance(pevOwner);
if (pOwner && pOwner->IsPlayer())
{
pGrenade->m_pentCurBombTarget = pOwner->m_pentCurBombTarget;
}
else
{
pGrenade->m_pentCurBombTarget = nullptr;
pEntCurBombTarget = pOwner->m_pentCurBombTarget;
}
pGrenade->m_pentCurBombTarget = pEntCurBombTarget;
return pGrenade;
}

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 19
#define REGAMEDLL_API_VERSION_MINOR 20
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -641,6 +641,7 @@ struct ReGameFuncs_t {
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
int (*Cmd_Argc)();
const char *(*Cmd_Argv)(int i);
class CGrenade *(*PlantBomb)(entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity);
};
class IReGameApi {