Raised This Month: $32 Target: $400
 8% 

missile_l4d.sp Missle Damage Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ricksfishin
Senior Member
Join Date: Oct 2017
Old 11-11-2018 , 22:03   missile_l4d.sp Missle Damage Help
Reply With Quote #1

No damage to survivors/players from missiles if possible. , coop only, Tried ontakedamage with no luck any help would be Appreciated.

PHP Code:
/* Plugin Template generated by Pawn Studio */

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <sdkhooks>

#define SOUNDMISSILELAUNCHER "physics/destruction/ExplosiveGasLeak.wav" 
#define SOUNDMISSILELAUNCHER2 "physics/destruction/explosivegasleak.wav"
#define SOUNDMISSILELOCK "UI/Beep07.wav" 

#define Missile_model_dummy "models/w_models/weapons/w_eq_molotov.mdl"
#define Missile_model "models/props_equipment/oxygentank01.mdl"
#define Missile_model2 "models/missiles/f18_agm65maverick.mdl"

#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 MissileTrace 1

new Handle:l4d_missile_radius ;
new 
Handle:l4d_missile_damage ;
new 
Handle:l4d_missile_damage_tosurvivor ;
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_radar_range ;

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_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 
Handle:l4d_missile_weapon_smg;
new 
Handle:l4d_missile_weapon_pistol;

new 
bool:gamestart=false;
 
new 
FloatLastUseTime[MAXPLAYERS+1];
new 
FloatLastTime[MAXPLAYERS+1];

new 
bool:Hooked[MAXPLAYERS+1];
new 
MissileCount[MAXPLAYERS+1];

new 
MissileEntity[MAXPLAYERS+1];
new 
MissileFlame[MAXPLAYERS+1];
new 
MissileOwner[MAXPLAYERS+1];
new 
MissileTeams[MAXPLAYERS+1];
new 
MissleModel[MAXPLAYERS+1];
new 
MissileType[MAXPLAYERS+1]; 
new 
MissileEnemy[MAXPLAYERS+1];
new 
Float:MissileScanTime[MAXPLAYERS+1];

new 
Float:PrintTime[MAXPLAYERS+1];
new 
ShowMsg[MAXPLAYERS+1];

new 
g_iVelocity ;
new 
L4D2Version;
new 
GameMode;
new 
g_sprite;

new 
Float:modeloffset=50.0//180.0 normal

new Float:missilespeed_trace=250.0;  
new 
Float:missilespeed_trace2=180.0;
new 
Float:missilespeed_normal=800.0//500
public Plugin:myinfo 
{
    
name "Missile",
    
author "Pan Xiaohai",
    
description "Missile , L4D & L4D2",
    
version "1.3",
    
url "<- URL ->"
}
 

public 
OnPluginStart()
{
 
     
l4d_missile_radius CreateConVar("l4d_missile_radius""200.0""missile explode radius"FCVAR_NOTIFY);
    
l4d_missile_damage CreateConVar("l4d_missile_damage""800.0""damage"FCVAR_NOTIFY);
    
l4d_missile_damage_tosurvivor CreateConVar("l4d_missile_damage_tosurvivor""0.0""damage"FCVAR_NOTIFY);
    
l4d_missile_push CreateConVar("l4d_missile_push""1200""push forece"FCVAR_NOTIFY);
    
    
l4d_missile_safe CreateConVar("l4d_missile_safe""1""0:normal , 1:less chance to hurt survivor"FCVAR_NOTIFY);

    
l4d_missile_infected_smoker CreateConVar("l4d_missile_infected_smoker""15.0""launch missile when smoker drag[0.0, 30.0]%"FCVAR_NOTIFY);
    
l4d_missile_infected_charger CreateConVar("l4d_missile_infected_charger""15.0""launch missile when charger charge[0.0, 30.0]%"FCVAR_NOTIFY);
    
l4d_missile_infected_spitter CreateConVar("l4d_missile_infected_spitter""15.0""spitter [0.0, 30.0]%"FCVAR_NOTIFY);
    
l4d_missile_infected_witch CreateConVar("l4d_missile_infected_witch""15.0""witch harasser[0.0, 30.0]%"FCVAR_NOTIFY);
     
l4d_missile_infected_tank_throw CreateConVar("l4d_missile_infected_tank_throw""20.0""[0.0, 30.0]%"FCVAR_NOTIFY);    
    
l4d_missile_infected_anti CreateConVar("l4d_missile_infected_anti""20.0""infected launch missile when survivor launch missile [0.0, 30.0]%"FCVAR_NOTIFY);    
    
    
l4d_missile_weapon_rifle CreateConVar("l4d_missile_weapon_rifle""1""enable or disable for rifle {0, 1}"FCVAR_NOTIFY);
    
l4d_missile_weapon_sniper CreateConVar("l4d_missile_weapon_sniper""1""enable or disable for  sniper {0, 1}"FCVAR_NOTIFY);
    
l4d_missile_weapon_shotgun CreateConVar("l4d_missile_weapon_shotgun""1""enable or disable for shotgun {0, 1}"FCVAR_NOTIFY);
    
l4d_missile_weapon_magnum  CreateConVar("l4d_missile_weapon_magnum""1""enable or disable for magnum {0, 1}"FCVAR_NOTIFY);    
    
l4d_missile_weapon_smg  CreateConVar("l4d_missile_weapon_smg""0""enable or disable for smg {0, 1}"FCVAR_NOTIFY);    
    
l4d_missile_weapon_pistol  CreateConVar("l4d_missile_weapon_pistol""0""enable or disable for pistol {0, 1}"FCVAR_NOTIFY);    

    
    
l4d_missile_limit CreateConVar("l4d_missile_limit""30""missile limit"FCVAR_NOTIFY);
     
l4d_missile_kills CreateConVar("l4d_missile_kills""10""how many kills reward a missile"FCVAR_NOTIFY);    
     
l4d_missile_tracefactor CreateConVar("l4d_missile_tracefactor""1.5""trace factor do not need change[0.5, 3.0]"FCVAR_NOTIFY);        
     
l4d_missile_radar_range CreateConVar("l4d_missile_radar_range""1500.0""radar scan range, missile do not lock on target if out of range [500.0, -]"FCVAR_NOTIFY);    
    
    
g_iVelocity FindSendPropInfo("CBasePlayer""m_vecVelocity[0]");
    
    
decl String:GameName[16];
    
GetConVarString(FindConVar("mp_gamemode"), GameNamesizeof(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(GameNamesizeof(GameName));
    if (
StrEqual(GameName"left4dead2"false))
    {
        
L4D2Version=true;
    }    
    else
    {
        
L4D2Version=false;
    }

    
AutoExecConfig(true"l4d_missile"); 
    
    if( 
GameMode!=2)
    { 
        
RegConsoleCmd("sm_miss"MissileHelp);    
        
        
HookEvent("player_death"player_death);
        
HookEvent("infected_death"Event_InfectedDeath);    
     
        
HookEvent("weapon_fire"weapon_fire); 
        
        
HookEvent("round_start"round_start);
        
HookEvent("round_end"round_end); 
        
HookEvent("map_transition"round_end);
        
        if(
L4D2VersionHookEvent("charger_charge_start"charger_charge_start);
        
HookEvent("tongue_grab"tongue_grab);
        
HookEvent("witch_harasser_set"witch_harasser_set);
        
HookEvent("ability_use"ability_use);
     
        
ResetAllState();
        
Set();
        
gamestart=false;
    }
    
    
}
public 
Action:MissileHelp(client,args)
{
    
PrintToChat(client"[MISS] For every %d killed infected you get 1 missile."GetConVarInt(l4d_missile_kills));
    
PrintToChat(client"[MISS] Miss1 = Gren. Launcher, Press USE and shoot");
    
PrintToChat(client"[MISS] Miss2 = Automatic Tracking Missile. DUCK and press USE while firing");
}
public 
Action:ability_use(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:s[20];
    
GetEventString(event"ability"s32);
    if(
StrEqual(s"ability_spit"true))
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if( 
MissileEntity[client]==&& GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_spitter) )
        {
            
LaunchMissile(clientmissilespeed_trace2MissileTrace,  true30.0);
        }
    }
    else if(
StrEqual(s"ability_throw"true))
    {
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        if(!
Hooked[client] && GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_tank_throw) )
        {
            
LaunchMissile(client,missilespeed_trace2MissileTrace,  true30.0);
        }        
    }

}
public 
Action:witch_harasser_set(Handle:hEvent, const String:strName[], bool:DontBroadcast)

    if(
GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_witch) )
    {
        
CreateTimer(GetRandomFloat(0.10.5), InfectedAntiMissile0);
    }
}
 
