From 1aaddea738166cf6336309b397659035f30deda3 Mon Sep 17 00:00:00 2001 From: FEDERICOMB <41979395+FEDERICOMB96@users.noreply.github.com> Date: Thu, 2 Sep 2021 14:57:09 -0300 Subject: [PATCH] Added new native: `rg_fire_buckshots` (#204) * Added new native: `rg_fire_buckshots` * Fix typo * Update CSEntity.h Co-authored-by: Sergey Shorokhov --- .../scripting/include/reapi_gamedll.inc | 17 ++++++++ reapi/include/cssdk/dlls/API/CSEntity.h | 40 ++++++++++++++++- reapi/src/natives/natives_helper.h | 4 ++ reapi/src/natives/natives_misc.cpp | 43 +++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 99d28ca..00b8970 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -342,6 +342,23 @@ native rg_multidmg_add(const inflictor, const victim, const Float:flDamage, cons */ native rg_fire_bullets(const inflictor, const attacker, const shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], const Float:flDistance, const Bullet:iBulletType, const iTracerFreq, const iDamage); +/* +* Fires buckshots from entity. +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that triggered the damage (such as the gun's owner) +* @param shots The number of shots +* @param vecSrc The source position of the barrel +* @param vecDirShooting Shooting direction +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iTracerFreq Tracer frequency +* @param iDamage Damage amount +* +* @noreturn +*/ +native rg_fire_buckshots(const inflictor, const attacker, const shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], const Float:flDistance, const iTracerFreq, const iDamage); + /* * Fires bullets from player's weapon. * diff --git a/reapi/include/cssdk/dlls/API/CSEntity.h b/reapi/include/cssdk/dlls/API/CSEntity.h index a8e5456..1e9ca2b 100644 --- a/reapi/include/cssdk/dlls/API/CSEntity.h +++ b/reapi/include/cssdk/dlls/API/CSEntity.h @@ -40,8 +40,46 @@ public: virtual ~CCSEntity() {} virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) = 0; + virtual void FireBuckshots(ULONG cShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iTracerFreq, int iDamage, entvars_t *pevAttacker) = 0; virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) = 0; +#if defined(_MSC_VER) +#pragma region reserve_vfuncs_Region +#endif + virtual void func_reserve1() {}; + virtual void func_reserve2() {}; + virtual void func_reserve3() {}; + virtual void func_reserve4() {}; + virtual void func_reserve5() {}; + virtual void func_reserve6() {}; + virtual void func_reserve7() {}; + virtual void func_reserve8() {}; + virtual void func_reserve9() {}; + virtual void func_reserve10() {}; + virtual void func_reserve11() {}; + virtual void func_reserve12() {}; + virtual void func_reserve13() {}; + virtual void func_reserve14() {}; + virtual void func_reserve15() {}; + virtual void func_reserve16() {}; + virtual void func_reserve17() {}; + virtual void func_reserve18() {}; + virtual void func_reserve19() {}; + virtual void func_reserve20() {}; + virtual void func_reserve21() {}; + virtual void func_reserve22() {}; + virtual void func_reserve23() {}; + virtual void func_reserve24() {}; + virtual void func_reserve25() {}; + virtual void func_reserve26() {}; + virtual void func_reserve27() {}; + virtual void func_reserve28() {}; + virtual void func_reserve29() {}; + virtual void func_reserve30() {}; +#if defined(_MSC_VER) +#pragma endregion +#endif + public: CBaseEntity *m_pContainingEntity; }; @@ -74,4 +112,4 @@ public: }; -#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION001" +#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION002" diff --git a/reapi/src/natives/natives_helper.h b/reapi/src/natives/natives_helper.h index bde9a09..f1cb162 100644 --- a/reapi/src/natives/natives_helper.h +++ b/reapi/src/natives/natives_helper.h @@ -28,6 +28,10 @@ public: { return m_value; } + operator ULONG() const + { + return ULONG(m_value); + } operator size_t() const { return size_t(m_value); diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index fda8f81..a52d6af 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -325,6 +325,48 @@ cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params) return TRUE; } +/* +* Fires buckshots from entity. +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that triggered the damage (such as the gun's owner) +* @param shots The number of shots +* @param vecSrc The source position of the barrel +* @param vecDirShooting Shooting direction +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iTracerFreq Tracer frequency +* @param iDamage Damage amount +* +* @noreturn +* +* native rg_fire_buckshots(const inflictor, const attacker, const shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], const Float:flDistance, const iTracerFreq, const iDamage); +*/ +cell AMX_NATIVE_CALL rg_fire_buckshots(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_inflictor, arg_attacker, arg_shots, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_tracefrq, arg_dmg }; + + CHECK_ISENTITY(arg_inflictor); + CHECK_ISENTITY(arg_attacker); + + CAmxArgs args(amx, params); + CBaseEntity *pInflictor = args[arg_inflictor]; + + pInflictor->m_pEntity->FireBuckshots + ( + args[arg_shots], + args[arg_vecSrc], + args[arg_dir], + args[arg_spread], + args[arg_dist], + args[arg_tracefrq], + args[arg_dmg], + args[arg_attacker] + ); + + return TRUE; +} + /* * Fires bullets from player's weapon. * @@ -2441,6 +2483,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] = { "rg_multidmg_add", rg_multidmg_add }, { "rg_fire_bullets", rg_fire_bullets }, + { "rg_fire_buckshots", rg_fire_buckshots }, { "rg_fire_bullets3", rg_fire_bullets3 }, { "rg_round_end", rg_round_end },