From bc4d102d0890023f59bfea846bc4cdc85651f92b Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 17 Apr 2015 22:43:31 +0200 Subject: [PATCH] changed variable initialization - everything is now done local --- addons/medical/XEH_init.sqf | 5 +-- addons/medical/XEH_respawn.sqf | 3 +- addons/medical/functions/fnc_init.sqf | 49 ++++++++++++++------------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/addons/medical/XEH_init.sqf b/addons/medical/XEH_init.sqf index 2f840fe950..f3fb2b1e93 100644 --- a/addons/medical/XEH_init.sqf +++ b/addons/medical/XEH_init.sqf @@ -4,7 +4,4 @@ private ["_unit"]; _unit = _this select 0; _unit addEventHandler ["HandleDamage", {_this call FUNC(handleDamage)}]; - -if (local _unit) then { - [_unit] call FUNC(init); -}; +[_unit] call FUNC(init); diff --git a/addons/medical/XEH_respawn.sqf b/addons/medical/XEH_respawn.sqf index b2101b1d4e..5047f0026c 100644 --- a/addons/medical/XEH_respawn.sqf +++ b/addons/medical/XEH_respawn.sqf @@ -6,8 +6,7 @@ _unit = _this select 0; if !(local _unit) exitWith {}; -diag_log "running respawn"; -[_unit] call FUNC(init); +[_unit, true] call FUNC(init); //Reset captive status for respawning unit if (!(_unit getVariable ["ACE_isUnconscious", false])) then { diff --git a/addons/medical/functions/fnc_init.sqf b/addons/medical/functions/fnc_init.sqf index fa6aa357c2..0147b99204 100644 --- a/addons/medical/functions/fnc_init.sqf +++ b/addons/medical/functions/fnc_init.sqf @@ -13,21 +13,24 @@ #include "script_component.hpp" -private ["_unit", "_allUsedMedication", "_logs"]; +private ["_unit", "_allUsedMedication", "_logs", "_forceNew"]; _unit = _this select 0; +_forceNew = if (count _this > 1) then {_this select 1} else {false}; -_unit setVariable [QGVAR(pain), 0, true]; -_unit setVariable [QGVAR(morphine), 0, true]; -_unit setVariable [QGVAR(bloodVolume), 100, true]; +if (!(isnil {_unit getvariable QGVAR(triageLevel)}) && !_forceNew) exitwith {}; + +_unit setVariable [QGVAR(pain), 0]; +_unit setVariable [QGVAR(morphine), 0]; +_unit setVariable [QGVAR(bloodVolume), 100]; // tourniquets -_unit setvariable [QGVAR(tourniquets), [0,0,0,0,0,0], true]; +_unit setvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; // wounds and injuries -_unit setvariable [QGVAR(openWounds), [], true]; -_unit setvariable [QGVAR(bandagedWounds), [], true]; -_unit setVariable [QGVAR(internalWounds), [], true]; +_unit setvariable [QGVAR(openWounds), []]; +_unit setvariable [QGVAR(bandagedWounds), []]; +_unit setVariable [QGVAR(internalWounds), []]; _unit setvariable [QGVAR(lastUniqueWoundID), 1]; // vitals @@ -40,8 +43,8 @@ _unit setVariable [QGVAR(peripheralResistance), 100]; _unit setVariable [QGVAR(fractures), []]; // triage card and logs -_unit setvariable [QGVAR(triageLevel), 0, true]; -_unit setvariable [QGVAR(triageCard), [], true]; +_unit setvariable [QGVAR(triageLevel), 0]; +_unit setvariable [QGVAR(triageCard), []]; // IVs _unit setVariable [QGVAR(salineIVVolume), 0]; @@ -49,21 +52,21 @@ _unit setVariable [QGVAR(plasmaIVVolume), 0]; _unit setVariable [QGVAR(bloodIVVolume), 0]; // damage storage -_unit setvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0], true]; +_unit setvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; // airway -_unit setvariable [QGVAR(airwayStatus), 100, true]; -_unit setVariable [QGVAR(airwayOccluded), false, true]; -_unit setvariable [QGVAR(airwayCollapsed), false, true]; +_unit setvariable [QGVAR(airwayStatus), 100]; +_unit setVariable [QGVAR(airwayOccluded), false]; +_unit setvariable [QGVAR(airwayCollapsed), false]; // generic medical admin -_unit setvariable [QGVAR(addedToUnitLoop), false, true]; -_unit setvariable [QGVAR(inCardiacArrest), false, true]; -_unit setVariable ["ACE_isUnconscious", false, true]; -_unit setvariable [QGVAR(hasLostBlood), false, true]; -_unit setvariable [QGVAR(isBleeding), false, true]; -_unit setvariable [QGVAR(hasPain), false, true]; -_unit setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives), true]; +_unit setvariable [QGVAR(addedToUnitLoop), false]; +_unit setvariable [QGVAR(inCardiacArrest), false]; +_unit setVariable ["ACE_isUnconscious", false]; +_unit setvariable [QGVAR(hasLostBlood), false]; +_unit setvariable [QGVAR(isBleeding), false]; +_unit setvariable [QGVAR(hasPain), false]; +_unit setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives)]; // medication _allUsedMedication = _unit getVariable [QGVAR(allUsedMedication), []]; @@ -74,9 +77,9 @@ _unit setVariable [QGVAR(allUsedMedication), []]; _logs = _unit getvariable [QGVAR(allLogs), []]; { - _unit setvariable [_x, nil, true]; + _unit setvariable [_x, nil]; } foreach _logs; -_unit setvariable [QGVAR(allLogs), [], true]; +_unit setvariable [QGVAR(allLogs), []]; // items [{