2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-03 23:42:13 +00:00
|
|
|
/*
|
2015-04-18 02:38:05 +00:00
|
|
|
* Author: Glowbal
|
|
|
|
* Spawns litter for the treatment action on the ground around the target
|
2015-04-03 23:42:13 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-22 14:25:10 +00:00
|
|
|
* 0: The Caller <OBJECT>
|
|
|
|
* 1: The target <OBJECT>
|
|
|
|
* 2: The treatment Selection Name <STRING>
|
|
|
|
* 3: The treatment classname <STRING>
|
2017-06-08 13:31:51 +00:00
|
|
|
* 4: ? <UNKNOWN>
|
|
|
|
* 5: Users of Items <UNKNOWN>
|
2015-12-11 04:58:44 +00:00
|
|
|
* 6: Blood Loss on selection (previously called _previousDamage) <NUMBER>
|
2015-04-03 23:42:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-04-03 23:42:13 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, kevin, "selection", "classname", , , 5] call ACE_medical_fnc_createLitter
|
|
|
|
*
|
2015-04-03 23:42:13 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-04-18 02:38:05 +00:00
|
|
|
#define MIN_ENTRIES_LITTER_CONFIG 3
|
|
|
|
|
2015-12-11 04:58:44 +00:00
|
|
|
params ["_caller", "_target", "_selectionName", "_className", "", "_usersOfItems", "_bloodLossOnSelection"];
|
2016-08-01 21:20:13 +00:00
|
|
|
TRACE_6("params",_caller,_target,_selectionName,_className,_usersOfItems,_bloodLossOnSelection);
|
2015-12-11 04:58:44 +00:00
|
|
|
|
|
|
|
//Ensures comptibilty with other possible medical treatment configs
|
|
|
|
private _previousDamage = _bloodLossOnSelection;
|
2015-04-18 02:38:05 +00:00
|
|
|
|
|
|
|
if !(GVAR(allowLitterCreation)) exitwith {};
|
2016-08-01 21:20:13 +00:00
|
|
|
if (vehicle _caller != _caller || {vehicle _target != _target}) exitwith {};
|
2015-04-18 02:38:05 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _config = if (GVAR(level) >= 2) then {
|
|
|
|
(configFile >> "ACE_Medical_Actions" >> "Advanced" >> _className);
|
|
|
|
} else {
|
|
|
|
(configFile >> "ACE_Medical_Actions" >> "Basic" >> _className)
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
2016-08-01 21:20:13 +00:00
|
|
|
if !(isClass _config) exitwith {TRACE_1("No action config", _className);};
|
2015-04-18 02:38:05 +00:00
|
|
|
|
2016-08-01 21:20:13 +00:00
|
|
|
if !(isArray (_config >> "litter")) exitwith {TRACE_1("No litter config", _className);};
|
2016-06-13 00:34:56 +00:00
|
|
|
private _litter = getArray (_config >> "litter");
|
2015-04-18 02:38:05 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _createLitter = {
|
2015-08-26 08:04:51 +00:00
|
|
|
params ["_unit", "_litterClass"];
|
2015-05-14 00:29:09 +00:00
|
|
|
// @TODO: handle carriers over water
|
|
|
|
// For now, don't spawn litter if we are over water to avoid floating litter
|
2016-06-13 00:34:56 +00:00
|
|
|
if (surfaceIsWater (getPos _unit)) exitWith { false };
|
2015-08-22 14:25:10 +00:00
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _position = getPosATL _unit;
|
2015-10-11 04:09:52 +00:00
|
|
|
_position params ["_posX", "_posY", "_posZ"];
|
|
|
|
_position = [_posX + (random 2) - 1, _posY + (random 2) - 1, _posZ];
|
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _direction = (random 360);
|
2015-05-03 22:16:12 +00:00
|
|
|
|
2015-04-18 18:48:44 +00:00
|
|
|
// Create the litter, and timeout the event based on the cleanup delay
|
2015-05-03 22:16:12 +00:00
|
|
|
// The cleanup delay for events in MP is handled by the server side
|
2016-08-01 21:20:13 +00:00
|
|
|
TRACE_3("Creating Litter on server",_litterClass,_position,_direction);
|
|
|
|
[QGVAR(createLitterServer), [_litterClass, _position, _direction]] call CBA_fnc_serverEvent;
|
2015-05-03 22:16:12 +00:00
|
|
|
|
2015-04-18 15:31:03 +00:00
|
|
|
true
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
|
|
|
|
2016-06-13 00:34:56 +00:00
|
|
|
private _createdLitter = [];
|
2015-04-18 02:38:05 +00:00
|
|
|
{
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_x isEqualType []) then {
|
2015-04-18 02:38:05 +00:00
|
|
|
if (count _x < MIN_ENTRIES_LITTER_CONFIG) exitwith {};
|
2015-08-22 14:25:10 +00:00
|
|
|
|
2015-08-26 08:04:51 +00:00
|
|
|
_x params ["_selection", "_litterCondition", "_litterOptions"];
|
2015-08-22 14:25:10 +00:00
|
|
|
|
2015-04-18 02:38:05 +00:00
|
|
|
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 {
|
2015-11-30 16:53:57 +00:00
|
|
|
_litterCondition = missionNamespace getVariable _litterCondition;
|
2015-11-20 17:40:31 +00:00
|
|
|
if (!(_litterCondition isEqualType {})) then {_litterCondition = {false}};
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
2015-12-11 04:58:44 +00:00
|
|
|
if !([_caller, _target, _selectionName, _className, _usersOfItems, _bloodLossOnSelection] call _litterCondition) exitwith {};
|
2015-04-18 02:38:05 +00:00
|
|
|
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_litterOptions isEqualType []) then {
|
2015-04-18 02:38:05 +00:00
|
|
|
// Loop through through the litter options and place the litter
|
|
|
|
{
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_x isEqualType [] && {(count _x > 0)}) then {
|
2015-11-29 15:33:25 +00:00
|
|
|
[_target, selectRandom _x] call _createLitter;
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_x isEqualType "") then {
|
2015-04-18 15:31:03 +00:00
|
|
|
[_target, _x] call _createLitter;
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _litterOptions;
|
2015-04-18 02:38:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _litter;
|