`/ Plugin Template generated by Pawn Studio /
include <sourcemod>
include <sdktools>
include <sdktools_functions>
define SOUNDGRENADELAUNCHER “weapons/grenade_launcher/grenadefire/grenade_launcher_explode_1.wav”
define SOUNDMISSILELAUNCHER “physics/destruction/ExplosiveGasLeak.wav”
define SOUNDMISSILELAUNCHER2 “physics/destruction/explosivegasleak.wav”
define SOUNDMISSILELOCK “UI/Beep07.wav”
define FilterSelf 0
define FilterSelfAndPlayer 1
define FilterSelfAndSurvivor 2
define FilterSelfAndInfected 3
define FilterSelfAndPlayerAndCI 4
define SurvivorTeam 2
define InfectedTeam 3
define MissileTeam 1
define MissileNormal 0
define MissileLarserGuid 1
define MissileTrace 2
new Handle:l4d_missile_radius ;
new Handle:l4d_missile_damage ;
new Handle:l4d_missile_push ;
new Handle:l4d_missile_limit ;
new Handle:l4d_missile_kills ;
new Handle:l4d_missile_safe;
new Handle:l4d_missile_tracefactor ;
new Handle:l4d_missile_infected_smoker ;
new Handle:l4d_missile_infected_charger ;
new Handle:l4d_missile_infected_spitter ;
new Handle:l4d_missile_infected_witch;
new Handle:l4d_missile_infected_tank_dead ;
new Handle:l4d_missile_infected_tank_throw;
new Handle:l4d_missile_infected_anti ;
new Handle:l4d_missile_weapon_rifle;
new Handle:l4d_missile_weapon_sniper;
new Handle:l4d_missile_weapon_shotgun;
new Handle:l4d_missile_weapon_magnum;
new bool:gamestart=false;
new Float: UseTime[MAXPLAYERS+1];
new Float: HookTime[MAXPLAYERS+1];
new Bullet[MAXPLAYERS+1];
new bool:Hooked[MAXPLAYERS+1];
new MissileEntity[MAXPLAYERS+1];
new MissileTeams[MAXPLAYERS+1];
new MissleModel[MAXPLAYERS+1];
new MissileType[MAXPLAYERS+1];
new Float:MissileAngleMAXPLAYERS+1;
new Float:MissilePlacePosMAXPLAYERS+1;
new Enemy[MAXPLAYERS+1];
new Float:PrintTime[MAXPLAYERS+1];
new ShowMsg[MAXPLAYERS+1];
new g_iVelocity ;
new L4D2Version;
new GameMode;
new g_sprite;
new Float:modeloffset=100.0; //180.0 normal
public Plugin:myinfo =
{
name = “Missile”,
author = “Pan Xiaohai”,
description = “Missile , L4D2 only”,
version = “1.1”,
url = “<- URL ->”
}
public OnPluginStart()
{
l4d_missile_radius = CreateConVar(“l4d_missile_radius”, “250.0”, “grenade explode radius”, FCVAR_PLUGIN);
l4d_missile_damage = CreateConVar(“l4d_missile_damage”, “800.0”, “damage”, FCVAR_PLUGIN);
l4d_missile_push = CreateConVar(“l4d_missile_push”, “1200”, “push forece”, FCVAR_PLUGIN);
l4d_missile_safe = CreateConVar(“l4d_missile_safe”, “0”, “0:normal , 1:less chance to hurt survivor”, FCVAR_PLUGIN);
l4d_missile_infected_smoker = CreateConVar(“l4d_missile_infected_smoker”, “5.0”, “launch missile when smoker drag[0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_charger = CreateConVar(“l4d_missile_infected_charger”, “5.0”, “launch missile when charger charge[0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_spitter = CreateConVar(“l4d_missile_infected_spitter”, “5.0”, “spitter [0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_witch = CreateConVar(“l4d_missile_infected_witch”, “20.0”, “witch harasser[0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_tank_dead = CreateConVar(“l4d_missile_infected_tank_dead”, “20.0”, “[0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_tank_throw = CreateConVar(“l4d_missile_infected_tank_throw”, “10.0”, “[0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_infected_anti = CreateConVar(“l4d_missile_infected_anti”, “10.0”, “infected launch missile when survivor launch missile [0.0, 30.0]%”, FCVAR_PLUGIN);
l4d_missile_weapon_rifle = CreateConVar(“l4d_missile_weapon_rifle”, “0”, “enable or disable for rifle {0, 1}”, FCVAR_PLUGIN);
l4d_missile_weapon_sniper = CreateConVar(“l4d_missile_weapon_sniper”, “0”, “enable or disable for sniper {0, 1}”, FCVAR_PLUGIN);
l4d_missile_weapon_shotgun = CreateConVar(“l4d_missile_weapon_shotgun”, “0”, “enable or disable for shotgun {0, 1}”, FCVAR_PLUGIN);
l4d_missile_weapon_magnum = CreateConVar(“l4d_missile_weapon_shotgun”, “1”, “enable or disable for magnum {0, 1}”, FCVAR_PLUGIN);
l4d_missile_limit = CreateConVar(“l4d_missile_limit”, “30”, “grenade limit”, FCVAR_PLUGIN);
l4d_missile_kills = CreateConVar(“l4d_missile_kills”, “10”, “how many kills reward a grenade”, FCVAR_PLUGIN);
l4d_missile_tracefactor = CreateConVar(“l4d_missile_tracefactor”, “1.5”, “trace factor [0.5, 3.0]”, FCVAR_PLUGIN);
g_iVelocity = FindSendPropOffs(“CBasePlayer”, “m_vecVelocity[0]”);
decl String:GameName[16];
GetConVarString(FindConVar(“mp_gamemode”), GameName, sizeof(GameName));
if (StrEqual(GameName, “survival”, false))
GameMode = 3;
else if (StrEqual(GameName, “versus”, false) || StrEqual(GameName, “teamversus”, false) || StrEqual(GameName, “scavenge”, false) || StrEqual(GameName, “teamscavenge”, false))
GameMode = 2;
else if (StrEqual(GameName, “coop”, false) || StrEqual(GameName, “realism”, false))
GameMode = 1;
else
{
GameMode = 0;
}
GetGameFolderName(GameName, sizeof(GameName));
if (StrEqual(GameName, “left4dead2”, false))
{
L4D2Version=true;
}
else
{
L4D2Version=false;
}
AutoExecConfig(true, “l4d2_missile”);
RegConsoleCmd(“sm_miss_help”, MissileHelp);
HookEvent(“weapon_fire”, weapon_fire);
HookEvent(“player_death”, Event_PlayerDeath);
HookEvent(“infected_death”, Event_InfectedDeath);
HookEvent(“witch_harasser_set”, witch_harasser_set);
HookEvent(“tongue_grab”, tongue_grab);
HookEvent(“ability_use”, ability_use);
HookEvent(“player_incapacitated”, player_incapacitated);
if(L4D2Version)
{
HookEvent(“round_start”, round_start);
HookEvent(“round_end”, round_end);
HookEvent(“finale_win”, round_end);
HookEvent(“mission_lost”, round_end);
HookEvent(“map_transition”, round_end);
HookEvent(“charger_charge_start”, charger_charge_start);
}
ResetAllState();
Set();
gamestart=true;
}
public Action:MissileHelp(client,args)
{
PrintToChat(client, “[MISS] Owners of a SHOTGUN can use 3 missile types.nFor every %d killed infected you get 1 missile.”, GetConVarInt(l4d_missile_kills));
PrintToChat(client, “[MISS] Miss1 = Gren. Launcher. Stand still, Press USE and shoot.nMiss2 = Automatic Tracking Missile. DUCK and press USE while firing”);
PrintToChat(client, “[MISS] Miss3 = Laserguided. Laser-Guided Missile.nYou must be walking, press USE and shoot.n Missile follows your mouse during flight”);
}
public Action:ability_use(Handle:event, const String:name[], bool:dontBroadcast)
{
decl String:s[20];
GetEventString(event, “ability”, s, 32);
if(StrEqual(s, “ability_spit”, true))
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if( MissileEntity[client]==0 && GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_spitter) )
{
Fire(client, 1050.0, MissileTrace, true);
}
}
else if(StrEqual(s, “ability_throw”, true))
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if(!Hooked[client] && GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_tank_throw) )
{
Fire(client, 1050.0, MissileTrace, true);
}
}
}
public Action:witch_harasser_set(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_witch) )
{
CreateTimer(GetRandomFloat(0.1, 0.5), InfectedAntiMissile, 0);
}
}
public Action:player_incapacitated(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if(GetClientTeam(client)==InfectedTeam && !Hooked[client] && GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_tan
k_dead))
{
Fire(client, 1050.0, MissileTrace, true);
}
}
public Action:charger_charge_start(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if(!Hooked[client] && GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_charger))
{
Fire(client, 1050.0, MissileTrace, true);
}
}
public Action:tongue_grab(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if(!Hooked[client] && GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_smoker))
{
Fire(client, 1050.0, MissileTrace, true);
}
}
public Action:weapon_fire(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, “userid”));
if(GetClientTeam(client)==2)
{
if(GetClientButtons(client) & IN_USE)
{
new bool:ok=false;
decl String:item[65];
GetEventString(event, “weapon”, item, 65);
if(GetConVarInt(l4d_missile_weapon_shotgun)>0 && StrContains(item, “shot”)>=0 )ok=true;
if(GetConVarInt(l4d_missile_weapon_rifle)>0 && StrContains(item, “rifle”)>=0 )ok=true;
if(GetConVarInt(l4d_missile_weapon_sniper)>0 && StrContains(item, “sniper”)>=0 )ok=true;
if(GetConVarInt(l4d_missile_weapon_magnum)>0 && StrContains(item, “magnum”)>=0 )ok=true;
if(ok)
{
gamestart=true;
new type=MissileNormal;
if(GetClientButtons(client) & IN_SPEED)type=MissileLarserGuid;
else if(GetClientButtons(client) & IN_DUCK)type=MissileTrace;
new Float:time=GetEngineTime();
Grenade(client, time, type);
}
}
}
else
{
//PrintToChatAll(“%N use %s”, client, name);
}
}
public Action:InfectedAntiMissile(Handle:timer, any:ent)
{
new selected=0;
decl andidate[MAXPLAYERS+1];
new index=0;
for(new client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client)==InfectedTeam && !Hooked[client])
{
andidate[index++]=client;
}
}
if(index>0)
{
selected=GetRandomInt(0, index-1);
Fire(andidate[selected], 1050.0, MissileTrace, true);
}
}
new upgradekillcount[MAXPLAYERS+1];
new totalkillcount[MAXPLAYERS+1];
UpGrade(x, kill)
{
upgradekillcount[x]+=kill;
totalkillcount[x]+=kill;
new v=upgradekillcount[x]/GetConVarInt(l4d_missile_kills);
upgradekillcount[x]=upgradekillcount[x]%GetConVarInt(l4d_missile_kills);
Bullet[x]+=v;
if (v>0)
{
PrintCenterText(x, “Infected killed: %d”, totalkillcount[x]);
if(Bullet[x]>GetConVarInt(l4d_missile_limit))Bullet[x]=GetConVarInt(l4d_missile_limit);
PrintHintText(x, “+ Missile %d”, Bullet[x]);
if(ShowMsg[x]<3)
{
PrintToChat(x, “Type !miss_help in the chat to learn how to use missile”, Bullet[x]);
ShowMsg[x]++;
}
}
}
public Action:Event_InfectedDeath(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
if(GameMode==2)return Plugin_Continue;
new attacker = GetClientOfUserId(GetEventInt(hEvent, “attacker”));
if (attacker<=0)
{
return Plugin_Continue;
}
if(IsClientInGame(attacker) )
{
if(GetClientTeam(attacker) == 2)
{
UpGrade(attacker, 1);
}
}
return Plugin_Continue;
}
public Action:Event_PlayerDeath(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
if(GameMode==2)return Plugin_Continue;
new victim = GetClientOfUserId(GetEventInt(hEvent, “userid”));
new attacker = GetClientOfUserId(GetEventInt(hEvent, “attacker”));
if (victim <= 0 || attacker<=0)
{
return Plugin_Continue;
}
if(IsClientInGame(attacker) )
{
if(GetClientTeam(attacker) == 2)
{
if(IsClientInGame(victim))
{
if( GetClientTeam(victim) == 3 )
{
new bool:headshot=GetEventBool(hEvent, "headshot");
if(headshot)
{
UpGrade(attacker, 5);
}
else
{
UpGrade(attacker, 3);
}
}
}
}
}
return Plugin_Continue;
}
Grenade(client, Float:time, type=MissileTrace)
{
if( time-UseTime[client]>1.0)
{
if(Bullet[client]-1>=0)// || true)
{
Bullet[client]=Bullet[client]-1;
UseTime[client]=time;
HookTime[client]=time;
Fire(client, 1050.0, type);
if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_missile_infected_anti) )
{
CreateTimer(GetRandomFloat(0.1, 2.0), InfectedAntiMissile, 0);
}
}
else
{
PrintHintText(client, “not enough missile”);
}
}
}
public Action:grenade_bounce(Handle:h_Event, const String:s_Name[], bool:b_DontBroadcast)
{
new userid = GetClientOfUserId(GetEventInt(h_Event, “userid”));
MissileHit(userid);
}
Hook(client)
{
Hooked[client]=true;
}
UnHook(client)
{
Hooked[client]=false;
if(IsEntityMissile(MissileEntity[client]))
{
new Float:angle[3];
angle[1]=-90.0;
angle[0]=-90.0;
angle[2]=0.0;
GetAngleVectors(angle, angle, NULL_VECTOR,NULL_VECTOR);
TeleportEntity(MissileEntity[client], MissilePlacePos[0], angle, angle);
SetEntityMoveType(MissileEntity[client], MOVETYPE_NONE);
}
}
bool:IsEntityMissile(ent)
{
new bool:r=false;
if(ent>0 && IsValidEdict(ent) && IsValidEntity(ent))
{
decl String:g_classname[64];
GetEdictClassname(ent, g_classname, 64);
if( StrEqual(g_classname, “grenade_launcher_projectile”, true) || StrEqual(g_classname, “molotov_projectile” ))
{
r=true;
}
}
return r;
}
bool:IsEntityMissileModel(ent)
{
new bool:r=false;
if(ent>0 && IsValidEdict(ent) && IsValidEntity(ent))
{
decl String:g_classname[64];
GetEdictClassname(ent, g_classname, 64);
if( StrEqual(g_classname, “prop_dynamic”, true) || StrEqual(g_classname, “prop_physics”, true) )
{
r=true;
}
}
return r;
}
CreateMissile(userid, Float:pos[3], Float:vol[3])
{
new ent = 0;
new ok=false;
if(!L4D2Version)//|| button & IN_SPEED || button & IN_DUCK)
{
ent=CreateEntityByName(“molotov_projectile”);
if(ent>0)DispatchKeyValue(ent, “model”, “models/w_models/weapons/w_eq_molotov.mdl”);
}
else
{
ent=CreateEntityByName(“grenade_launcher_projectile”);
if(ent>0)DispatchKeyValue(ent, “model”, “models/w_models/weapons/w_HE_grenade.mdl”);
}
if(ent>0)
{
//SetEntPropEnt(ent, Prop_Data, “m_hOwnerEntity”, userid) ;
DispatchSpawn(ent);
TeleportEntity(ent, pos, NULL_VECTOR, vol);
ActivateEntity(ent);
//PrintToChatAll(“%d”, GetEntityMoveType(ent));
ok=true;
}
else ok=false;
new ment=0;
if(L4D2Version)
{
ment=CreateEntityByName(“prop_dynamic”);
if(ment>0 && ok)
{
new String:tname[20];
Format(tname, 20, “missile%d”, ent);
DispatchKeyValue(ent, “targetname”, tname);
//SetEntPropEnt(ment, Prop_Data, “m_hOwnerEntity”, userid) ;
DispatchKeyValue(ment, “parentname”, tname);
DispatchKeyValue(ment, “model”, “models/missiles/f18_agm65maverick.mdl”);
DispatchSpawn(ment);
TeleportEntity(ment, pos, NULL_VECTOR, NULL_VECTOR);
SetVariantString(tname);
AcceptEntityInput(ment, “SetParent”,ment, ment, 0);
//DispatchKeyValue(ment, “m_fadeMinDist”, “9999.0”);
//DispatchKeyValue(ment, “m_fadeMaxDist”, “9999.0”);
//SetEntPropFloat(ment, Prop_Send, “m_fadeMinDist”, 9999.0) ;
//SetEntPropFloat(ment, Prop_Send, “m_fadeMaxDist”, 9999.0) ;
}
else ok=false;
}
else
{
ment=CreateEntityByName(“prop_physics”);
if(ment>0 && ok)
{
new String:tname[20];
Format(tname, 20, “missile%d”, ent);
DispatchKeyValue(ent, “targetname”, tname);
//SetEntPropEnt(ment, Prop_Data, “m_hOwnerEntity”, userid) ;
DispatchKeyValue(ment, “parentname”, tname);
//DispatchKeyValue(ment, “model”, “models/props_equipment/oxygentank01.mdl”);
DispatchKeyValue(ment, “model”, “models/props_junk/propanecanister001a.mdl”);
DispatchSpawn(ment);
TeleportEntity(ment, pos, NULL_VECTOR, NULL_VECTOR);
SetVariantString(tname);
AcceptEntityInput(ment, “SetParent”,ment, ment, 0);
//DispatchKeyValue(ment, “m_fadeMinDist”, “9999.0”);
//DispatchKeyValue(ment, “m_fadeMaxDist”, “9999.0”);
//SetEntPropFloat(ment, Prop_Send, “m_fadeMinDist”, 9999.0) ;
//SetEntPropFloat(ment, Prop_Send, “m_fadeMaxDist”, 9999.0) ;
}
else ok=false;
}
if(!ok)
{
ent=0;
ment=0;
}
SetEntProp(ent, Prop_Data, “m_takedamage”, 0, 1);
SetEntProp(ment, Prop_Data, “m_takedamage”, 0, 1);
MissleModel[userid]=ment;
MissileEntity[userid]=ent;
return ent;
}
Fire(userid, Float:force, type=MissileTrace, bool:up=false)
{
decl Float:pos[3];
decl Float:angles[3];
decl Float:velocity[3];
GetClientAbsOrigin(userid, pos);
if(MissilePlacePos0==0.0)CopyVector(pos, MissilePlacePos[0]);
GetClientEyePosition(userid, pos);
GetClientEyeAngles(userid, angles);
if(up)
{
angles[1]=-90.0;
angles[0]=-90.0;
angles[2]=0.0;
}
GetEntDataVector(userid, g_iVelocity, velocity);
angles[0]-=5.0;
velocity[0] = force Cosine(DegToRad(angles[1])) Cosine(DegToRad(angles[0]));
velocity[1] = force Sine(DegToRad(angles[1])) Cosine(DegToRad(angles[0]));
velocity[2] = force Sine(DegToRad(angles[0])) -1.0;
//new Float:force=GetConVarFloat(w_laugch_force);
GetAngleVectors(angles, velocity, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(velocity, velocity);
ScaleVector(velocity, force);
{
new Float:B=-3.1415926/2.0;
decl Float:vec[3];
decl Float:vec2[3];
GetAngleVectors(angles,vec, NULL_VECTOR, NULL_VECTOR);
GetAngleVectors(angles,vec2, NULL_VECTOR, NULL_VECTOR);
new Float:x0=vec[0];
new Float:y0=vec[1];
new Float:x1=x0Cosine(B)-y0Sine(B);
new Float:y1=x0Sine(B)+y0Cosine(B);
vec[0]=x1;
vec[1]=y1;
vec[2]=0.0;
NormalizeVector(vec,vec);
NormalizeVector(vec2,vec2);
ScaleVector(vec, 12.0);
ScaleVector(vec2, 30.0);
AddVectors(pos, vec, pos);
AddVectors(pos, vec2, pos);
}
GetVectorAngles(velocity, angles);
new Float:temp[3];
new Float:dis=CalRay(pos, angles, 0.0, 0.0, temp, userid, false, FilterSelf);
if(dis<150.0)
{
PrintHintText(userid, “Not enough space to launch”);
return;
}
new ent=0;
if(!(IsEntityMissile(MissileEntity[userid]) && IsEntityMissileModel(MissleModel[userid])))
{
ent=CreateMissile(userid, pos, velocity);
}
else
{
ent=MissileEntity[userid];
}
if(ent<=0)
{
return;
}
Enemy[userid]=-1;
MissileType[userid]=type;
MissileTeams[userid]=GetClientTeam(userid);
SetEntityMoveType(ent, 5);
TeleportEntity(ent, pos, NULL_VECTOR, velocity);
IgniteEntity(ent, 0.0);
SetEntProp(ent , Prop_Data, “m_iHealth”, 99999);
SetEntProp(MissleModel[userid] , Prop_Data, “m_iHealth”, 99999);
SetEntProp(ent, Prop_Data, “m_CollisionGroup”, 0);
SetEntProp(MissleModel[userid], Prop_Data, “m_CollisionGroup”, 0);
SetEntProp(ent, Prop_Data, “m_MoveCollide”, 0);
SetEntProp(MissleModel[userid], Prop_Data, “m_MoveCollide”, 0);
MissileAngleuserid=MissileAngleuserid=MissileAngleuserid=0.0;
if(type==MissileLarserGuid)
{
SetEntityGravity(ent, 0.01);
}
else if(type==MissileTrace)
{
SetEntityGravity(ent, 0.01);
}
else
{
if(!L4D2Version)SetEntityGravity(ent, 0.6);
else SetEntityGravity(ent, 0.4);
}
Hook(userid);
if(L4D2Version) EmitSoundToAll(SOUNDMISSILELAUNCHER2, 0, SNDCHAN_WEAPON, SNDLEVEL_TRAFFIC, SND_NOFLAGS, SNDVOL_NORMAL, 100, _, pos, NULL_VECTOR, false, 0.0);
else EmitSoundToAll(SOUNDMISSILELAUNCHER, 0, SNDCHAN_WEAPON, SNDLEVEL_TRAFFIC, SND_
NOFLAGS, SNDVOL_NORMAL, 100, _, pos, NULL_VECTOR, false, 0.0);
PrintHintText(userid, “Missile %d”, Bullet[userid]);
if(GetClientTeam(userid)==3)PrintToChatAll(“x04%N x03Launched Missile”, userid);
return;
}
public OnGameFrame()
{
if(!gamestart)return;
for(new client = 1; client <= MaxClients; client++)
{
if(Hooked[client])Do(client);
}
}
Do(client)
{
new bool:unhook=false;
//if(IsClientInGame(client))// && IsPlayerAlive(client))
{
if(IsEntityMissile(MissileEntity[client]) && IsEntityMissileModel(MissleModel[client]))
{
new Float:time=GetEngineTime();
new Float:duration=time-HookTime[client];
HookTime[client]=time;
if(MissileType[client]==MissileNormal)Missile(client, duration);
if(MissileType[client]==MissileTrace)TraceMissile(client, duration);
if(MissileType[client]==MissileLarserGuid)LaserGuideMissile(client, duration);
}
else
{
unhook=true;
}
}
if(unhook)
{
UnHook(client);
}
}
Missile(client, Float:duration)
{
decl Float:missionangle[3];
decl Float:voffset[3];
decl Float:missilepos[3];
decl Float:velocitymissile[3];
new ent=MissileEntity[client];
duration=duration*1.0;
GetEntPropVector(ent, Prop_Send, “m_vecOrigin”, missilepos);
GetEntDataVector(ent, g_iVelocity, velocitymissile);
NormalizeVector(velocitymissile,velocitymissile);
CopyVector(velocitymissile, voffset);
ScaleVector(voffset, modeloffset);
AddVectors(missilepos, voffset, missilepos);
decl Float:temp[3];
GetVectorAngles(velocitymissile, missionangle);
new Float:disenemy=CalRay(missilepos, missionangle, 0.0, 0.0, temp, MissleModel[client], false, FilterSelf);
//PrintToChatAll(“%f”, disenemy);
SetEntProp(ent, Prop_Data, “m_takedamage”, 0, 1);
SetEntProp(MissleModel[client], Prop_Data, “m_takedamage”, 0, 1);
MissileAngleclient+=15.0;
DispatchKeyValueVector(MissleModel[client], “Angles”, MissileAngle[client]);
if(disenemy<30.0)
{
MissileHit(client);
}
}
LaserGuideMissile(client, Float:duration)
{
decl Float:angle[3];
decl Float:voffset[3];
decl Float:pos[3];
decl Float:targetpos[3];
decl Float:missilepos[3];
decl Float:velocitymissile[3];
decl Float:tracedirectoin[3];
new ent=MissileEntity[client];
GetClientEyePosition(client, pos);
GetClientEyeAngles(client, angle);
GetEntPropVector(MissileEntity[client], Prop_Send, “m_vecOrigin”, missilepos);
GetEntDataVector(MissileEntity[client], g_iVelocity, velocitymissile);
NormalizeVector(velocitymissile,velocitymissile);
GetRayHitPos(pos, angle, targetpos, client, FilterSelfAndSurvivor);
MakeVectorFromPoints(missilepos, targetpos, tracedirectoin);
NormalizeVector(tracedirectoin, tracedirectoin);
CopyVector(tracedirectoin, voffset);
ScaleVector(voffset, 180.0);
AddVectors(missilepos, voffset, missilepos);
decl Float:missionangle[3];
decl Float:temp[3];
GetVectorAngles(tracedirectoin, missionangle);
new Float:disenemy=CalRay(missilepos, missionangle, 0.0, 0.0, temp, MissleModel[client], false, FilterSelf);
ShowLarserByPos(missilepos, targetpos);
new Float:a=GetAngle(velocitymissile, tracedirectoin);
new Float:amax=3.14159 duration GetConVarFloat(l4d_missile_tracefactor);
if(a> amax )a=amax ;
ScaleVector(tracedirectoin ,a);
//PrintToChat(client, “%f %f %f”, tracedirectoin[0], tracedirectoin[1], tracedirectoin[2]);
AddVectors(tracedirectoin, velocitymissile, tracedirectoin);
NormalizeVector( tracedirectoin, tracedirectoin);
ScaleVector(tracedirectoin, 300.0);
TeleportEntity(ent, NULL_VECTOR, NULL_VECTOR ,tracedirectoin);
MissileAngleclient+=25.0;
DispatchKeyValueVector(MissleModel[client], “Angles”, MissileAngle[client]);
SetEntityGravity(ent, 0.01);
AcceptEntityInput(ent, “Ignite”);
SetEntProp(ent, Prop_Data, “m_takedamage”, 0, 1);
SetEntProp(MissleModel[client], Prop_Data, “m_takedamage”, 0, 1);
if(disenemy<10.0)
{
MissileHit(client);
}
}
TraceMissile(client, Float:duration)
{
decl Float:posmissile[3];
decl Float:voffset[3];
decl Float:velocitymissile[3];
new ent=MissileEntity[client];
GetEntPropVector(ent, Prop_Send, “m_vecOrigin”, posmissile);
GetEntDataVector(ent, g_iVelocity, velocitymissile);
NormalizeVector(velocitymissile, velocitymissile);
CopyVector(velocitymissile, voffset);
ScaleVector(voffset, modeloffset);
AddVectors(posmissile, voffset, posmissile);
new myteam=MissileTeams[client];
new enemyteam=myteam==SurvivorTeam?InfectedTeam:SurvivorTeam;
new enemy=GetEnemy(posmissile, velocitymissile, enemyteam);
decl Float:velocityenemy[3];
decl Float:vtrace[3];
vtrace[0]=vtrace[1]=vtrace[2]=0.0;
new bool:visible=false;
decl Float:missionangle[3];
new Float:disenemy=1000.0;
new Float:disobstacle=1000.0;
new Float:disexploded=40.0;
new bool:show=false;
new bool:enemyismissile=false;
if(PrintTime[client]>0.2)
{
PrintTime[client]=0.0;
show=true;
}
PrintTime[client]+=duration;
if(enemy>0)
{
decl Float:posenemy[3];
GetClientEyePosition(enemy, posenemy);
disenemy=GetVectorDistance(posmissile, posenemy);
visible=IfTwoPosVisible(posmissile, posenemy, ent, myteam);
//if(visible)PrintToChatAll(“%N visible %f “, client, disenemy);
GetEntDataVector(enemy, g_iVelocity, velocityenemy);
ScaleVector(velocityenemy, duration);
AddVectors(posenemy, velocityenemy, posenemy);
MakeVectorFromPoints(posmissile, posenemy, vtrace);
//PrintToChatAll(“%N lock %N D:%f”, client,enemy, disenemy);
if(show)
{
if(enemy>0 && IsClientInGame(enemy) && IsPlayerAlive(enemy))
{
if(client > 0 && IsClientInGame(client) && IsPlayerAlive(client)) PrintHintText(enemy, "Your are locked by %N's missile, Distance: %d", client, RoundFloat(disenemy) );
else PrintHintText(enemy, "Warning! Your are locked by enemy's missile, Distance: %d", RoundFloat(disenemy) );
EmitSoundToClient(enemy, SOUNDMISSILELOCK);
}
if(client > 0 && IsClientInGame(client) && IsPlayerAlive(client))
{
if(enemy>0 && IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintCenterText(client, "Missile Locked On: %N, Distance: %d", enemy, RoundFloat(disenemy));
else PrintCenterText(client, "Missile Locked On: enemy, Distance: %d", RoundFloat(disenemy));
}
}
Enemy[client]=enemy;
}
else if(enemy<0)
{
enemy=-enemy;
if(IsEntityMissile(MissileEntity[enemy]))
{
decl Float:posenemy[3];
GetEntPropVector(MissileEntity[enemy], Prop_Send, “m_vecOrigin”, posenemy);
GetEntDataVector(MissileEntity[enemy], g_iVelocity, velocityenemy);
NormalizeVector(velocityenemy, velocityenemy);
CopyVector(velocityenemy, voffset);
ScaleVector(voffset, modeloffset);
AddVectors(posenemy, voffset, posenemy);
disenemy=GetVectorDistance(posmissile, posenemy);
visible=IfTwoPosVisible(posmissile, posenemy, MissleModel[enemy], MissileTeam);
ScaleVector(velocityenemy, duration);
AddVectors(posenemy, velocityenemy, posenemy);
MakeVectorFromPoints(posmissile, posenemy, vtrace);
if(show)
{
if(client > 0 && IsClientInGame(client) && IsPlayerAlive(client))
{
if(enemy>0 && IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintCenterText(client, "Missile Locked On %N's Missile, Distance: %d", enemy, RoundFloat(disenemy));
else PrintCenterText(client, "Missile Locked On enemy's Missile, Distance: %d", RoundFloat(disenemy));
}
//if(IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintHintText(enemy, "Your Missile locked by %N's missile, Distance: %d", client, RoundFloat(disenemy));
}
Enemy[client]=enemy;
disexploded=modeloffset;
enemyismissile=true;
//PrintToChatAll(“lock missile distance %f”, distance);
}
else Enemy[client]=enemy=0;
}
else if(show)
{
if(client>0 && IsClientInGame(client) && IsPlayerAlive(client))PrintCenterText(client, “No target locked”);
}
////////////////////////////////////////////////////////////////////////////////////
GetVectorAngles(velocitymissile, missionangle);
decl Float:vleft[3];
decl Float:vright[3];
decl Float:vup[3];
decl Float:vdown[3];
decl Float:vfront[3];
decl Float:vv1[3];
decl Float:vv2[3];
decl Float:vv3[3];
decl Float:vv4[3];
decl Float:vv5[3];
decl Float:vv6[3];
decl Float:vv7[3];
decl Float:vv8[3];
vfront[0]=vfront[1]=vfront[2]=0.0;
new Float:factor2=0.5;
new Float:factor1=0.2;
new Float:t;
new Float:base=1500.0;
if(visible)
{
base=80.0;
}
{
//PrintToChatAll(“%f %f %f %f %f”,front, up, down, left, right);
new flag=FilterSelfAndInfected;
new bool:print=false;
new self=MissleModel[client];
new Float:front=CalRay(posmissile, missionangle, 0.0, 0.0, vfront, self, print, flag);
print=false;
disobstacle=CalRay(posmissile, missionangle, 0.0, 0.0, vfront, self, print, FilterSelf);
new Float:down=CalRay(posmissile, missionangle, 90.0, 0.0, vdown, self, print, flag);
new Float:up=CalRay(posmissile, missionangle, -90.0, 0.0, vup, self, print);
new Float:left=CalRay(posmissile, missionangle, 0.0, 90.0, vleft, self, print, flag);
new Float:right=CalRay(posmissile, missionangle, 0.0, -90.0, vright, self, print, flag);
new Float:f1=CalRay(posmissile, missionangle, 30.0, 0.0, vv1, self, print, flag);
new Float:f2=CalRay(posmissile, missionangle, 30.0, 45.0, vv2, self, print, flag);
new Float:f3=CalRay(posmissile, missionangle, 0.0, 45.0, vv3, self, print, flag);
new Float:f4=CalRay(posmissile, missionangle, -30.0, 45.0, vv4, self, print, flag);
new Float:f5=CalRay(posmissile, missionangle, -30.0, 0.0, vv5, self, print,flag);
new Float:f6=CalRay(posmissile, missionangle, -30.0, -45.0, vv6, self, print, flag);
new Float:f7=CalRay(posmissile, missionangle, 0.0, -45.0, vv7, self, print, flag);
new Float:f8=CalRay(posmissile, missionangle, 30.0, -45.0, vv8, self, print, flag);
NormalizeVector(vfront,vfront);
NormalizeVector(vup,vup);
NormalizeVector(vdown,vdown);
NormalizeVector(vleft,vleft);
NormalizeVector(vright,vright);
NormalizeVector(vtrace, vtrace);
NormalizeVector(vv1,vv1);
NormalizeVector(vv2,vv2);
NormalizeVector(vv3,vv3);
NormalizeVector(vv4,vv4);
NormalizeVector(vv5,vv5);
NormalizeVector(vv6,vv6);
NormalizeVector(vv7,vv7);
NormalizeVector(vv8,vv8);
if(front>base) front=base;
if(up>base) up=base;
if(down>base) down=base;
if(left>base) left=base;
if(right>base) right=base;
if(f1>base) f1=base;
if(f2>base) f2=base;
if(f3>base) f3=base;
if(f4>base) f4=base;
if(f5>base) f5=base;
if(f6>base) f6=base;
if(f7>base) f7=base;
if(f8>base) f8=base;
t=-1.0factor1(base-front)/base;
ScaleVector( vfront, t);
t=-1.0factor1(base-up)/base;
ScaleVector( vup, t);
t=-1.0factor1(base-down)/base;
ScaleVector( vdown, t);
t=-1.0factor1(base-left)/base;
ScaleVector( vleft, t);
t=-1.0factor1(base-right)/base;
ScaleVector( vright, t);
t=-1.0factor1(base-f1)/f1;
ScaleVector( vv1, t);
t=-1.0factor1(base-f2)/f2;
ScaleVector( vv2, t);
t=-1.0factor1(base-f3)/f3;
ScaleVector( vv3, t);
t=-1.0factor1(base-f4)/f4;
ScaleVector( vv4, t);
t=-1.0factor1(base-f5)/f5;
ScaleVector( vv5, t);
t=-1.0factor1(base-f6)/f6;
ScaleVector( vv6, t);
t=-1.0factor1(base-f7)/f7;
ScaleVector( vv7, t);
t=-1.0factor1(base-f8)/f8;
ScaleVector( vv8, t);
if(disenemy>=500.0)disenemy=500.0;
t=1.0factor2(1000.0-disenemy)/500.0;
ScaleVector( vtrace, t);
AddVectors(vfront, vup, vfront);
AddVectors(vfront, vdown, vfront);
AddVectors(vfront, vleft, vfront);
AddVectors(vfront, vright, vfront);
AddVectors(vfront, vv1, vfront);
AddVectors(vfront, vv2, vfront);
AddVectors(vfront, vv3, vfront);
AddVectors(vfront, vv4, vfront);
AddVectors(vfront, vv5, vfront);
AddVectors(vfront, vv6, vfront);
AddVectors(vfront, vv7, vfront);
AddVectors(vfront, vv8, vfront);
AddVectors(vfront, vtrace, vfront);
NormalizeVector(vfront, vfront);
}
new Float:a=GetAngle(vfront, velocitymissile);
new Float:amax=3.14159durationGetConVarFloat(l4d_missile_tracefactor);
if(a> amax )a=amax ;
ScaleVector(vfront ,a);
//PrintToChat(client, “max %f %f “,amax , a);
decl Float:newvelocitymissile[3];
AddVectors(velocitymissile, vfront, newvelocitymissile);
new Float:speed=0.0;
if(myteam==SurvivorTeam)speed=500.0;
else speed=300.0;
ScaleVector(newvelocitymissile,speed);
TeleportEntity(ent, NULL_VECTOR, NULL_VECTOR ,newvelocitymissile);
MissileAngleclient+=25.0;
DispatchKeyValueVector(MissleModel[client], “Angles”, MissileAngle[client]);
SetEntityGravity(ent, 0.01);
AcceptEntityInput(ent, “Ignite”);
SetEntProp(ent, Prop_Data, “m_takedamage”, 0, 1);
SetEntProp(MissleModel[client], Prop_Data, “m_takedamage”, 0, 1);
if(disenemy<disexploded || disobstacle<disexploded)
{
new bool:hitenemy=false;
if(disenemy<150.0)hitenemy=true;
if(enemyismissile )
{
MissileHitMissileMsg(client, enemy, hitenemy);
if(hitenemy)MissileHit(enemy, 1);
}
else
{
MissileHitPlayerMsg(client, enemy, hitenemy)
}
MissileHit(client);
}
}
MissileHitMissileMsg(client, enemy, bool:hit=true)
{
if(hit)
{
if(enemy>0 && IsClientInGame(enemy))
{
if(client> 0 && IsClientInGame(client))PrintHintText(enemy, “Your missile was intercepted by %N”, client);
else PrintHintText(enemy, “Your missile was intercepted by enemy”);
}
if(client>0 && IsClientInGame(client))
{
if(enemy>0 && IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintHintText(client, “You intercepted %N’s missile”, enemy);
else PrintHintText(client, “You intercepted enemy’s missile”);
}
}
else
{
if(client> 0 && IsClientInGame(client))PrintHintText(client, “Your Missile hit obstacle”);
}
}
MissileHitPlayerMsg(client, enemy, bool:hit)
{
if(hit)
{
if(enemy>0 && IsClientInGame(enemy) )
{
if(client> 0 && IsClientInGame(client))PrintHintText(enemy, “You hitted by %N’s missile”, client);
else PrintHintText(enemy, “You hitted by enemy’s missile”);
}
if(client>0 && IsClientInGame(client))
{
if(enemy>0 && IsClientInGame(enemy))PrintHintText(client, “Your missile hitted %N”, enemy);
else PrintHintText(client, “Your missile hit obstacle”);
}
}
else
{
if(client> 0 && IsClientInGame(client))PrintHintText(client, “Your Missile hit obstacle”);
}
}
MissileHit(userid, num=2)
{
//UnHook(userid);
//return;
if(IsEntityMissile(MissileEntity[userid]))
{
//PrintToChatAll(“bounce ok”);
decl Float:pos[3];
decl Float:voffset[3];
GetEntPropVector(MissileEntity[userid], Prop_Send, “m_vecOrigin”, pos);
decl Float:velocitymissile[3];
GetEntDataVector(MissileEntity[userid], g_iVelocity, velocitymissile);
NormalizeVector(velocitymissile, vel
ocitymissile);
CopyVector(velocitymissile, voffset);
ScaleVector(voffset, modeloffset);
AddVectors(pos, voffset, pos);
new ent1=0;
new ent2=0;
new ent3=0;
{
ent1=CreateEntityByName(“prop_physics”);
DispatchKeyValue(ent1, “model”, “models/props_junk/propanecanister001a.mdl”);
DispatchSpawn(ent1);
TeleportEntity(ent1, pos, NULL_VECTOR, NULL_VECTOR);
ActivateEntity(ent1);
}
if(num>1)
{
ent2=CreateEntityByName(“prop_physics”);
DispatchKeyValue(ent2, “model”, “models/props_junk/propanecanister001a.mdl”);
DispatchSpawn(ent2);
TeleportEntity(ent2, pos, NULL_VECTOR, NULL_VECTOR);
ActivateEntity(ent2);
}
if(num>2)
{
ent3=CreateEntityByName(“prop_physics”);
DispatchKeyValue(ent3, “model”, “models/props_junk/propanecanister001a.mdl”);
DispatchSpawn(ent3);
TeleportEntity(ent3, pos, NULL_VECTOR, NULL_VECTOR);
ActivateEntity(ent3);
}
new Handle:h=CreateDataPack();
WritePackCell(h, ent1);
WritePackCell(h, ent2);
WritePackCell(h, ent3);
WritePackFloat(h, pos[0]);
WritePackFloat(h, pos[1]);
WritePackFloat(h, pos[2]);
new Float:damage=GetConVarFloat(l4d_missile_damage);
new Float:radius=GetConVarFloat(l4d_missile_radius);
new Float:pushforce=GetConVarFloat(l4d_missile_push);
new Float:mindistance=GetSurvivorMinDistance(pos);
if(GetConVarInt(l4d_missile_safe)==1 && mindistance<radius && MissileTeams[userid]==SurvivorTeam)
{
radius=mindistance;
}
WritePackFloat(h, damage);
WritePackFloat(h, radius);
WritePackFloat(h, pushforce);
ExplodeG(INVALID_HANDLE, h);
if(MissileType[userid]!=MissileTrace && IsClientInGame(userid) && IsPlayerAlive(userid))PrintCenterText(userid, “missile exploded”);
}
UnHook(userid);
}
GetEnemy(Float:pos[3], Float:vec[3], enemyteam)
{
new Float:min=4.0;
decl Float:pos2[3];
new Float:t;
new s=0;
new bool:hasmissile=false;
for(new client = 1; client <= MaxClients; client++)
{
new bool:playerok=IsClientInGame(client) && GetClientTeam(client)==enemyteam && IsPlayerAlive(client);
new bool:ismissile=Hooked[client] && MissileTeams[client]==enemyteam && IsEntityMissile(MissileEntity[client]) && IsEntityMissileModel(MissleModel[client]);
if(playerok || ismissile)
{
if(ismissile)
{
if(!hasmissile)min=4.0;
hasmissile=true;
GetEntPropVector(MissileEntity[client], Prop_Send, "m_vecOrigin", pos2)
MakeVectorFromPoints(pos, pos2, pos2);
t=GetAngle(vec, pos2);
if(t<=min)
{
min=t;
s=-client;
}
}
if(!hasmissile && playerok)
{
GetClientEyePosition(client, pos2);
MakeVectorFromPoints(pos, pos2, pos2);
t=GetAngle(vec, pos2);
//PrintToChatAll("%N %f", client, 360.0*t/3.1415926/2.0);
if(t<=min)
{
min=t;
s=client;
}
}
}
}
return s;
}
Float:GetSurvivorMinDistance(Float:pos[3])
{
new Float:min=99999.0;
decl Float:pos2[3];
new Float:t;
for(new client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client)==2 )
{
GetClientEyePosition(client, pos2);
t=GetVectorDistance(pos, pos2);
if(t<=min)
{
min=t;
}
}
}
return min;
}
bool:IfTwoPosVisible(Float:pos1[3], Float:pos2[3], self, team=SurvivorTeam)
{
new bool:r=true;
new Handle:trace ;
if(team==SurvivorTeam)trace=TR_TraceRayFilterEx(pos2, pos1, MASK_SOLID, RayType_EndPoint, DontHitSelfAndInfected,self);
else if(team==InfectedTeam)trace=TR_TraceRayFilterEx(pos2, pos1, MASK_SOLID, RayType_EndPoint, DontHitSelfAndSurvivor,self);
else trace=TR_TraceRayFilterEx(pos2, pos1, MASK_SOLID, RayType_EndPoint, DontHitSelfAndMissile,self);
if(TR_DidHit(trace))
{
r=false;
}
CloseHandle(trace);
return r;
}
Float:CalRay(Float:posmissile[3], Float:angle[3], Float:offset1, Float:offset2, Float:force[3], ent, bool:printlaser=true, flag=FilterSelf)
{
decl Float:ang[3];
CopyVector(angle, ang);
ang[0]+=offset1;
ang[1]+=offset2;
GetAngleVectors(ang, force, NULL_VECTOR,NULL_VECTOR);
new Float:dis=GetRayDistance(posmissile, ang, ent, flag) ;
if(printlaser)ShowLarserByAngleAndDistance(posmissile, ang, dis*0.5);
//PrintToChatAll(“%f %f, %f”, dis, offset1, offset2);
return dis;
}
ShowLarserByAngleAndDistance(Float:pos1[3], Float:angle[3], Float:dis, flag=0, Float:life=0.06)
{
new Float:pos2[3];
GetAngleVectors(angle, pos2, NULL_VECTOR,NULL_VECTOR);
NormalizeVector(pos2, pos2);
ScaleVector(pos2, dis);
AddVectors(pos1, pos2, pos2);
ShowLarserByPos(pos1, pos2, flag, life);
}
ShowLarserByPos(Float:pos1[3], Float:pos2[3], flag=0, Float:life=0.06)
{
decl color[4];
if(flag==0)
{
color[0] = 200;
color[1] = 200;
color[2] = 200;
color[3] = 230;
}
else
{
color[0] = 200;
color[1] = 0;
color[2] = 0;
color[3] = 230;
}
new Float:width1=0.5;
new Float:width2=0.5;
if(L4D2Version)
{
width2=0.3;
width2=0.3;
}
TE_SetupBeamPoints(pos1, pos2, g_sprite, 0, 0, 0, life, width1, width2, 1, 0.0, color, 0);
TE_SendToAll();
}
CopyVector(Float:source[3], Float:target[3])
{
target[0]=source[0];
target[1]=source[1];
target[2]=source[2];
}
Float:GetRayDistance(Float:pos[3], Float: angle[3], self, flag)
{
decl Float:hitpos[3];
GetRayHitPos(pos, angle, hitpos, self, flag);
return GetVectorDistance( pos, hitpos);
}
Float:GetAngle(Float:x1[3], Float:x2[3])
{
return ArcCosine(GetVectorDotProduct(x1, x2)/(GetVectorLength(x1)*GetVectorLength(x2)));
}
GetRayHitPos(Float:pos[3], Float: angle[3], Float:hitpos[3], self, flag)
{
new Handle:trace ;
new hit=0;
if(flag==FilterSelf)
{
trace= TR_TraceRayFilterEx(pos, angle, MASK_SOLID, RayType_Infinite, DontHitSelf, self);
}
else if(flag==FilterSelfAndPlayer)
{
trace= TR_TraceRayFilterEx(pos, angle, MASK_SOLID, RayType_Infinite, DontHitSelfAndPlayer, self);
}
else if(flag==FilterSelfAndSurvivor)
{
trace= TR_TraceRayFilterEx(pos, angle, MASK_SOLID, RayType_Infinite, DontHitSelfAndSurvivor, self);
}
else if(flag==FilterSelfAndInfected)
{
trace= TR_TraceRayFilterEx(pos, angle, MASK_SOLID, RayType_Infinite, DontHitSelfAndInfected, self);
}
else if(flag==FilterSelfAndPlayerAndCI)
{
trace= TR_TraceRayFilterEx(pos, angle, MASK_SOLID, RayType_Infinite, DontHitSelfAndPlayerAndCI, self);
}
if(TR_DidHit(trace))
{
TR_GetEndPosition(hitpos, trace);
hit=TR_GetEntityIndex( trace);
}
CloseHandle(trace);
return hit;
}
public Action:ExplodeG(Handle:timer, Handle:h)
{
ResetPack(h);
new ent1=ReadPackCell(h);
new ent2=ReadPackCell(h);
new ent3=ReadPackCell(h);
decl Float:pos[3];
pos[0]=ReadPackFloat(h);
pos[1]=ReadPackFloat(h);
pos[2]=ReadPackFloat(h);
new Float:damage=ReadPackFloat(h);
new Float:radius=ReadPackFloat(h);
new Float:force=ReadPackFloat(h);
CloseHandle(h);
if(ent1>0 && IsValidEntity(ent1) && IsValidEdict(ent1))
{
AcceptEntityInput(ent1, “break”);
RemoveEdict(ent1);
if(ent2>0 && IsValidEntity(ent2) && IsValidEdict(ent2))
{
AcceptEntityInput(ent2, “break”);
RemoveEdict(ent2);
}
if(ent3>0 && IsValidEntity(ent3) && IsValidEdict(ent3))
{
AcceptEntityInput(ent3, “break”);
RemoveEdict(ent3);
}
}
ShowParticle(pos, “gas_explosion_pump”, 3.0);
new pointHurt = CreateEntityByName(“point_hurt”);
DispatchKeyValueFloat(pointHurt, “Damage”, damage);
DispatchKeyValueFloat(pointHurt, “DamageRadius”, radius);
DispatchKeyValue(pointHurt, “DamageDelay”, “0.0”);
DispatchSpawn(pointHurt);
TeleportEntity(pointHurt, pos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(pointHurt, “Hurt”);
CreateTimer(0.1, DeletePointHurt, pointHurt);
new push = CreateEntityByName(“point_push”);
DispatchKeyValueFloat (push, “magnitude”, force);
DispatchKeyValueFloat (push, “radius”, radius*1.0);
SetVariantString(“spawnflags 24”);
AcceptEntityInput(push, “AddOutput”);
DispatchSpawn(push);
TeleportEntity(push, pos, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(push, “Enable”);
CreateTimer(0.5, DeletePushForce, push);
//PushAway(pos, force, radius);
return;
}
public PrecacheParticle(String:particlename[])
{
new particle = CreateEntityByName(“info_particle_system”);
if (IsValidEdict(particle))
{
DispatchKeyValue(particle, “effect_name”, particlename);
DispatchKeyValue(particle, “targetname”, “particle”);
DispatchSpawn(particle);
ActivateEntity(particle);
AcceptEntityInput(particle, “start”);
CreateTimer(0.01, DeleteParticles, particle);
}
}
public Action:DeleteParticles(Handle:timer, any:particle)
{
if (particle> 0 && IsValidEntity(particle) && IsValidEdict(particle))
{
decl String:classname[64];
GetEdictClassname(particle, classname, sizeof(classname));
if (StrEqual(classname, “info_particle_system”, false))
{
AcceptEntityInput(particle, "stop");
AcceptEntityInput(particle, "kill");
RemoveEdict(particle);
}
}
}
public Action:DeletePushForce(Handle:timer, any:ent)
{
if (ent> 0 && IsValidEntity(ent) && IsValidEdict(ent))
{
decl String:classname[64];
GetEdictClassname(ent, classname, sizeof(classname));
if (StrEqual(classname, “point_push”, false))
{
AcceptEntityInput(ent, "Disable");
AcceptEntityInput(ent, "Kill");
RemoveEdict(ent);
}
}
}
public Action:DeletePointHurt(Handle:timer, any:ent)
{
if (ent> 0 && IsValidEntity(ent) && IsValidEdict(ent))
{
decl String:classname[64];
GetEdictClassname(ent, classname, sizeof(classname));
if (StrEqual(classname, “point_hurt”, false))
{
AcceptEntityInput(ent, "Kill");
RemoveEdict(ent);
}
}
}
public ShowParticle(Float:pos[3], String:particlename[], Float:time)
{
new particle = CreateEntityByName(“info_particle_system”);
if (IsValidEdict(particle))
{
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
DispatchKeyValue(particle, “effect_name”, particlename);
DispatchKeyValue(particle, “targetname”, “particle”);
DispatchSpawn(particle);
ActivateEntity(particle);
AcceptEntityInput(particle, “start”);
CreateTimer(time, DeleteParticles, particle);
}
}
public Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
ResetAllState();
gamestart=true;
return Plugin_Continue;
}
public Action:round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
gamestart=false;
}
ResetAllState()
{
MissilePlacePos0=0.0;
new Float:t=GetEngineTime();
for (new x = 0; x < MAXPLAYERS+1; x++)
{
UseTime[x]=t;
Bullet[x]=0;
Hooked[x]=false;
ShowMsg[x]=0;
PrintTime[x]=0.0;
}
}
public OnConfigExecuted()
{
ResetAllState();
Set();
}
Set()
{
}
public CvarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
Set();
}
public OnMapStart()
{
PrecacheModel(“models/props_junk/propanecanister001a.mdl”, true);
PrecacheModel(“models/props_junk/gascan001a.mdl”, true);
PrecacheParticle(“gas_explosion_pump”);
PrecacheParticle(“gas_explosion_main”);
PrecacheSound(SOUNDMISSILELOCK, true);
if(L4D2Version)
{
g_sprite = PrecacheModel(“materials/sprites/laserbeam.vmt”);
PrecacheModel(“models/missiles/f18_agm65maverick.mdl”);
PrecacheSound(SOUNDGRENADELAUNCHER, true);
PrecacheSound(SOUNDMISSILELAUNCHER2, true);
}
else
{
g_sprite = PrecacheModel(“materials/sprites/laser.vmt”);
PrecacheModel(“models/props_equipment/oxygentank01.mdl”);
PrecacheSound(SOUNDMISSILELAUNCHER, true);
}
}
public bool:DontHitSelf(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
return true;
}
public bool:DontHitSelfAndPlayer(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
else if(entity>0 && entity<=MaxClients)
{
if(IsClientInGame(entity))
{
return false;
}
}
return true;
}
public bool:DontHitSelfAndPlayerAndCI(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
else if(entity>0 && entity<=MaxClients)
{
if(IsClientInGame(entity))
{
return false;
}
}
else
{
if(IsValidEntity(entity) && IsValidEdict(entity))
{
decl String:edictname[128];
GetEdictClassname(entity, edictname, 128);
if(StrContains(edictname, “infected”)>=0)
{
return false;
}
}
}
return true;
}
public bool:DontHitSelfAndMissile(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
else if(entity > MaxClients)
{
if(IsValidEntity(entity) && IsValidEdict(entity))
{
decl String:edictname[128];
GetEdictClassname(entity, edictname, 128);
if(StrContains(edictname, “prop_dynamic”)>=0)
{
return false;
}
}
}
return true;
}
public bool:DontHitSelfAndSurvivor(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
else if(entity>0 && entity<=MaxClients)
{
if(IsClientInGame(entity) && GetClientTeam(entity)==2)
{
return false;
}
}
return true;
}
public bool:DontHitSelfAndInfected(entity, mask, any:data)
{
if(entity == data)
{
return false;
}
else if(entity>0 && entity<=MaxClients)
{
if(IsClientInGame(entity) && GetClientTeam(entity)==3)
{
return false;
}
}
return true;
}`