Jump to content
nikiller

HandleDamage broken/changed since 1.54?

Recommended Posts

hi,

 

I have a script based on addEventHandler HandleDamage. It works fine in legacy 152 but not in 1.54. I guess it is related to the new "personal protective equipment".

_u = _this select 0;

_u addEventHandler ["HandleDamage", 
{ 
	private ["_return"];
	_unit = _this select 0; 
	_selection = _this select 1; 
	_passedDamage = _this select 2; 
	_source	= _this select 3; 
	_projectile = _this select 4; 
		
	_oldDamage = 0; 
		
	_bodyMultiplier = 1.01; 
	_legsMultiplier = 1; 
	_handsMultiplier = 1;
	_headMultiplier = 1.5;
	_overAllMultiplier = 1.05; 
		
	switch (_selection) do
	{ 
		case("head"):
		{
			_oldDamage = _unit getHitPointDamage "HitHead";
			_return = _oldDamage + ((_passedDamage - _oldDamage) * _headMultiplier); 
		}; 
		case("body"):
		{
			_oldDamage = _unit getHitPointDamage "HitBody";
			_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
		}; 
		case("hands"):
		{
			_oldDamage = _unit getHitPointDamage "HitHands";
			_return = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 
		}; 
		case("legs"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
		}; 
		case(""):
		{
			_oldDamage = damage _unit;
			_return = _oldDamage + ((_passedDamage - _oldDamage) * _overAllMultiplier); 
		}; 
		default{}; 
	}; 
		
	_return
}];

Then if you have a script based on handledamage I suggest you to check it. If you have a solution please post here.

 

Thank you.

 

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

There's new hitparts now:

["","neck","head","pelvis","spine1","spine2","spine3","body","hands","legs"]

(I think)

 

 

Share this post


Link to post
Share on other sites

oldDamage + passedDamage - oldDamage = passedDamage

I guess your script doesnt modify anything?

Share this post


Link to post
Share on other sites

oldDamage + passedDamage - oldDamage = passedDamage

I guess your script doesnt modify anything?

 

it's not 

oldDamage + passedDamage - oldDamage = passedDamage

but

_oldDamage = _unit getHitPointDamage "HitHands";
_return = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 

Test the script in 1.52 legacy before saying it doesn't work please. You obviously read the code too fast and didn't notice that getHitPointDamage was used.

Share this post


Link to post
Share on other sites

There's new hitparts now:

["","neck","head","pelvis","spine1","spine2","spine3","body","hands","legs"]

(I think)

 

Thanks Greenfist I will give it a try with the new hitparts.

Share this post


Link to post
Share on other sites

Thanks Greenfist I will give it a try with the new hitparts.

Sorry, those names were wrong; new ones are actually:

face_hub, neck, head, pelvis, spine1, spine2, spine3, body, arms, hands, legs, " "

Share this post


Link to post
Share on other sites

Sorry, those names were wrong; new ones are actually:

face_hub, neck, head, pelvis, spine1, spine2, spine3, body, arms, hands, legs, " "

 

I also noticed the new parts list with getAllHitPointsDamage . It is very precise now and that's very good!

 

here's a list with hit point and corresponding hit selection names

"face_hub" ==> "HitFace"
"neck" ==> "HitNeck"
"head" ==> "HitHead"
"pelvis" ==> "HitPelvis"
"spine1" ==> "HitAbdomen"
"spine2" ==> "HitDiaphragm"
"spine3" ==> "HitChest"
"body" ==> "HitBody"
"arms" ==> "HitArms"
"hands" ==> "HitHands"
"legs" ==> "HitLegs"

Many thanks greenfist!

 

solved.

 

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

it's not

oldDamage + passedDamage - oldDamage = passedDamage
but

_oldDamage = _unit getHitPointDamage "HitHands";_return = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier);
Test the script in 1.52 legacy before saying it doesn't work please. You obviously read the code too fast and didn't notice that getHitPointDamage was used.
oh i see it wrapped it on the new line for me. I really dont like this forum formatting so easy to overlook things.

Share this post


Link to post
Share on other sites

