Fix Load Patient/Captive actions (#5544)

* Disable (un)load patient action if unit is dead but was uncoscious before

* Remove handcuffs on death (prevents stand-up ragoll restart), Don't show load patient and captive at the same time

* Only allow unloading from outside - fix #5525 as discussed

* Also prevent unloading captives from inside

* Add debug logging
This commit is contained in:
jonpas 2017-09-27 22:41:05 +02:00 committed by PabstMirror
parent 32b2d99887
commit a48db26996
7 changed files with 41 additions and 4 deletions

View File

@ -63,3 +63,11 @@ class Extended_Local_EventHandlers {
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call FUNC(handleKilled));
};
};
};

View File

@ -1,4 +1,3 @@
PREP(canApplyHandcuffs);
PREP(canEscortCaptive);
PREP(canFriskPerson);
@ -18,6 +17,7 @@ PREP(handleAnimChangedHandcuffed);
PREP(handleAnimChangedSurrendered);
PREP(handleGetIn);
PREP(handleGetOut);
PREP(handleKilled);
PREP(handleLocal);
PREP(handleOnUnconscious);
PREP(handlePlayerChanged);

View File

@ -19,6 +19,9 @@
params ["_unit", "_target","_vehicle"];
// Don't show "Load Captive" if unit is unconscious (already has "Load Patient")
if (_target getVariable ["ACE_isUnconscious", false]) exitWith {false};
if ((isNull _target) && {_unit getVariable [QGVAR(isEscorting), false]}) then {
//Looking at a vehicle while escorting, get target from attached objects:
{

View File

@ -18,4 +18,5 @@
params ["_player", "_unit"];
((vehicle _unit) != _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}
// Don't show "Unload Captive" if unit is unconscious (already has "Unload Patient")
(vehicle _unit != _unit) && {vehicle _player == _player} && {_unit getVariable [QGVAR(isHandcuffed), false]} && {!(_unit getVariable ["ACE_isUnconscious", false])}

View File

@ -0,0 +1,24 @@
/*
* Author: Jonpas
* Called when a unit dies.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [bob] call ace_captives_fnc_handleKilled
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
TRACE_1("handleKilled",_unit);
// Remove handcuffs on a dead unit, removing them after unit goes into ragdoll causes a stand-up twitch and restarts the ragdoll
if (_unit getVariable [QGVAR(isHandcuffed), false]) then {
[_unit, false] call FUNC(setHandcuffed);
};

View File

@ -17,6 +17,7 @@
#include "script_component.hpp"
params ["_unit","_dead"];
TRACE_2("handleRespawn",_unit,_dead);
if (!local _unit) exitWith {};

View File

@ -545,7 +545,7 @@ class CfgVehicles {
class GVAR(loadPatient) {
displayName = CSTRING(LoadPatient);
distance = 5;
condition = QUOTE(_target getVariable[ARR_2(QUOTE(QUOTE(ACE_isUnconscious)),false)] && vehicle _target == _target);
condition = QUOTE(_target getVariable [ARR_2(QUOTE(QUOTE(ACE_isUnconscious)), false)] && {alive _target} && {vehicle _target == _target});
statement = QUOTE([ARR_2(_player, _target)] call DFUNC(actionLoadUnit));
showDisabled = 0;
priority = 2;
@ -555,7 +555,7 @@ class CfgVehicles {
class GVAR(UnLoadPatient) {
displayName = CSTRING(UnloadPatient);
distance = 5;
condition = QUOTE(_target getVariable[ARR_2(QUOTE(QUOTE(ACE_isUnconscious)),false)] && vehicle _target != _target);
condition = QUOTE(_target getVariable [ARR_2(QUOTE(QUOTE(ACE_isUnconscious)), false)] && {vehicle _target != _target} && {vehicle _player == _player});
statement = QUOTE([ARR_2(_player, _target)] call DFUNC(actionUnloadUnit));
showDisabled = 0;
priority = 2;