Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified addons/sourcemod/plugins/optional/l4d2_hittable_control.smx
Binary file not shown.
30 changes: 17 additions & 13 deletions addons/sourcemod/scripting/l4d2_hittable_control.sp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Plugin myinfo =
{
name = "L4D2 Hittable Control",
author = "Stabby, Visor, Sir, Derpduck, Forgetest",
version = "0.9.1",
version = "0.9.2",
description = "Allows for customisation of hittable damage values (and debugging)"
};

Expand Down Expand Up @@ -360,19 +360,20 @@ public void OnEntityCreated(int entity, const char[] classname)
}
}

public void OnEntityDestroyed(int entity)
{
if (entity > 0 && entity < MAX_EDICTS)
{
g_nPhysicsHitInfoEntry[entity] = -1;
}
}

void Physics_OnSpawnPost(int entity)
{
g_nPhysicsHitInfoEntry[entity] = -1;

int parent = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
if (parent != -1)
{
// In case the breakable parent was forced to
if (g_nPhysicsHitInfoEntry[parent] == -1)
{
g_nPhysicsHitInfoEntry[parent] = NewPhysicsHitInfo();
DebugMsg("Physics_OnSpawnPost (missing info from breakable parent#%d) [#%d]", parent, g_nPhysicsHitInfoEntry[parent]);
}

g_nPhysicsHitInfoEntry[entity] = g_nPhysicsHitInfoEntry[parent];
}
g_iPhysicsDamage[entity] = -1;
Expand All @@ -394,10 +395,10 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
if (!IsValidEdict(attacker))
return Plugin_Continue;

DebugMsg("(#%d) Physics_OnTakeDamage (attacker %d)", victim, attacker);

if (attacker > 0 && attacker <= MaxClients && IsTank(attacker))
{
DebugMsg("(#%d) Physics_OnTakeDamage tank (%N #%d)", victim, attacker, attacker);

// A tank punches me, create a new entry if not
if (g_nPhysicsHitInfoEntry[victim] == -1)
{
Expand All @@ -416,6 +417,8 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
}
else if (IsEntityClassname(attacker, "prop_physics*"))
{
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d)", victim, attacker);

// Collides with other physics, clone their hit info
if (g_nPhysicsHitInfoEntry[attacker] != -1)
{
Expand All @@ -438,7 +441,7 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
selfinfo.lastAttackerTime = GetGameTime();

g_PhysicsHitInfos.SetArray(g_nPhysicsHitInfoEntry[victim], selfinfo);
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d) [%d]", victim, g_nPhysicsHitInfoEntry[attacker], selfinfo.lastAttackerId);
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d) [lastAttackerId %d]", victim, g_nPhysicsHitInfoEntry[attacker], selfinfo.lastAttackerId);
}
}
else
Expand Down Expand Up @@ -597,7 +600,8 @@ Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, in
// Hey, we don't care.
if (!IsValidEdict(attacker)
|| !IsValidEdict(inflictor)
|| g_nPhysicsHitInfoEntry[inflictor] == -1)
|| g_nPhysicsHitInfoEntry[inflictor] == -1
|| !IsEntityClassname(inflictor, "prop_physics*"))
return Plugin_Continue;

if (IsTank(victim) && hTankSelfDamage.BoolValue)
Expand Down
Loading