Anything u see wrong here guys?

// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
//	@file Name: FAR_HandleDamage_EH.sqf
//	@file Author: Farooq, AgentRev

#include "FAR_defines.sqf"
#include "gui_defines.hpp"

//private ["_unit", "_selection", "_damage", "_source", "_dead", "_killerVehicle", "_oldDamage"];

_unit = _this select 0;
//_selection = _this select 1;
//_damage = _this select 2;
_source = _this select 3;
_ammo = _this select 4;

_criticalHit = (_selection in ["","body","head"]);
_dead = (_damage >= 1 && alive _unit && _criticalHit);

// Find suspects
if (((_dead && !isNull _source) || (_criticalHit && UNCONSCIOUS(_unit))) && isNil {_unit getVariable "FAR_killerVehicle"}) then
{
	[_unit, _source, _ammo] call FAR_setKillerInfo;
};

if (UNCONSCIOUS(_unit)) then
{
	//if (_selection != "?") then
	//{
		_oldDamage = if (_selection == "") then { damage _unit } else { _unit getHit _selection };

		if (!isNil "_oldDamage") then
		{
			// Apply part of the damage without multiplier when below the stabilization threshold of 50% damage
			if (STABILIZED(_unit) && {_criticalHit && FAR_DamageMultiplier < 1}) then
			{
				_oldDamage = _damage min 0.5;
			};

			_damage = ((_damage - _oldDamage) * FAR_DamageMultiplier) + _oldDamage;

			if (_criticalHit) then
			{
				_unit setDamage _damage;
			};
		};

		if (_damage >= 1 && _criticalHit) then
		{
			diag_log format ["KILLED by [%1] with [%2]", _source, _ammo];
		};
	//};
}
else
{
	// Allow revive if unit is dead and not in exploded vehicle
	if (_dead && alive vehicle _unit) then
	{
		_unit setVariable ["FAR_isUnconscious", 1, true];
		[] spawn fn_deletePlayerData;

		_unit allowDamage false;
		//if (vehicle _unit == _unit) then { [_unit, "AinjPpneMstpSnonWrflDnon"] call switchMoveGlobal };
		_unit enableFatigue true;
		_unit setFatigue 1;

		if (!isNil "FAR_Player_Unconscious_thread" && {typeName FAR_Player_Unconscious_thread == "SCRIPT" && {!scriptDone FAR_Player_Unconscious_thread}}) then
		{
			terminate FAR_Player_Unconscious_thread;
		};

		closeDialog ReviveBlankGUI_IDD;
		closeDialog ReviveGUI_IDD;

		FAR_Player_Unconscious_thread = [_unit, _source] spawn FAR_Player_Unconscious;

		_damage = 0.5;

		diag_log format ["INCAPACITATED by [%1] with [%2]", _source, _ammo];
	};
};

//_damage

Problem is that before 1.54 patch, players were revivable* no matter where or how they got hit.  Now there is 50/50 chance to get instanly killed without gettin injured.
Iv been messing around with this issue since new patch came out but as non coder it seems i cant figure it out.

Share this post


Link to post
Share on other sites

Problem is that before 1.54 patch, players were revivable* no matter where or how they got hit.  Now there is 50/50 chance to get instanly killed without gettin injured.

Iv been messing around with this issue since new patch came out but as non coder it seems i cant figure it out.

 

Have the same problem with my own revive script.

 

The problem seems to be the "critital damage list": _criticalHit = (_selection in ["","body","head"]);

The script above (and my own) check for terminal damage in hit selections that can actually kill the player (dammage > 1 is possible for hands without killing the player for example). Now there are new selections that kill the player upon dammage >1 which are not checked by the revive scripts, for example "face_hub". Adding those to the list will probably fix the problem. Will confirm it on tuesday.

 

Probably "neck","Face_hub" and maybe "spineX" have to be added to that list.

 

Regarding the criticalHit-list see here: https://forums.bistudio.com/topic/146926-farooqs-revive/page-11#entry2895193

Share this post


Link to post
Share on other sites

Have the same problem with my own revive script.

 

