Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical - Add corpse carrying and dragging #7939

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/dragging/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions addons/dragging/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions addons/dragging/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion addons/dragging/functions/fnc_canCarry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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})}
2 changes: 1 addition & 1 deletion addons/dragging/functions/fnc_canDrag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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})}
26 changes: 26 additions & 0 deletions addons/dragging/functions/fnc_createClone.sqf
Original file line number Diff line number Diff line change
@@ -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;
BaerMitUmlaut marked this conversation as resolved.
Show resolved Hide resolved

[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent;

_clone
26 changes: 26 additions & 0 deletions addons/dragging/functions/fnc_dropClone.sqf
Original file line number Diff line number Diff line change
@@ -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_dropClone;
*
* Public: No
*/
params ["_clone"];

private _unit = _clone getVariable [QGVAR(original), objNull];
_unit setPosASL getPosASL _clone;
_unit hideObjectGlobal false;
BaerMitUmlaut marked this conversation as resolved.
Show resolved Hide resolved

detach _clone;
BaerMitUmlaut marked this conversation as resolved.
Show resolved Hide resolved
deleteVehicle _clone;

_unit
5 changes: 5 additions & 0 deletions addons/dragging/functions/fnc_dropObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions addons/dragging/functions/fnc_dropObject_carry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions addons/dragging/functions/fnc_startCarry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions addons/dragging/functions/fnc_startDrag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down