From 88eae19646065d8be645b10092d77e056b5db254 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Wed, 17 Feb 2016 22:54:43 -0300 Subject: [PATCH] Replace execRemoteFnc in ace_medical --- addons/common/XEH_postInit.sqf | 4 +++- addons/medical/XEH_postInit.sqf | 18 +++++++++++++++++- .../functions/fnc_actionCheckBloodPressure.sqf | 6 +++++- .../medical/functions/fnc_actionCheckPulse.sqf | 7 +++++-- .../functions/fnc_addToInjuredCollection.sqf | 2 +- addons/medical/functions/fnc_addToLog.sqf | 2 +- .../medical/functions/fnc_addToTriageCard.sqf | 2 +- addons/medical/functions/fnc_setDead.sqf | 4 ++-- .../functions/fnc_setHitPointDamage.sqf | 2 +- .../medical/functions/fnc_setUnconscious.sqf | 2 +- .../functions/fnc_treatmentAdvanced_CPR.sqf | 6 +++++- .../fnc_treatmentAdvanced_bandage.sqf | 7 ++++++- .../fnc_treatmentAdvanced_fullHeal.sqf | 7 +++++-- .../functions/fnc_treatmentBasic_bandage.sqf | 6 +++++- .../functions/fnc_treatmentBasic_bloodbag.sqf | 6 +++++- .../functions/fnc_treatmentBasic_morphine.sqf | 6 +++++- addons/medical/functions/fnc_treatmentIV.sqf | 7 ++++++- .../functions/fnc_treatmentTourniquet.sqf | 6 +++++- addons/medical/functions/fnc_useItem.sqf | 18 +++++++++++++++--- 19 files changed, 94 insertions(+), 24 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 65b9804da5..a265600d28 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -251,7 +251,7 @@ call FUNC(checkFiles); // Publish all settings data after all configs and modules are read publicVariable QGVAR(settings); }; - + // Load user settings from profile if (hasInterface) then { call FUNC(loadSettingsFromProfile); @@ -476,6 +476,8 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then { }; }] call FUNC(addEventhandler); +["useItem", DFUNC(useItem)] call FUNC(addEventHandler); + ////////////////////////////////////////////////// // Add various canInteractWith conditions diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 7345c2a54e..e38fd14199 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -12,7 +12,23 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; //Treatment EventHandlers: ["medical_advMedication", FUNC(treatmentAdvanced_medicationLocal)] call EFUNC(common,addEventHandler); - +["actionCheckBloodPressureLocal", DFUNC(actionCheckBloodPressureLocal)] call EFUNC(common,addEventHandler); +["actionCheckPulseLocal", DFUNC(actionCheckPulseLocal)] call EFUNC(common,addEventHandler); +["addToInjuredCollection", DFUNC(addToInjuredCollection)] call EFUNC(common,addEventHandler); +["addToMedicalLog", DFUNC(addToLog)] call EFUNC(common,addEventHandler); +["addToTriageList", DFUNC(addToTriageList)] call EFUNC(common,addEventHandler); +["setDead", DFUNC(setDead)] call EFUNC(common,addEventHandler); +["setHitPointDamage", DFUNC(setHitPointDamage)] call EFUNC(common,addEventHandler); +["setUnconscious", DFUNC(setUnconscious)] call EFUNC(common,addEventHandler); +["treatmentAdvanced_bandageLocal", DFUNC(treatmentAdvanced_bandageLocal)] call EFUNC(common,addEventHandler); +["treatmentAdvanced_CPRLocal", DFUNC(treatmentAdvanced_CPRLocal)] call EFUNC(common,addEventHandler); +["treatmentAdvanced_fullHealLocal", DFUNC(treatmentAdvanced_fullHealLocal)] call EFUNC(common,addEventHandler); +["treatmentAdvanced_medicationLocal", DFUNC(treatmentAdvanced_medicationLocal)] call EFUNC(common,addEventHandler); +["treatmentBasic_bandageLocal", DFUNC(treatmentBasic_bandageLocal)] call EFUNC(common,addEventHandler); +["treatmentBasic_bloodbagLocal", DFUNC(treatmentBasic_bloodbagLocal)] call EFUNC(common,addEventHandler); +["treatmentBasic_morphineLocal", DFUNC(treatmentBasic_morphineLocal)] call EFUNC(common,addEventHandler); +["treatmentIVLocal", DFUNC(treatmentIVLocal)] call EFUNC(common,addEventHandler); +["treatmentTourniquetLocal", DFUNC(treatmentTourniquetLocal)] call EFUNC(common,addEventHandler); ["medical_onUnconscious", { params ["_unit", "_status"]; diff --git a/addons/medical/functions/fnc_actionCheckBloodPressure.sqf b/addons/medical/functions/fnc_actionCheckBloodPressure.sqf index 889cc90de9..4d821ea6b0 100644 --- a/addons/medical/functions/fnc_actionCheckBloodPressure.sqf +++ b/addons/medical/functions/fnc_actionCheckBloodPressure.sqf @@ -15,4 +15,8 @@ #include "script_component.hpp" params ["_caller", "_target", "_selectionName"]; -[[_caller, _target, _selectionName], QUOTE(DFUNC(actionCheckBloodPressureLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["actionCheckBloodPressureLocal", [_caller, _target, _selectionName]] call EFUNC(common,localEvent); +} else { + ["actionCheckBloodPressureLocal", _target, [_caller, _target, _selectionName]] call EFUNC(common,targetEvent); +}; diff --git a/addons/medical/functions/fnc_actionCheckPulse.sqf b/addons/medical/functions/fnc_actionCheckPulse.sqf index 8c2c6cf109..2c0a46c826 100644 --- a/addons/medical/functions/fnc_actionCheckPulse.sqf +++ b/addons/medical/functions/fnc_actionCheckPulse.sqf @@ -15,5 +15,8 @@ #include "script_component.hpp" params ["_caller","_target", "_selectionName"]; -[[_caller, _target, _selectionName], QUOTE(DFUNC(actionCheckPulseLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ - +if (local _target) then { + ["actionCheckPulseLocal", [_caller, _target, _selectionName]] call EFUNC(common,localEvent); +} else { + ["actionCheckPulseLocal", _target, [_caller, _target, _selectionName]] call EFUNC(common,targetEvent); +}; diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index 48e400f7b2..aa545f491e 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -18,7 +18,7 @@ params ["_unit", ["_force", false]]; if ([_unit] call FUNC(hasMedicalEnabled) || _force) then { if !(local _unit) exitWith { - [[_unit, _force], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + ["addToInjuredCollection", _unit, [_unit, _force]] call EFUNC(common,targetEvent); }; if ((_unit getVariable[QGVAR(addedToUnitLoop),false] || !alive _unit) && !_force) exitWith{}; diff --git a/addons/medical/functions/fnc_addToLog.sqf b/addons/medical/functions/fnc_addToLog.sqf index 8d1b337514..88c463d1eb 100644 --- a/addons/medical/functions/fnc_addToLog.sqf +++ b/addons/medical/functions/fnc_addToLog.sqf @@ -20,7 +20,7 @@ private ["_moment", "_logVarName", "_log","_newLog", "_logs"]; params ["_unit", "_type", "_message", "_arguments"]; if (!local _unit) exitWith { - [_this, QFUNC(addToLog), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + ["addToMedicalLog", _unit, _this] call EFUNC(common,targetEvent); }; date params ["", "", "", "_hour", "_minute"]; diff --git a/addons/medical/functions/fnc_addToTriageCard.sqf b/addons/medical/functions/fnc_addToTriageCard.sqf index bd988fa84c..6fc9777ddf 100644 --- a/addons/medical/functions/fnc_addToTriageCard.sqf +++ b/addons/medical/functions/fnc_addToTriageCard.sqf @@ -18,7 +18,7 @@ private ["_log", "_inList", "_amount"]; params ["_unit", "_newItem"]; if (!local _unit) exitWith { - [_this, QUOTE(DFUNC(addToTriageCard)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + ["addToTriageList", _unit, _this] call EFUNC(common,targetEvent); }; _log = _unit getVariable [QGVAR(triageCard), []]; diff --git a/addons/medical/functions/fnc_setDead.sqf b/addons/medical/functions/fnc_setDead.sqf index 7c4f94b260..913431ccac 100644 --- a/addons/medical/functions/fnc_setDead.sqf +++ b/addons/medical/functions/fnc_setDead.sqf @@ -20,7 +20,7 @@ params ["_unit", ["_force", false], ["_delaySetDamage", false]]; if ((!alive _unit) || {_unit getVariable ["ACE_isDead", false]}) exitWith {true}; if (!local _unit) exitwith { - [[_unit, _force], QUOTE(DFUNC(setDead)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + ["setDead", _unit, [_unit, _force]] call EFUNC(common,targetEvent); false; }; @@ -86,7 +86,7 @@ if (isPLayer _unit) then { ["medical_onSetDead", [_unit]] call EFUNC(common,localEvent); -//Delay a frame before killing the unit via scripted damage +//Delay a frame before killing the unit via scripted damage //to avoid triggering the "Killed" Event twice (and having the wrong killer) if (!_delaySetDamage) then { diff --git a/addons/medical/functions/fnc_setHitPointDamage.sqf b/addons/medical/functions/fnc_setHitPointDamage.sqf index f8698a7fe0..5c8c419905 100644 --- a/addons/medical/functions/fnc_setHitPointDamage.sqf +++ b/addons/medical/functions/fnc_setHitPointDamage.sqf @@ -26,7 +26,7 @@ params ["_unit", "_selection", "_damage", ["_disabled", false]]; // Unit isn't local, give function to machine where it is. if !(local _unit) exitWith { - [_this, QUOTE(DFUNC(setHitPointDamage)), _unit] call EFUNC(common,execRemoteFnc); + ["setHitPointDamage", _unit, _this] call EFUNC(common,targetEvent); }; // Check if overall damage adjustment is disabled diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 7cfc6f55b4..71bfab49b0 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -39,7 +39,7 @@ if !(_set) exitWith { if !(!(isNull _unit) && {(_unit isKindOf "CAManBase") && ([_unit] call EFUNC(common,isAwake))}) exitWith{}; if (!local _unit) exitWith { - [[_unit, _set, _minWaitingTime, _force], QUOTE(DFUNC(setUnconscious)), _unit, false] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + ["setUnconscious", _unit, [_unit, _set, _minWaitingTime, _force]] call EFUNC(common,targetEvent); }; _unit setVariable ["ACE_isUnconscious", true, true]; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf b/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf index f86e620625..291c8f6cbe 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf @@ -19,6 +19,10 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; if (alive _target && {(_target getVariable [QGVAR(inCardiacArrest), false] || _target getVariable [QGVAR(inReviveState), false])}) then { - [[_caller, _target], QUOTE(DFUNC(treatmentAdvanced_CPRLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + if (local _target) then { + ["treatmentAdvanced_CPRLocal", [_caller, _target]] call EFUNC(common,localEvent); + } else { + ["treatmentAdvanced_CPRLocal", _target, [_caller, _target]] call EFUNC(common,targetEvent); + }; }; true; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf index bb69a1e45a..98881e1a28 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf @@ -26,7 +26,12 @@ if !([_target] call FUNC(hasMedicalEnabled)) exitWith { _this call FUNC(treatmentBasic_bandage); }; -[[_target, _className, _selectionName, _specificSpot], QUOTE(DFUNC(treatmentAdvanced_bandageLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentAdvanced_bandageLocal", [_target, _className, _selectionName, _specificSpot]] call EFUNC(common,localEvent); +} else { + ["treatmentAdvanced_bandageLocal", _target, [_target, _className, _selectionName, _specificSpot]] call EFUNC(common,targetEvent); +}; + /* { if (_x != "") then { [_target, _x] call FUNC(addToTriageCard); diff --git a/addons/medical/functions/fnc_treatmentAdvanced_fullHeal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_fullHeal.sqf index a26876568d..a5332df107 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_fullHeal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_fullHeal.sqf @@ -12,7 +12,10 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; -// TODO replace by event system -[[_caller, _target], QUOTE(DFUNC(treatmentAdvanced_fullHealLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentAdvanced_fullHealLocal", [_caller, _target]] call EFUNC(common,localEvent); +} else { + ["treatmentAdvanced_fullHealLocal", _target, [_caller, _target]] call EFUNC(common,targetEvent); +}; true; diff --git a/addons/medical/functions/fnc_treatmentBasic_bandage.sqf b/addons/medical/functions/fnc_treatmentBasic_bandage.sqf index 04cace08af..3e04ad3bd8 100644 --- a/addons/medical/functions/fnc_treatmentBasic_bandage.sqf +++ b/addons/medical/functions/fnc_treatmentBasic_bandage.sqf @@ -20,4 +20,8 @@ private ["_hitSelections", "_hitPoints", "_point", "_damage"]; params ["_caller", "_target", "_selection", "_className"]; -[[_target, _selection], QUOTE(DFUNC(treatmentBasic_bandageLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentBasic_bandageLocal", [_target, _selection]] call EFUNC(common,localEvent); +} else { + ["treatmentBasic_bandageLocal", _target, [_target, _selection]] call EFUNC(common,targetEvent); +}; diff --git a/addons/medical/functions/fnc_treatmentBasic_bloodbag.sqf b/addons/medical/functions/fnc_treatmentBasic_bloodbag.sqf index 5700d351cb..f28b634038 100644 --- a/addons/medical/functions/fnc_treatmentBasic_bloodbag.sqf +++ b/addons/medical/functions/fnc_treatmentBasic_bloodbag.sqf @@ -18,4 +18,8 @@ params ["_caller", "_target", "_treatmentClassname"]; -[[_target, _treatmentClassname], QUOTE(DFUNC(treatmentBasic_bloodbagLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentBasic_bloodbagLocal", [_target, _treatmentClassname]] call EFUNC(common,localEvent); +} else { + ["treatmentBasic_bloodbagLocal", _target, [_target, _treatmentClassname]] call EFUNC(common,targetEvent); +}; diff --git a/addons/medical/functions/fnc_treatmentBasic_morphine.sqf b/addons/medical/functions/fnc_treatmentBasic_morphine.sqf index 87559d0dd2..d2f7de45a9 100644 --- a/addons/medical/functions/fnc_treatmentBasic_morphine.sqf +++ b/addons/medical/functions/fnc_treatmentBasic_morphine.sqf @@ -19,4 +19,8 @@ params ["_caller", "_target"]; -[[_target], QUOTE(DFUNC(treatmentBasic_morphineLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentBasic_morphineLocal", [_target]] call EFUNC(common,localEvent); +} else { + ["treatmentBasic_morphineLocal", _target, [_target]] call EFUNC(common,targetEvent); +}; diff --git a/addons/medical/functions/fnc_treatmentIV.sqf b/addons/medical/functions/fnc_treatmentIV.sqf index ebf33c75c7..29173fe23b 100644 --- a/addons/medical/functions/fnc_treatmentIV.sqf +++ b/addons/medical/functions/fnc_treatmentIV.sqf @@ -22,7 +22,12 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; if (count _items == 0) exitWith {false}; _removeItem = _items select 0; -[[_target, _className], QUOTE(DFUNC(treatmentIVLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentIVLocal", [_target, _className]] call EFUNC(common,localEvent); +} else { + ["treatmentIVLocal", _target, [_target, _className]] call EFUNC(common,targetEvent); +}; + [_target, _removeItem] call FUNC(addToTriageCard); [_target, "activity", LSTRING(Activity_gaveIV), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); [_target, "activity_view", LSTRING(Activity_gaveIV), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message diff --git a/addons/medical/functions/fnc_treatmentTourniquet.sqf b/addons/medical/functions/fnc_treatmentTourniquet.sqf index 1c5c9282db..b410a899a4 100644 --- a/addons/medical/functions/fnc_treatmentTourniquet.sqf +++ b/addons/medical/functions/fnc_treatmentTourniquet.sqf @@ -40,7 +40,11 @@ if ((_tourniquets select _part) > 0) exitWith { }; _removeItem = _items select 0; -[[_target, _removeItem, _selectionName], QUOTE(DFUNC(treatmentTourniquetLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ +if (local _target) then { + ["treatmentTourniquetLocal", [_target, _removeItem, _selectionName]] call EFUNC(common,localEvent); +} else { + ["treatmentTourniquetLocal", _target, [_target, _removeItem, _selectionName]] call EFUNC(common,targetEvent); +}; [_target, _removeItem] call FUNC(addToTriageCard); [_target, "activity", LSTRING(Activity_appliedTourniquet), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); diff --git a/addons/medical/functions/fnc_useItem.sqf b/addons/medical/functions/fnc_useItem.sqf index 7abf80c464..71b5304c67 100644 --- a/addons/medical/functions/fnc_useItem.sqf +++ b/addons/medical/functions/fnc_useItem.sqf @@ -24,12 +24,20 @@ if (isNil QGVAR(setting_allowSharedEquipment)) then { }; if (GVAR(setting_allowSharedEquipment) && {[_patient, _item] call EFUNC(common,hasItem)}) exitWith { - [[_patient, _item], QUOTE(EFUNC(common,useItem)), _patient] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + if (local _patient) then { + ["useItem", [_patient, _item]] call EFUNC(common,localEvent); + } else { + ["useItem", _patient, [_patient, _item]] call EFUNC(common,targetEvent); + }; [true, _patient]; }; if ([_medic, _item] call EFUNC(common,hasItem)) exitWith { - [[_medic, _item], QUOTE(EFUNC(common,useItem)), _medic] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + if (local _medic) then { + ["useItem", [_medic, _item]] call EFUNC(common,localEvent); + } else { + ["useItem", _medic, [_medic, _item]] call EFUNC(common,targetEvent); + }; [true, _medic]; }; @@ -39,7 +47,11 @@ if ([vehicle _medic] call FUNC(isMedicalVehicle) && {vehicle _medic != _medic}) { if ([_medic, _x] call FUNC(canAccessMedicalEquipment) && {([_x, _item] call EFUNC(common,hasItem))}) exitWith { _return = [true, _x]; - [[_x, _item], QUOTE(EFUNC(common,useItem)), _x] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + if (local _x) then { + ["useItem", [_x, _item]] call EFUNC(common,localEvent); + } else { + ["useItem", _x, [_x, _item]] call EFUNC(common,targetEvent); + }; }; } forEach _crew; };