#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_engine>
#include <sdktools_trace>
#include <sdktools_tempents>
#include <sdktools_tempents_stocks>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
new Handle:g_hHEGrenades, Handle:mp_restartgame;
public OnPluginStart()
{
mp_restartgame = FindConVar("mp_restartgame");
HookConVarChange(mp_restartgame, ClearAdtArray);
g_hHEGrenades = CreateArray();
HookEvent("hegrenade_detonate", Event_HEGrenadeDetonate);
HookEvent("round_start", Event_RoundStart);
}
public OnMapEnd()
{
ClearArray(g_hHEGrenades);
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
ClearArray(g_hHEGrenades);
}
public ClearAdtArray(Handle:convar, const String:oldValue[], const String:newValue[])
{
ClearArray(g_hHEGrenades);
}
public Event_HEGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new Float:fOrigin[3], Float:fOriginHE[3];
fOrigin[0] = GetEventFloat(event, "x");
fOrigin[1] = GetEventFloat(event, "y");
fOrigin[2] = GetEventFloat(event, "z");
new iSize = GetArraySize(g_hHEGrenades);
if(iSize > 0)
{
new Handle:hGrenade, iGrenade;
for(new i=0; i<iSize; i++)
{
hGrenade = GetArrayCell(g_hHEGrenades, i);
iGrenade = GetArrayCell(hGrenade, 0);
if(IsValidEdict(iGrenade))
{
GetEntPropVector(iGrenade, Prop_Send, "m_vecOrigin", fOriginHE);
if(fOrigin[0] == fOriginHE[0] && fOrigin[1] == fOriginHE[1] && fOrigin[2] == fOriginHE[2] && (GetArraySize(hGrenade) > 1))
{
new particle = GetArrayCell(hGrenade, 1);
if(IsValidEdict(particle))
{
AcceptEntityInput(particle, "TurnOff");
AcceptEntityInput(particle, "Kill");
break;
}
}
}
}
}
}
public OnEntityCreated(entity, const String:classname[])
{
if(StrEqual(classname, "hegrenade_projectile", false))
SDKHook(entity, SDKHook_Spawn, Hook_OnSpawnProjectile);
}
public Hook_OnSpawnProjectile(entity)
{
new particle = CreateEntityByName("env_smokestack");
if(IsValidEdict(particle))
{
decl String:Name[32], Float:fPos[3];
Format(Name, sizeof(Name), "SmokeParticle_%i", entity);
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fPos);
new Float:fAng[3] = {0.0, 0.0, 0.0};
DispatchKeyValueVector(particle, "Origin", fPos);
DispatchKeyValueVector(particle, "Angles", fAng);
DispatchKeyValueFloat(particle, "BaseSpread", 2.0);
DispatchKeyValueFloat(particle, "StartSize", 1.0);
DispatchKeyValueFloat(particle, "EndSize", 2.2);
DispatchKeyValueFloat(particle, "Twist", 0.0);
DispatchKeyValue(particle, "Name", Name);
DispatchKeyValue(particle, "SmokeMaterial", "particle/fire.vmt");
DispatchKeyValue(particle, "RenderColor", "255 0 0");
DispatchKeyValue(particle, "SpreadSpeed", "10");
DispatchKeyValue(particle, "RenderAmt", "300");
DispatchKeyValue(particle, "JetLength", "13");
DispatchKeyValue(particle, "RenderMode", "0");
DispatchKeyValue(particle, "Initial", "0");
DispatchKeyValue(particle, "Speed", "10");
DispatchKeyValue(particle, "Rate", "173");
DispatchSpawn(particle);
SetVariantString("!activator");
AcceptEntityInput(particle, "SetParent", entity, particle, 0);
AcceptEntityInput(particle, "TurnOn");
new Handle:hGrenade = CreateArray();
PushArrayCell(hGrenade, entity);
PushArrayCell(hGrenade, particle);
PushArrayCell(g_hHEGrenades, hGrenade);
}
else
LogError("Failed to create env_smokestack!");
}