Create clones for corpse carrying/dragging

This commit is contained in:
BaerMitUmlaut 2020-10-04 22:39:52 +02:00
parent 4e83b387e5
commit b00977eda0
12 changed files with 89 additions and 2 deletions

View File

@ -2,6 +2,9 @@
class CBA_Extended_EventHandlers;
class CfgVehicles {
class C_man_1;
class GVAR(clone): C_man_1 {};
// Static weapons
class LandVehicle;
class StaticWeapon: LandVehicle {

View File

@ -5,8 +5,10 @@ PREP(canDrop);
PREP(canDrop_carry);
PREP(carryObject);
PREP(carryObjectPFH);
PREP(createClone);
PREP(dragObject);
PREP(dragObjectPFH);
PREP(dropClone);
PREP(dropObject);
PREP(dropObject_carry);
PREP(getWeight);

View File

@ -27,6 +27,14 @@ if (isNil "ACE_maxWeightCarry") then {
// handle waking up dragged unit and falling unconscious while dragging
["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler;
// handle local effect commands for clones
[QGVAR(cloneCreated), {
params ["_unit", "_clone"];
_clone setFace face _unit;
_clone setMimic "unconscious";
}] call CBA_fnc_addEventHandler;
// display event handler
["MouseZChanged", {_this select 1 call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler;

View File

@ -27,4 +27,4 @@ if ((_unit getHitPointDamage "HitLegs") >= 0.5) exitWith {false};
// a static weapon has to be empty for dragging (ignore UAV AI)
if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false};
alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}
(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}

View File

@ -23,4 +23,4 @@ if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exi
// a static weapon has to be empty for dragging (ignore UAV AI)
if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false};
alive _target && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}
(alive _target || {_target isKindOf "CAManBase"}) && {vehicle _target isEqualto _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious", "deadstate"] || (_target getVariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}

View File

@ -26,6 +26,9 @@ private _direction = _target getVariable [QGVAR(carryDirection), 0];
// handle objects vs persons
if (_target isKindOf "CAManBase") then {
if (!alive _target) then {
_target = [_target] call FUNC(createClone);
};
[_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation);
[_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation);

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Creates a draggable / carryable clone of a dead unit.
*
* Arguments:
* 0: Dead unit <OBJECT>
*
* Return Value:
* Cloned unit.
*
* Example:
* [player] call ace_dragging_fnc_createClone;
*
* Public: No
*/
params ["_unit"];
private _clone = QGVAR(clone) createVehicle [0, 0, 0];
_clone setUnitLoadout getUnitLoadout _unit;
_clone setVariable [QGVAR(original), _unit];
_unit hideObjectGlobal true;
[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent;
_clone

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: BaerMitUmlaut
* Drops a draggable / carryable clone of a dead unit.
*
* Arguments:
* 0: Clone <OBJECT>
*
* Return Value:
* Original unit.
*
* Example:
* [player] call ace_dragging_fnc_createClone;
*
* Public: No
*/
params ["_clone"];
private _unit = _clone getVariable [QGVAR(original), objNull];
_unit setPosASL getPosASL _clone;
_unit hideObjectGlobal false;
detach _clone;
deleteVehicle _clone;
_unit

View File

@ -24,6 +24,11 @@ TRACE_2("params",_unit,_target);
private _inBuilding = [_unit] call FUNC(isObjectOnObject);
// drop cloned dead units
if (_target isKindOf QGVAR(clone)) then {
_target = [_target] call FUNC(dropClone);
};
if !(_unit getVariable ["ACE_isUnconscious", false]) then {
// play release animation
[_unit, "released"] call EFUNC(common,doGesture);

View File

@ -24,6 +24,11 @@ TRACE_1("params",_this);
private _inBuilding = [_unit] call FUNC(isObjectOnObject);
// drop cloned dead units
if (_target isKindOf QGVAR(clone)) then {
_target = [_target] call FUNC(dropClone);
};
// prevent collision damage
[QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent;
[QEGVAR(common,fixCollision), _target, _target] call CBA_fnc_targetEvent;

View File

@ -32,6 +32,10 @@ private _timer = CBA_missionTime + 5;
// handle objects vs persons
if (_target isKindOf "CAManBase") then {
// create clone for dead units
if (!alive _target) then {
_target = [_target] call FUNC(createClone);
};
// add a primary weapon if the unit has none.
if (primaryWeapon _unit isEqualto "") then {

View File

@ -28,6 +28,11 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && {
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
};
// create clone for dead units
if (!alive _target) then {
_target = [_target] call FUNC(createClone);
};
// add a primary weapon if the unit has none.
// @todo prevent opening inventory when equipped with a fake weapon
if (primaryWeapon _unit isEqualto "") then {