Skip to content

Commit 552e198

Browse files
Add a new native "rg_plant_bomb" (#178)
Add a new native called "rg_plant_bomb", when called it will spawn a C4 with defined parameters and also we will be able to pass a player index or not.
1 parent 7b4d68a commit 552e198

3 files changed

Lines changed: 51 additions & 2 deletions

File tree

reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,17 @@ native rg_transfer_c4(const index, const receiver = 0);
679679
*/
680680
native rg_instant_reload_weapons(const index, const weapon = 0);
681681

682+
/*
683+
* Plant a bomb.
684+
*
685+
* @param index Owner index or 0 for worldspawn.
686+
* @param origin The origin of the bomb where it will be planted.
687+
* @param angles The angles of the planted bomb.
688+
*
689+
* @return Index of bomb entity or AMX_NULLENT (-1) otherwise
690+
*/
691+
native rg_plant_bomb(const index, Float:vecOrigin[3], Float:vecAngles[3] = {0.0,0.0,0.0});
692+
682693
/*
683694
* Sets the amount of reward in the game account for all players.
684695
*

reapi/include/cssdk/dlls/regamedll_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <API/CSInterfaces.h>
4040

4141
#define REGAMEDLL_API_VERSION_MAJOR 5
42-
#define REGAMEDLL_API_VERSION_MINOR 18
42+
#define REGAMEDLL_API_VERSION_MINOR 20
4343

4444
// CBasePlayer::Spawn hook
4545
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@@ -625,6 +625,7 @@ struct ReGameFuncs_t {
625625
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
626626
int (*Cmd_Argc)();
627627
const char *(*Cmd_Argv)(int i);
628+
class CGrenade *(*PlantBomb)(entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity);
628629
};
629630

630631
class IReGameApi {

reapi/src/natives/natives_misc.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,42 @@ cell AMX_NATIVE_CALL rg_instant_reload_weapons(AMX *amx, cell *params)
16001600
return TRUE;
16011601
}
16021602

1603+
/*
1604+
* Plant a bomb.
1605+
*
1606+
* @param index Owner index or 0 for worldspawn.
1607+
* @param origin The origin of the bomb where it will be planted.
1608+
* @param angles The angles of the planted bomb.
1609+
*
1610+
* @return Index of bomb entity or AMX_NULLENT (-1) otherwise
1611+
*
1612+
* native rg_plant_bomb(const index, Float:vecOrigin[3], Float:vecAngles[3] = {0.0,0.0,0.0});
1613+
*/
1614+
cell AMX_NATIVE_CALL rg_plant_bomb(AMX *amx, cell *params)
1615+
{
1616+
enum args_e { arg_count, arg_index, arg_origin, arg_angles };
1617+
CAmxArgs args(amx, params);
1618+
1619+
entvars_t *pevOwner = nullptr;
1620+
1621+
if (params[arg_index] != 0)
1622+
{
1623+
CHECK_ISPLAYER(arg_index);
1624+
1625+
CBasePlayer *pPlayer = UTIL_PlayerByIndex(params[arg_index]);
1626+
CHECK_CONNECTED(pPlayer, arg_index);
1627+
pevOwner = pPlayer->pev;
1628+
}
1629+
1630+
CGrenade *pBomb = g_ReGameFuncs->PlantBomb(pevOwner, args[arg_origin], args[arg_angles]);
1631+
1632+
// Sanity check anyway
1633+
if (pBomb)
1634+
return indexOfPDataAmx(pBomb);
1635+
1636+
return AMX_NULLENT;
1637+
}
1638+
16031639
/*
16041640
* Sets the amount of reward in the game account for all players.
16051641
*
@@ -2231,7 +2267,7 @@ cell AMX_NATIVE_CALL rg_initialize_player_counts(AMX *amx, cell *params)
22312267
cell& numAliveCT = *getAmxAddr(amx, params[arg_num_alive_ct]);
22322268
cell& numDeadTerrorist = *getAmxAddr(amx, params[arg_num_dead_terrorist]);
22332269
cell& numDeadCT = *getAmxAddr(amx, params[arg_num_dead_ct]);
2234-
2270+
22352271
CSGameRules()->InitializePlayerCounts(numAliveTerrorist, numAliveCT, numDeadTerrorist, numDeadCT);
22362272
return TRUE;
22372273
}
@@ -2371,6 +2407,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
23712407

23722408
{ "rg_transfer_c4", rg_transfer_c4 },
23732409
{ "rg_instant_reload_weapons", rg_instant_reload_weapons },
2410+
{ "rg_plant_bomb", rg_plant_bomb },
23742411

23752412
{ "rg_set_account_rules", rg_set_account_rules },
23762413
{ "rg_get_account_rules", rg_get_account_rules },

0 commit comments

Comments
 (0)