Page MenuHomeFeedback Tracker

"HandleDamage" being called at shooter side for unrelated reasons
New, NormalPublic

Description

HandleDamage event handler on units fires at shooter client for overall and HitHead damage for unrelated reasons: Overall damage call (hit_index = -1) is used to calculate bleeding and HitHead is used for something else I couldn't figure out. This weird HitHead event also gets *added* damage compared to *final* damage in all other event fires. Even more, it is called before HitPart which is also local to shooter. Here is RPT output from a test mission I made for this ticket:

21:39:25 ---------------------------------------------------------
21:39:25 "Frame 5641101: [[[ 2 ]]], HandleDamageVehicle: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","head",0.1,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","B_65x39_Caseless",2,"<NULL-object> ()","hithead",true]
21:39:25 "getBleedingRemaining _unit = 0"
21:39:25 ---------------------------------------------------------
21:39:25 "Frame 5641101: [[[ -1 ]]], HandleDamageVehicle: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","",0.302144,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","B_65x39_Caseless",-1,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","",true]
21:39:25 "getBleedingRemaining _unit = 0"
21:39:25 
21:39:25 #########################################################
21:39:25 "Frame 5641102: HitPart: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","10: tracer_red.p3d (B_65x39_Caseless)",[3536.04,7572.88,5.33965],[-28.0875,775.292,-182.54],["rightleg","hit_rightleg","hit_legs"],[10,0,0,0,"B_65x39_Caseless"],[-0.743263,-0.534084,0.402883],0.137528,"a3\data_f\penetration\meat.bisurf",true]
21:39:25 ---------------------------------------------------------
21:39:25 "Frame 5641102: [[[ -1 ]]], HandleDamageVehicle: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","",0.402144,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","B_65x39_Caseless",-1,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","",true]
21:39:25 "getBleedingRemaining _unit = 24.084"
21:39:25 ---------------------------------------------------------
21:39:25 "Frame 5641102: [[[ 10 ]]], HandleDamageVehicle: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","legs",0.589212,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","B_65x39_Caseless",10,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","hitlegs",true]
21:39:25 "getBleedingRemaining _unit = 24.084"
21:39:25 ---------------------------------------------------------
21:39:25 "Frame 5641102: [[[ 11 ]]], HandleDamageVehicle: B_Soldier_F"
21:39:25 ["B Alpha 1-1:2 (B_Soldier_F)","body",0.100001,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","B_65x39_Caseless",11,"B Alpha 1-1:1 (Sa-Matra) (B_Soldier_F)","incapacitated",true]
21:39:25 "getBleedingRemaining _unit = 24.084"

Test unit starts with setDamage 0.1, [[[ -1 ]]] highlight EH's hit index for easier reading. Notice that first overall damage fire had 0.302144 as damage argument, while in the next frame same hit part has 0.402144 (0.1 original + 0.302144 added). It seems that return number of this EH affects how much bleeding will be added to unit, no matter what you return, this isn't actual damage but just a number for bleeding

There is also second weird EH fire for HitHead [[[ 2 ]]] which doesn't actually set head damage, BUT will kill unit if returned value is >=1.01 (1 won't kill for some reason). I have no idea what this is for. It also doesn't provide projectile instigator.

The issue with bleeding is that it is applied only at shooter side, target side never ends up getting any bleeding. I also tested it in Alpha 0.50 and its there in same exact state, this whole system is ancient and not MP-compatible.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce

Better repro mission that logs HandleDamage to all units in the game and displays it on the screen (and some other values):


Repro mission:

EH fires logs observation:

  1. Run attached mission with 1 player
  2. Shoot AI in front of you once
  3. Open RPT and observe these weird HandleDamage fires before HitPart and one frame before real EHs.

Bleeding being local:

  1. Run attached mission with 2 players
  2. Have one player shoot another once
  3. Shooter: Observe getBleedingRemaining result above target being >0
  4. Target: Observe getBleedingRemaining result in hint being 0
Additional Information

All in all these HandleDamage fires are misleading and very annoying because they break usual engine behavior of HandleDamage of firing for all affected hit indexes from -1 to the last one, you end up with fires like 2,-1,-1,0,1,2,3.

Here are my proposed solutions:

  1. Figure out what this HitHead fake HandleDamage event is for and move it from HandleDamage elsewhere, its not real HandleDamage anyways.
  2. Bleeding needs to be moved to target side and made MP-compatible

a) Easier solution, use return of overall damage (-1) for bleeding in normal event fire, then broadcast it (at the end of frame in case several events fire)
b) Introduce new HandleBleeding event handler that gets added overall damage and returns amount of added bleeding, then broadcast final bleeding.

Event Timeline

SaMatra created this task.Oct 10 2023, 5:10 PM
SaMatra updated the task description. (Show Details)
jaj22 added a subscriber: jaj22.Oct 10 2023, 5:20 PM
SaMatra edited Steps To Reproduce. (Show Details)Nov 30 2023, 3:34 PM

Better repro mission:

SaMatra added a comment.EditedApr 25 2024, 2:31 PM

Since source for roadkill damage changed from being a driver to an actual vehicle, damage from physx objects is still unit itself.

v = createVehicle ["Land_ToiletBox_F", player modelToWorld [0,10,0]]; 
pos = getPos v; 
onEachFrame {v setPos pos; v setVelocity [0,100,0]}; 
u = group player createUnit [typeOf player, v, [], 0, "CAN_COLLIDE"];

Here is a repro script to kill a unit with PhysX object.

v = createVehicle ["C_Hatchback_01_F", player modelToWorld [0,10,0]]; 
pos = getPos v; 
onEachFrame {v setPos pos; v setVelocity [0,100,0]}; 
u = group player createUnit [typeOf player, v, [], 0, "CAN_COLLIDE"];

Same repro with a vehicle instead of object properly attributes the vehicle as damage source