From 02c308e141ed7e29bfc5d8433829cd813c3c76ff Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 1 Aug 2016 16:20:13 -0500 Subject: [PATCH] Use createSimpleObject for medical litter --- addons/medical/ACE_Settings.hpp | 2 -- addons/medical/XEH_postInit.sqf | 10 +++++----- addons/medical/functions/fnc_createLitter.sqf | 10 ++++++---- .../functions/fnc_handleCreateLitter.sqf | 20 +++++++++++-------- .../functions/fnc_litterCleanupLoop.sqf | 15 +++++++------- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index a785c2cad5..9434686f4b 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -159,8 +159,6 @@ class ACE_Settings { value = 3; values[] = {"Off", "Low", "Medium", "High", "Ultra"}; _values[] = { 0, 50, 100, 1000, 5000 }; - - isClientSettable = 1; }; class GVAR(litterCleanUpDelay) { category = CSTRING(Category_Medical); diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 2b1e31e04a..93ba23ed84 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -27,8 +27,11 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"]; [QGVAR(treatmentTourniquetLocal), DFUNC(treatmentTourniquetLocal)] call CBA_fnc_addEventHandler; [QGVAR(actionPlaceInBodyBag), FUNC(actionPlaceInBodyBag)] call CBA_fnc_addEventHandler; -//Handle Deleting Bodies on Server: -if (isServer) then {["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler;}; +//Handle Deleting Bodies and creating litter on Server: +if (isServer) then { + ["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler; + [QGVAR(createLitterServer), FUNC(handleCreateLitter)] call CBA_fnc_addEventHandler; +}; ["ace_unconscious", { params ["_unit", "_status"]; @@ -267,9 +270,6 @@ GVAR(lastHeartBeatSound) = CBA_missionTime; }; ["ace_settingsInitialized", { - // Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set) - [QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); - [ {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)}, {(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9}, diff --git a/addons/medical/functions/fnc_createLitter.sqf b/addons/medical/functions/fnc_createLitter.sqf index fd3bc9a403..2780642056 100644 --- a/addons/medical/functions/fnc_createLitter.sqf +++ b/addons/medical/functions/fnc_createLitter.sqf @@ -22,21 +22,22 @@ #define MIN_ENTRIES_LITTER_CONFIG 3 params ["_caller", "_target", "_selectionName", "_className", "", "_usersOfItems", "_bloodLossOnSelection"]; +TRACE_6("params",_caller,_target,_selectionName,_className,_usersOfItems,_bloodLossOnSelection); //Ensures comptibilty with other possible medical treatment configs private _previousDamage = _bloodLossOnSelection; if !(GVAR(allowLitterCreation)) exitwith {}; -if (vehicle _caller != _caller || vehicle _target != _target) exitwith {}; +if (vehicle _caller != _caller || {vehicle _target != _target}) exitwith {}; private _config = if (GVAR(level) >= 2) then { (configFile >> "ACE_Medical_Actions" >> "Advanced" >> _className); } else { (configFile >> "ACE_Medical_Actions" >> "Basic" >> _className) }; -if !(isClass _config) exitwith {false}; +if !(isClass _config) exitwith {TRACE_1("No action config", _className);}; -if !(isArray (_config >> "litter")) exitwith {}; +if !(isArray (_config >> "litter")) exitwith {TRACE_1("No litter config", _className);}; private _litter = getArray (_config >> "litter"); private _createLitter = { @@ -53,7 +54,8 @@ private _createLitter = { // Create the litter, and timeout the event based on the cleanup delay // The cleanup delay for events in MP is handled by the server side - [QGVAR(createLitter), [_litterClass, _position, _direction], 0] call EFUNC(common,syncedEvent); + TRACE_3("Creating Litter on server",_litterClass,_position,_direction); + [QGVAR(createLitterServer), [_litterClass, _position, _direction]] call CBA_fnc_serverEvent; true }; diff --git a/addons/medical/functions/fnc_handleCreateLitter.sqf b/addons/medical/functions/fnc_handleCreateLitter.sqf index b67d2107b0..2c701a2917 100644 --- a/addons/medical/functions/fnc_handleCreateLitter.sqf +++ b/addons/medical/functions/fnc_handleCreateLitter.sqf @@ -14,10 +14,9 @@ */ #include "script_component.hpp" -if(!hasInterface) exitWith { false }; - params ["_litterClass", "_position", "_direction"]; -private["_litterObject", "_maxLitterCount"]; +TRACE_3("params",_litterClass,_position,_direction); + //IGNORE_PRIVATE_WARNING(_values); if (isNil QGVAR(allCreatedLitter)) then { @@ -25,17 +24,22 @@ if (isNil QGVAR(allCreatedLitter)) then { GVAR(litterPFHRunning) = false; }; -_litterObject = _litterClass createVehicleLocal _position; +private _p3dFile = getText (configFile >> "CfgVehicles" >> _litterClass >> "model"); +if (_p3dFile == "") exitWith {TRACE_2("no model",_litterClass,_p3dFile)}; +// createSimpleObject expects a path without the leading slash +if ((_p3dFile select [0,1]) == "\") then {_p3dFile = _p3dFile select [1];}; + +private _litterObject = createSimpleObject [_p3dFile, [0,0,0]]; +TRACE_2("created",_litterClass,_litterObject); _litterObject setDir _direction; _litterObject setPosATL _position; // Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112 [{ params ["_object", "_pos"]; _object setPosATL _pos; }, [_litterObject, _position]] call CBA_fnc_execNextFrame; -_maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail); -if((count GVAR(allCreatedLitter)) > _maxLitterCount ) then { +private _maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail); +if ((count GVAR(allCreatedLitter)) > _maxLitterCount) then { // gank the first litter object, and spawn ours. - private["_oldLitter"]; - _oldLitter = GVAR(allCreatedLitter) deleteAt 0; + private _oldLitter = GVAR(allCreatedLitter) deleteAt 0; { deleteVehicle _x; } forEach (_oldLitter select 1); diff --git a/addons/medical/functions/fnc_litterCleanupLoop.sqf b/addons/medical/functions/fnc_litterCleanupLoop.sqf index 00e301be6e..417144dd64 100644 --- a/addons/medical/functions/fnc_litterCleanupLoop.sqf +++ b/addons/medical/functions/fnc_litterCleanupLoop.sqf @@ -15,17 +15,18 @@ { _x params ["_time", "_objects"]; - if (CBA_missionTime - _time >= GVAR(litterCleanUpDelay)) then { - { - deleteVehicle _x; - } forEach _objects; - GVAR(allCreatedLitter) set[_forEachIndex, objNull]; - }; + //Older elements are always at the begining of the array: + if ((CBA_missionTime - _time) < GVAR(litterCleanUpDelay)) exitWith {}; + TRACE_2("deleting",_time,_objects); + { + deleteVehicle _x; + } forEach _objects; + GVAR(allCreatedLitter) set [_forEachIndex, objNull]; } forEach GVAR(allCreatedLitter); GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull]; // If no more litter remaining, exit the loop -if ( (count GVAR(allCreatedLitter)) == 0) exitWith { +if (GVAR(allCreatedLitter) isEqualTo []) exitWith { GVAR(litterPFHRunning) = false; };