mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical Treatment - Add preferred seats for loading patients (#8789)
* Medical Treatment - Add preferred seats for loading patients * load patients in reverse order * add option for reverse fill * Update addons/medical_treatment/functions/fnc_loadUnit.sqf Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> * Update docs/wiki/framework/medical-treatment-framework.md Co-authored-by: PabstMirror <pabstmirror@gmail.com> Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
cae743ae31
commit
90d63475d5
@ -7,6 +7,8 @@
|
||||
* 0: Unit that will load <OBJECT>
|
||||
* 1: Unit to be loaded <OBJECT>
|
||||
* 2: Vehicle that the unit will be loaded in <OBJECT> (default: objNull)
|
||||
* 3: Preferred seats <ARRAY>
|
||||
* 4: Reverse fill <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* Vehicle that the unitToBeloaded has been loaded in. Returns objNull if function failed <OBJECT>
|
||||
@ -19,8 +21,8 @@
|
||||
|
||||
#define GROUP_SWITCH_ID QFUNC(loadPerson)
|
||||
|
||||
params ["_caller", "_unit", ["_vehicle", objNull]];
|
||||
TRACE_3("loadPerson",_caller,_unit,_vehicle);
|
||||
params ["_caller", "_unit", ["_vehicle", objNull], ["_preferredSeats", []], ["_reverseFill", false]];
|
||||
TRACE_5("loadPerson",_caller,_unit,_vehicle,_preferredSeats,_reverseFill);
|
||||
|
||||
if (!([_caller, _unit, ["isNotDragging", "isNotCarrying", "isNotSwimming"]] call FUNC(canInteractWith)) || {_caller == _unit}) exitWith { objNull };
|
||||
|
||||
@ -39,8 +41,8 @@ if (!isNull _vehicle) then {
|
||||
};
|
||||
};
|
||||
|
||||
TRACE_3("sending ace_loadPersonEvent",_unit,_vehicle,_caller);
|
||||
["ace_loadPersonEvent", [_unit, _vehicle, _caller], _unit] call CBA_fnc_targetEvent;
|
||||
TRACE_5("sending ace_loadPersonEvent",_unit,_vehicle,_caller,_preferredSeats,_reverseFill);
|
||||
["ace_loadPersonEvent", [_unit, _vehicle, _caller, _preferredSeats, _reverseFill], _unit] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
_vehicle
|
||||
|
@ -7,6 +7,8 @@
|
||||
* 0: unit to be loaded <OBJECT>
|
||||
* 1: vehicle that will beloaded <OBJECT>
|
||||
* 2: caller that will load <OBJECT>
|
||||
* 3: preferred seats <ARRAY>
|
||||
* 4: reverse fill <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -17,14 +19,33 @@
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params ["_unit", "_vehicle", ["_caller", objNull]];
|
||||
TRACE_3("loadPersonLocal",_unit,_vehicle,_caller);
|
||||
params ["_unit", "_vehicle", ["_caller", objNull], ["_preferredSeats", []], ["_reverseFill", false]];
|
||||
TRACE_5("loadPersonLocal",_unit,_vehicle,_caller,_preferredSeats,_reverseFill);
|
||||
|
||||
private _slotsOpen = false;
|
||||
if ((_vehicle emptyPositions "cargo" > 0) && {!(_unit getVariable ['ACE_isUnconscious', false]) || {(getNumber (configOf _vehicle >> "ejectDeadCargo")) == 0}}) then {
|
||||
_unit moveInCargo _vehicle;
|
||||
TRACE_1("moveInCargo",_vehicle);
|
||||
if (_preferredSeats isNotEqualTo []) then {
|
||||
private _taken = [];
|
||||
{
|
||||
_taken pushBackUnique (_vehicle getCargoIndex _x);
|
||||
} forEach crew _vehicle;
|
||||
private _preferredSeats = _preferredSeats - _taken;
|
||||
if (count _preferredSeats > 0) then {
|
||||
_unit moveInCargo [_vehicle, _preferredSeats select 0];
|
||||
TRACE_2("moveInCargo",_vehicle,_preferredSeats select 0);
|
||||
_slotsOpen = true;
|
||||
};
|
||||
};
|
||||
if (!_slotsOpen) then {
|
||||
private _cargoSeats = fullCrew [_vehicle, "cargo", true];
|
||||
if (_reverseFill) then {
|
||||
reverse _cargoSeats;
|
||||
};
|
||||
private _index = _cargoSeats findIf {isNull (_x select 0)};
|
||||
_unit moveInCargo [_vehicle, (_cargoSeats select _index) select 2];
|
||||
TRACE_2("moveInCargo",_vehicle,_index);
|
||||
_slotsOpen = true;
|
||||
};
|
||||
} else {
|
||||
// Check if an empty turret is available
|
||||
// This already excludes FFV seats, which count as cargo positions
|
||||
|
@ -328,4 +328,14 @@ class CfgVehicles {
|
||||
MACRO_ADDITEM(ACE_bodyBag,5);
|
||||
};
|
||||
};
|
||||
|
||||
class Van_02_base_F;
|
||||
class Van_02_medevac_base_F: Van_02_base_F {
|
||||
GVAR(patientSeats)[] = {3,4};
|
||||
};
|
||||
|
||||
class Heli_Transport_04_base_F;
|
||||
class O_Heli_Transport_04_medevac_F: Heli_Transport_04_base_F {
|
||||
GVAR(patientSeats)[] = {0,1,2};
|
||||
};
|
||||
};
|
||||
|
@ -32,7 +32,13 @@ if (_patient call EFUNC(medical_status,isBeingDragged)) then {
|
||||
[_medic, _patient] call EFUNC(dragging,dropObject);
|
||||
};
|
||||
|
||||
private _vehicle = [_medic, _patient, _vehicle] call EFUNC(common,loadPerson);
|
||||
private _vehicle = [
|
||||
_medic,
|
||||
_patient,
|
||||
_vehicle,
|
||||
getArray (configOf _vehicle >> QGVAR(patientSeats)),
|
||||
([configOf _vehicle >> QGVAR(patientReverseFill), "NUMBER", 1] call CBA_fnc_getConfigEntry) > 0
|
||||
] call EFUNC(common,loadPerson);
|
||||
|
||||
if (isNull _vehicle) exitWith { TRACE_1("no vehicle found",_vehicle); };
|
||||
|
||||
|
40
docs/wiki/framework/medical-treatment-framework.md
Normal file
40
docs/wiki/framework/medical-treatment-framework.md
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
layout: wiki
|
||||
title: Medical Treatment Framework
|
||||
description: Explains extending the treatment system for developers.
|
||||
group: framework
|
||||
order: 5
|
||||
parent: wiki
|
||||
mod: ace
|
||||
version:
|
||||
major: 3
|
||||
minor: 14
|
||||
patch: 2
|
||||
---
|
||||
|
||||
## 1. Config Values
|
||||
|
||||
### 1.1 Vehicle Patient Seats
|
||||
|
||||
Defines the seats that will be prioritized when loading patients into vehicles. Uses `moveInCargo` indexes.
|
||||
|
||||
```cpp
|
||||
class CfgVehicles {
|
||||
class MyCar {
|
||||
ace_medical_treatment_patientSeats[] = {3,4};
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### 1.2 Patient Reverse Fill
|
||||
|
||||
When no patient seats are available, by default patients will be filled from the highest cargo index to the lowest.
|
||||
This can be changed to fill from the lowest to the highest.
|
||||
|
||||
```cpp
|
||||
class CfgVehicles {
|
||||
class MyCar {
|
||||
ace_medical_treatment_patientReverseFill = 0;
|
||||
};
|
||||
};
|
||||
```
|
Loading…
Reference in New Issue
Block a user