Add new unit_setFractures function to handle better broken bones

- Removes old object_setHit
- Double checks if global broken bone variables are properly set after changing clothes.
- This should finally fix broken bones after changing clothes.
This commit is contained in:
A Man
2022-06-03 20:48:52 +02:00
parent d9f41afd19
commit 56787c71a0
5 changed files with 32 additions and 23 deletions

View File

@@ -15,6 +15,8 @@ _old addEventHandler ["HandleDamage", {0}];
//Logout
local _humanity = player getVariable ["humanity",0];
local _medical = player call player_sumMedical;
local _legsBroken = r_fracture_legs;
local _armsBroken = r_fracture_arms;
local _worldspace = [round(direction player),getPosATL player];
local _zombieKills = player getVariable ["zombieKills",0];
local _headShots = player getVariable ["headShots",0];
@@ -59,7 +61,7 @@ if (count _medical > 0) then {
player setVariable ["blood_type",(_medical select 11),true];
player setVariable ["rh_factor",(_medical select 12),true];
player setVariable ["messing",(_medical select 13),true];
player setVariable ["blood_testdone",(_medical select 14),true];
player setVariable ["blood_testdone",(_medical select 14),true];
//Add Wounds
{
@@ -71,14 +73,12 @@ if (count _medical > 0) then {
//Add fractures
local _fractures = _medical select 9;
// player setVariable ["hit_legs",(_fractures select 0),true];
// player setVariable ["hit_hands",(_fractures select 1),true];
[player,"legs",(_fractures select 0)] call object_setHit;
[player,"hands",(_fractures select 1)] call object_setHit;
[player,"legs",(_fractures select 0),_legsBroken,_armsBroken] call unit_setFractures;
[player,"hands",(_fractures select 1),_legsBroken,_armsBroken] call unit_setFractures;
} else {
//Reset Fractures
player setVariable ["hit_legs",0,true];
player setVariable ["hit_hands",0,true];
[player,"legs",0,false,false] call unit_setFractures;
[player,"hands",0,false,false] call unit_setFractures;
player setVariable ["USEC_injured",false,true];
player setVariable ["USEC_inPain",false,true];
};

View File

@@ -0,0 +1,15 @@
local _unit = _this select 0;
local _selection = _this select 1;
local _damage = _this select 2;
local _fracture_legs = _this select 3;
local _fracture_arms = _this select 4;
local _fracture = "hit_" + _selection;
// Setting damage directly. Do not get the damage from the new unit first. This damage has to be 0. If not the new unit broke its legs in debug. If we add it with the damage the old unit had before, it will result in broken bones even the player had no broken bones before.
_unit setVariable [_fracture,_damage,true];
_unit setHit [_selection,_damage];
// This makes sure that even when the player broke his legs during changing clothes the fracture variables getting properly resetted.
r_fracture_legs = _fracture_legs;
r_fracture_arms = _fracture_arms;