Untitled

                Never    
C++
       
#include <sourcemod>  
#include <sdktools>  
#include sdkhooks  
   
#pragma tabsize 0  
   
float GrenadeDamage = 1000.0  
float PipeBombDamage = 1000.0  
float BarrelDamage = 1000.0  
   
float GrenadeRadius = 660.0  
float PipeRadius = 660.0  
float BarrelRadius = 660.0  
   
float GrenadeFling = 450.0  
float PipeFling = 450.0  
float BarrelFling = 450.0  
   
float RadiusFlingGrenade = 250.0  
float RadiusFlingPipe = 250.0  
float RadiusFlingBarrel = 250.0  
   
float ShakeGrenade = 880.0  
float ShakePipe = 880.0  
float ShakeBarrel = 880.0  
   
float PowerShakeG = 50.0  
float PowerShakeP = 50.0  
float PowerShakeB = 50.0  


Handle sdkCallPushPlayer;  
   
public OnPluginStart()  
{  
    Handle GameConf = LoadGameConfigFile("added_explosion-for-survivor");    
             
    if(GameConf == INVALID_HANDLE)  
    {  
        SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");  
    }  
         
    StartPrepSDKCall(SDKCall_Player);  
    PrepSDKCall_SetFromConf(GameConf, SDKConf_Signature, "CTerrorPlayer_Fling");  
    PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);  
    PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);  
    PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer);  
    PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);  
    sdkCallPushPlayer = EndPrepSDKCall();  
}  
   
bool IsAllow = false;  
   
public OnMapStart()  
{  
    IsAllow = false;  
    CreateTimer(3.0, allow)  
}  
   
public Action allow(Handle timer)  
{  
    IsAllow = true;  
}  
   
public void OnEntityDestroyed(int entity)  
{  
    if(!IsAllow) return;  
     
    if (IsValidEntity(entity) && IsValidEdict(entity))  
    {  
        char classname[128];  
        GetEdictClassname(entity, classname, 128);  
        if (StrEqual(classname, "grenade_launcher_projectile", false))  
        {  
            GrenadeTouch(entity);  
        }  
        if (StrEqual(classname, "pipe_bomb_projectile", false))  
        {  
            BombTouch(entity);  
        }  
        if (StrEqual(classname, "prop_fuel_barrel", false))  
        {  
            BarrelTouch(entity);  
        }  
    }  
}  
   
public int GrenadeTouch(int entity)  
{  
    float pos[3];  
    GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
    GranadeExplode(pos);  
}  
   
public int BombTouch(int entity)  
{  
    float pos[3];  
    GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
    BombExplode(pos)  
}  
   
public int BarrelTouch(int entity)  
{  
    float pos[3];  
    GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);  
    BarrelExplode(pos);  
}  
   
int GranadeExplode(float pos[3])  
{  
    float fDistance = 0.0;  
    float pos2[3];  
    for( int i = 0; i < 32; i++ )  
    {  
        if(IsValidClient(i) && GetClientTeam(i) == 2)  
        {  
            int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
            if(vClass == 9)  
            {  
                GetClientAbsOrigin(i, pos2);  
                fDistance = GetVectorDistance(pos, pos2);  
                if(fDistance < RadiusFlingGrenade && IsVisibleTo(pos, pos2))  
                {  
                    Fly(i, i, GrenadeFling)  
                }  
                if(fDistance < GrenadeRadius && IsVisibleTo(pos, pos2))  
                {  
                    float iOne = GrenadeRadius - fDistance  
                    float vForward = GrenadeRadius / iOne  
                    int iDamage = RoundToCeil(GrenadeDamage / (vForward * vForward * vForward))  
                    ForceDamageEntity(i, iDamage, i)
                }  
                if(fDistance < ShakeGrenade)  
                {  
                    float iOne = ShakeGrenade - fDistance  
                    float vForward = ShakeGrenade / iOne  
                    float iDamage = (PowerShakeG / (vForward * vForward * vForward)) * 1.0  
                    ScreenShake(i, iDamage)  
                }
            }  
        }  
    }  
}  
   
int BombExplode(float pos[3])  
{  
    float fDistance = 0.0;  
    float pos2[3];  
    for( int i = 0; i < 32; i++ )  
    {  
        if(IsValidClient(i) && GetClientTeam(i) == 2)  
        {  
            int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
            if(vClass == 9)  
            {  
                GetClientAbsOrigin(i, pos2);  
                fDistance = GetVectorDistance(pos, pos2);  
                if(fDistance < RadiusFlingPipe && IsVisibleTo(pos, pos2))  
                {  
                    Fly(i, i, PipeFling)  
                }  
                if(fDistance < PipeRadius && IsVisibleTo(pos, pos2))  
                {  
                    float iOne = PipeRadius - fDistance  
                    float vForward = PipeRadius / iOne  
                    int iDamage = RoundToCeil(PipeBombDamage / (vForward * vForward * vForward))  
                    ForceDamageEntity(i, iDamage, i)
                }  
                if(fDistance < ShakePipe)  
                {  
                    float iOne = ShakePipe - fDistance  
                    float vForward = ShakePipe / iOne  
                    float iDamage = (PowerShakeP / (vForward * vForward * vForward)) * 1.0  
                    ScreenShake(i, iDamage)  
                }
            }  
        }  
    }  
}  
   