The problem seems to be the "critital damage list": _criticalHit = (_selection in ["","body","head"]);

The script above (and my own) check for terminal damage in hit selections that can actually kill the player (dammage > 1 is possible for hands without killing the player for example). Now there are new selections that kill the player upon dammage >1 which are not checked by the revive scripts, for example "face_hub". Adding those to the list will probably fix the problem. Will confirm it on tuesday.

 

Probably "neck","Face_hub" and maybe "spineX" have to be added to that list.

 

Regarding the criticalHit-list see here: https://forums.bistudio.com/topic/146926-farooqs-revive/page-11#entry2895193

 

This is exactly one of the things what iv been trying, but i might have done something wrong there...

 

Original:   _criticalHit = (_selection in ["","body","head"]);

My Test:   _criticalHit = (_selection in ["neck","body","head","face_hub"]);      <-- i took these (neck, face_hub) from nikiller's post above. Didn't work    As u noticed i also removed first "".

Maybe i should take hit points from here: https://community.bistudio.com/wiki/getAllHitPointsDamage    <--No face_hub listed here.

This might help also: http://thezombieinfection.com/wiki/index.php/Arma_3_Hit_Point_Info

 

EDIT*   Did some runs and this seems to work:      _criticalHit = (_selection in ["","body","head","face_hub","neck","spine2","spine3"]);

If u guys have any suggestions or improvements i would be happy to hear.

Share this post


Link to post
Share on other sites

That is what I thought. You should also add "spine1" too.

And "" is the overall damage. Don't remove it from the list.

Share this post


Link to post
Share on other sites

My script is identical to OP's. I use it to reduce damage received but I can't get it to work even with the new hit parts list. Can someone post an example? Here's what I have but I may have done it totally wrong. Any input is appreciated - I've spent many hours trying to work this out

 

u1 = _this select 0;

u1 addEventHandler ["HandleDamage", 
{ 
	private ["_return"];
	_unit = _this select 0; 
	_selection = _this select 1; 
	_passedDamage = _this select 2; 
	_source	= _this select 3; 
	_projectile = _this select 4; 
		
	_oldDamage = 0; 
		
	_face_hubMultiplier = 0.30; 
	_neckMultiplier = 0.35; 
	_headMultiplier = 0.40;
	_pelvisMultiplier = 0.35;
	_spine1Multiplier = 0.35;
	_spine2Multiplier = 0.35;
	_spine3Multiplier = 0.35;
	_bodyMultiplier = 0.35;
	_armsMultiplier = 0.20;
	_handsMultiplier = 0.15;
	_legsMultiplier = 0.25;
	_overAllMultiplier = 0.30; 
		
	switch (_selection) do
	{ 
		case("HitFace"):
		{
			_oldDamage = _unit getHitPointDamage "HitHead";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _face_hubMultiplier); 
		}; 
		case("HitNeck"):
		{
			_oldDamage = _unit getHitPointDamage "HitBody";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _neckMultiplier); 
		}; 
		case("hitHead"):
		{
			_oldDamage = _unit getHitPointDamage "HitHands";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _headMultiplier); 
		}; 
		case("HitPelvis"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _pelvisMultiplier); 
		};
		case("HitAbdomen"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _spine1Multiplier); 
		}; 
		case("HitDiaphragm"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _spine2Multiplier); 
		};
		case("HitChest"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _spine3Multiplier); 
		};
		case("HitBody"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _bodyMultiplier); 
		};
		case("HitArms"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _armsMultiplier); 
		};
		case("HitHands"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _handsMultiplier); 
		};
		case("HitLegs"):
		{
			_oldDamage = _unit getHitPointDamage "HitLegs";
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _legsMultiplier); 
		};
		case(""):
		{
			_oldDamage = damage _unit;
			_return = _oldDamage + ((_passedDamage - 

_oldDamage) * _overAllMultiplier); 
		}; 
		default{}; 
	}; 
		
	_return
}];

Share this post


Link to post
Share on other sites

We just discovered that some community uniforms also return an unknown hit selection "?". It seems to be a hitpoint near the throat. Maybe add it too, as fallback.

