Skip to content

Commit

Permalink
Misc - Add interactions for better patient loading/unloading when car…
Browse files Browse the repository at this point in the history
…ried (#378)

**When merged this pull request will:**
- Add ability to load carried patients directly into vehicle, without
having to drop and then load.
- Add ability to unload and carry patients directly from vehicles,
without having to unload (drop) and then carry.
- Add more ace macros


![image](https://github.com/KAT-Advanced-Medical/KAM/assets/15182031/a471bb32-09d7-406a-a7b0-f9444388d466)

![image](https://github.com/KAT-Advanced-Medical/KAM/assets/15182031/7237a27b-96c4-4399-8ac5-0813a99a6905)


### IMPORTANT

- [Development Guidelines](https://ace3.acemod.org/wiki/development/)
are read, understood and applied.
- Title of this PR uses our standard template `Component -
Add|Fix|Improve|Change|Make|Remove {changes}`.
  • Loading branch information
BlueTheKing authored Aug 23, 2023
1 parent c350954 commit d51262e
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addons/main/script_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

#define ACEGVAR(module,var) TRIPLES(ACE_PREFIX,module,var)
#define QACEGVAR(module,var) QUOTE(ACEGVAR(module,var))
#define QQACEGVAR(module,var) QUOTE(QACEGVAR(module,var))

#define ACEFUNC(module,function) TRIPLES(DOUBLES(ACE_PREFIX,module),fnc,function)
#define QACEFUNC(module,function) QUOTE(ACEFUNC(module,function))
Expand All @@ -75,6 +76,9 @@
#define ACELLSTRING(module,string) localize ACELSTRING(module,string)
#define ACECSTRING(module,string) QUOTE(TRIPLES($STR,DOUBLES(ACE_PREFIX,module),string))

#define ACEPATHTOF(component,path) \z\ace\addons\component\path
#define QACEPATHTOF(component,path) QUOTE(ACEPATHTOF(component,path))

// Macros for checking if unit is in medical vehicle or facility
// Defined mostly to make location check in canTreat more readable
#define IN_MED_VEHICLE(unit) (unit call ACEFUNC(medical_treatment,isInMedicalVehicle))
Expand All @@ -86,7 +90,6 @@
#define TREATMENT_LOCATIONS_VEHICLES_AND_FACILITIES 3
#define TREATMENT_LOCATIONS_NONE 4


// item types
#define TYPE_DEFAULT 0
#define TYPE_MUZZLE 101
Expand Down
20 changes: 20 additions & 0 deletions addons/misc/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,23 @@ class Extended_Respawn_EventHandlers {
};
};
};

class Extended_InitPost_EventHandlers {
class LandVehicle {
class ADDON {
init = QUOTE(_this call FUNC(addVehicleCarryLoadActions));
};
};

class Air {
class ADDON {
init = QUOTE(_this call FUNC(addVehicleCarryLoadActions));
};
};

class Ship {
class ADDON {
init = QUOTE(_this call FUNC(addVehicleCarryLoadActions));
};
};
};
133 changes: 133 additions & 0 deletions addons/misc/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,139 @@ class CfgVehicles {
statement = "[_player, _target, 'leg_r', 'SalineIV_Stand_250'] call ace_medical_treatment_fnc_treatment";
};
};
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(_target getVariable [ARR_2('ACE_isUnconscious', false)] && {!(isNull (objectParent _target))} && {isNull (objectParent _player)});
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = QUOTE([ARR_2(_player, _target)] call FUNC(unloadAndCarryPatient));
icon = QACEPATHTOF(dragging,UI\icons\person_carry.paa);
};
};
};
};

class LandVehicle;
class Car: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Car_F: Car {};
class Quadbike_01_base_F: Car_F {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Kart_01_Base_F: Car_F {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Tank: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Motorcycle: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Air;
class Helicopter: Air {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Plane: Air {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(medical_gui,ui\cross.paa);
};
};
};
};

