From 15328fd76421caae2f133a25465dc90da590a6c6 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 4 Jan 2021 22:22:45 +0700 Subject: [PATCH] API: Implemented PlantBomb Closes #589 API: Bump minor version --- gradle.properties | 2 +- regamedll/dlls/API/CAPI_Impl.cpp | 8 +++++++- regamedll/dlls/ggrenade.cpp | 22 +++++++++++++--------- regamedll/public/regamedll/regamedll_api.h | 3 ++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 066e86c1..b58725dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=5 -minorVersion=19 +minorVersion=20 maintenanceVersion=0 diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index e45e1cc8..e6dbeaed 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -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); diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 9a33234c..7b8e9684 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -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; - pGrenade->pev->owner = ENT(pevOwner); + + 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; - CBasePlayer *pOwner = CBasePlayer::Instance(pevOwner); - if (pOwner && pOwner->IsPlayer()) + edict_t *pEntCurBombTarget = nullptr; + if (pevOwner) { - pGrenade->m_pentCurBombTarget = pOwner->m_pentCurBombTarget; - } - else - { - pGrenade->m_pentCurBombTarget = nullptr; + CBasePlayer *pOwner = CBasePlayer::Instance(pevOwner); + if (pOwner && pOwner->IsPlayer()) + pEntCurBombTarget = pOwner->m_pentCurBombTarget; } + pGrenade->m_pentCurBombTarget = pEntCurBombTarget; + return pGrenade; } diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 1bb86793..3e496117 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 19 +#define REGAMEDLL_API_VERSION_MINOR 20 // CBasePlayer::Spawn hook typedef IHookChainClass 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 {