From 4ce524ed3c3bdde067e9971b262eed3e07424751 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Thu, 12 Mar 2015 21:16:49 +0100 Subject: [PATCH 01/15] First draft of carry and drop unit --- addons/medical/XEH_preInit.sqf | 3 + .../medical/functions/fnc_actionCarryUnit.sqf | 83 +++++++++++++++++++ .../fnc_actionCheckBloodPressure.sqf | 2 + .../functions/fnc_actionCheckPulse.sqf | 2 + .../medical/functions/fnc_actionDropUnit.sqf | 23 +++++ .../medical/functions/fnc_actionLoadUnit.sqf | 2 - .../functions/fnc_actionUnloadUnit.sqf | 2 +- .../functions/fnc_onCarryObjectDropped.sqf | 71 ++++++++++++++++ addons/medical/stringtable.xml | 12 +++ 9 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 addons/medical/functions/fnc_actionCarryUnit.sqf create mode 100644 addons/medical/functions/fnc_actionDropUnit.sqf create mode 100644 addons/medical/functions/fnc_onCarryObjectDropped.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index c6ddbf0783..32ec3621a5 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -11,6 +11,8 @@ PREP(actionPlaceInBodyBag); PREP(actionRemoveTourniquet); PREP(actionLoadUnit); PREP(actionUnloadUnit); +PREP(actionCarryUnit); +PREP(actionDropUnit); PREP(addHeartRateAdjustment); PREP(addToInjuredCollection); PREP(addToLog); @@ -49,6 +51,7 @@ PREP(isMedicalVehicle); PREP(onMedicationUsage); PREP(onWoundUpdateRequest); PREP(onPropagateWound); +PREP(onCarryObjectDropped); PREP(parseConfigForInjuries); PREP(playInjuredSound); PREP(reactionToDamage); diff --git a/addons/medical/functions/fnc_actionCarryUnit.sqf b/addons/medical/functions/fnc_actionCarryUnit.sqf new file mode 100644 index 0000000000..db880d95f2 --- /dev/null +++ b/addons/medical/functions/fnc_actionCarryUnit.sqf @@ -0,0 +1,83 @@ +/* + * Author: Glowbal + * makes the calling unit start carrying the specified unit + * + * Arguments: + * 0: The caller + * 1: The target + * 2: Carry object. True is carry, false is dragging + * + * Return Value: + * NONE + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_caller", "_target", "_positionUnit", "_carry"]; +_caller = _this select 0; +_target = _this select 1; +_carry = _this select 2; + +if (!(_target isKindOf "CaManBase") || !(_caller isKindOf "CaManBase")) exitwith{ }; +if (vehicle _caller != _caller || vehicle _target != _target) exitwith {}; +if (!([_caller] call EFUNC(common,canInteract)) || {_caller == _target} || {(([_target] call EFUNC(common,isAwake)))}) exitwith {}; + +_caller action ["WeaponOnBack", _caller]; +if (!alive _target) exitwith { + if (missionNamespace getvariable [QGVAR(allowDeadbodyMovement), false]) then { + [{ + _this call FUNC(actionCarryUnit); + }, [_caller, ([_target,_caller] call FUNC(makeCopyOfBody)), _carry], 0.25, 0.25] call EFUNC(common,waitAndExecute); + }; +}; + +if !([_caller,_target] call EFUNC(common,carryObj)) exitwith {}; + +if (primaryWeapon _caller == "") then { + _caller addWeapon "ACE_FakePrimaryWeapon"; +}; +_caller selectWeapon (primaryWeapon _caller); + +if (_carry) then { + _target attachTo [_caller, [0.1, -0.1, -1.25], "LeftShoulder"]; + [_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation); + [_caller, "acinpercmstpsraswrfldnon", 1] call EFUNC(common,doAnimation); +} else { + _target attachTo [_caller, [0.125, 1.007, 0]]; + _target setDir (getDir _target + 180) % 360; + _target setPos ((getPos _target) vectorAdd ((vectorDir _caller) vectorMultiply 1.5)); +}; + +[ + 2, + [_caller, _target, _carry], + { + private ["_caller","_target"]; + _caller = _this select 0; + _target = _this select 1; + _carry = _this select 2; + + _target setvariable [QGVAR(beingCarried), _caller, true]; + _caller setvariable [QGVAR(carrying), _target, true]; + _caller setvariable [QGVAR(isCarrying), if (_carry) then {1} else {0}, true]; + + // Removing any old drop scroll wheel actions + // TODO Do we still want scroll wheel actions? + if (!isnil QGVAR(DROP_ADDACTION)) then { + _caller removeAction GVAR(DROP_ADDACTION); + GVAR(DROP_ADDACTION) = nil; + }; + // Adding the drop scroll wheel action. + GVAR(DROP_ADDACTION) = _caller addAction [format["Drop %1",[_target] call EFUNC(common,getName)], {[_this select 1, _this select 2] call FUNC(actionDropUnit);}]; + + [_target, true] call EFUNC(common,disableAI); + }, + { + [(_this select 0), objNull,[0, 0, 0]] call EFUNC(common,carryObj); + // TODO reset animations.. + }, + if (_carry) then {localize "STR_ACE_MEDICAL_ACTION_CARRY"} else {localize "STR_ACE_MEDICAL_ACTION_DRAG"}, + {true} +] call EFUNC(common,progressBar); diff --git a/addons/medical/functions/fnc_actionCheckBloodPressure.sqf b/addons/medical/functions/fnc_actionCheckBloodPressure.sqf index 7db155483e..e8e03bb4c0 100644 --- a/addons/medical/functions/fnc_actionCheckBloodPressure.sqf +++ b/addons/medical/functions/fnc_actionCheckBloodPressure.sqf @@ -11,7 +11,9 @@ * * Public: No */ + #include "script_component.hpp" + private ["_caller","_target"]; _caller = _this select 0; _target = _this select 1; diff --git a/addons/medical/functions/fnc_actionCheckPulse.sqf b/addons/medical/functions/fnc_actionCheckPulse.sqf index 9fa79b2183..f545c11144 100644 --- a/addons/medical/functions/fnc_actionCheckPulse.sqf +++ b/addons/medical/functions/fnc_actionCheckPulse.sqf @@ -11,7 +11,9 @@ * * Public: No */ + #include "script_component.hpp" + private ["_caller","_target","_title","_content"]; _caller = _this select 0; _target = _this select 1; diff --git a/addons/medical/functions/fnc_actionDropUnit.sqf b/addons/medical/functions/fnc_actionDropUnit.sqf new file mode 100644 index 0000000000..db1c02aced --- /dev/null +++ b/addons/medical/functions/fnc_actionDropUnit.sqf @@ -0,0 +1,23 @@ +/* + * Author: Glowbal + * Drop a unit if the caller nit is currently dragging or carrying a unit + * + * Arguments: + * 0: The caller + * + * Return Value: + * NONE + * + * Public: No + */ + +#include "script_component.hpp" + +private "_caller"; +_caller = _this select 0; + +if (!isnil QGVAR(DROP_ADDACTION)) then { + [_caller,objNull] call EFUNC(common,carryObj); + _caller removeAction GVAR(DROP_ADDACTION); + GVAR(DROP_ADDACTION) = nil; +}; diff --git a/addons/medical/functions/fnc_actionLoadUnit.sqf b/addons/medical/functions/fnc_actionLoadUnit.sqf index f88adc02d7..7f55d585d6 100644 --- a/addons/medical/functions/fnc_actionLoadUnit.sqf +++ b/addons/medical/functions/fnc_actionLoadUnit.sqf @@ -12,10 +12,8 @@ * Public: No */ - #include "script_component.hpp" - private ["_caller", "_target","_vehicle", "_loaded"]; _caller = _this select 0; _target = _this select 1; diff --git a/addons/medical/functions/fnc_actionUnloadUnit.sqf b/addons/medical/functions/fnc_actionUnloadUnit.sqf index 92c06e176a..8c05a43fc9 100644 --- a/addons/medical/functions/fnc_actionUnloadUnit.sqf +++ b/addons/medical/functions/fnc_actionUnloadUnit.sqf @@ -27,7 +27,7 @@ if (([_target] call cse_fnc_isAwake)) exitwith {}; if ([_caller, _target] call EFUNC(common,unloadPerson)) then { if (_drag) then { if ((vehicle _caller) == _caller) then { - [[_caller, _target], QUOTE(DFUNC(actionDragUnit)), _caller, false] call BIS_fnc_MP; + [[_caller, _target, true], QUOTE(DFUNC(actionDragUnit)), _caller, false] call EFUNC(common,execRemoteFnc); // TODO replace by event }; }; }; diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf new file mode 100644 index 0000000000..e2972adfd6 --- /dev/null +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -0,0 +1,71 @@ +/* + * Author: Glowbal + * Called on event CarryObjectDropped + * + * Arguments: + * 0: The caller + * + * Return Value: + * NONE + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_unit","_params"]; +_caller = _this select 0; +_target = _caller getvariable [QGVAR(carrying), objNull]; +_carrying = _caller getvariable [QGVAR(isCarrying), -1]; + +if (_carrying >= 0) then { + _caller setvariable [QGVAR(isCarrying), -1, true]; + if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then { + _caller removeWeapon "ACE_FakePrimaryWeapon"; + }; + + [_target, false] call EFUNC(common,disableAI); + _caller setvariable[QGVAR(onStartMovingUnitParams), nil]; + + // handle the drag & carry administration + if (_dragging) then { + _target setvariable [QGVAR(beingDragged), nil, true]; + _caller setvariable [QGVAR(dragging), nil, true]; + } else { + _target setvariable [QGVAR(beingCarried), nil, true]; + _caller setvariable [QGVAR(carrying), nil, true]; + }; + + // handle the drag & carry animiations + if ([_caller] call EFUNC(common,isAwake) && (vehicle _caller == _caller)) then { + [_caller,"amovpercmstpsraswrfldnon_amovpknlmstpslowwrfldnon", 1] call EFUNC(common,doAnimation); + }; + + if (vehicle _target == _target) then { + if (_dragging) then { + [_target,"AinjPpneMstpSnonWrflDb_release", 2, true] call EFUNC(common,doAnimation); + } else { + [_target,"AinjPfalMstpSnonWrflDnon_carried_Down", 2, true] call EFUNC(common,doAnimation); + }; + } else { + if ([_target] call EFUNC(common,isAwake)) then { + [_target,"", 2] call EFUNC(common,doAnimation); // TODO play animation for the current seat instead + } else { + // this might not work properly + [_target,([_target] call EFUNC(common,getDeathAnim)), 1] call EFUNC(common,doAnimation); + }; + }; + + // Ensure that the unit does not get dropped through the floor of a building + if (!surfaceIsWater getPos _caller) then { + [{ + EXPLODE_3_PVT(_this,_caller,_target,_killOnDrop); + if (vehicle _target == _target && (vehicle _caller == _caller)) then { + // This will set the target body/unit on the correct position, so it doesn't fall through floors. + _positionUnit = getPosATL _target; + _positionUnit set [2, (getPosATL _caller) select 2]; + _target setPosATL _positionUnit; + }; + }, [_caller,_target], 0.5, 0.5] call EFUNC(common,waitAndExecute); + }; +}; \ No newline at end of file diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 6b63aaa416..efedab0ca9 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -556,6 +556,18 @@ %1 проводит вам интубацию %1 te está intubando + + Carry Patient + + + Drag Patient + + + Load Patient + + + Unload Patient + From 99b1986059eb5d81ba807f25f70386397302c3cb Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 14 Mar 2015 09:37:19 +0100 Subject: [PATCH 02/15] Added setting for allowing movement of dead bodies --- addons/medical/ACE_Settings.hpp | 4 ++++ addons/medical/functions/fnc_actionCarryUnit.sqf | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index a57bc43dff..003d9897b8 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -68,4 +68,8 @@ class ACE_Settings { typeName = "NUMBER"; value = 120; }; + class GVAR(allowDeadBodyMovement) { + typeName = "BOOL"; + value = false; + }; }; diff --git a/addons/medical/functions/fnc_actionCarryUnit.sqf b/addons/medical/functions/fnc_actionCarryUnit.sqf index db880d95f2..fd5731ffd6 100644 --- a/addons/medical/functions/fnc_actionCarryUnit.sqf +++ b/addons/medical/functions/fnc_actionCarryUnit.sqf @@ -26,7 +26,7 @@ if (!([_caller] call EFUNC(common,canInteract)) || {_caller == _target} || {(([_ _caller action ["WeaponOnBack", _caller]; if (!alive _target) exitwith { - if (missionNamespace getvariable [QGVAR(allowDeadbodyMovement), false]) then { + if (GVAR(allowDeadBodyMovement)) then { [{ _this call FUNC(actionCarryUnit); }, [_caller, ([_target,_caller] call FUNC(makeCopyOfBody)), _carry], 0.25, 0.25] call EFUNC(common,waitAndExecute); From dcf3a7351866545615a69b4af787a55683283986 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 14 Mar 2015 09:48:16 +0100 Subject: [PATCH 03/15] Added copyDeadBody function --- addons/medical/XEH_preInit.sqf | 1 + .../medical/functions/fnc_actionCarryUnit.sqf | 2 +- addons/medical/functions/fnc_copyDeadBody.sqf | 93 +++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 addons/medical/functions/fnc_copyDeadBody.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 32ec3621a5..008c86bf8a 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -87,6 +87,7 @@ PREP(moduleAssignMedicRoles); PREP(moduleAssignMedicalVehicle); PREP(moduleAssignMedicalFacility); PREP(moduleTreatmentConfiguration); +PREP(copyDeadBody); GVAR(injuredUnitCollection) = []; call FUNC(parseConfigForInjuries); diff --git a/addons/medical/functions/fnc_actionCarryUnit.sqf b/addons/medical/functions/fnc_actionCarryUnit.sqf index fd5731ffd6..c7a1cdeda3 100644 --- a/addons/medical/functions/fnc_actionCarryUnit.sqf +++ b/addons/medical/functions/fnc_actionCarryUnit.sqf @@ -29,7 +29,7 @@ if (!alive _target) exitwith { if (GVAR(allowDeadBodyMovement)) then { [{ _this call FUNC(actionCarryUnit); - }, [_caller, ([_target,_caller] call FUNC(makeCopyOfBody)), _carry], 0.25, 0.25] call EFUNC(common,waitAndExecute); + }, [_caller, ([_target,_caller] call FUNC(copyDeadBody)), _carry], 0.25, 0.25] call EFUNC(common,waitAndExecute); }; }; diff --git a/addons/medical/functions/fnc_copyDeadBody.sqf b/addons/medical/functions/fnc_copyDeadBody.sqf new file mode 100644 index 0000000000..96465cdbd3 --- /dev/null +++ b/addons/medical/functions/fnc_copyDeadBody.sqf @@ -0,0 +1,93 @@ +/* + * Author: Glowbal + * Makes a copy of a dead body. For handling dead bodies for actions such as load and carry. + * + * Arguments: + * 0: The oldbody + * 1: The caller + * + * Return Value: + * OBJECT Returns the copy of the unit. If no copy could be made, returns the oldBody + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_oldBody","_newUnit","_class","_group","_position","_side","_allVariables"]; +_oldBody = _this select 0; +_caller = _this select 1; + +if (alive _oldBody) exitwith {_oldBody}; // we only want to do this for dead bodies + +_name = _oldBody getvariable ["ACE_name", "unknown"]; +_class = typeof _oldBody; +_side = side _caller; +_group = createGroup _side; +_position = getPos _oldBody; + +_newUnit = _group createUnit [typeof _oldBody, _position, [], 0, "NONE"]; + +_allVariables = [_oldBody] call EFUNC(common,getAllDefinedSetVariables); +// [NAME (STRING), TYPENAME (STRING), VALUE (ANY), DEFAULT GLOBAL (BOOLEAN)] +{ + [_newUnit,_x select 0, _x select 2] call EFUNC(common,setDefinedVariable); +}foreach _allVariables; + +_allVars = allVariables _oldBody; +_public = !(local _oldBody); +{ + _newUnit setvariable [_x, (_oldBody getvariable _x), false]; +}foreach _allVars; + +// find the remaining variables? +if !(_public) then { + // exec on server? +} else { + // Exec on client +}; + +_newUnit setVariable ["ACE_name", _name, true]; + +_newUnit disableAI "TARGET"; +_newUnit disableAI "AUTOTARGET"; +_newUnit disableAI "MOVE"; +_newUnit disableAI "ANIM"; +_newUnit disableAI "FSM"; +_newUnit setvariable ["ACE_isDead", true, true]; + +removeallweapons _newUnit; +removeallassigneditems _newUnit; +removeUniform _newUnit; +removeHeadgear _newUnit; +removeBackpack _newUnit; +removeVest _newUnit; + +_newUnit addHeadgear (headgear _oldBody); +_newUnit addBackpack (backpack _oldBody); +clearItemCargoGlobal (backpackContainer _newUnit); +clearMagazineCargoGlobal (backpackContainer _newUnit); +clearWeaponCargoGlobal (backpackContainer _newUnit); + +_newUnit addVest (vest _oldBody); +clearItemCargoGlobal (backpackContainer _newUnit); +clearMagazineCargoGlobal (backpackContainer _newUnit); +clearWeaponCargoGlobal (backpackContainer _newUnit); + +_newUnit addUniform (uniform _oldBody); +clearItemCargoGlobal (backpackContainer _newUnit); +clearMagazineCargoGlobal (backpackContainer _newUnit); +clearWeaponCargoGlobal (backpackContainer _newUnit); + +{_newUnit addMagazine _x} count (magazines _oldBody); +{_newUnit addWeapon _x} count (weapons _oldBody); +{_newUnit addItem _x} count (items _oldBody); + +_newUnit selectWeapon (primaryWeapon _newUnit); + +// TODO sometimes the old body does not get cleaned up properly. Look into garbage collection. +deleteVehicle _oldBody; + +_newUnit setDamage 0.89; + +_newUnit \ No newline at end of file From 2bee533a8c7e1fdfd6a49c474d7b9070beaab1d3 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 14 Mar 2015 09:51:08 +0100 Subject: [PATCH 04/15] Added AGM stringtables for drag, carry, load & unload --- addons/medical/stringtable.xml | 61 ++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index efedab0ca9..91acb56d14 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -556,19 +556,66 @@ %1 проводит вам интубацию %1 te está intubando - - Carry Patient - - Drag Patient + Drag + Ziehen + Arrastrar + Ciągnij + Táhnout + Тащить + Tracter + Húzás + Arrastar + Trascina + + + Carry + Tragen + Cargar + Nieś + Nést + Нести + Porter + Cipelés + Carregar + Trasporta + + + Release + Loslassen + Soltar + Połóż + Položit + Отпустить + Déposer + Elenged + Largar + Lascia - Load Patient + Load Patient Into + Patient Einladen + Cargar el paciente en + Załaduj pacjenta + Naložit pacianta do + Погрузить пациента в + Embarquer le Patient + Sebesült berakása + Carregar Paciente Em + Carica paziente nel - Unload Patient + Unload Patient + Patient Ausladen + Descargar el paciente + Wyładuj pacjenta + Vyložit pacienta + Выгрузить пациента + Débarquer le Patient + Sebesült kihúzása + Descarregar Paciente + Scarica il paziente - From 62460e8b795969bc7bd208e1d92b11dfa0279216 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 15 Mar 2015 01:12:02 +0100 Subject: [PATCH 05/15] Fixes for animations and script error --- addons/medical/XEH_postInit.sqf | 1 + addons/medical/functions/fnc_actionCarryUnit.sqf | 15 ++++++++++----- .../functions/fnc_onCarryObjectDropped.sqf | 7 +++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index d23a02225f..6dc3416bf4 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -12,6 +12,7 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; ["Medical_treatmentCompleted", FUNC(onTreatmentCompleted)] call ace_common_fnc_addEventHandler; ["medical_propagateWound", FUNC(onPropagateWound)] call ace_common_fnc_addEventHandler; ["medical_woundUpdateRequest", FUNC(onWoundUpdateRequest)] call ace_common_fnc_addEventHandler; +["carryObjectDropped", FUNC(onCarryObjectDropped)] call ace_common_fnc_addEventHandler; // Initialize all effects _fnc_createEffect = { diff --git a/addons/medical/functions/fnc_actionCarryUnit.sqf b/addons/medical/functions/fnc_actionCarryUnit.sqf index c7a1cdeda3..3a71351ed2 100644 --- a/addons/medical/functions/fnc_actionCarryUnit.sqf +++ b/addons/medical/functions/fnc_actionCarryUnit.sqf @@ -38,7 +38,9 @@ if !([_caller,_target] call EFUNC(common,carryObj)) exitwith {}; if (primaryWeapon _caller == "") then { _caller addWeapon "ACE_FakePrimaryWeapon"; }; -_caller selectWeapon (primaryWeapon _caller); +if (currentWeapon _caller != (primaryWeapon _caller)) then { + _caller selectWeapon (primaryWeapon _caller); +}; if (_carry) then { _target attachTo [_caller, [0.1, -0.1, -1.25], "LeftShoulder"]; @@ -48,16 +50,19 @@ if (_carry) then { _target attachTo [_caller, [0.125, 1.007, 0]]; _target setDir (getDir _target + 180) % 360; _target setPos ((getPos _target) vectorAdd ((vectorDir _caller) vectorMultiply 1.5)); + [_caller, "AcinPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation); + [_target, "AinjPpneMstpSnonWrflDb", 2, true] call EFUNC(common,doAnimation); }; [ 2, [_caller, _target, _carry], { - private ["_caller","_target"]; - _caller = _this select 0; - _target = _this select 1; - _carry = _this select 2; + private ["_caller","_target", "_carry", "_args"]; + _args = _this select 0; + _caller = _args select 0; + _target = _args select 1; + _carry = _args select 2; _target setvariable [QGVAR(beingCarried), _caller, true]; _caller setvariable [QGVAR(carrying), _target, true]; diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf index e2972adfd6..54633f873f 100644 --- a/addons/medical/functions/fnc_onCarryObjectDropped.sqf +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -18,7 +18,10 @@ _caller = _this select 0; _target = _caller getvariable [QGVAR(carrying), objNull]; _carrying = _caller getvariable [QGVAR(isCarrying), -1]; +systemChat format["handle onCarryObjectDropped %1", [_this, _target, _carrying]]; + if (_carrying >= 0) then { + _caller setvariable [QGVAR(isCarrying), -1, true]; if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then { _caller removeWeapon "ACE_FakePrimaryWeapon"; @@ -28,7 +31,7 @@ if (_carrying >= 0) then { _caller setvariable[QGVAR(onStartMovingUnitParams), nil]; // handle the drag & carry administration - if (_dragging) then { + if (_carrying == 0) then { _target setvariable [QGVAR(beingDragged), nil, true]; _caller setvariable [QGVAR(dragging), nil, true]; } else { @@ -42,7 +45,7 @@ if (_carrying >= 0) then { }; if (vehicle _target == _target) then { - if (_dragging) then { + if (_carrying == 0) then { [_target,"AinjPpneMstpSnonWrflDb_release", 2, true] call EFUNC(common,doAnimation); } else { [_target,"AinjPfalMstpSnonWrflDnon_carried_Down", 2, true] call EFUNC(common,doAnimation); From be4ba6144f9ae6ce9430a5d6faf175bbd5cd24a8 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Wed, 18 Mar 2015 18:17:42 +0100 Subject: [PATCH 06/15] Removed unnecessary line --- addons/medical/functions/fnc_actionCarryUnit.sqf | 1 - addons/medical/functions/fnc_copyDeadBody.sqf | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/medical/functions/fnc_actionCarryUnit.sqf b/addons/medical/functions/fnc_actionCarryUnit.sqf index 3a71351ed2..1653c11027 100644 --- a/addons/medical/functions/fnc_actionCarryUnit.sqf +++ b/addons/medical/functions/fnc_actionCarryUnit.sqf @@ -24,7 +24,6 @@ if (!(_target isKindOf "CaManBase") || !(_caller isKindOf "CaManBase")) exitwith if (vehicle _caller != _caller || vehicle _target != _target) exitwith {}; if (!([_caller] call EFUNC(common,canInteract)) || {_caller == _target} || {(([_target] call EFUNC(common,isAwake)))}) exitwith {}; -_caller action ["WeaponOnBack", _caller]; if (!alive _target) exitwith { if (GVAR(allowDeadBodyMovement)) then { [{ diff --git a/addons/medical/functions/fnc_copyDeadBody.sqf b/addons/medical/functions/fnc_copyDeadBody.sqf index 96465cdbd3..710051e5ea 100644 --- a/addons/medical/functions/fnc_copyDeadBody.sqf +++ b/addons/medical/functions/fnc_copyDeadBody.sqf @@ -85,9 +85,10 @@ clearWeaponCargoGlobal (backpackContainer _newUnit); _newUnit selectWeapon (primaryWeapon _newUnit); -// TODO sometimes the old body does not get cleaned up properly. Look into garbage collection. +// TODO sometimes the old body does not get cleaned up properly. +// TODO Maybe it is better to hide the body, attach it as well, and remove the copy once we are done with it instead? deleteVehicle _oldBody; _newUnit setDamage 0.89; -_newUnit \ No newline at end of file +_newUnit; From 0428a1d558f807f7b8e36aa569cf41a26e6da96b Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 10:28:33 +0100 Subject: [PATCH 07/15] Added canDrag --- addons/medical/XEH_preInit.sqf | 1 + addons/medical/functions/fnc_canCarry.sqf | 29 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 addons/medical/functions/fnc_canCarry.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 57179d9097..75f4221aba 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -22,6 +22,7 @@ PREP(addUnloadPatientActions); PREP(canAccessMedicalEquipment); PREP(canTreat); PREP(canTreatCached); +PREP(canCarry); PREP(determineIfFatal); PREP(getBloodLoss); PREP(getBloodPressure); diff --git a/addons/medical/functions/fnc_canCarry.sqf b/addons/medical/functions/fnc_canCarry.sqf new file mode 100644 index 0000000000..a7db1f6cc3 --- /dev/null +++ b/addons/medical/functions/fnc_canCarry.sqf @@ -0,0 +1,29 @@ +/* + * Author: Glowbal + * Check if caller can carry or drag the target + * + * Arguments: + * 0: The caller + * 1: The target + * + * Return Value: + * NONE + * + * Public: No + */ + +#include "script_component.hpp" + + private ["_caller", "_target", "_positionUnit", "_carry"]; +_caller = _this select 0; +_target = _this select 1; + +if (!(_target isKindOf "CaManBase") || !(_caller isKindOf "CaManBase")) exitwith{false}; + +if (vehicle _caller != _caller || vehicle _target != _target) exitwith {false}; + +if (!([_caller] call EFUNC(common,canInteract)) || {_caller == _target} || {(([_target] call EFUNC(common,isAwake)))}) exitwith {false}; + +if (!alive _target) exitwith {GVAR(allowDeadBodyMovement)}; + +((isNull ([_caller] call FUNC(getCarriedObj))) && {isNull ([_target] call FUNC(getCarriedObj))} && {isNull ([_caller] call FUNC(getCarriedBy))} && {isNull ([_target] call FUNC(getCarriedBy))}) From ac4309237bb8e99c07f7fff7a519b851a98228b7 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 10:28:41 +0100 Subject: [PATCH 08/15] Added drag/carry actions --- addons/medical/ACE_Medical_Treatments.hpp | 50 +++++++++++++++++++++++ addons/medical/CfgVehicles.hpp | 22 ++++++++++ addons/medical/XEH_postInit.sqf | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index 28a9b82d8c..514b636872 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -49,6 +49,31 @@ class ACE_Medical_Actions { callbackSuccess = QUOTE(DFUNC(treatmentBasic_bloodbag)); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; }; + class Carry: Bandage { + displayName = ""; + displayNameProgress = ""; + treatmentLocations[] = {"All"}; + requiredMedic = 0; + treatmentTime = 0; + items[] = {}; + condition = QUOTE(DFUNC(canCarry)); + callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, true)] call DFUNC(actionCarryUnit)); + callbackFailure = ""; + callbackProgress = ""; + animationPatient = ""; + itemConsumed = 0; + animationPatient = ""; + animationCaller = ""; + animationCallerProne = ""; + animationCallerSelf = ""; + animationCallerSelfProne = ""; + }; + class Drag: Carry { + displayName = ""; + displayNameProgress = ""; + condition = QUOTE(DFUNC(canCarry)); + callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, false)] call DFUNC(actionCarryUnit)); + }; }; class Advanced { @@ -199,6 +224,31 @@ class ACE_Medical_Actions { animationPatient = ""; itemConsumed = 0; }; + class Carry: fieldDressing { + displayName = ""; + displayNameProgress = ""; + treatmentLocations[] = {"All"}; + requiredMedic = 0; + treatmentTime = 0; + items[] = {}; + condition = QUOTE(DFUNC(canCarry)); + callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, true)] call DFUNC(actionCarryUnit)); + callbackFailure = ""; + callbackProgress = ""; + animationPatient = ""; + itemConsumed = 0; + animationPatient = ""; + animationCaller = ""; + animationCallerProne = ""; + animationCallerSelf = ""; + animationCallerSelfProne = ""; + }; + class Drag: Carry { + displayName = ""; + displayNameProgress = ""; + condition = QUOTE(DFUNC(canCarry)); + callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, false)] call DFUNC(actionCarryUnit)); + }; }; }; diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index 1efd4917fd..81d81c06e3 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -433,6 +433,28 @@ class CfgVehicles { enableInside = 1; icon = PATHTOF(UI\icons\bandage.paa); }; + class Carry { + displayName = "$STR_ACE_MEDICAL_CARRY"; + distance = 2.0; + condition = QUOTE([ARR_4(_player, _target, 'body', 'Carry')] call DFUNC(canTreatCached)); + statement = QUOTE([ARR_4(_player, _target, 'body', 'Carry')] call DFUNC(treatment)); + showDisabled = 1; + priority = 2; + hotkey = ""; + enableInside = 1; + //icon = PATHTOF(UI\icons\bandage.paa); + }; + class Drag { + displayName = "$STR_ACE_MEDICAL_DRAG"; + distance = 2.0; + condition = QUOTE([ARR_4(_player, _target, 'body', 'Drag')] call DFUNC(canTreatCached)); + statement = QUOTE([ARR_4(_player, _target, 'body', 'Drag')] call DFUNC(treatment)); + showDisabled = 1; + priority = 2; + hotkey = ""; + enableInside = 1; + //icon = PATHTOF(UI\icons\bandage.paa); + }; class TriageCard { displayName = "Triage Card"; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index b32f634b73..f0cebacc58 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -219,7 +219,7 @@ if (isNil QGVAR(level)) then { }, 0, []] call CBA_fnc_addPerFrameHandler; // broadcast injuries to JIP clients in a MP session -if (isMultiplayer and GVAR(level) >= 2) then { +if (isMultiplayer && GVAR(level) >= 2) then { [QGVAR(onPlayerConnected), "onPlayerConnected", { if (isNil QGVAR(InjuredCollection)) then { GVAR(InjuredCollection) = []; From 5063e9cff9f1ce14cffaafc55203bb0a969b9b18 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 11:21:08 +0100 Subject: [PATCH 09/15] fixed config duplicate entry --- addons/medical/ACE_Medical_Treatments.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/medical/ACE_Medical_Treatments.hpp b/addons/medical/ACE_Medical_Treatments.hpp index 514b636872..da8c723c8a 100644 --- a/addons/medical/ACE_Medical_Treatments.hpp +++ b/addons/medical/ACE_Medical_Treatments.hpp @@ -60,7 +60,6 @@ class ACE_Medical_Actions { callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, true)] call DFUNC(actionCarryUnit)); callbackFailure = ""; callbackProgress = ""; - animationPatient = ""; itemConsumed = 0; animationPatient = ""; animationCaller = ""; @@ -235,7 +234,6 @@ class ACE_Medical_Actions { callbackSuccess = QUOTE([ARR_3(_this select 0, _this select 1, true)] call DFUNC(actionCarryUnit)); callbackFailure = ""; callbackProgress = ""; - animationPatient = ""; itemConsumed = 0; animationPatient = ""; animationCaller = ""; From 55e7e768ca3c470b6afc8fe079474c1e02351dcf Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 11:21:17 +0100 Subject: [PATCH 10/15] removed systemChat messages --- addons/medical/functions/fnc_addUnloadPatientActions.sqf | 2 -- addons/medical/functions/fnc_onCarryObjectDropped.sqf | 2 -- 2 files changed, 4 deletions(-) diff --git a/addons/medical/functions/fnc_addUnloadPatientActions.sqf b/addons/medical/functions/fnc_addUnloadPatientActions.sqf index 3a96c0b089..89960afae9 100644 --- a/addons/medical/functions/fnc_addUnloadPatientActions.sqf +++ b/addons/medical/functions/fnc_addUnloadPatientActions.sqf @@ -39,6 +39,4 @@ _actions = []; }; } forEach crew _vehicle; -systemChat str(count _actions); - _actions diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf index 54633f873f..39aa1d0df6 100644 --- a/addons/medical/functions/fnc_onCarryObjectDropped.sqf +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -18,8 +18,6 @@ _caller = _this select 0; _target = _caller getvariable [QGVAR(carrying), objNull]; _carrying = _caller getvariable [QGVAR(isCarrying), -1]; -systemChat format["handle onCarryObjectDropped %1", [_this, _target, _carrying]]; - if (_carrying >= 0) then { _caller setvariable [QGVAR(isCarrying), -1, true]; From 6eac19382596dca440309059ed9ed3964c48a4ba Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 20:37:55 +0100 Subject: [PATCH 11/15] Replaced deleting of body by hiding it --- addons/medical/functions/fnc_copyDeadBody.sqf | 35 ++++++------------- .../functions/fnc_onCarryObjectDropped.sqf | 11 ++++++ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/addons/medical/functions/fnc_copyDeadBody.sqf b/addons/medical/functions/fnc_copyDeadBody.sqf index 710051e5ea..4aabbed44c 100644 --- a/addons/medical/functions/fnc_copyDeadBody.sqf +++ b/addons/medical/functions/fnc_copyDeadBody.sqf @@ -27,26 +27,6 @@ _group = createGroup _side; _position = getPos _oldBody; _newUnit = _group createUnit [typeof _oldBody, _position, [], 0, "NONE"]; - -_allVariables = [_oldBody] call EFUNC(common,getAllDefinedSetVariables); -// [NAME (STRING), TYPENAME (STRING), VALUE (ANY), DEFAULT GLOBAL (BOOLEAN)] -{ - [_newUnit,_x select 0, _x select 2] call EFUNC(common,setDefinedVariable); -}foreach _allVariables; - -_allVars = allVariables _oldBody; -_public = !(local _oldBody); -{ - _newUnit setvariable [_x, (_oldBody getvariable _x), false]; -}foreach _allVars; - -// find the remaining variables? -if !(_public) then { - // exec on server? -} else { - // Exec on client -}; - _newUnit setVariable ["ACE_name", _name, true]; _newUnit disableAI "TARGET"; @@ -54,7 +34,6 @@ _newUnit disableAI "AUTOTARGET"; _newUnit disableAI "MOVE"; _newUnit disableAI "ANIM"; _newUnit disableAI "FSM"; -_newUnit setvariable ["ACE_isDead", true, true]; removeallweapons _newUnit; removeallassigneditems _newUnit; @@ -85,10 +64,16 @@ clearWeaponCargoGlobal (backpackContainer _newUnit); _newUnit selectWeapon (primaryWeapon _newUnit); -// TODO sometimes the old body does not get cleaned up properly. -// TODO Maybe it is better to hide the body, attach it as well, and remove the copy once we are done with it instead? -deleteVehicle _oldBody; +// We are attaching the old unit and hiding it, so we can keep the original unit until later. +_oldBody attachTo [_newUnit, [0,0,0]]; +if (isMultiplayer) then { + hideObjectGlobal _oldBody; +} else { + hideObject _oldBody; +}; +_newUnit setvariable [QGVAR(copyOfUnit), _oldBody, true]; +_newUnit setvariable ["ACE_isDead", true, true]; +_newUnit setvariable ["ACE_isUnconscious", true, true]; _newUnit setDamage 0.89; - _newUnit; diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf index 39aa1d0df6..f8733be8d5 100644 --- a/addons/medical/functions/fnc_onCarryObjectDropped.sqf +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -19,6 +19,17 @@ _target = _caller getvariable [QGVAR(carrying), objNull]; _carrying = _caller getvariable [QGVAR(isCarrying), -1]; if (_carrying >= 0) then { + if !(isNull (_target getvariable [QGVAR(copyOfUnit), objNull])) then { + _copy = _target; + _target = _copy getvariable [QGVAR(copyOfUnit), objNull]; + if (isMultiplayer) then { + _target hideObjectGlobal false; + } else { + _target hideObject false; + }; + detach _copy; + deleteVehicle _copy; + }; _caller setvariable [QGVAR(isCarrying), -1, true]; if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then { From 7bc6fa3c3b0c863e70951d2cb02b1848915b962b Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 20:39:22 +0100 Subject: [PATCH 12/15] Disable interaction for objects --- addons/interact_menu/functions/fnc_render.sqf | 2 +- addons/medical/functions/fnc_copyDeadBody.sqf | 3 +++ addons/medical/functions/fnc_onCarryObjectDropped.sqf | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 523520ee91..6a0b49c417 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -37,7 +37,7 @@ if (GVAR(keyDown)) then { _numInteractions = 0; // Prevent interacting with yourself or your own vehicle - if (_target != ACE_player && {_target != vehicle ACE_player}) then { + if (_target != ACE_player && {_target != vehicle ACE_player} && {_target getvariable [QEGVAR(interaction,enabled), true]}) then { // Iterate through object actions, find base level actions and render them if appropiate _actionsVarName = format [QGVAR(Act_%1), typeOf _target]; diff --git a/addons/medical/functions/fnc_copyDeadBody.sqf b/addons/medical/functions/fnc_copyDeadBody.sqf index 4aabbed44c..8474728c7b 100644 --- a/addons/medical/functions/fnc_copyDeadBody.sqf +++ b/addons/medical/functions/fnc_copyDeadBody.sqf @@ -75,5 +75,8 @@ if (isMultiplayer) then { _newUnit setvariable [QGVAR(copyOfUnit), _oldBody, true]; _newUnit setvariable ["ACE_isDead", true, true]; _newUnit setvariable ["ACE_isUnconscious", true, true]; +_newUnit setvariable [QEGVAR(interaction,enabled), false, true]; +_oldBody setvariable [QEGVAR(interaction,enabled), false, true]; + _newUnit setDamage 0.89; _newUnit; diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf index f8733be8d5..4f001e40a1 100644 --- a/addons/medical/functions/fnc_onCarryObjectDropped.sqf +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -29,6 +29,7 @@ if (_carrying >= 0) then { }; detach _copy; deleteVehicle _copy; + _target setvariable [QEGVAR(interaction,enabled), nil, true]; }; _caller setvariable [QGVAR(isCarrying), -1, true]; From 4995016a660d6432162399c4d76001a0c8ca5ac9 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 20:59:57 +0100 Subject: [PATCH 13/15] Switched to canInteractConditions --- addons/interact_menu/functions/fnc_render.sqf | 2 +- addons/medical/XEH_postInit.sqf | 3 +++ addons/medical/functions/fnc_copyDeadBody.sqf | 5 +++-- addons/medical/functions/fnc_onCarryObjectDropped.sqf | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 6a0b49c417..523520ee91 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -37,7 +37,7 @@ if (GVAR(keyDown)) then { _numInteractions = 0; // Prevent interacting with yourself or your own vehicle - if (_target != ACE_player && {_target != vehicle ACE_player} && {_target getvariable [QEGVAR(interaction,enabled), true]}) then { + if (_target != ACE_player && {_target != vehicle ACE_player}) then { // Iterate through object actions, find base level actions and render them if appropiate _actionsVarName = format [QGVAR(Act_%1), typeOf _target]; diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index f0cebacc58..3731867489 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -15,6 +15,9 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; ["carryObjectDropped", FUNC(onCarryObjectDropped)] call ace_common_fnc_addEventHandler; ["interactMenuClosed", {[objNull, false] call FUNC(displayPatientInformation); }] call ace_common_fnc_addEventHandler; + +[QGVAR(disableInteraction), {!((_this select 1) getVariable [QGVAR(disableInteraction), false])}] call EFUNC(common,addCanInteractWithCondition); + // Initialize all effects _fnc_createEffect = { private ["_type", "_layer", "_default"]; diff --git a/addons/medical/functions/fnc_copyDeadBody.sqf b/addons/medical/functions/fnc_copyDeadBody.sqf index 8474728c7b..68d5a356ec 100644 --- a/addons/medical/functions/fnc_copyDeadBody.sqf +++ b/addons/medical/functions/fnc_copyDeadBody.sqf @@ -73,10 +73,11 @@ if (isMultiplayer) then { }; _newUnit setvariable [QGVAR(copyOfUnit), _oldBody, true]; +_oldBody setvariable [QGVAR(hasCopy), _newUnit, true]; _newUnit setvariable ["ACE_isDead", true, true]; _newUnit setvariable ["ACE_isUnconscious", true, true]; -_newUnit setvariable [QEGVAR(interaction,enabled), false, true]; -_oldBody setvariable [QEGVAR(interaction,enabled), false, true]; +_newUnit setvariable [QGVAR(disableInteraction), true, true]; +_oldBody setvariable [QGVAR(disableInteraction), true, true]; _newUnit setDamage 0.89; _newUnit; diff --git a/addons/medical/functions/fnc_onCarryObjectDropped.sqf b/addons/medical/functions/fnc_onCarryObjectDropped.sqf index 4f001e40a1..8f6dd57310 100644 --- a/addons/medical/functions/fnc_onCarryObjectDropped.sqf +++ b/addons/medical/functions/fnc_onCarryObjectDropped.sqf @@ -29,7 +29,8 @@ if (_carrying >= 0) then { }; detach _copy; deleteVehicle _copy; - _target setvariable [QEGVAR(interaction,enabled), nil, true]; + _target setvariable [QGVAR(disableInteraction), nil, true]; + _target setvariable [QGVAR(hasCopy), nil, true]; }; _caller setvariable [QGVAR(isCarrying), -1, true]; From 1bb32dcfcb2a71984f055a7e2e17ce355ae8f255 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 22:20:44 +0100 Subject: [PATCH 14/15] fixed missing condition variable --- addons/medical/functions/fnc_canTreat.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/medical/functions/fnc_canTreat.sqf b/addons/medical/functions/fnc_canTreat.sqf index 6a49652301..5467031cea 100644 --- a/addons/medical/functions/fnc_canTreat.sqf +++ b/addons/medical/functions/fnc_canTreat.sqf @@ -40,6 +40,7 @@ _locations = getArray (_config >> "treatmentLocations"); _return = true; if (getText (_config >> "condition") != "") then { + _condition = getText (_config >> "condition"); if (isnil _condition) then { _condition = compile _condition; } else { From 15edb0bff21d60862ffa7bbf1fa1013c51161d4b Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Mar 2015 23:24:24 +0100 Subject: [PATCH 15/15] fixes --- addons/medical/CfgVehicles.hpp | 46 +++++++++---------- addons/medical/XEH_preInit.sqf | 3 ++ .../functions/fnc_getBloodVolumeChange.sqf | 22 +++------ .../functions/fnc_handleUnitVitals.sqf | 2 +- .../fnc_treatmentAdvanced_medicationLocal.sqf | 6 +-- .../functions/fnc_treatmentIVLocal.sqf | 9 +++- 6 files changed, 42 insertions(+), 46 deletions(-) diff --git a/addons/medical/CfgVehicles.hpp b/addons/medical/CfgVehicles.hpp index 25d833fa2e..53e22f1aa8 100644 --- a/addons/medical/CfgVehicles.hpp +++ b/addons/medical/CfgVehicles.hpp @@ -1072,27 +1072,27 @@ class CfgVehicles { statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'BloodIV')] call DFUNC(treatment)); }; class PlasmaIV_500: PlasmaIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Plasma IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'PlasmaIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'PlasmaIV_500')] call DFUNC(treatment)); }; class PlasmaIV_250: PlasmaIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Plasma IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'PlasmaIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'PlasmaIV_250')] call DFUNC(treatment)); }; class SalineIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Saline IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV')] call DFUNC(treatment)); }; class SalineIV_500: SalineIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Saline IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV_500')] call DFUNC(treatment)); }; class SalineIV_250: SalineIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Saline IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'SalineIV_250')] call DFUNC(treatment)); }; @@ -1197,32 +1197,32 @@ class CfgVehicles { statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'BloodIV_250')] call DFUNC(treatment)); }; class PlasmaIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Plasma IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'BloodIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'BloodIV')] call DFUNC(treatment)); }; class PlasmaIV_500: PlasmaIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Plasma IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV_500')] call DFUNC(treatment)); }; class PlasmaIV_250: PlasmaIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Plasma IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'PlasmaIV_250')] call DFUNC(treatment)); }; class SalineIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Saline IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV')] call DFUNC(treatment)); }; class SalineIV_500: SalineIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Saline IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV_500')] call DFUNC(treatment)); }; class SalineIV_250: SalineIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Saline IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'SalineIV_250')] call DFUNC(treatment)); }; @@ -1329,32 +1329,32 @@ class CfgVehicles { statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'BloodIV_250')] call DFUNC(treatment)); }; class PlasmaIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Plasma IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'BloodIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'BloodIV')] call DFUNC(treatment)); }; class PlasmaIV_500: PlasmaIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Plasma IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV_500')] call DFUNC(treatment)); }; class PlasmaIV_250: PlasmaIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Plasma IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'PlasmaIV_250')] call DFUNC(treatment)); }; class SalineIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give saline IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV')] call DFUNC(treatment)); }; class SalineIV_500: SalineIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give saline IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV_500')] call DFUNC(treatment)); }; class SalineIV_250: SalineIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give saline IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_l', 'SalineIV_250')] call DFUNC(treatment)); }; @@ -1449,32 +1449,32 @@ class CfgVehicles { statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'BloodIV_250')] call DFUNC(treatment)); }; class PlasmaIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Plasma IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'BloodIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'BloodIV')] call DFUNC(treatment)); }; class PlasmaIV_500: PlasmaIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Plasma IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV_500')] call DFUNC(treatment)); }; class PlasmaIV_250: PlasmaIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Plasma IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'PlasmaIV_250')] call DFUNC(treatment)); }; class SalineIV: BloodIV { - displayName = "Give Blood IV (1000ml)"; + displayName = "Give Saline IV (1000ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV')] call DFUNC(treatment)); }; class SalineIV_500: SalineIV { - displayName = "Give Blood IV (500ml)"; + displayName = "Give Saline IV (500ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV_500')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV_500')] call DFUNC(treatment)); }; class SalineIV_250: SalineIV { - displayName = "Give Blood IV (250ml)"; + displayName = "Give Saline IV (250ml)"; condition = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV_250')] call DFUNC(canTreatCached)); statement = QUOTE([ARR_4(_player, _target, 'leg_r', 'SalineIV_250')] call DFUNC(treatment)); }; diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index c5833d8544..c72407b199 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -29,6 +29,7 @@ PREP(getBloodPressure); PREP(getBloodVolumeChange); PREP(getCardiacOutput); PREP(getTypeOfDamage); +PREP(getHeartRateChange); PREP(getTriageStatus); PREP(getUnconsciousCondition); PREP(handleDamage); @@ -97,6 +98,8 @@ PREP(copyDeadBody); PREP(requestWoundSync); GVAR(injuredUnitCollection) = []; +GVAR(IVBags) = []; + call FUNC(parseConfigForInjuries); ADDON = true; diff --git a/addons/medical/functions/fnc_getBloodVolumeChange.sqf b/addons/medical/functions/fnc_getBloodVolumeChange.sqf index 92b4408fbf..b031ae4585 100644 --- a/addons/medical/functions/fnc_getBloodVolumeChange.sqf +++ b/addons/medical/functions/fnc_getBloodVolumeChange.sqf @@ -37,21 +37,13 @@ _bloodVolume = _unit getvariable [QGVAR(bloodVolume), 100]; _bloodVolumeChange = -(_unit call FUNC(getBloodLoss)); if (_bloodVolume < 100.0) then { - if ((_unit getvariable [QGVAR(salineIVVolume), 0]) > 0) then { - _bloodVolumeChange = _bloodVolumeChange + BLOOD_CHANGE_PER_SECOND; - _ivVolume = (_unit getvariable [QGVAR(salineIVVolume), 0]) + IV_CHANGE_PER_SECOND; - _unit setvariable [QGVAR(salineIVVolume),_ivVolume]; - }; - if ((_unit getvariable [QGVAR(plasmaIVVolume), 0]) > 0) then { - _bloodVolumeChange = _bloodVolumeChange + BLOOD_CHANGE_PER_SECOND; - _ivVolume = (_unit getvariable [QGVAR(plasmaIVVolume), 0]) + IV_CHANGE_PER_SECOND; - _unit setvariable [QGVAR(plasmaIVVolume),_ivVolume]; - }; - if ((_unit getvariable [QGVAR(bloodIVVolume), 0]) > 0) then { - _bloodVolumeChange = _bloodVolumeChange + BLOOD_CHANGE_PER_SECOND; - _ivVolume = (_unit getvariable [QGVAR(bloodIVVolume), 0]) + IV_CHANGE_PER_SECOND; - _unit setvariable [QGVAR(bloodIVVolume),_ivVolume]; - }; + { + if ((_unit getvariable [_x, 0]) > 0) then { + _bloodVolumeChange = _bloodVolumeChange + BLOOD_CHANGE_PER_SECOND; + _ivVolume = (_unit getvariable [_x, 0]) + IV_CHANGE_PER_SECOND; + _unit setvariable [_x,_ivVolume]; + }; + }foreach GVAR(IVBags); }; _bloodVolumeChange; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 68bd98a153..fb085a19b7 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -105,7 +105,7 @@ if (GVAR(level) >= 2) then { }; // Set the vitals - _heartRate = (_unit getvariable [QGVAR(heartRate), 0]) + ([_unit] call FUNC(getHeartRateChange)) * _interval; + _heartRate = (_unit getvariable [QGVAR(heartRate), 0]) + (([_unit] call FUNC(getHeartRateChange)) * _interval); _unit setvariable [QGVAR(heartRate), _heartRate, _syncValues]; _bloodPressure = [_unit] call FUNC(getBloodPressure); diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf index a3d3e26d1d..714f0f7e7f 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf @@ -73,11 +73,7 @@ if (alive _target) then { // Reduce the pain level _pain = _target getvariable [QGVAR(pain), 0]; -_pain = _pain * _painReduce; -if (_pain <= 0) then { - _pain = 0; -}; -_target setvariable [QGVAR(pain), _pain]; +_target setvariable [QGVAR(pain), (_pain - _painReduce) max 0]; _resistance = _unit getvariable [QGVAR(peripheralResistance), 100]; _resistance = _resistance + _viscosityChange; diff --git a/addons/medical/functions/fnc_treatmentIVLocal.sqf b/addons/medical/functions/fnc_treatmentIVLocal.sqf index 190498a8a6..52b83e1d0f 100644 --- a/addons/medical/functions/fnc_treatmentIVLocal.sqf +++ b/addons/medical/functions/fnc_treatmentIVLocal.sqf @@ -21,8 +21,8 @@ _ivItem = _this select 1; // Find the proper attributes for the used IV _config = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "IV"); -_volumeAdded = getNumber (_medicationConfig >> "volume"); -_typeOf = getText (_medicationConfig >> "type"); +_volumeAdded = getNumber (_config >> "volume"); +_typeOf = getText (_config >> "type"); if (isClass (_config >> _className)) then { _config = (_config >> _className); @@ -33,6 +33,11 @@ if (isClass (_config >> _className)) then { _varName = format["ACE_Medical_IVVolume_%1",_typeOf]; _target setvariable [_varName, (_target getvariable [_varName, 0]) + _volumeAdded]; +if !(_varName in GVAR(IVBags)) then { + GVAR(IVBags) pushback _varName; + publicVariable GVAR(IVBags); +}; + // TODO localization //[_target,"treatment",format["%1 has given %4 a %2(%3ml)",[_caller] call EFUNC(common,getName),_attributes select 2,_attributes select 1,_target]] call FUNC(addActivityToLog); //[_target,_removeItem] call FUNC(addToTriageList);