#define DEFAULT_DURATION_SMOK 18.0 // Стандартная продолжительность смока !не менять! (Возможно стоит сменить т.к. я не помню какая продолжительность стандартного смока)
#define DURATION_SMOK 10.0
public void OnEntityCreated(int entity, const char[] classname){
if(StrEqual(classname, "env_particlesmokegrenade", false))
SDKHook(entity, SDKHook_SpawnPost, OnSpawnPostProjectile);
}
public void OnSpawnPostProjectile(int smoke){
float pos_smoke[3];
GetEntPropVector(smoke, Prop_Send, "m_vecOrigin", pos_smoke);
int grenade;
while((grenade = FindEntityByClassname(grenade, "smokegrenade_projectile")) > 0){
float pos_nade[3];
GetEntPropVector(grenade, Prop_Send, "m_vecOrigin", pos_nade);
if(pos_smoke[0] == pos_nade[0] && pos_smoke[1] == pos_nade[1] && pos_smoke[2] == pos_nade[2]){
int owner = GetEntPropEnt(grenade, Prop_Data, "m_hOwnerEntity");
if(owner > 0){
if(DURATION_SMOK > DEFAULT_DURATION_SMOK){
float fade_start = GetEntPropFloat(smoke, Prop_Send, "m_FadeStartTime");
float fade_end = GetEntPropFloat(smoke, Prop_Send, "m_FadeEndTime");
int stage = GetEntProp(smoke, Prop_Send, "m_CurrentStage");
AcceptEntityInput(smoke, "kill");
int new_smoke = CreateEntityByName("env_particlesmokegrenade");
if(new_smoke > 0){
TeleportEntity(new_smoke, pos_smoke, NULL_VECTOR, NULL_VECTOR);
SetEntProp(new_smoke, Prop_Send, "m_CurrentStage", stage);
SetEntPropFloat(new_smoke, Prop_Send, "m_FadeStartTime", fade_start);
SetEntPropFloat(new_smoke, Prop_Send, "m_FadeEndTime", fade_end);
DispatchSpawn(new_smoke);
ActivateEntity(new_smoke);
SetEntPropEnt(new_smoke, Prop_Data, "m_hOwnerEntity", owner);
RemoveEnt(new_smoke);
}
}
else{
RemoveEnt(smoke);
}
}
break;
}
}
}
void RemoveEnt(int ent){
static char buffer[256];
FormatEx(buffer, sizeof(buffer), "OnUser1 !self:Kill::%f:1", DURATION_SMOK);
SetVariantString(buffer);
AcceptEntityInput(ent, "AddOutput");
AcceptEntityInput(ent, "FireUser1");
}