int BarrelExplode(float pos[3])  
{  
    float fDistance = 0.0;  
    float pos2[3];  
    for( int i = 0; i < 32; i++ )  
    {  
        if(IsValidClient(i) && GetClientTeam(i) == 2)  
        {  
            int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")  
            if(vClass == 9)  
            {  
                GetClientAbsOrigin(i, pos2);  
                fDistance = GetVectorDistance(pos, pos2);  
                if(fDistance < RadiusFlingBarrel && IsVisibleTo(pos, pos2))  
                {  
                    Fly(i, i, BarrelFling)  
                }  
                if(fDistance < BarrelRadius && IsVisibleTo(pos, pos2))  
                {  
                    float iOne = BarrelRadius - fDistance  
                    float vForward = BarrelRadius / iOne  
                    int iDamage = RoundToCeil(BarrelDamage / (vForward * vForward * vForward))
                    ForceDamageEntity(i, iDamage, i)
                }  
                if(fDistance < ShakeBarrel)  
                {  
                    float iOne = ShakeBarrel - fDistance  
                    float vForward = ShakeBarrel / iOne  
                    float iDamage = (PowerShakeB / (vForward * vForward * vForward)) * 1.0  
                    ScreenShake(i, iDamage)
                   
                }
            }
        }  
    }  
}  
 
 
public Fly(explosion, int target, float power)  
{  
    if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target))  return;  
     
    float targetPos[3], explosionPos[3], traceVec[3], resultingFling[3];  
     
    GetEntPropVector(target, Prop_Data, "m_vecOrigin", targetPos);        
    GetEntPropVector(explosion, Prop_Data,"m_vecOrigin", explosionPos);  
     
    float fDistance = GetVectorDistance(targetPos, explosionPos)  
    float iOne = GrenadeRadius - fDistance  
    float iDamage = GrenadeRadius / iOne  
    power = (GrenadeDamage / (iDamage * iDamage * iDamage)) * 1.0  
    if(power < 1)  
        return;  
     
    MakeVectorFromPoints(explosionPos, targetPos, traceVec);  
    GetVectorAngles(traceVec, resultingFling);  
         
    resultingFling[0] = Cosine(DegToRad(resultingFling[1])) * power;  
    resultingFling[1] = Sine(DegToRad(resultingFling[1])) * power;  
    resultingFling[2] = power + (power * 0.5);  
    if (GetClientTeam(target) == 2)  
    {  
        SDKCall(sdkCallPushPlayer, target, resultingFling, 76, target, 2.0);  
    }  
    else  
    {  
        SDKCall(sdkCallPushPlayer, target, resultingFling, 2, target, 2.0);  
    }  
}  
   
public void ScreenShake(int target, float power)  
{  
    Handle msg;  
    msg = StartMessageOne("Shake", target);  
    BfWriteByte(msg, 0);  
    BfWriteFloat(msg, power);  
    BfWriteFloat(msg, 10.0);  
    BfWriteFloat(msg, 3.0);  
    EndMessage();  
}  
 
static bool IsVisibleTo(float position[3], float targetposition[3])  
{  
    float vAngles[3], vLookAt[3];  
     
    MakeVectorFromPoints(position, targetposition, vLookAt);
    GetVectorAngles(vLookAt, vAngles);
    Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter);  
     
    bool isVisible = false;  
    if (TR_DidHit(trace))  
    {  
        float vStart[3];  
        TR_GetEndPosition(vStart, trace);
        if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))  
        {  
            isVisible = true;
        }  
    }  
     
    return isVisible;  
}  

public bool _TraceFilter(int entity, int contentsMask)  
{  

}

stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达  
{  
    float victim_origin[3];  
    char rupture[32];  
    char damage_victim[32];  
    IntToString(damage, rupture, sizeof(rupture));  
    Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);  
    GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);  
    int entity = CreateEntityByName("point_hurt");  
    DispatchKeyValue(victim, "targetname", damage_victim);  
    DispatchKeyValue(entity, "DamageTarget", damage_victim);  
    DispatchKeyValue(entity, "Damage", rupture);  
    DispatchSpawn(entity);  
    TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);  
    AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);  
    DispatchKeyValue(entity, "classname", "point_hurt");  
    DispatchKeyValue(victim, "targetname", "null");  
    AcceptEntityInput(entity, "Kill");  
}  
   
stock bool IsValidClient(int client)  
{  
    if ( client < 1 || client > MaxClients ) return false;  
    if( !IsClientInGame(client)) return false;  
    if ( !IsPlayerAlive( client )) return false;  
    return true;  
}