Skip to content

Commit

Permalink
Added new native: rg_fire_buckshots (#204)
Browse files Browse the repository at this point in the history
* Added new native: `rg_fire_buckshots`

* Fix typo

* Update CSEntity.h

Co-authored-by: Sergey Shorokhov <[email protected]>
  • Loading branch information
FEDERICOMB96 and wopox1337 authored Sep 2, 2021
1 parent e966296 commit 1aaddea
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
17 changes: 17 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
40 changes: 39 additions & 1 deletion reapi/include/cssdk/dlls/API/CSEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,46 @@ class CCSEntity

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;
};
Expand Down Expand Up @@ -74,4 +112,4 @@ class CCSMonster: public CCSToggle

};

#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION001"
#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION002"
4 changes: 4 additions & 0 deletions reapi/src/natives/natives_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class CAmxArg
{
return m_value;
}
operator ULONG() const
{
return ULONG(m_value);
}
operator size_t() const
{
return size_t(m_value);
Expand Down
43 changes: 43 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 1aaddea

Please sign in to comment.