mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
port litter to treatment
This commit is contained in:
parent
27314c34b1
commit
81d962f0d5
@ -11,7 +11,6 @@ call FUNC(stateMachine);
|
|||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler;
|
["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler;
|
||||||
};
|
};
|
||||||
[QGVAR(createLitterServer), FUNC(handleCreateLitter)] call CBA_fnc_addEventHandler;
|
|
||||||
|
|
||||||
["ace_unconscious", {
|
["ace_unconscious", {
|
||||||
params ["_unit", "_status"];
|
params ["_unit", "_status"];
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Author: Glowbal
|
|
||||||
* Spawns litter for the treatment action on the ground around the target
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: The Caller <OBJECT>
|
|
||||||
* 1: The target <OBJECT>
|
|
||||||
* 2: The treatment Selection Name <STRING>
|
|
||||||
* 3: The treatment classname <STRING>
|
|
||||||
* 4: ?
|
|
||||||
* 5: Users of Items <?>
|
|
||||||
* 6: Blood Loss on selection (previously called _previousDamage) <NUMBER>
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Public: No
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
#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 {};
|
|
||||||
|
|
||||||
private _config = if (GVAR(level) >= 2) then {
|
|
||||||
(configFile >> "ACE_Medical_Actions" >> "Advanced" >> _className);
|
|
||||||
} else {
|
|
||||||
(configFile >> "ACE_Medical_Actions" >> "Basic" >> _className)
|
|
||||||
};
|
|
||||||
if !(isClass _config) exitwith {TRACE_1("No action config", _className);};
|
|
||||||
|
|
||||||
if !(isArray (_config >> "litter")) exitwith {TRACE_1("No litter config", _className);};
|
|
||||||
private _litter = getArray (_config >> "litter");
|
|
||||||
|
|
||||||
private _createLitter = {
|
|
||||||
params ["_unit", "_litterClass"];
|
|
||||||
// @TODO: handle carriers over water
|
|
||||||
// For now, don't spawn litter if we are over water to avoid floating litter
|
|
||||||
if (surfaceIsWater (getPos _unit)) exitWith { false };
|
|
||||||
|
|
||||||
private _position = getPosATL _unit;
|
|
||||||
_position params ["_posX", "_posY", "_posZ"];
|
|
||||||
_position = [_posX + (random 2) - 1, _posY + (random 2) - 1, _posZ];
|
|
||||||
|
|
||||||
private _direction = (random 360);
|
|
||||||
|
|
||||||
// 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
|
|
||||||
TRACE_3("Creating Litter on server",_litterClass,_position,_direction);
|
|
||||||
[QGVAR(createLitterServer), [_litterClass, _position, _direction]] call CBA_fnc_serverEvent;
|
|
||||||
|
|
||||||
true
|
|
||||||
};
|
|
||||||
|
|
||||||
private _createdLitter = [];
|
|
||||||
{
|
|
||||||
if (_x isEqualType []) then {
|
|
||||||
if (count _x < MIN_ENTRIES_LITTER_CONFIG) exitwith {};
|
|
||||||
|
|
||||||
_x params ["_selection", "_litterCondition", "_litterOptions"];
|
|
||||||
|
|
||||||
if (toLower _selection in [toLower _selectionName, "all"]) then { // in is case sensitve. We can be forgiving here, so lets use toLower.
|
|
||||||
|
|
||||||
if (isnil _litterCondition) then {
|
|
||||||
_litterCondition = if (_litterCondition != "") then {compile _litterCondition} else {{true}};
|
|
||||||
} else {
|
|
||||||
_litterCondition = missionNamespace getVariable _litterCondition;
|
|
||||||
if (!(_litterCondition isEqualType {})) then {_litterCondition = {false}};
|
|
||||||
};
|
|
||||||
if !([_caller, _target, _selectionName, _className, _usersOfItems, _bloodLossOnSelection] call _litterCondition) exitwith {};
|
|
||||||
|
|
||||||
if (_litterOptions isEqualType []) then {
|
|
||||||
// Loop through through the litter options and place the litter
|
|
||||||
{
|
|
||||||
if (_x isEqualType [] && {(count _x > 0)}) then {
|
|
||||||
[_target, selectRandom _x] call _createLitter;
|
|
||||||
};
|
|
||||||
if (_x isEqualType "") then {
|
|
||||||
[_target, _x] call _createLitter;
|
|
||||||
};
|
|
||||||
} foreach _litterOptions;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} foreach _litter;
|
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
PREP(actionCheckBloodPressure);
|
PREP(actionCheckBloodPressure);
|
||||||
PREP(actionCheckBloodPressureLocal);
|
PREP(actionCheckBloodPressureLocal);
|
||||||
PREP(actionCheckPulse);
|
PREP(actionCheckPulse);
|
||||||
@ -52,3 +53,8 @@ PREP(useItem);
|
|||||||
PREP(useItems);
|
PREP(useItems);
|
||||||
|
|
||||||
PREP(checkItems);
|
PREP(checkItems);
|
||||||
|
|
||||||
|
// litter
|
||||||
|
PREP(litterCreate);
|
||||||
|
PREP(litterHandleCreate);
|
||||||
|
PREP(litterCleanupLoop);
|
||||||
|
@ -5,3 +5,5 @@
|
|||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
_unit call FUNC(checkItems);
|
_unit call FUNC(checkItems);
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
[QGVAR(createLitterServer), FUNC(litterHandleCreate)] call CBA_fnc_addEventHandler;
|
||||||
|
@ -10,25 +10,28 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
{
|
{
|
||||||
_x params ["_time", "_objects"];
|
_x params ["_time", "_objects"];
|
||||||
//Older elements are always at the begining of the array:
|
|
||||||
if ((CBA_missionTime - _time) < GVAR(litterCleanUpDelay)) exitWith {};
|
// Older elements are always at the begining of the array
|
||||||
|
if (CBA_missionTime - _time < GVAR(litterCleanUpDelay)) exitWith {};
|
||||||
|
|
||||||
TRACE_2("deleting",_time,_objects);
|
TRACE_2("deleting",_time,_objects);
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
} forEach _objects;
|
} forEach _objects;
|
||||||
|
|
||||||
GVAR(allCreatedLitter) set [_forEachIndex, objNull];
|
GVAR(allCreatedLitter) set [_forEachIndex, objNull];
|
||||||
} forEach GVAR(allCreatedLitter);
|
} forEach GVAR(allCreatedLitter);
|
||||||
|
|
||||||
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
|
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
|
||||||
|
|
||||||
// If no more litter remaining, exit the loop
|
// If no more litter remain, exit the loop
|
||||||
if (GVAR(allCreatedLitter) isEqualTo []) exitWith {
|
if (GVAR(allCreatedLitter) isEqualTo []) exitWith {
|
||||||
GVAR(litterPFHRunning) = false;
|
GVAR(litterPFHRunning) = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Schedule the loop to be executed again 30 sec later
|
// Schedule the loop to be executed again 30 sec later
|
||||||
[DFUNC(litterCleanupLoop), [], 30] call CBA_fnc_waitAndExecute;
|
[FUNC(litterCleanupLoop), [], 30] call CBA_fnc_waitAndExecute;
|
98
addons/medical_treatment/functions/fnc_litterCreate.sqf
Normal file
98
addons/medical_treatment/functions/fnc_litterCreate.sqf
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Author: Glowbal
|
||||||
|
* Spawns litter for the treatment action on the ground around the target
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: The Caller <OBJECT>
|
||||||
|
* 1: The target <OBJECT>
|
||||||
|
* 2: The treatment Selection Name <STRING>
|
||||||
|
* 3: The treatment classname <STRING>
|
||||||
|
* 4: ?
|
||||||
|
* 5: Users of Items <?>
|
||||||
|
* 6: Blood Loss on selection (previously called _previousDamage) <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
// Exit if litter is disabled by setting
|
||||||
|
if !(EGVAR(medical,allowLitterCreation)) exitWith {};
|
||||||
|
|
||||||
|
// Don't create litter if medic or patient are inside a vehicle
|
||||||
|
if (vehicle _caller != _caller || {vehicle _target != _target}) exitWith {};
|
||||||
|
|
||||||
|
private _config = configFile >> "ACE_Medical_Treatment_Actions" >> ["Basic", "Advanced"] select (EGVAR(medical,level) >= 2) >> _className;
|
||||||
|
if !(isClass _config) exitWith {TRACE_1("No action config",_className);};
|
||||||
|
|
||||||
|
if !(isArray (_config >> "litter")) exitWith {TRACE_1("No litter config",_className);};
|
||||||
|
private _litter = getArray (_config >> "litter");
|
||||||
|
|
||||||
|
private _createLitter = {
|
||||||
|
params ["_unit", "_litterClass"];
|
||||||
|
|
||||||
|
private _position = getPosASL _unit;
|
||||||
|
|
||||||
|
// @TODO: handle carriers over water
|
||||||
|
// For now, don't spawn litter if we are over water to avoid floating litter
|
||||||
|
if (surfaceIsWater _position) exitWith {false};
|
||||||
|
|
||||||
|
_position = _position vectorAdd [
|
||||||
|
random 2 - 1,
|
||||||
|
random 2 - 1,
|
||||||
|
0
|
||||||
|
];
|
||||||
|
|
||||||
|
private _direction = random 360;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
TRACE_3("Creating Litter on server",_litterClass,_position,_direction);
|
||||||
|
[QGVAR(createLitterServer), [_litterClass, _position, _direction]] call CBA_fnc_serverEvent;
|
||||||
|
|
||||||
|
true
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
if (count _x < MIN_ENTRIES_LITTER_CONFIG) then {
|
||||||
|
WARNING_1("Wrong litter array: %1",_x);
|
||||||
|
} else {
|
||||||
|
_x params [
|
||||||
|
["_selection", "", [""]],
|
||||||
|
["_litterCondition", "", [""]],
|
||||||
|
["_litterOptions", [], [[]]]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (toLower _selection in [toLower _selectionName, "all"]) then {
|
||||||
|
if (_litterCondition isEqualTo "") then {
|
||||||
|
_litterCondition = {true};
|
||||||
|
} else {
|
||||||
|
_litterCondition = compile _litterCondition;
|
||||||
|
};
|
||||||
|
|
||||||
|
// existing configs seem to use carried over magic variables. we pass them as arguments (_this) anyway
|
||||||
|
if !([_caller, _target, _selectionName, _className, _usersOfItems, _bloodLossOnSelection] call _litterCondition) exitWith {};
|
||||||
|
|
||||||
|
// Loop through through the litter options and place the litter
|
||||||
|
{
|
||||||
|
if (_x isEqualType "") then {
|
||||||
|
[_target, _x] call _createLitter;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_x isEqualType [] && {count _x > 0}) then {
|
||||||
|
[_target, selectRandom _x] call _createLitter;
|
||||||
|
};
|
||||||
|
} foreach _litterOptions;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} foreach _litter;
|
@ -24,22 +24,33 @@ if (isNil QGVAR(allCreatedLitter)) then {
|
|||||||
GVAR(litterPFHRunning) = false;
|
GVAR(litterPFHRunning) = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _p3dFile = getText (configFile >> "CfgVehicles" >> _litterClass >> "model");
|
private _model = getText (configFile >> "CfgVehicles" >> _litterClass >> "model");
|
||||||
if (_p3dFile == "") exitWith {TRACE_2("no model",_litterClass,_p3dFile)};
|
if (_model == "") exitWith {TRACE_2("no model",_litterClass,_model)};
|
||||||
|
|
||||||
// createSimpleObject expects a path without the leading slash
|
// createSimpleObject expects a path without the leading slash
|
||||||
if ((_p3dFile select [0,1]) == "\") then {_p3dFile = _p3dFile select [1];};
|
if (_model select [0,1] == "\") then {
|
||||||
|
_model = _model select [1];
|
||||||
|
};
|
||||||
|
|
||||||
private _litterObject = createSimpleObject [_p3dFile, [0,0,0]];
|
private _litterObject = createSimpleObject [_model, [0,0,0]];
|
||||||
TRACE_2("created",_litterClass,_litterObject);
|
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;
|
|
||||||
|
|
||||||
private _maxLitterCount = getArray (configFile >> "ACE_Settings" >> QGVAR(litterSimulationDetail) >> "_values") select GVAR(litterSimulationDetail);
|
_litterObject setDir _direction;
|
||||||
if ((count GVAR(allCreatedLitter)) > _maxLitterCount) then {
|
_litterObject setPosASL _position;
|
||||||
|
|
||||||
|
// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112
|
||||||
|
[{
|
||||||
|
params ["_object", "_position"];
|
||||||
|
|
||||||
|
_object setPosASL _position;
|
||||||
|
}, [_litterObject, _position]] call CBA_fnc_execNextFrame;
|
||||||
|
|
||||||
|
private _maxLitterCount = getArray (configFile >> "ACE_Settings" >> QEGVAR(medical,litterSimulationDetail) >> "_values") select GVAR(medical,litterSimulationDetail);
|
||||||
|
|
||||||
|
if (count GVAR(allCreatedLitter) > _maxLitterCount) then {
|
||||||
// gank the first litter object, and spawn ours.
|
// gank the first litter object, and spawn ours.
|
||||||
private _oldLitter = GVAR(allCreatedLitter) deleteAt 0;
|
private _oldLitter = GVAR(allCreatedLitter) deleteAt 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
} forEach (_oldLitter select 1);
|
} forEach (_oldLitter select 1);
|
@ -81,7 +81,7 @@ TRACE_1("advanced",_bloodLossOnSelection);
|
|||||||
|
|
||||||
_args call _callback;
|
_args call _callback;
|
||||||
_args pushBack _bloodLossOnSelection;
|
_args pushBack _bloodLossOnSelection;
|
||||||
_args call FUNC(createLitter);
|
_args call FUNC(litterCreate);
|
||||||
|
|
||||||
//If we're not already tracking vitals, start:
|
//If we're not already tracking vitals, start:
|
||||||
if (!(_target getVariable [QGVAR(addedToUnitLoop),false])) then {
|
if (!(_target getVariable [QGVAR(addedToUnitLoop),false])) then {
|
||||||
|
Loading…
Reference in New Issue
Block a user