Add ability to pull dead body out of vehicle (#5630)

* Add ability to pull dead body out of vehicle

* Fix interaction not in vehicle

* Fix interaction with crew of dead vehicle

* Fix medical unload patient when he is dead

* Cleanup

* Fix cargo index, fix menu visible in vehicle
This commit is contained in:
Dystopian 2017-11-18 01:47:58 +03:00 committed by PabstMirror
parent 0672b0da35
commit a0e9b752e9
6 changed files with 139 additions and 15 deletions

View File

@ -168,6 +168,14 @@ class CfgVehicles {
showDisabled = 0;
priority = 2.6;
};
class GVAR(PullOutBody) {
displayName = CSTRING(PullOutBody);
condition = QUOTE(call DFUNC(canPullOutBody));
statement = QUOTE(call DFUNC(pullOutBody));
exceptions[] = {"isNotSwimming"};
icon = "\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\getout_ca.paa";
};
};
class ACE_Torso {
@ -342,7 +350,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -353,7 +361,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};
@ -370,7 +378,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -381,7 +389,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};
@ -397,7 +405,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -408,7 +416,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -428,7 +436,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -439,7 +447,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};
@ -456,7 +464,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -467,7 +475,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};
@ -505,7 +513,7 @@ class CfgVehicles {
};
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -516,7 +524,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};
@ -532,7 +540,7 @@ class CfgVehicles {
condition = "true";
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
exceptions[] = {"isNotSwimming"};
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
@ -543,7 +551,7 @@ class CfgVehicles {
class ACE_SelfActions {
class ACE_Passengers {
displayName = CSTRING(Passengers);
condition = "true";
condition = QUOTE(alive _target);
statement = "";
insertChildren = QUOTE(_this call DFUNC(addPassengersActions));
};

View File

@ -28,6 +28,8 @@ PREP(canTapShoulder);
PREP(tapShoulder);
PREP(canPardon);
PREP(pardon);
PREP(canPullOutBody);
PREP(pullOutBody);
// interaction with doors
PREP(getDoor);

View File

@ -0,0 +1,47 @@
/*
* Author: Dystopian
* Checks if unit can pull target body out of vehicle.
*
* Arguments:
* 1: Body <OBJECT>
* 2: Unit <OBJECT>
*
* Return Value:
* Able to pull out target body <BOOL>
*
* Example:
* [crew cursorObject select 0, player] call ace_interaction_fnc_canPullOutBody
*
* Public: No
*/
#include "script_component.hpp"
params ["_body", "_unit"];
private _vehicle = objectParent _body;
if (
!isNull objectParent _unit
|| {alive _body}
|| {isNull _vehicle}
|| {1 < locked _vehicle}
|| {
0 < {alive _x} count crew _vehicle // alive is in vehicle
// group is used here for situations when side player == ENEMY
&& {0.6 > side group _unit getFriend side group _vehicle} // player is enemy
}
) exitWith {false};
((fullCrew [_vehicle, ""] select {_body == _x select 0}) select 0) params ["", "", "_cargoIndex", "_turretPath"];
private _locked = if (!(_turretPath isEqualTo [])) then {
_vehicle lockedTurret _turretPath;
} else {
if (_cargoIndex > -1) then {
_vehicle lockedCargo _cargoIndex;
} else {
lockedDriver _vehicle;
};
};
!_locked

View File

@ -0,0 +1,63 @@
/*
* Author: Dystopian
* Makes unit pull target body out of vehicle.
*
* Arguments:
* 0: Body <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [crew cursorObject select 0, player] call ace_interaction_fnc_pullOutBody
*
* Public: No
*/
#include "script_component.hpp"
params ["_body", "_unit"];
private _vehicle = objectParent _body; // vehicle command doesn't work for dead
// get target crew properties
private ["_cargoIndex", "_turretPath"];
private _cargoNumber = -1;
{
if ("cargo" == _x select 1) then {
INC(_cargoNumber);
};
if (_body == _x select 0) exitWith {
_cargoIndex = _x select 2;
_turretPath = _x select 3;
};
} forEach fullCrew [_vehicle, "", true];
TRACE_3("",_cargoIndex,_cargoNumber,_turretPath);
private _preserveEngineOn = false;
// first get in to target seat
if (!(_turretPath isEqualTo [])) then {
_unit action ["GetInTurret", _vehicle, _turretPath];
} else {
if (_cargoIndex > -1) then {
_unit action ["GetInCargo", _vehicle, _cargoNumber];
} else {
_unit action ["GetInDriver", _vehicle];
_preserveEngineOn = isEngineOn _vehicle;
};
};
// then get out
[
{(_this select 0) in (_this select 1)},
{
params ["_unit", "_vehicle", "_preserveEngineOn"];
TRACE_3("",_unit,_vehicle,_preserveEngineOn);
_unit action ["GetOut", _vehicle];
if (_preserveEngineOn) then {
[{isNull driver _this}, {_this engineOn true}, _vehicle] call CBA_fnc_waitUntilAndExecute;
};
},
[_unit, _vehicle, _preserveEngineOn]
] call CBA_fnc_waitUntilAndExecute;

View File

@ -1073,5 +1073,9 @@
<Chinesesimp>显示"给予弹匣"互动动作</Chinesesimp>
<Chinese>顯示"給予彈匣"互動動作</Chinese>
</Key>
<Key ID="STR_ACE_Interaction_PullOutBody">
<English>Pull out body</English>
<Russian>Вытащить тело</Russian>
</Key>
</Package>
</Project>

View File

@ -556,7 +556,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} && {vehicle _player == _player});
condition = QUOTE(_target getVariable [ARR_2(QUOTE(QUOTE(ACE_isUnconscious)), false)] && {alive _target} && {vehicle _target != _target} && {vehicle _player == _player});
statement = QUOTE([ARR_2(_player, _target)] call DFUNC(actionUnloadUnit));
showDisabled = 0;
priority = 2;