Share this post


Link to post
Share on other sites

hi,

 

 

My script is identical to OP's. I use it to reduce damage received but I can't get it to work even with the new hit parts list. Can someone post an example? Here's what I have but I may have done it totally wrong. Any input is appreciated - I've spent many hours trying to work this out
 

 

You are using hit point instead of selection.

 

i.e for the legs you must use:


case("legs"):
{
     _oldDamage = _unit getHitPointDamage "HitLegs";
     _return = _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
};

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

hi,

 

 

You are using hit point instead of selection.

 

i.e for the legs you must use:


case("legs"):
{
     _oldDamage = _unit getHitPointDamage "HitLegs";
     _return = _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
};

cya.

 

Nikiller.

Hello,

Thanks for the help. I realized there were quite a few things wrong with what I posted with your help. Sadly, after fixing it, it still doesn't work at all. Prior to 1.54 this was a very simple thing to do. I'll keep searching for a solution.

Share this post


Link to post
Share on other sites

I think you forget possible case in your script that's why it doesn't work.

 

All those case must be covered or it won't work

"face_hub" ==> "HitFace"
"neck" ==> "HitNeck"
"head" ==> "HitHead"
"pelvis" ==> "HitPelvis"
"spine1" ==> "HitAbdomen"
"spine2" ==> "HitDiaphragm"
"spine3" ==> "HitChest"
"body" ==> "HitBody"
"arms" ==> "HitArms"
"hands" ==> "HitHands"
"legs" ==> "HitLegs"

This script should works give it a try null = [unitName] execVM "scriptName.sqf"

//v4

_u = _this select 0;

	_u addEventHandler ["HandleDamage", 
	{ 
		private ["_return"];
		_unit = _this select 0; 
		_selection = _this select 1; 
		_passedDamage = _this select 2; 
		_source	= _this select 3; 
		_projectile = _this select 4; 
		
		_oldDamage = 0; 
		
		_headMultiplier = 1;
		_neckMultiplier = 0.01;
		_bodyMultiplier = 0.01;
		_legsMultiplier = 0.001; 
		_handsMultiplier = 0.001;
		_overAllMultiplier = 0.05; 
		
		switch (_selection) do
		{ 
			case("face_hub"):
			{
				_oldDamage = _unit getHitPointDamage "HitFace";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _headMultiplier); 
			};
			case("neck"):
			{
				_oldDamage = _unit getHitPointDamage "HitNeck";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _neckMultiplier); 
			}; 			
			case("head"):
			{
				_oldDamage = _unit getHitPointDamage "HitHead";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _headMultiplier); 
			};
			case("pelvis"):
			{
				_oldDamage = _unit getHitPointDamage "HitPelvis";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
			}; 
			case("spine1"):
			{
				_oldDamage = _unit getHitPointDamage "HitAbdomen";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
			};  
			case("spine2"):
			{
				_oldDamage = _unit getHitPointDamage "HitDiaphragm";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
			};  
			case("spine3"):
			{
				_oldDamage = _unit getHitPointDamage "HitChest";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
			};			
			case("body"):
			{
				_oldDamage = _unit getHitPointDamage "HitBody";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
			}; 
			case("arms"):
			{
				_oldDamage = _unit getHitPointDamage "HitArms";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 
			};  
			case("hands"):
			{
				_oldDamage = _unit getHitPointDamage "HitHands";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 
			}; 
			case("legs"):
			{
				_oldDamage = _unit getHitPointDamage "HitLegs";
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
			}; 
			case(""):
			{
				_oldDamage = damage _unit;
				_return = _oldDamage + ((_passedDamage - _oldDamage) * _overAllMultiplier); 
			};
			default{}; 
		}; 
		
		_return
	}];

Share this post


Link to post
Share on other sites

 

I think you forget possible case in your script that's why it doesn't work.

 

All those case must be covered or it won't work

 

This script should works give it a try 

I must have messed up the formatting while changing the cases. I had them all. Your script, however, is working perfectly so far. Thanks so much for the help! 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×