public 
Action:charger_charge_start(Handle:event, const String:name[], bool:dontBroadcast)
{     
     new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
Hooked[client] && GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_charger))
    {
        
LaunchMissile(clientmissilespeed_trace2MissileTracetrue30.0);
    }
}
public 
Action:tongue_grab(Handle:event, const String:name[], bool:dontBroadcast)
{     
     new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
Hooked[client] && GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_smoker))
    {
        
LaunchMissile(clientmissilespeed_trace2MissileTracetrue30.0);
    }
}
 public 
Action:weapon_fire(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
gamestart==false)return;
     new 
client GetClientOfUserId(GetEventInt(event"userid"));
     
    if(
GetClientTeam(client)==2)
    {
        if(
GetClientButtons(client) & IN_USE)
        {
            new 
Float:time=GetEngineTime();
            if( 
time-LastUseTime[client]>1.0)
            {
                
LastUseTime[client]=time
                new 
bool:ok=false;
                
decl String:item[65];
                
GetEventString(event"weapon"item65);    
                if(
GetConVarInt(l4d_missile_weapon_shotgun)>&& StrContains(item"shot")>=)ok=true;
                else if(
GetConVarInt(l4d_missile_weapon_sniper)>&& (StrContains(item"sniper")>=|| StrContains(item"hunting")>=0))ok=true;    
                else if(
GetConVarInt(l4d_missile_weapon_rifle)>&& StrContains(item"rifle")>=)ok=true;                     
                else if(
GetConVarInt(l4d_missile_weapon_magnum)>&& StrContains(item"magnum")>=)ok=true;
                else if(
GetConVarInt(l4d_missile_weapon_pistol)>&& StrContains(item"pistol")>=)ok=true;    
                else if(
GetConVarInt(l4d_missile_weapon_smg)>&& StrContains(item"smg")>=)ok=true;    
                if(
ok)
                {
                 
                    new 
type=MissileNormal;
                    if(
GetClientButtons(client) & IN_DUCK)type=MissileTrace
                    
StartMissile(clienttimetype);
                }
            }
        }
         
    }
    else
    {
        
//PrintToChatAll("%N use %s", client, name);
    
}
}
public 
Action:InfectedAntiMissile(Handle:timerany:ent)
{
    new 
selected=0;
    
decl andidate[MAXPLAYERS+1];
    new 
index=0;
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client)==InfectedTeam && !Hooked[client])
        {
            
andidate[index++]=client;
        }
    }
    if(
index>0)
    {
        
selected=GetRandomInt(0index-1);
        
LaunchMissile(andidate[selected], missilespeed_trace2MissileTracetrue30.0);
    }
 
}
new 
upgradekillcount[MAXPLAYERS+1];
new 
totalkillcount[MAXPLAYERS+1];
UpGrade(xkill)
{
     
upgradekillcount[x]+=kill;
    
totalkillcount[x]+=kill;
    new 
v=upgradekillcount[x]/GetConVarInt(l4d_missile_kills);
    
upgradekillcount[x]=upgradekillcount[x]%GetConVarInt(l4d_missile_kills);
    
MissileCount[x]+=v;
    if (
v>0
    {
        
PrintCenterText(x"Infected killed: %d"totalkillcount[x]);
        if(
MissileCount[x]>GetConVarInt(l4d_missile_limit))MissileCount[x]=GetConVarInt(l4d_missile_limit);
        
PrintHintText(x"+ Missile %d"MissileCount[x]);
        if(
ShowMsg[x]<3)
        {
            
PrintToChat(x"Type !miss in the chat to learn how to use missile"MissileCount[x]);
            
ShowMsg[x]++;
        }
        
    }
}
public 
Action:Event_InfectedDeath(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
 
    new 
attacker GetClientOfUserId(GetEventInt(hEvent"attacker"));
    if (
attacker<=0
    {
         return 
Plugin_Continue;
    }
    if(
IsClientInGame(attacker) )
    {
        if(
GetClientTeam(attacker) == 2)
        {
            
UpGrade(attacker1);
        }
    }
 
    return 
Plugin_Continue;
}
public 
Action:player_death(Handle:hEvent, const String:strName[], bool:DontBroadcast)
{
 
    new 
victim GetClientOfUserId(GetEventInt(hEvent"userid"));
     new 
attacker GetClientOfUserId(GetEventInt(hEvent"attacker"));
    if (
victim <= || attacker<=0
    {
         return 
Plugin_Continue;
    }
    if(
IsClientInGame(attacker) )
    {
        if(
GetClientTeam(attacker) == 2)
        {
            if(
IsClientInGame(victim))
            {
                if( 
GetClientTeam(victim) == )
                {
                    new 
bool:headshot=GetEventBool(hEvent"headshot");
                    if(
headshot)
                    {
                        
UpGrade(attacker5);
                    }
                    else
                    {
                        
UpGrade(attacker3);
                    }
                }
            }
        }
    }
    if(
victim>0)
    {
        
UnHookMissilevictim);
        
ResetClientState(victim);
    }
    return 
Plugin_Continue;
}

 
UnHookMissile(client)
{
    if(
client>&& Hooked[client])
    {
        if(
IsEntityMissileModel(MissleModel[client]))
        {
            
AcceptEntityInput(MissleModel[client], "kill");     
        }    
        if(
IsEntityMissile(MissileEntity[client]))
        {
            
AcceptEntityInput(MissileEntity[client], "kill");     
        }
        
SDKUnhook(clientSDKHook_PreThinkThinkMissile);
    }
    
Hooked[client]=false;
    
MissileEntity[client]=0;
    
MissleModel[client]=0;

bool:IsEntityMissile(ent)
{
    new 
bool:r=false;
    if(
ent>&& IsValidEdict(ent) && IsValidEntity(ent))
    {
        
decl String:g_classname[64];
        
GetEdictClassname(entg_classname64);    
        if( 
StrEqual(g_classname"molotov_projectile" ))
        {
            
r=true;
        }
    }
    return 
r;
}
bool:IsEntityMissileModel(ent)
{
    new 
bool:r=false;
    if(
ent>&& IsValidEdict(ent) && IsValidEntity(ent))
    { 
        
decl String:g_classname[64];
        
GetEdictClassname(entg_classname64);    
        if(
StrEqual(g_classname"prop_dynamic_override"true) )
        {
            
r=true;
        }
    }
    return 
r;
}

StartMissile(clientFloat:timetype=MissileTrace)
{  
    
time+=0.0;
    if(
MissileCount[client]-1>=0)
    { 
        new 
bool:ok;
        if(
type==MissileNormal)    ok=LaunchMissile(clientmissilespeed_normaltypefalse15.0);
        else 
ok=LaunchMissile(clientmissilespeed_tracetypefalse15.0);
        if(
ok && GetRandomFloat(0.0100.0)<GetConVarFloat(l4d_missile_infected_anti) )
        {
            
CreateTimer(GetRandomFloat(0.11.0), InfectedAntiMissile0TIMER_FLAG_NO_MAPCHANGE);
        }
    }
    else
    {
        
PrintHintText(client"not enough missile");
    } 
}

bool:LaunchMissile(clientFloat:forcetype=MissileTracebool:up=falseFloat:offset)
{
    if(
Hooked[client])UnHookMissile(client);
    
    
decl Float:pos[3];
    
decl Float:angles[3];
    
decl Float:velocity[3];
    
GetClientEyePosition(clientpos); 
    
GetClientEyeAngles(clientangles);
    if(
up && true)
    {
        
angles[1]=-90.0;
        
angles[0]=-90.0;
        
angles[2]=0.0;
         
    } 
    
    
GetAngleVectors(anglesvelocityNULL_VECTORNULL_VECTOR);
    
NormalizeVector(velocityvelocity);
    
ScaleVector(velocityforce); 
    {
        
decl Float:vec[3];
        
GetAngleVectors(angles,vecNULL_VECTORNULL_VECTOR); 
        
NormalizeVector(vec,vec); 
        
ScaleVector(vecoffset);
         
AddVectors(posvecpos);
    }
     
    new 
Float:temp[3];
    new 
Float:dis=CalRay(posangles0.00.0tempclientfalseFilterSelf);

    if(
dis<150.0)
    {
        
PrintHintText(client"Not enough space to launch");
        return 
false;
    }
 
    new 
bool:ok=CreateMissile(client,type,  posvelocityangles); 
    if( !
ok )    return false;
    
SetEntPropFloat(MissileEntity[client], Prop_Send"m_fadeMaxDist"client*1.0);  
    
    
MissileEnemy[client]=0;
    
MissileType[client]=type;
    
MissileTeams[client]=GetClientTeam(client); 
    
MissileOwner[client]=client;
    
LastTime[client]=0.0;
    
MissileScanTime[client]=0.0;
    
MissileCount[client]=MissileCount[client]-1;
    
Hooked[client]=true;
    
PrintTime[client]=0.0;
    
    
SDKUnhook(clientSDKHook_PreThinkThinkMissile);
    
SDKHook(clientSDKHook_PreThinkThinkMissile); 
    
    if(
L4D2Version)    EmitSoundToAll(SOUNDMISSILELAUNCHER20SNDCHAN_WEAPONSNDLEVEL_TRAFFICSND_NOFLAGSSNDVOL_NORMAL100_posNULL_VECTORfalse0.0);    
    else 
EmitSoundToAll(SOUNDMISSILELAUNCHER0SNDCHAN_WEAPONSNDLEVEL_TRAFFICSND_NOFLAGSSNDVOL_NORMAL100_posNULL_VECTORfalse0.0);    
    
PrintHintText(client"Missile %d"MissileCount[client]);
    if(
GetClientTeam(client)==3)PrintToChatAll("\x04%N \x03Launched Missile"client);
    return 
true;
}
bool:CreateMissileclienttype,  Float:pos[3], Float:vol[3], Float:ang[3])
{     
    new 
ok=false;
     
type=type+0;
    new 
ent=CreateEntityByName("molotov_projectile");  
    if(
ent>0)DispatchKeyValue(ent"model"Missile_model_dummy);  
    
decl Float:ang1[3];
    if(
ent>0)
    {
        
SetEntPropEnt(entProp_Data"m_hOwnerEntity", -1)    ;     
        
CopyVector(angang1);
        
ScaleVector(vol 1.0);
        if(!
L4D2Version)ang1[0]-=90.0
        
DispatchKeyValueVector(ent"origin"pos); 
        
//if(type==MissileNormal)SetEntityGravity(ent, 1.0); 
        //else SetEntityGravity(ent, 0.01); 
        
SetEntityGravity(ent0.01); 
        
DispatchSpawn(ent);  
        
ok=true;
    }
    else 
ok=false
    new 
ment=0;
    if(
ok)
    {
        
ment=CreateEntityByName("prop_dynamic_override");
        if(
ment>&& ok)
        {
            new 
String:tname[20];
            
Format(tname20"missile%d"ent);
            
DispatchKeyValue(ent"targetname"tname);
            if(
L4D2Version)
            {
                
DispatchKeyValue(ment"model"Missile_model2);  
                
            }
            else     
DispatchKeyValue(ment"model"Missile_model);  
            
DispatchKeyValue(ment"parentname"tname);  
             
            
decl Float:ang2[3]; 
            
decl Float:offset[3];
            
SetVector(offset0.00.080.0);
            
            
            
NormalizeVector(offsetoffset);
            
ScaleVector(offset, -0.0);
            
            
AddVectors(posoffsetpos); 
         
            
CopyVector(angang2);
            if(
L4D2Version)
            {
                
SetVector(ang20.00.0,0.0);
            }
            else
            {
                
SetVector(ang20.00.0, -180.0);
            }
            
//ang2[1]+=180.0;
            
DispatchKeyValueVector(ment"Angles"ang2); 
            
DispatchKeyValueVector(ment"origin"pos);
 
            
            
SetVariantString(tname);
            
AcceptEntityInput(ment"SetParent",mentment0);
            
            
DispatchSpawn(ment);  
            
DispatchKeyValueVector(ent"Angles"ang1);
            
TeleportEntity(entNULL_VECTORNULL_VECTORvol);
    
            
DispatchKeyValueFloat(ment"fademindist"10000.0);
            
DispatchKeyValueFloat(ment"fademaxdist"20000.0);
            
DispatchKeyValueFloat(ment"fadescale"0.0); 
            if(
L4D2Version)
            {
                
SetEntPropFloat(mentProp_Send,"m_flModelScale",0.5);
            }
            
AttachFlame(clientment);
        }
        else 
ok=false;
    }
    if(!
ok)
    {
        
ent=0;
        
ment=0;    
        
MissleModel[client]=ment;
        
MissileEntity[client]=ent;    
        return 
false;
    }
     
    
SetEntityMoveType(entMOVETYPE_NOCLIP); 
    
SetEntityMoveType(mentMOVETYPE_NOCLIP); 
    
//IgniteEntity(ent, 0.0);
 
    //SetEntProp(ent, Prop_Data, "m_CollisionGroup", 0);
    //SetEntProp(ment, Prop_Data, "m_CollisionGroup", 0);
    //SetEntProp(ent, Prop_Data, "m_MoveCollide", 0);
    //SetEntProp(ment, Prop_Data, "m_MoveCollide", 0);     
 
    
MissleModel[client]=ment;
    
MissileEntity[client]=ent;    
    return 
true;

AttachFlameclientent )

    
decl String:flame_name[128];
    
Format(flame_namesizeof(flame_name), "target%d"ent);
     
    new 
Float:origin[3];
    
SetVector(origin,  0.00.0,  0.0);
    
decl Float:ang[3];
    if(
L4D2Version)    SetVector(ang0.0180.00.0); 
    else 
SetVector(ang90.00.00.0); 
  
     
    new 
flame3 CreateEntityByName("env_steam");
    
DispatchKeyValueent,"targetname"flame_name);
    
DispatchKeyValue(flame3,"SpawnFlags""1");
    
DispatchKeyValue(flame3,"Type""0");
    
DispatchKeyValue(flame3,"InitialState""1");
    
DispatchKeyValue(flame3,"Spreadspeed""10");
    
DispatchKeyValue(flame3,"Speed""350");
    
DispatchKeyValue(flame3,"Startsize""5");
    
DispatchKeyValue(flame3,"EndSize""10");
    
DispatchKeyValue(flame3,"Rate""555");
    
DispatchKeyValue(flame3,"RenderColor""0 160 55"); //"242 55 55"
    
DispatchKeyValue(flame3,"JetLength""50"); 
    
DispatchKeyValue(flame3,"RenderAmt""180");
    
    
DispatchSpawn(flame3);     
    
SetVariantString(flame_name);
    
AcceptEntityInput(flame3"SetParent"flame3flame30);
    
TeleportEntity(flame3originang,NULL_VECTOR);
    
AcceptEntityInput(flame3"TurnOn");    
    
    
MissileFlame[client]=flame3;
     
}
public 
ThinkMissile(client)

    
//if(IsEntityMissile(MissileEntity[client]) && IsEntityMissileModel(MissleModel[client]))
    
