ACE3/addons/medical_treatment/functions/fnc_litterHandleCreate.sqf

69 lines
1.9 KiB
Plaintext
Raw Normal View History

2016-05-30 16:37:03 +00:00
/*
* Author: Glowbal
* handle Litter Create
*
* Arguments:
* 0: Litter Class <STRING>
* 1: Position <ARRAY>
* 2: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* ["litter", [2, 5, 6], bob] call ACE_medical_treatment_fnc_handleCreateLitter
*
2016-05-30 16:37:03 +00:00
* Public: No
*/
#include "script_component.hpp"
params ["_litterClass", "_position", "_direction"];
TRACE_3("params",_litterClass,_position,_direction);
2017-05-14 20:14:22 +00:00
//IGNORE_PRIVATE_WARNING ["_values"];
2016-05-30 16:37:03 +00:00
if (isNil QGVAR(allCreatedLitter)) then {
GVAR(allCreatedLitter) = [];
GVAR(litterPFHRunning) = false;
};
2016-09-19 07:55:30 +00:00
private _model = getText (configFile >> "CfgVehicles" >> _litterClass >> "model");
if (_model == "") exitWith {TRACE_2("no model",_litterClass,_model)};
// createSimpleObject expects a path without the leading slash
2016-09-19 07:55:30 +00:00
if (_model select [0,1] == "\") then {
_model = _model select [1];
};
2016-09-19 07:55:30 +00:00
private _litterObject = createSimpleObject [_model, [0,0,0]];
TRACE_2("created",_litterClass,_litterObject);
2016-09-19 07:55:30 +00:00
2016-05-30 16:37:03 +00:00
_litterObject setDir _direction;
2016-09-19 07:55:30 +00:00
_litterObject setPosASL _position;
2016-05-30 16:37:03 +00:00
// Move the litter next frame to get rid of HORRIBLE spacing, fixes #1112
2016-09-19 07:55:30 +00:00
[{
params ["_object", "_position"];
2016-05-30 16:37:03 +00:00
2016-09-19 07:55:30 +00:00
_object setPosASL _position;
}, [_litterObject, _position]] call CBA_fnc_execNextFrame;
2016-09-19 15:52:16 +00:00
private _maxLitterCount = getArray (configFile >> "ACE_Settings" >> QEGVAR(medical,litterSimulationDetail) >> "_values") select EGVAR(medical,litterSimulationDetail);
2016-09-19 07:55:30 +00:00
if (count GVAR(allCreatedLitter) > _maxLitterCount) then {
2016-05-30 16:37:03 +00:00
// gank the first litter object, and spawn ours.
private _oldLitter = GVAR(allCreatedLitter) deleteAt 0;
2016-09-19 07:55:30 +00:00
2016-05-30 16:37:03 +00:00
{
deleteVehicle _x;
} forEach (_oldLitter select 1);
};
2016-06-02 15:02:09 +00:00
GVAR(allCreatedLitter) pushBack [CBA_missionTime, [_litterObject]];
2016-05-30 16:37:03 +00:00
2016-09-19 07:55:30 +00:00
if (!GVAR(litterPFHRunning) && {GVAR(litterCleanUpDelay) > 0}) then {
2016-05-30 16:37:03 +00:00
// Start the litter cleanup loop
GVAR(litterPFHRunning) = true;
call FUNC(litterCleanupLoop);
};