Quando um HE granada explode, ele também detona granadas que estão nas proximidades. Como no video acima
Cvars:
- hdg_affect_radius - afetam raio. Padrão 350.
- hdg_survival_chance - uma chance (default 3% (+ alguma chance randomizado distância)) para uma granada para sobreviver a uma explosão de uma granada HE nas proximidades. Defina 0 para desabilitado
Sma:
Código:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#define FL_EXPLODED FL_IMMUNE_SLIME
#define m_usEvent 114
#define XO_WEAPON 4
#define HEGRENADE (1<<0)
#define SMOKENADE (1<<1)
new cvar_AffectRadius, cvar_SurvivalChance
public plugin_init()
{
register_plugin("HEs destroy grenades", "1.0", "beast")
register_think("grenade", "ThinkGrenade")
cvar_AffectRadius = register_cvar("hdg_affect_radius", "350")
cvar_SurvivalChance = register_cvar("hdg_survival_chance", "3")
}
public ThinkGrenade(he)
{
// ent not valid or not a HE
if(!pev_valid(he) || ~get_pdata_int(he, m_usEvent, XO_WEAPON) & HEGRENADE)
return PLUGIN_CONTINUE
static flags
flags = pev(he, pev_flags)
// grenade has exploded
if(flags & FL_EXPLODED)
return PLUGIN_CONTINUE
static Float:dmgTime
pev(he, pev_dmgtime, dmgTime)
// not ready to explode yet
if(dmgTime > get_gametime())
return PLUGIN_CONTINUE
// marking the grenade as exploded
set_pev(he, pev_flags, flags | FL_EXPLODED)
static nearbyNades[32], count, nearbyNade, Float:affectRadius, survivalChance,
Float:originHe[3], Float:originNearbyNade[3]
affectRadius = get_pcvar_float(cvar_AffectRadius)
survivalChance = get_pcvar_num(cvar_SurvivalChance)
pev(he, pev_origin, originHe)
// finding nearby grenades
count = find_sphere_class(he, "grenade", affectRadius, nearbyNades, charsmax(nearbyNades))
for(new i = 0; i < count; i++)
{
nearbyNade = nearbyNades[i]
if(nearbyNade == he)
continue
if(survivalChance)
{
pev(nearbyNade, pev_origin, originNearbyNade)
// grenade has a chance to survive
if(random_float(0.0, 100.0) <= survivalChance + // some distance randomness
get_distance_f(originHe, originNearbyNade) * random_float(0.0, 5.0) / affectRadius)
continue
}
// detonating he and flashbang
set_pev(nearbyNade, pev_dmgtime, 0.0)
// detonating smokenade
if(get_pdata_int(nearbyNade, m_usEvent, XO_WEAPON) & SMOKENADE)
{
set_pev(nearbyNade, pev_flags, pev(nearbyNade, pev_flags) | FL_ONGROUND)
dllfunc(DLLFunc_Think, nearbyNade)
}
}
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1063\\ f0\\ fs16 \n\\ par }
*/