class Ship;
class Ship_F: Ship {
class ACE_Actions {
class ACE_MainActions {
class KAT_UnloadAndCarryPatient {
displayName = CSTRING(CarryPatient);
condition = QUOTE(alive _target);
exceptions[] = {"isNotDragging", "isNotCarrying", "isNotInside"};
statement = "";
insertChildren = QUOTE(call FUNC(addVehicleUnloadCarryPatientActions));
icon = QACEPATHTOF(dragging,UI\icons\person_carry.paa);
};
};
};
};
};
3 changes: 3 additions & 0 deletions addons/misc/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PREP(actionLowerBy10);
PREP(addActionRaise);
PREP(addIVbag);
PREP(addPassengersActions);
PREP(addVehicleUnloadCarryPatientActions);
PREP(addVehicleCarryLoadActions);
PREP(attachStretcher);
PREP(BubbleWrap);
PREP(checkArmbandCondition);
Expand All @@ -22,5 +24,6 @@ PREP(slingArmband);
PREP(stretcher);
PREP(stringToArray);
PREP(treatmentIV);
PREP(unloadAndCarryPatient);
PREP(unSlingArmband);
PREP(useItem);
79 changes: 79 additions & 0 deletions addons/misc/functions/fnc_addVehicleCarryLoadActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "script_component.hpp"
/*
* Author: Blue
* Add carry load ace actions to vehicle.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [vehicle] call kat_misc_fnc_addVehicleCarryLoadActions;
*
* Public: No
*/

params ["_vehicle"];

private _type = (typeOf _vehicle);

private _fnc_getFreeSeats = {
params ["_vehicle"];

// From ace_common_fnc_nearestVehiclesFreeSeat
private _canSitInCargo = (getNumber (configOf _vehicle >> "ejectDeadCargo")) == 0;

private _seatIndex = (fullCrew [_vehicle, "", true]) findIf {
_x params ["_body", "_role", "_cargoIndex"];

(isNull _body) && {_role != "DRIVER"} && {_canSitInCargo || {_cargoIndex == -1}}
};

_seatIndex;
};

private _action = [format ["KAT_MainActions_%1", _type],
ACELLSTRING(Interaction,MainAction),
"",
{},
{
params ["_vehicle", "_medic", "_args"];

!(_medic getVariable [QACEGVAR(dragging,carriedObject), objNull] isEqualTo objNull) && {_medic getVariable [QACEGVAR(dragging,carriedObject), objNull] isKindOf 'CAManBase'}
},
{
params ["_vehicle", "_medic", "_args"];
_args params ["_type", "_fnc_getFreeSeats"];

private _loadAction = [];
_loadAction pushBack [
[format ["KAT_LoadCarriedPatient_%1", _type],
ACELLSTRING(medical_gui,LoadPatient),
QACEPATHTOF(medical_gui,ui\cross.paa),
{
params ["", "", "_args"];
_args params ["_vehicle", "_medic", "_fnc_getFreeSeats"];

[_medic, (_medic getVariable [QACEGVAR(dragging,carriedObject), objNull]), _vehicle] call ACEFUNC(medical_treatment,loadUnit);
},
{
params ["", "", "_args"];
_args params ["_vehicle", "_medic", "_fnc_getFreeSeats"];

([_vehicle] call _fnc_getFreeSeats) != -1;
},
{},
[_vehicle, _medic, _fnc_getFreeSeats]
] call ACEFUNC(interact_menu,createAction),
[],
(_this select 1)
];

_loadAction;
},
[_type, _fnc_getFreeSeats],
{call ACEFUNC(interaction,getVehiclePos)}, 4] call ACEFUNC(interact_menu,createAction);

[_type, 0, [], _action] call ACEFUNC(interact_menu,addActionToClass);
47 changes: 47 additions & 0 deletions addons/misc/functions/fnc_addVehicleUnloadCarryPatientActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "script_component.hpp"
/*
* Author: Blue
* Add carry and unload ace actions to vehicle.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Ace actions <ARRAY>
*
* Example:
* [vehicle] call kat_misc_fnc_addVehicleUnloadCarryPatientActions;
*
* Public: No
*/

params ["_vehicle"];

private _type = (typeOf _vehicle);

private _vehicleSeats = fullCrew [_vehicle, ""];

private _actions = [];

{
private _unit = _x select 0;
if (IS_UNCONSCIOUS(_unit)) then {
_actions pushBack [[format ["KAT_UnloadAndCarryPatient_%1", _unit],
[_unit, true] call ACEFUNC(common,getName),
"",
{
params ["_vehicle", "_medic", "_args"];
_args params ["_patient"];

[_medic, _patient] call FUNC(unloadAndCarryPatient);
},
{
true;
},
{},
[_unit]
] call ACEFUNC(interact_menu,createAction),[], _medic];
};
} forEach (_vehicleSeats);

_actions;
Loading

0 comments on commit d51262e

Please sign in to comment.