Skip to content

Commit 7357d47

Browse files
committed
Fallback to classname check and remove OnEntityDestroyed
Change: - Added back the classname check in `OnTakeDamage`, and remove unnecessary resetting in `OnEntityDestroyed`. - Minor debug message changes.
1 parent d98de58 commit 7357d47

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

-22 Bytes
Binary file not shown.

addons/sourcemod/scripting/l4d2_hittable_control.sp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,10 @@ public void OnEntityCreated(int entity, const char[] classname)
360360
}
361361
}
362362

363-
public void OnEntityDestroyed(int entity)
364-
{
365-
if (entity > 0 && entity < MAX_EDICTS)
366-
{
367-
g_nPhysicsHitInfoEntry[entity] = -1;
368-
}
369-
}
370-
371363
void Physics_OnSpawnPost(int entity)
372364
{
365+
g_nPhysicsHitInfoEntry[entity] = -1;
366+
373367
int parent = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
374368
if (parent != -1)
375369
{
@@ -401,10 +395,10 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
401395
if (!IsValidEdict(attacker))
402396
return Plugin_Continue;
403397

404-
DebugMsg("(#%d) Physics_OnTakeDamage (attacker %d)", victim, attacker);
405-
406398
if (attacker > 0 && attacker <= MaxClients && IsTank(attacker))
407399
{
400+
DebugMsg("(#%d) Physics_OnTakeDamage tank (%N #%d)", victim, attacker, attacker);
401+
408402
// A tank punches me, create a new entry if not
409403
if (g_nPhysicsHitInfoEntry[victim] == -1)
410404
{
@@ -423,6 +417,8 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
423417
}
424418
else if (IsEntityClassname(attacker, "prop_physics*"))
425419
{
420+
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d)", victim, attacker);
421+
426422
// Collides with other physics, clone their hit info
427423
if (g_nPhysicsHitInfoEntry[attacker] != -1)
428424
{
@@ -445,7 +441,7 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
445441
selfinfo.lastAttackerTime = GetGameTime();
446442

447443
g_PhysicsHitInfos.SetArray(g_nPhysicsHitInfoEntry[victim], selfinfo);
448-
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d) [%d]", victim, g_nPhysicsHitInfoEntry[attacker], selfinfo.lastAttackerId);
444+
DebugMsg("(#%d) Physics_OnTakeDamage prop_physics (#%d) [lastAttackerId %d]", victim, g_nPhysicsHitInfoEntry[attacker], selfinfo.lastAttackerId);
449445
}
450446
}
451447
else
@@ -604,7 +600,8 @@ Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, in
604600
// Hey, we don't care.
605601
if (!IsValidEdict(attacker)
606602
|| !IsValidEdict(inflictor)
607-
|| g_nPhysicsHitInfoEntry[inflictor] == -1)
603+
|| g_nPhysicsHitInfoEntry[inflictor] == -1
604+
|| !IsEntityClassname(inflictor, "prop_physics*"))
608605
return Plugin_Continue;
609606

610607
if (IsTank(victim) && hTankSelfDamage.BoolValue)

0 commit comments

Comments
 (0)