if(Hooked[client]==false)
    {
        
UnHookMissile(client);
        return;
    }
    if(
IsClientInGame(client))
    {
        new 
Float:time=GetEngineTime();
        new 
Float:duration=time-LastTime[client];
        
LastTime[client]=time;    
        if(
duration>0.1)duration=0.1;
        else if (
duration<0.01)duration=0.01;
        
        if(
MissileType[client]==MissileTrace)TraceMissile(client,  timeduration);
        else if(
MissileType[client]==MissileNormal)Missile(client,   duration);  
    }
    else
    {
        
UnHookMissile(client);
    }
         
}
TraceMissile(clientFloat:time,  Float:duration)
{
     
    
decl Float:posradar[3];
    
decl Float:posmissile[3];
    
decl Float:voffset[3];            
    
decl Float:velocitymissile[3];    
    new 
ent=MissileEntity[client];
    
GetClientEyePosition(clientposradar);
    
GetEntPropVector(entProp_Send"m_vecOrigin"posmissile);    
    
GetEntDataVector(entg_iVelocityvelocitymissile);
    
NormalizeVector(velocitymissilevelocitymissile);
    
    
CopyVector(velocitymissilevoffset);
    
ScaleVector(voffsetmodeloffset);
    
AddVectors(posmissilevoffsetposmissile);
    
    new 
myteam=MissileTeams[client];
    
    new 
enemyteam=myteam==SurvivorTeam?InfectedTeam:SurvivorTeam;
    new 
enemy=MissileEnemy[client];
    if(
time-MissileScanTime[client]>0.3)
    {
        
MissileScanTime[client]=time;
        
enemy=ScanEnemy(posmissileposradarvelocitymissileenemyteam);
        
//PrintToChatAll("%N scan %f enmey %d", client, time, enemy);
    

    else
    {
        if(
enemy>0)
        {
            if(
IsClientInGame(enemy) && IsPlayerAlive(enemy)){}
            else 
enemy=0;
        }
        else if(
enemy<0)
        {
            if(
Hooked[0-enemy]){}
            else 
enemy=0;
        }
    }
     
    
MissileEnemy[client]=enemy;
    

    
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=20.0;
    new 
bool:show=false;
    new 
bool:enemyismissile=false;
    if(
time-PrintTime[client]>0.2)
    {
        
PrintTime[client]=time;
        
show=true;
    } 
    new 
Float:speed=0.0;
    if(
myteam==SurvivorTeam)speed=missilespeed_trace;
    else 
speed=missilespeed_trace2;
    new 
Float:tracefactor=GetConVarFloat(l4d_missile_tracefactor);
    if(
enemy>0)    
    {
        
decl Float:posenemy[3];
        
GetClientEyePosition(enemyposenemy);
        
        
disenemy=GetVectorDistance(posmissileposenemy);
         
        
visible=IfTwoPosVisible(posmissileposenemyentmyteam);
            
        
//if(visible)PrintToChatAll("%N visible %f ", client, disenemy);    
        
GetEntDataVector(enemyg_iVelocityvelocityenemy);
 
        
ScaleVector(velocityenemyduration);

        
AddVectors(posenemyvelocityenemyposenemy);
        
MakeVectorFromPoints(posmissileposenemyvtrace);
        
//PrintToChatAll("%N lock %N D:%f", client,enemy, disenemy); 
        
        
if(show)
        {
            if(
enemy>&& IsClientInGame(enemy) && IsPlayerAlive(enemy))
            {
                if(
client && IsClientInGame(client) && IsPlayerAlive(client))    PrintHintText(enemy"Your are locked by %N's missile, Distance: %d"clientRoundFloat(disenemy) );
                else 
PrintHintText(enemy"Warning! Your are locked by enemy's missile, Distance: %d"RoundFloat(disenemy) );
                
EmitSoundToClient(enemySOUNDMISSILELOCK);
            }
            if(
client && IsClientInGame(client) && IsPlayerAlive(client))
            {
                if(
enemy>&& IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintCenterText(client"Missile Locked On: %N, Distance: %d"enemyRoundFloat(disenemy));
                else 
PrintCenterText(client"Missile Locked On: enemy, Distance: %d"RoundFloat(disenemy));
            }
        } 
     
    }
    else if(
enemy<0)
    {
        
enemy=-enemy
        
        
decl Float:posenemy[3];
        
GetEntPropVector(MissileEntity[enemy], Prop_Send"m_vecOrigin"posenemy);    
        
GetEntDataVector(MissileEntity[enemy], g_iVelocityvelocityenemy);
        
NormalizeVector(velocityenemyvelocityenemy);
        
        
CopyVector(velocityenemyvoffset);
        
ScaleVector(voffsetmodeloffset);
        
AddVectors(posenemyvoffsetposenemy);            

        
disenemy=GetVectorDistance(posmissileposenemy);            
        
visible=IfTwoPosVisible(posmissileposenemyMissleModel[enemy], MissileTeam);
        
ScaleVector(velocityenemyduration);
        
AddVectors(posenemyvelocityenemyposenemy);
        
MakeVectorFromPoints(posmissileposenemyvtrace);
        if(
show)
        {
            if(
client && IsClientInGame(client) && IsPlayerAlive(client))
            {
                if(
enemy>&& IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintCenterText(client"Missile Locked On %N's Missile, Distance: %d"enemyRoundFloat(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));
        
}
         
        
//disexploded=modeloffset;
        
enemyismissile=true;
        
//PrintToChatAll("lock missile distance  %f", distance);
 
    
}
    else if(
show)
    {
        if(
client>&& IsClientInGame(client) && IsPlayerAlive(client))PrintCenterText(client"Missile Have No target");
    }
    if(
enemy==&& myteam==)
    {
        
speed=missilespeed_trace2;
        new 
Float:range=GetConVarFloat(l4d_missile_radar_range);
        new 
Float:dis=GetVectorDistance(posmissile,posradar);
        
//if(dis>range)
        
{      
            
decl Float:posenemy[3];
            
CopyVector(posradarposenemy);             
            
disenemy=dis;     
            
MakeVectorFromPoints(posmissileposenemyvtrace);
        }
         
    }
 
    
////////////////////////////////////////////////////////////////////////////////////
    
GetVectorAngles(velocitymissilemissionangle);
 
    
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(posmissilemissionangle0.00.0vfrontself, print, flag);
        print=
false;
        
disobstacle=CalRay(posmissilemissionangle0.00.0vfrontself, print, FilterSelf);
         
        new 
Float:down=CalRay(posmissilemissionangle90.00.0vdownself, print,  flag);
        new 
Float:up=CalRay(posmissilemissionangle, -90.00.0vupself, print);
        new 
Float:left=CalRay(posmissilemissionangle0.090.0vleftself, print, flag);
        new 
Float:right=CalRay(posmissilemissionangle0.0, -90.0vrightself, print, flag);
        
        new 
Float:f1=CalRay(posmissilemissionangle30.00.0vv1self, print, flag);
        new 
Float:f2=CalRay(posmissilemissionangle30.045.0vv2self, print, flag);
        new 
Float:f3=CalRay(posmissilemissionangle0.045.0vv3self, print, flag);
        new 
Float:f4=CalRay(posmissilemissionangle, -30.045.0vv4self, print, flag);
        new 
Float:f5=CalRay(posmissilemissionangle, -30.00.0vv5self, print,flag);
        new 
Float:f6=CalRay(posmissilemissionangle, -30.0, -45.0vv6self, print, flag);    
        new 
Float:f7=CalRay(posmissilemissionangle0.0, -45.0vv7self, print, flag);
        new 
Float:f8=CalRay(posmissilemissionangle30.0, -45.0vv8self, print, flag);                    
          
        
NormalizeVector(vfront,vfront);
        
NormalizeVector(vup,vup);
        
NormalizeVector(vdown,vdown);
        
NormalizeVector(vleft,vleft);
        
NormalizeVector(vright,vright);
        
NormalizeVector(vtracevtrace);

        
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>basefront=base;
        if(
up>baseup=base;
        if(
down>basedown=base;
        if(
left>baseleft=base;
        if(
right>baseright=base;
        
        if(
f1>basef1=base;    
        if(
f2>basef2=base;    
        if(
f3>basef3=base;    
        if(
f4>basef4=base;    
        if(
f5>basef5=base;    
        if(
f6>basef6=base;    
        if(
f7>basef7=base;    
        if(
f8>basef8=base;    
     
        new 
Float:b2=10.0;
        if(
front<b2front=b2;
        if(
up<b2up=b2;
        if(
down<b2down=b2;
        if(
left<b2left=b2;
        if(
right<b2right=b2;
          
        if(
f1<b2f1=b2;    
        if(
f2<b2f2=b2;    
        if(
f3<b2f3=b2;    
        if(
f4<b2f4=b2;    
        if(
f5<b2f5=b2;    
        if(
f6<b2f6=b2;    
        if(
f7<b2f7=b2;    
        if(
f8<b2f8=b2;        
 
        
t=-1.0*factor1*(base-front)/base;
        
ScaleVectorvfrontt);
        
        
t=-1.0*factor1*(base-up)/base;
        
ScaleVectorvupt);
        
        
t=-1.0*factor1*(base-down)/base;
        
ScaleVectorvdownt);
        
        
t=-1.0*factor1*(base-left)/base;
        
ScaleVectorvleftt);
        
        
t=-1.0*factor1*(base-right)/base;
        
ScaleVectorvrightt);
        
        
t=-1.0*factor1*(base-f1)/f1;
        
ScaleVectorvv1t);
        
        
t=-1.0*factor1*(base-f2)/f2;
        
ScaleVectorvv2t);
        
        
t=-1.0*factor1*(base-f3)/f3;
        
ScaleVectorvv3t);
        
        
t=-1.0*factor1*(base-f4)/f4;
        
ScaleVectorvv4t);
        
        
t=-1.0*factor1*(base-f5)/f5;
        
ScaleVectorvv5t);
        
        
t=-1.0*factor1*(base-f6)/f6;
        
ScaleVectorvv6t);
        
        
t=-1.0*factor1*(base-f7)/f7;
        
ScaleVectorvv7t);
        
        
t=-1.0*factor1*(base-f8)/f8;
        
ScaleVectorvv8t);
         
        if(
disenemy>=500.0)disenemy=500.0;
        
t=1.0*factor2*(1000.0-disenemy)/500.0;
        
ScaleVectorvtracet);                            

        
AddVectors(vfrontvupvfront);
        
AddVectors(vfrontvdownvfront);
        
AddVectors(vfrontvleftvfront);
        
AddVectors(vfrontvrightvfront);


        
AddVectors(vfrontvv1vfront);
        
AddVectors(vfrontvv2vfront);
        
AddVectors(vfrontvv3vfront);
        
AddVectors(vfrontvv4vfront);
        
AddVectors(vfrontvv5vfront);
        
AddVectors(vfrontvv6vfront);
        
AddVectors(vfrontvv7vfront);
        
AddVectors(vfrontvv8vfront);

        
        
AddVectors(vfrontvtracevfront);    
        
NormalizeVector(vfrontvfront);
    }
    
    new 
Float:a=GetAngle(vfrontvelocitymissile);             
    new 
Float:amax=3.14159*duration*tracefactor;
     
    if(
aamax )a=amax ;
    
    
ScaleVector(vfront ,a);
    
    
//PrintToChat(client, "max %f %f  ",amax , a);
    
decl Float:newvelocitymissile[3];
    
AddVectors(velocitymissilevfrontnewvelocitymissile);
    

    
ScaleVector(newvelocitymissile,speed); 
    
    
decl Float:angle[3];
    
GetVectorAngles(newvelocitymissile,  angle);
    if(!
L4D2Version)angle[0]-=90.0;
    
//DispatchKeyValueVector(ent , "Angles", angle);
    //DispatchKeyValueVector(MissleModel[client], "Angles", angle);    
    //return;
    
TeleportEntity(entNULL_VECTOR,  angle ,newvelocitymissile); 
     
    if(
disenemy<disexploded || disobstacle<disexploded)
    {
        new 
bool:hitenemy=false;
        if(
disenemy<150.0)hitenemy=true;
         
        if(
enemyismissile )
        {
            
MissileHitMissileMsg(clientenemyhitenemy);
            if(
hitenemy)
            {
                
MissileHit(enemy1);
                
UnHookMissile(enemy);
            }
        }
        else
        {
            
MissileHitPlayerMsg(clientenemyhitenemy);
        }
        
MissileHit(client);
        
UnHookMissile(client);
    }
     


Missile(clientFloat: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(entProp_Send"m_vecOrigin"missilepos);
    
GetEntDataVector(entg_iVelocityvelocitymissile);
    
NormalizeVector(velocitymissile,velocitymissile);
     
CopyVector(velocitymissilevoffset);
    
ScaleVector(voffsetmodeloffset);
    
AddVectors(missileposvoffsetmissilepos);

    
decl Float:temp[3];
    
GetVectorAngles(velocitymissilemissionangle);
    new 
Float:disenemy=CalRay(missileposmissionangle0.00.0tempMissileEntity[client], falseFilterSelf);
    
//PrintToChatAll("%f", disenemy); 
    
    
decl Float:angle[3];
    
GetVectorAngles(velocitymissile,  angle);
    if(!
L4D2Version)angle[0]-=90.0;
    
//DispatchKeyValueVector(ent , "Angles", angle);
  
    
DispatchKeyValueVector(ent"Angles"angle);
    if(
disenemy<20.0)
    {
        
MissileHit(client);
        
UnHookMissile(client);
    }
 
}
 
MissileHitMissileMsg(clientenemybool:hit=true)
{
    if(
hit)
    {
        if(
enemy>&& IsClientInGame(enemy))
        {
            if(
client&& IsClientInGame(client))PrintHintText(enemy"Your missile was intercepted by %N"client);
            else 
PrintHintText(enemy"Your missile was intercepted by enemy");
        }
        if(
client>&& IsClientInGame(client))
        {
            if(
enemy>&& IsClientInGame(enemy) && IsPlayerAlive(enemy))PrintHintText(client"You intercepted %N's missile"enemy);
            else 
PrintHintText(client"You intercepted enemy's missile");
        }
    }
    else
    {
        if(
client&& IsClientInGame(client))PrintHintText(client"Your Missile hit obstacle");
    }
}
MissileHitPlayerMsg(clientenemybool:hit)
{
    if(
hit)
    {
        if(
enemy>&& IsClientInGame(enemy) )
        {
            if(
client&& IsClientInGame(client))PrintHintText(enemy"You hitted by %N's missile"client);
            else 
PrintHintText(enemy"You hitted by enemy's missile");
        }
        if(
client>&& IsClientInGame(client))
        {
            if(
enemy>&& IsClientInGame(enemy))PrintHintText(client"Your missile hitted %N"enemy);
            else 
PrintHintText(client"Your missile hit obstacle");
        }
    }
    else
    {
        if(
client&& IsClientInGame(client))PrintHintText(client"Your Missile hit obstacle");
    }
}
MissileHit(clientnum=2)
{
 
    
//return;
    //if(IsEntityMissile(MissileEntity[client]))
    
{
          
        
decl Float:pos[3];
        
decl Float:voffset[3];    
        
GetEntPropVector(MissileEntity[client], Prop_Send"m_vecOrigin"pos);        
     
        
decl Float:velocitymissile[3];    
        
GetEntDataVector(MissileEntity[client], g_iVelocityvelocitymissile);
        
NormalizeVector(velocitymissilevelocitymissile);
    
        
CopyVector(velocitymissilevoffset);
        
ScaleVector(voffsetmodeloffset);
        
AddVectors(posvoffsetpos);
        
        new 
ent1=0;        
        new 
ent2=0;
        new 
ent3=0;
        {
            
ent1=CreateEntityByName("prop_physics"); 
            
DispatchKeyValue(ent1"model""models/props_junk/propanecanister001a.mdl"); 
            
DispatchSpawn(ent1); 
            
TeleportEntity(ent1posNULL_VECTORNULL_VECTOR);
            
ActivateEntity(ent1);
        }
        if(
num>1)
        {
            
ent2=CreateEntityByName("prop_physics");     
            
DispatchKeyValue(ent2"model""models/props_junk/propanecanister001a.mdl"); 
            
DispatchSpawn(ent2); 
            
TeleportEntity(ent2posNULL_VECTORNULL_VECTOR);
            
ActivateEntity(ent2);
        }
        if(
num>2)
        {
            
ent3=CreateEntityByName("prop_physics"); 
            
DispatchKeyValue(ent3"model""models/props_junk/propanecanister001a.mdl"); 
            
DispatchSpawn(ent3); 
            
TeleportEntity(ent3posNULL_VECTORNULL_VECTOR);
            
ActivateEntity(ent3);    
        }
        new 
Handle:h=CreateDataPack();        
        
WritePackCell(hent1);
        
WritePackCell(hent2);
        
WritePackCell(hent3);
  
        
WritePackFloat(hpos[0]);
        
WritePackFloat(hpos[1]);
        
WritePackFloat(hpos[2]);

        
        new 
Float:damage=0.0;
        if(
MissileTeams[client]==3)damage=GetConVarFloat(l4d_missile_damage_tosurvivor);
        else 
damage=GetConVarFloat(l4d_missile_damage);
        
        new 
Float:radius=GetConVarFloat(l4d_missile_radius);
        new 
Float:pushforce=GetConVarFloat(l4d_missile_push);        
        
        
        if(
GetConVarInt(l4d_missile_safe)==&& MissileTeams[client]==SurvivorTeam)
        {
            new 
Float:mindistance=GetSurvivorMinDistance(pos);
            if(
mindistance<radius)radius=mindistance;
        }         
        
WritePackFloat(hdamage);
        
WritePackFloat(hradius);
        
WritePackFloat(hpushforce);
        
        
ExplodeG(INVALID_HANDLEh);
        
        if(
MissileType[client]!=MissileTrace &&  IsClientInGame(client) && IsPlayerAlive(client))PrintCenterText(client"missile exploded");
    }
    
//UnHook(userid);
}
ScanEnemy(Float:missilePos[3], Float:radarPos[3], Float:vec[3], enemyteam)
{
    new 
Float:min=4.0;
    
decl Float:enmeyPos[3];
    
decl Float:dir[3];
    new 
Float:t;
    new 
selected=0;
    new 
bool:hasmissile=false;
    new 
Float:range=GetConVarFloat(l4d_missile_radar_range);
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            new 
bool:playerok=IsPlayerAlive(client) && GetClientTeam(client)==enemyteam;
            new 
bool:ismissile=Hooked[client] && MissileTeams[client]==enemyteam  ;
            if(
playerok || ismissile)
            {
                if(
ismissile)
                {
                    
GetEntPropVector(MissileEntity[client], Prop_Send"m_vecOrigin"enmeyPos);
                    if(
enemyteam==|| GetVectorDistance(enmeyPos,radarPos)<range)
                    {                    
                        if(!
hasmissile)min=4.0;
                        
hasmissile=true;
                        
                        
MakeVectorFromPoints(missilePosenmeyPosdir);
                        
t=GetAngle(vecdir);
                        if(
t<=min)
                        {
                            
min=t;
                            
selected=-client;
                        }
                    }
                }
                if(!
hasmissile && playerok)
                {
                    
GetClientEyePosition(clientenmeyPos);
                    if(
enemyteam==|| GetVectorDistance(enmeyPos,radarPos)<range)
                    {
                        
MakeVectorFromPoints(missilePosenmeyPos,  dir);
                        
t=GetAngle(vec,  dir);
                        
//PrintToChatAll("%N %f", client, 360.0*t/3.1415926/2.0);
                        
if(t<=min)
                        {
                            
min=t;
                            
selected=client;
                        }
                    }
                }
            }
        }
    }
    return 
selected;
}
Float:GetSurvivorMinDistance(Float:pos[3])
{
    new 
Float:min=99999.0;
    
decl Float:pos2[3];
    new 
Float:t;
    for(new 
client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client)==)
        {
            
GetClientEyePosition(clientpos2);
            
t=GetVectorDistance(pospos2);
            if(
t<=min)
            {
                
min=t;
            }
        }
    }
    return 
min;
}
bool:IfTwoPosVisible(Float:pos1[3], Float:pos2[3], selfteam=SurvivorTeam)
{
    new 
bool:r=true;
    new 
Handle:trace ;
    if(
team==SurvivorTeam)trace=TR_TraceRayFilterEx(pos2pos1MASK_SOLIDRayType_EndPointDontHitSelfAndInfected,self);
    else if(
team==InfectedTeam)trace=TR_TraceRayFilterEx(pos2pos1MASK_SOLIDRayType_EndPointDontHitSelfAndSurvivor,self);
    else 
trace=TR_TraceRayFilterEx(pos2pos1MASK_SOLIDRayType_EndPointDontHitSelfAndMissile,self);
    if(
TR_DidHit(trace))
    {
        
r=false;
    }
     
CloseHandle(trace);
    return 
r;
}
Float:CalRay(Float:posmissile[3], Float:angle[3], Float:offset1Float:offset2,   Float:force[3], entbool:printlaser=trueflag=FilterSelf
{
    

    
decl Float:ang[3];
    
CopyVector(angleang);
    
ang[0]+=offset1;
    
ang[1]+=offset2;
    
GetAngleVectors(angforceNULL_VECTOR,NULL_VECTOR);
    new 
Float:dis=GetRayDistance(posmissileangentflag) ;    
    if(
printlaser)ShowLarserByAngleAndDistance(posmissileangdis*0.5);
    
//PrintToChatAll("%f %f, %f", dis, offset1, offset2);
    
return dis;
}
ShowLarserByAngleAndDistance(Float:pos1[3], Float:angle[3], Float:disflag=0Float:life=0.06)
{
 
    new 
Float:pos2[3];
    
GetAngleVectors(anglepos2NULL_VECTOR,NULL_VECTOR);
    
NormalizeVector(pos2pos2);
    
ScaleVector(pos2dis);
    
AddVectors(pos1pos2pos2);
    
ShowLarserByPos(pos1pos2flaglife);    
 
}
ShowLarserByPos(Float:pos1[3], Float:pos2[3], flag=0Float: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(pos1pos2g_sprite000lifewidth1width210.0color0);
    
TE_SendToAll();
}
CopyVector(Float:source[3], Float:target[3])
{
    
target[0]=source[0];
    
target[1]=source[1];
    
target[2]=source[2];
}
SetVector(Float:target[3], Float:xFloat:yFloat:z)
{
    
target[0]=x;
    
target[1]=y;
    
target[2]=z;
}
Float:GetRayDistance(Float:pos[3], Floatangle[3], selfflag)
{
    
decl Float:hitpos[3];
    
GetRayHitPos(posanglehitposselfflag);
    return 
GetVectorDistancepos,  hitpos);
}
Float:GetAngle(Float:x1[3], Float:x2[3])
{
    return 
ArcCosine(GetVectorDotProduct(x1x2)/(GetVectorLength(x1)*GetVectorLength(x2)));
}
GetRayHitPos(Float:pos[3], Floatangle[3], Float:hitpos[3], selfflag)
{
    new 
Handle:trace ;
    new 
hit=0;
    if(
flag==FilterSelf)
    {
        
traceTR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteDontHitSelfself);
    }
    else if(
flag==FilterSelfAndPlayer)
    {
        
traceTR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteDontHitSelfAndPlayerself);
    }
    else if(
flag==FilterSelfAndSurvivor)
    {
        
traceTR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteDontHitSelfAndSurvivorself);
    }
    else if(
flag==FilterSelfAndInfected)
    {
        
traceTR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteDontHitSelfAndInfectedself);
    }
    else if(
flag==FilterSelfAndPlayerAndCI)
    {
        
traceTR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteDontHitSelfAndPlayerAndCIself);
    }
    if(
TR_DidHit(trace))
    {
            
        
TR_GetEndPosition(hitpostrace);
        
hit=TR_GetEntityIndextrace);
            
    }
    
CloseHandle(trace);
    return 
hit;
}


public 
Action:ExplodeG(Handle:timerHandle: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>&& IsValidEntity(ent1) && IsValidEdict(ent1))
    {
         
         
AcceptEntityInput(ent1"break");
        
AcceptEntityInput(ent1"kill");
         if(
ent2>&& IsValidEntity(ent2)  && IsValidEdict(ent2))
        {
            
AcceptEntityInput(ent2"break");
            
AcceptEntityInput(ent2"kill");
        }
         if(
ent3>&& IsValidEntity(ent3) && IsValidEdict(ent3))
        {
            
AcceptEntityInput(ent3"break");
            
AcceptEntityInput(ent3"kill");
        }

    }
     
    
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(pointHurtposNULL_VECTORNULL_VECTOR);  
    
AcceptEntityInput(pointHurt"Hurt");    
    
CreateTimer(0.1DeletePointHurtpointHurt); 

 
    new 
push CreateEntityByName("point_push");         
      
DispatchKeyValueFloat (push"magnitude"force);                     
    
DispatchKeyValueFloat (push"radius"radius*1.0);                     
      
SetVariantString("spawnflags 24");                     
    
AcceptEntityInput(push"AddOutput");
     
DispatchSpawn(push);   
    
TeleportEntity(pushposNULL_VECTORNULL_VECTOR);  
     
AcceptEntityInput(push"Enable");
    
CreateTimer(0.5DeletePushForcepush);
 
    
//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.01DeleteParticlesparticle);
 } 
}
public 
Action:DeleteParticles(Handle:timerany:particle)
{
     if (
particle&& IsValidEntity(particle) && IsValidEdict(particle))
     {
         
decl String:classname[64];
         
GetEdictClassname(particleclassnamesizeof(classname));
         if (
StrEqual(classname"info_particle_system"false))
            {
                
AcceptEntityInput(particle"stop");
                
AcceptEntityInput(particle"kill");
                
RemoveEdict(particle);
            }
     }
}
public 
Action:DeletePushForce(Handle:timerany:ent)
{
     if (
ent&& IsValidEntity(ent) && IsValidEdict(ent))
     {
         
decl String:classname[64];
         
GetEdictClassname(entclassnamesizeof(classname));
         if (
StrEqual(classname"point_push"false))
                {
                     
AcceptEntityInput(ent"Disable");
                    
AcceptEntityInput(ent"Kill"); 
                    
RemoveEdict(ent);
                }
     }
}
public 
Action:DeletePointHurt(Handle:timerany:ent)
{
     if (
ent&& IsValidEntity(ent) && IsValidEdict(ent))
     {
         
decl String:classname[64];
         
GetEdictClassname(entclassnamesizeof(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(particleposNULL_VECTORNULL_VECTOR);
        
DispatchKeyValue(particle"effect_name"particlename);
        
DispatchKeyValue(particle"targetname""particle");
        
DispatchSpawn(particle);
        
ActivateEntity(particle);
        
AcceptEntityInput(particle"start");
        
CreateTimer(timeDeleteParticlesparticle);
 } 
}
public 
Action:round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
ResetAllState(); 
    
gamestart=true;
}
public 
Action:round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    
UnHookAll();
    
ResetAllState(); 
    
gamestart=false;
}
ResetAllState()
{
    for (new 
1MAXPLAYERS+1x++)
    {
        
ResetClientState(x);
     }
}
ResetClientState(x)
{
    
LastUseTime[x]=0.0;
    
PrintTime[x]=0.0;
    
MissileCount[x]=1;
    
Hooked[x]=false;
    
ShowMsg[x]=0
    
MissileEntity[x]=0;
    
MissleModel[x]=0
    
MissileFlame[x]=0;
}
UnHookAll()
{
    for (new 
1MAXPLAYERS+1x++)
    {
        
UnHookMissile(x);
     }    
}
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(Missile_model_dummytrue);
    
PrecacheParticle("gas_explosion_pump"); 
    
PrecacheSound(SOUNDMISSILELOCKtrue);    
    if(
L4D2Version)
    {
        
PrecacheModel(Missile_modeltrue);
        
g_sprite PrecacheModel("materials/sprites/laserbeam.vmt");    
        
PrecacheSound(SOUNDMISSILELAUNCHER2true);    
    }
    else
    {
        
PrecacheModel(Missile_modeltrue);
        
g_sprite PrecacheModel("materials/sprites/laser.vmt");    
        
PrecacheSound(SOUNDMISSILELAUNCHERtrue);    
    }
    
ResetAllState();
    
gamestart=true
}
public 
bool:DontHitSelf(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    return 
true;
}
public 
bool:DontHitSelfAndPlayer(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
entity>&& entity<=MaxClients)
    {
        if(
IsClientInGame(entity))
        {
            return 
false;
        }
    }
    return 
true;
}
public 
bool:DontHitSelfAndPlayerAndCI(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
entity>&& entity<=MaxClients)
    {
        if(
IsClientInGame(entity))
        {
            return 
false;
        }
    }
    else
    {
        if(
IsValidEntity(entity) && IsValidEdict(entity))
        {
            
decl String:edictname[128];
            
GetEdictClassname(entityedictname128);
            if(
StrContains(edictname"infected")>=0)
            {
                return 
false;
            }
        }
    }
    return 
true;
}
public 
bool:DontHitSelfAndMissile(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
entity MaxClients)
    {
        if(
IsValidEntity(entity) && IsValidEdict(entity))
        {
            
decl String:edictname[128];
            
GetEdictClassname(entityedictname128);
            if(
StrContains(edictname"prop_dynamic")>=0)
            {
                return 
false;
            }
        }
        
    }
    return 
