@@ -140,7 +140,7 @@ public Plugin myinfo =
140140{
141141 name = " L4D2 Hittable Control" ,
142142 author = " Stabby, Visor, Sir, Derpduck, Forgetest" ,
143- version = " 0.9.1 " ,
143+ version = " 0.9.2 " ,
144144 description = " Allows for customisation of hittable damage values (and debugging)"
145145};
146146
@@ -360,19 +360,20 @@ 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-
371363void 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 {
370+ // In case the breakable parent was forced to
371+ if (g_nPhysicsHitInfoEntry [parent ] == - 1 )
372+ {
373+ g_nPhysicsHitInfoEntry [parent ] = NewPhysicsHitInfo ();
374+ DebugMsg (" Physics_OnSpawnPost (missing info from breakable parent#%d ) [#%d ]" , parent , g_nPhysicsHitInfoEntry [parent ]);
375+ }
376+
376377 g_nPhysicsHitInfoEntry [entity ] = g_nPhysicsHitInfoEntry [parent ];
377378 }
378379 g_iPhysicsDamage [entity ] = - 1 ;
@@ -394,10 +395,10 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
394395 if (! IsValidEdict (attacker ))
395396 return Plugin_Continue ;
396397
397- DebugMsg (" (#%d ) Physics_OnTakeDamage (attacker %d )" , victim , attacker );
398-
399398 if (attacker > 0 && attacker <= MaxClients && IsTank (attacker ))
400399 {
400+ DebugMsg (" (#%d ) Physics_OnTakeDamage tank (%N #%d )" , victim , attacker , attacker );
401+
401402 // A tank punches me, create a new entry if not
402403 if (g_nPhysicsHitInfoEntry [victim ] == - 1 )
403404 {
@@ -416,6 +417,8 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
416417 }
417418 else if (IsEntityClassname (attacker , " prop_physics*" ))
418419 {
420+ DebugMsg (" (#%d ) Physics_OnTakeDamage prop_physics (#%d )" , victim , attacker );
421+
419422 // Collides with other physics, clone their hit info
420423 if (g_nPhysicsHitInfoEntry [attacker ] != - 1 )
421424 {
@@ -438,7 +441,7 @@ Action Physics_OnTakeDamage(int victim, int &attacker, int &inflictor, float &da
438441 selfinfo .lastAttackerTime = GetGameTime ();
439442
440443 g_PhysicsHitInfos .SetArray (g_nPhysicsHitInfoEntry [victim ], selfinfo );
441- 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 );
442445 }
443446 }
444447 else
@@ -597,7 +600,8 @@ Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, in
597600 // Hey, we don't care.
598601 if (! IsValidEdict (attacker )
599602 || ! IsValidEdict (inflictor )
600- || g_nPhysicsHitInfoEntry [inflictor ] == - 1 )
603+ || g_nPhysicsHitInfoEntry [inflictor ] == - 1
604+ || ! IsEntityClassname (inflictor , " prop_physics*" ))
601605 return Plugin_Continue ;
602606
603607 if (IsTank (victim ) && hTankSelfDamage .BoolValue )
0 commit comments