Skip to content

Commit

Permalink
Fix Load Patient/Captive actions (#5544)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jonpas authored and PabstMirror committed Sep 27, 2017
1 parent 32b2d99 commit a48db26
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
8 changes: 8 additions & 0 deletions addons/captives/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ class Extended_Local_EventHandlers {
};
};
};

class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call FUNC(handleKilled));
};
};
};
2 changes: 1 addition & 1 deletion addons/captives/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

PREP(canApplyHandcuffs);
PREP(canEscortCaptive);
PREP(canFriskPerson);
Expand All @@ -18,6 +17,7 @@ PREP(handleAnimChangedHandcuffed);
PREP(handleAnimChangedSurrendered);
PREP(handleGetIn);
PREP(handleGetOut);
PREP(handleKilled);
PREP(handleLocal);
PREP(handleOnUnconscious);
PREP(handlePlayerChanged);
Expand Down
3 changes: 3 additions & 0 deletions addons/captives/functions/fnc_canLoadCaptive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
{
Expand Down
3 changes: 2 additions & 1 deletion addons/captives/functions/fnc_canUnloadCaptive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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])}
24 changes: 24 additions & 0 deletions addons/captives/functions/fnc_handleKilled.sqf
Original file line number Diff line number Diff line change
@@ -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);
};
1 change: 1 addition & 0 deletions addons/captives/functions/fnc_handleRespawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "script_component.hpp"

params ["_unit","_dead"];
TRACE_2("handleRespawn",_unit,_dead);

if (!local _unit) exitWith {};

Expand Down
4 changes: 2 additions & 2 deletions addons/medical/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a48db26

Please sign in to comment.