mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical - Add 'Open (Backpack)' action to dead units (#9239)
* add open bag interaction * only add actions to uncon/dead * improve assembly backpack check * Fixes * Removed test code * move to postInit * fix locality * locality edge case * Fix double actions on dead units * improve comment Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
e5a49f3acf
commit
36f34ec551
@ -1,3 +1,4 @@
|
||||
PREP(addInventoryActions);
|
||||
PREP(addMedicationAdjustment);
|
||||
PREP(adjustPainLevel);
|
||||
PREP(getBloodLoss);
|
||||
|
@ -3,6 +3,23 @@
|
||||
// Handle pain changes on injury
|
||||
[QEGVAR(medical,injured), LINKFUNC(adjustPainLevel)] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
||||
// Add inventory and open backpack actions to units
|
||||
[QGVAR(addInventoryActions), LINKFUNC(addInventoryActions)] call CBA_fnc_addEventHandler;
|
||||
// apply to all living and dead now
|
||||
{
|
||||
[QGVAR(addInventoryActions), _x] call CBA_fnc_localEvent;
|
||||
} forEach (allUnits + allDeadMen);
|
||||
// apply to all future units
|
||||
["CAManBase", "init", LINKFUNC(addInventoryActions), true, [], false] call CBA_fnc_addClassEventHandler;
|
||||
// Respawn is called locally
|
||||
["CAManBase", "respawn", {
|
||||
params ["_unit"];
|
||||
if (!local _unit) exitWith {};
|
||||
[QGVAR(addInventoryActions), _unit] call CBA_fnc_globalEvent;
|
||||
}, true] call CBA_fnc_addClassEventHandler;
|
||||
|
||||
|
||||
// Handle comms status effects for spectator
|
||||
// Separate from medical_feedback as these affect unit behavior rather than what the player sees
|
||||
["featureCamera", {
|
||||
|
@ -25,20 +25,4 @@ PREP_RECOMPILE_END;
|
||||
|
||||
addMissionEventHandler ["EntityKilled", {_this call FUNC(handleKilledMission)}];
|
||||
|
||||
if (hasInterface) then {
|
||||
//Add Inventory action to uncon units
|
||||
["CAManBase", "init", {
|
||||
params ["_unit"];
|
||||
|
||||
private _id = _unit addAction ["", {
|
||||
params ["_target", "_caller", "_actionId", "_arguments"];
|
||||
|
||||
_caller action ["Gear", _target];
|
||||
}, nil, 5.1, true, true, "gear", "_target getVariable ['ACE_isUnconscious',false] && {alive _target}", 3.5];
|
||||
|
||||
_unit setUserActionText [_id, localize "STR_ACTION_GEAR", "<img image='\A3\ui_f\data\igui\cfg\actions\gear_ca.paa' size='2.5' shadow=2 />"];
|
||||
|
||||
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
};
|
||||
|
||||
ADDON = true;
|
||||
|
50
addons/medical_status/functions/fnc_addInventoryActions.sqf
Normal file
50
addons/medical_status/functions/fnc_addInventoryActions.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: LinkIsGrim, johnb43
|
||||
* Adds inventory and open backpack actions to uncon units.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [cursorTarget] call ace_medical_status_fnc_addInventoryActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
// Gear Action - For Unconscious Units
|
||||
private _id = _unit addAction ["", {
|
||||
params ["_target", "_caller"];
|
||||
|
||||
_caller action ["Gear", _target];
|
||||
}, nil, 5.1, true, true, "gear", toString {
|
||||
(_target isNotEqualTo ACE_player) &&
|
||||
{(lifeState _target) isEqualTo "INCAPACITATED"}
|
||||
}, 2];
|
||||
|
||||
_unit setUserActionText [_id, localize "STR_ACTION_GEAR", "<img image='\A3\ui_f\data\igui\cfg\actions\gear_ca.paa' size='2.5' shadow=2 />"];
|
||||
|
||||
// Open Bag Action - For Dead Units
|
||||
_unit addAction ["OpenBag", {
|
||||
params ["_target", "_caller"];
|
||||
|
||||
_caller action ["OpenBag", _target];
|
||||
}, nil, 5.2, true, true, "", toString {
|
||||
private _backpackContainer = backpackContainer _target;
|
||||
private _backpackConfig = configOf _backpackContainer;
|
||||
|
||||
(_target isNotEqualTo ACE_player) &&
|
||||
{!((lifeState _target) in ["HEALTHY", "INJURED", "INCAPACITATED"])} &&
|
||||
{!isNull _backpackContainer} &&
|
||||
{!lockedInventory _backpackContainer} &&
|
||||
{maxLoad _backpackContainer > 0} &&
|
||||
{getNumber (_backpackConfig >> "disableInventory") != 1} &&
|
||||
{_target setUserActionText [_actionId, format [localize "STR_ACTION_OPEN_BAG", getText (_backpackConfig >> "displayName")]]; true}
|
||||
}, 2];
|
Loading…
Reference in New Issue
Block a user