ShadowRanger24 50 Posted October 8, 2016 So HandleDamage doesn't seem to be working very well for detecting headshots. It doesn't seem to pick up any hits on face_nub, neck etc. To test this I applied the following event handler to a unit: this addEventHandler ["HandleDamage", { _unit = _this select 0; _selectionName = _this select 1; _damage = _this select 2; _headshot = false; if ((_selectionName in ["face_hub", "neck", "head"]) && (_damage > 0.9)) then { _headshot = true; }; (format ["[HandleDamage] - %1 - %2 - Headshot: %3", _selectionName, _damage, _headshot]) remoteExec ["systemChat"]; _damage; }]; Output when shooting the unit in the head: [HandleDamage] - spine2 - 0.0282824 - Headshot: false [HandleDamage] - spine3 - 3.59421 - Headshot: false [HandleDamage] - body - 0 - Headshot: false [HandleDamage] - arms - 0.211573 - Headshot: false [HandleDamage] - hands - 0.0133059 - Headshot: false [HandleDamage] - - 0.444013 - Headshot: false Edit: Did some more testing, it's really weird how this event handler works. It seems to be detecting/registering head/face_hub/neck shots more often and properly with pistol shots compared to rifles. Share this post Link to post Share on other sites
xjoker_ 25 Posted October 9, 2016 I did some tests and sometimes the selection is "" when you get HS so i would add it _selectionName in ["face_hub", "neck", "head", ""] The problem is that this selection is used in other situations. So i would add _source = _this select 3; _projectile = _this select 4; And check if source isn't null, source isn't the player, and projectile isn't "FuelExplosion" Share this post Link to post Share on other sites
giallustio 770 Posted October 9, 2016 For every hit, handleDamage will fire several time. You need to store them all and check what's the higher value. "" usually is the final damage that will be applied, but a lot of time has passed since my last tests Share this post Link to post Share on other sites
ShadowRanger24 50 Posted October 10, 2016 Thanks for the help guys. Do you know of any examples of how to implement these checks? @giallustio I'm having a bit of trouble understanding how I would implement that. Could you please try and explain it to me or provide a small example or something? Thanks in advance. Share this post Link to post Share on other sites
.kju 3244 Posted October 10, 2016 Check: https://cdn.discordapp.com/attachments/184527246378139648/233308416376832000/testInfantryDamage.vr.7z More details here: https://forums.bistudio.com/topic/194918-release-vehicle-damage-and-armor-test-mission/ Share this post Link to post Share on other sites
Bnae 1431 Posted October 10, 2016 [] spawn { while {true} do { sleep 0.1; _damagehead= player getHit "head"; if (_damagehead > 0.9) then {_headshot = 1}; }; }; I used similiar for fullbody damage map layer. Share this post Link to post Share on other sites
ShadowRanger24 50 Posted October 13, 2016 Still having trouble with this. Can't seem to get it working properly. Any help please? Share this post Link to post Share on other sites
Bnae 1431 Posted October 13, 2016 I tried that what is on your first post and i got positive from every headshot. Just keep on mind that the original chat only shows certain amounts of lines so you have to open the chat and pageUp to see all the lines. 1 Share this post Link to post Share on other sites
ShadowRanger24 50 Posted October 14, 2016 Alright so I've managed to get this somewhat working. Only issue is, the code I have is making it so the unit will not die when hit anywhere that isn't the head. Not sure if I've missed something that might be causing this. fnc_getPartDamage = { params ["_unit", "_selection"]; _damage = 0; _index = _unit getVariable ["selections", []] find _selection; if (_index >= 0) then { _damage = (_unit getVariable "getHit") select _index; }; _damage }; player setVariable ["selections", []]; player setVariable ["getHit", []]; headshot = false; player addEventHandler ["HandleDamage", { _unit = _this select 0; _selection = _this select 1; _damage = _this select 2; _selections = _unit getVariable ["selections", []]; _getHit = _unit getVariable ["getHit", []]; if (!(_selection in _selections)) then { _selections set [count _selections, _selection]; _getHit set [count _getHit, 0]; }; _i = _selections find _selection; _getHit set [_i, _damage]; _criticalHit = (_selection in ["", "face_hub", "neck", "head", "pelvis", "spine1", "spine2", "spine3", "body"]); _fatalHit = (_damage >= 1 && alive _unit && _criticalHit); if (_fatalHit && !headshot) then { _headParts = ["face_hub", "head"]; { _partDamage = [_unit, _x] call fnc_getPartDamage; if (_partDamage > 0.9) exitWith {headshot = true}; } forEach _headParts; (format ["Headshot: %1", headshot]) remoteExec ["systemChat"]; }; _damage }]; Share this post Link to post Share on other sites