true;
}
public 
bool:DontHitSelfAndSurvivor(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
entity>&& entity<=MaxClients)
    {
        if(
IsClientInGame(entity) && GetClientTeam(entity)==2)
        {
            return 
false;
        }
    }
    return 
true;
}
public 
bool:DontHitSelfAndInfected(entitymaskany:data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
entity>&& entity<=MaxClients)
    {
        if(
IsClientInGame(entity) && GetClientTeam(entity)==3)
        {
            return 
false;
        }
    }
    return 
true;
}
PrintVector(String:s[], Float:target[3])
{
    
PrintToChatAll("%s - %f %f %f"starget[0], target[1], target[2]); 
}
showlaser(Float:pos1[3], Float:pos2[3])
{
    
        
decl color[4];
        
color[0] = 200
        
color[1] = 200;
        
color[2] = 200;
        
color[3] = 230;
        
        new 
Float:life=5.0;
        new 
Float:width1=1.0;
        new 
Float:width2=11.0;        
  
    
        
TE_SetupBeamPoints(pos1pos2g_sprite000lifewidth1width210.0color0);
        
TE_SendToAll();
}
showlaser2(Float:pos1[3], Float:vol[3], Float:length=200.0)
{
    
        
decl color[4];
        
color[0] = 200
        
color[1] = 200;
        
color[2] = 200;
        
color[3] = 230;
        
        new 
Float:life=5.0;
        new 
Float:width1=1.0;
        new 
Float:width2=11.0;        
        
        
decl Float:pos2[3];
        
decl Float:t[3];
        
CopyVector(volt);
        
NormalizeVector(tt);
        
ScaleVector(tlength);
        
AddVectors(pos1tpos2);
        
TE_SetupBeamPoints(pos1pos2g_sprite000lifewidth1width210.0color0);
        
TE_SendToAll();


Last edited by ricksfishin; 11-13-2018 at 14:21.
ricksfishin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-12-2018 , 16:51   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #2

Rather than posting a whole plugin. Replicate your issue with a small snippet.
__________________
Neuro Toxin is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 11-12-2018 , 17:38   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #3

Do not know how, Nor do i know what a snippet is sorry.

Last edited by ricksfishin; 11-13-2018 at 14:21.
ricksfishin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-13-2018 , 18:24   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #4

Original plugin: https://forums.alliedmods.net/showthread.php?p=1278437

ricksfishin, why just not change convar l4d_missile_damage_tosurvivor to zero.
I see you already done it by changing default value in plugin.
Is it not work?
Maybe, you forgot to change the same value in cfg file?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 11-13-2018 , 19:05   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #5

l4d_missile_damage_tosurvivor "0.0" -->cfg.
I also tried your post How to set SDKHook on round_start correctly?
using your script bout the closet i come to it working correctly

Tank would take damage but survivors would not get damage from tank or missle. or survivors would take damage from tank and missle. Tried other numbers on these GetClientTeam(victim) == 2 if (team == 2) etc. Thanks Dragokas hope that helps.

Last edited by ricksfishin; 11-13-2018 at 19:06.
ricksfishin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-13-2018 , 20:11   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #6

I didn't study that plugin but in most panxiaohai's plugins damage is not impersonated. So, you have to build correct filter in SDKHook callback function. Like, check inflictor, attacker and damage type.

Such way I did in his lethal plugin:
PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    if (
g_bBlockBlastDamage || g_bBlockFireDamage)
    {
        if (
inflictor == attacker && attacker MaxClients// not impersonated entity
        
{
            
// DMG_BLAST
            // DMG_BURN | DMG_PREVENT_PHYSICS_FORCE
            // DMG_DIRECT | DMG_PREVENT_PHYSICS_FORCE

            
if ((g_bBlockBlastDamage && damagetype == DMG_BLAST) || 
                (
g_bBlockFireDamage && (damagetype & (DMG_BURN DMG_DIRECT) != 0)))
            {
                if (
victim && victim <= MaxClients)
                {
                    return 
Plugin_Handled// block friendly fire on propanetank blast or fire
                
}
            }
        }
    }
    return 
Plugin_Continue;

You need something similar.

Use damage info plugin (attached below) to see all incoming parameters to find out what concrete condition to build.

=========
Although, it's better to see is it possible to disable damage without using SDKCall.
Like print and ensure correct convar values. Try to set 0.1 instead of 0 and so.
Attached Files
File Type: sp Get Plugin or Get Source (damageinfo.sp - 110 views - 5.5 KB)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 11-13-2018 , 22:03   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #7

Here is missile to tank, missile to bot,& recieved tank claw.

Attacking -- victim:5 | attacker:1 | inflictor:1 | dmg:53.31 | dmg type:-2147483646 | ammo type | hitbox:29 | hitgroup: 0
Damage given -- victim:5 | attacker:1 | inflictor:1 | dmg:53.31 | dmg type:-2147483646 | weapon ent:221 | force:859.34 | dmg pos:866.85
Send hurt event -- victim:5 | attacker:1 | hitgroup:0 | dmg:53 | dmg armor:0 | weapon:rifle_ak47
Attacking -- victim:5 | attacker:1 | inflictor:1 | dmg:53.31 | dmg type:-2147483646 | ammo type | hitbox:29 | hitgroup: 0
Damage given -- victim:5 | attacker:1 | inflictor:1 | dmg:53.31 | dmg type:-2147483646 | weapon ent:221 | force:859.34 | dmg pos:866.85
Damage given -- victim:5 | attacker:1 | inflictor:1 | dmg:53.37 | dmg type:-2147483646 | weapon ent:221 | force:863.32 | dmg pos:856.33
Damage taken -- victim:1 | attacker:0 | inflictor:0 | dmg:0.69 | dmg type2 | weapon ent:-1 | force:0.00 | dmg pos:0.00
Receive attack -- victim:1 | attacker:5 | inflictor:190 | dmg:24.00 | dmg type:128 | ammo type:-1 | hitbox:0 | hitgroup: 0
Damage taken -- victim:1 | attacker:5 | inflictor:190 | dmg:24.00 | dmg type:128 | weapon ent:-1 | force:5915.92 | dmg pos:-26.76
Receive attack -- victim:1 | attacker:5 | inflictor:190 | dmg:24.00 | dmg type:128 | ammo type:-1 | hitbox:0 | hitgroup: 0
Damage taken -- victim:1 | attacker:5 | inflictor:190 | dmg:24.00 | dmg type:128 | weapon ent:-1 | force:5915.92 | dmg pos:-26.76
Receive hurt event -- victim:1 | attacker:5 | hitgroup:0 | dmg:8 | dmg armor:0 | weapon:tank_claw
Attacking -- victim:6 | attacker:1 | inflictor:1 | dmg:57.28 | dmg type:-2147483646 | ammo type | hitbox:0 | hitgroup: 3
Damage given -- victim:6 | attacker:1 | inflictor:1 | dmg:71.60 | dmg type:-2147483646 | weapon ent:221 | force:-214.53 | dmg pos:250.41
Send hurt event -- victim:6 | attacker:1 | hitgroup | dmg:71 | dmg armor:0 | weapon:rifle_ak47
Attacking -- victim:6 | attacker:1 | inflictor:1 | dmg:57.28 | dmg type:-2147483646 | ammo type | hitbox:0 | hitgroup: 3
Damage given -- victim:6 | attacker:1 | inflictor:1 | dmg:71.60 | dmg type:-2147483646 | weapon ent:221 | force:-214.53 | dmg pos:250.41
0
Damage taken -- victim:1 | attacker:5 | inflictor:190 | dmg:24.00 | dmg type:128 | weapon ent:-1 | force:-5384.72 | dmg pos:72.71

With script above added to plugin I could not compile on spider compiler said not enough memory,
and web compiler got this

/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(182) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(190) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(190) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : warning 217: loose indentation
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : warning 215: expression has no effect
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : error 001: expected token: ";", but found ")"
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : error 029: invalid expression, assumed zero
/home/groups/sourcemod/upload_tmp/phpDNWxpH.sp(191) : fatal error 189: too many error messages on one line
Hope this helps to fix Thank you Dragokas.

Last edited by ricksfishin; 11-13-2018 at 22:08.
ricksfishin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-13-2018 , 22:38   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #8

Try this one:

(new con var "l4d_missile_ff")
Attached Files
File Type: sp Get Plugin or Get Source (missile_l4d.sp - 193 views - 49.5 KB)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 11-14-2018 , 00:18   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #9

Thank you Dragokas works great. But still deals a bit to much damage to survivors. other than that though all is working, will continue testing.
ricksfishin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-14-2018 , 07:20   Re: missile_l4d.sp Missle Damage Help
Reply With Quote #10

In what cases?
I noticed different damage when missile launched by ally and when launched by infected.
Do you use L4d or L4d2?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode