I'm trying to fix this plugin, is it possible to block damage through walls?
Any tips
Spoiler
PHP Code:
public OnEntityDestroyed(entity)
{
if(entity <= 0 || !IsValidEntity(entity) || !IsValidEdict(entity)) // some checks to see if it is worth continuing
return;
decl String:EntityName[128];
if(!GetEdictClassname(entity, EntityName, sizeof(EntityName))) // getting the name of the destroyed entity and an extra check
return;
/* checks if the entity is an explosive */
if (StrEqual(EntityName, "prop_fuel_barrel", false) || StrEqual(EntityName, "pipe_bomb_projectile", false) || StrEqual(EntityName, "grenade_launcher_projectile", false))
{
decl Float:force;
if(StrEqual(EntityName, "grenade_launcher_projectile", false))
{
force = float(GetConVarInt(l4d2_grenade_detonation_force)); // getting the power for the grenade launcher
}
else
if(StrEqual(EntityName, "prop_fuel_barrel", false))
{
force = float(GetConVarInt(l4d2_barrel_detonation_force)); // getting the power for the fuel barrel
}
else
{
if(GetEntityFlags(entity) == 1)
{
force = float(GetConVarInt(l4d2_pipe_detonation_force)); // getting the power for the pipe bomb
}
else
{
force = float(GetConVarInt(l4d2_bomb_detonation_force)); // getting the power for the rest of the explosives
}
}
for (new client = 1; client <= MaxClients; client++)
{
Fly(entity, client, force); // checks if any client is affected by the explosion
}
}
}
public Fly(explosion, target, Float:power)
{
if(target <= 0 || !IsValidEntity(target) || !IsValidEdict(target)) // check if the taget is a valid entity
return;
power = power - GetVectorDistance(targetPos,explosionPos); // an easy way to define the explosion power, is the "base power" minus the distance between the target and the explosion
if(power < 1) // if the power is irrelevant, doesn't worth to continue
return;
/* for L4D 2 */
if (IsSurvivor(target))
{
if(GetConVarBool(l4d2_detonation_force_immunity_survivors))
{
DamageEffect(target, RoundToNearest(power * GetConVarFloat(l4d2_detonation_scale_damage_survivors))); // apply damage to the survivor
}
}
if (IsValidInfected(target))
{
if(GetConVarBool(l4d2_detonation_force_immunity_infected))
{
DamageEffect(target, RoundToNearest(power * GetConVarFloat(l4d2_detonation_scale_damage_infected))); // apply damage to the infected
}
}
if (IsValidTank(target))
{
if(GetConVarBool(l4d2_detonation_force_immunity_tank))
{
DamageEffect(target, RoundToNearest(power * GetConVarFloat(l4d2_detonation_scale_damage_tank))); // apply damage to the tank
}
}
}
MakeVectorFromPoints(position, targetposition, vLookAt); // compute vector from start to target
GetVectorAngles(vLookAt, vAngles); // get angles from vector for trace
new bool:isVisible = false;
if (TR_DidHit(trace))
{
decl Float:vStart[3];
TR_GetEndPosition(vStart, trace); // retrieve our trace endpoint
if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition))
{
isVisible = true; // if trace ray length plus tolerance equal or bigger absolute distance, you hit the target
}
}
else
{
LogError("Tracer Bug: Player-Zombie Trace did not hit anything, WTF");
isVisible = true;
}
CloseHandle(trace);
return isVisible;
}
public bool:_TraceFilter(entity, contentsMask)
{
if (!entity || entity <= MaxClients || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
{
return false;
}
return true;
}