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

Dragging - Corpse carrying and dragging - continued #9273

Merged
merged 59 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b00977e
Create clones for corpse carrying/dragging
BaerMitUmlaut Oct 4, 2020
905e8ca
Fix doccomment for dropClone
BaerMitUmlaut Oct 5, 2020
3fa5b69
Remove duplicate clone
BaerMitUmlaut Oct 5, 2020
28e0491
Add comment with reasoning for detach before delete
BaerMitUmlaut Oct 11, 2020
efd71c6
Bury corpse to prevent desecration
BaerMitUmlaut Oct 11, 2020
2d30be4
Prevent screams of agony from dragged corpse
BaerMitUmlaut Oct 11, 2020
ccbf480
Merge remote-tracking branch 'upstream/master' into corpse-carry-cont…
johnb432 Jul 20, 2023
fb065d1
Continue corpse carry
johnb432 Jul 20, 2023
cbc7748
Update XEH_postInit.sqf
johnb432 Jul 20, 2023
b32ad48
Potential fix for duplicating
johnb432 Jul 21, 2023
4969f48
Merge branch 'master' into corpse-carry-continued2
johnb432 Jul 22, 2023
d40346d
Merge branch 'master' into corpse-carry-continued2
johnb432 Jul 24, 2023
1ad961c
Merge remote-tracking branch 'upstream/master' into corpse-carry-cont…
LinkIsGrim Sep 6, 2023
98e516b
Merge branch 'master' into corpse-carry-continued2
johnb432 Oct 3, 2023
897ca7a
Update fnc_handleAnimChanged.sqf
johnb432 Oct 3, 2023
52cd637
Merge branch 'corpse-carry-continued2' of https://github.com/johnb432…
johnb432 Oct 3, 2023
1ccd2b4
New script_component
johnb432 Oct 3, 2023
29881bc
Update fnc_createClone.sqf
johnb432 Oct 21, 2023
04238fd
Merge branch 'master' into pr/9273
johnb432 Jan 7, 2024
4a5f056
Fixed/improved checks
johnb432 Jan 7, 2024
573bfbb
Fix not hidden
johnb432 Jan 7, 2024
3387898
Check correct ragdoll state
johnb432 Jan 7, 2024
d1755af
Remove body moving under terrain
johnb432 Jan 7, 2024
68f9ea2
Merge remote-tracking branch 'upstream/master' into corpse-carry-cont…
LinkIsGrim Jan 8, 2024
884bccf
add wound texture handling
LinkIsGrim Jan 8, 2024
594e118
Readd body moving under terrain
johnb432 Jan 9, 2024
c8b3c15
Update dragging.md
johnb432 Jan 10, 2024
097b3e8
Merge remote-tracking branch 'upstream/master' into corpse-carry-cont…
LinkIsGrim Jan 11, 2024
15b581b
Update fnc_createClone.sqf
johnb432 Jan 11, 2024
ceb940a
Merged master
johnb432 Jan 14, 2024
c4b29e6
Merge branch 'master' into pr/9273
johnb432 Jan 21, 2024
85f138f
Merge branch 'master' into pr/9273
johnb432 Feb 2, 2024
824a9f6
Another attempt
johnb432 Feb 2, 2024
f805604
Update addons/dragging/functions/fnc_dropClone.sqf
johnb432 Feb 2, 2024
43fb261
Update addons/dragging/functions/fnc_createClone.sqf
johnb432 Feb 2, 2024
2d8dc01
Cleanup
johnb432 Feb 2, 2024
58e220b
Update XEH_preInit.sqf
johnb432 Feb 3, 2024
a627dfd
Merge branch 'master' into pr/9273
johnb432 Mar 2, 2024
1a20df8
Merge branch 'master' into pr/9273
johnb432 Apr 1, 2024
fdbaeab
Try syncing individually on each client
johnb432 Apr 1, 2024
04564b4
`setPosATL` globally
johnb432 Apr 9, 2024
9c65030
Merge branch 'master' into pr/9273
johnb432 Jun 29, 2024
28560b9
Sync corpses when JIP to avoid weird hitbox collision, renamed functi…
johnb432 Jul 1, 2024
b5205c1
Update addons/dragging/XEH_postInit.sqf
johnb432 Jul 1, 2024
471d33a
More cleanup
johnb432 Jul 1, 2024
5ee6478
Merge branch 'master' into pr/9273
johnb432 Jul 16, 2024
de1c2a5
Update docs/wiki/framework/events-framework.md
johnb432 Jul 20, 2024
7a26177
Merge branch 'master' into pr/9273
johnb432 Jul 20, 2024
5b87267
Merge branch 'corpse-carry-continued2' of https://github.com/johnb432…
johnb432 Jul 20, 2024
f93ac13
Remove ; in headers
johnb432 Jul 20, 2024
78adfdf
Merge branch 'master' into pr/9273
PabstMirror Aug 25, 2024
a5d047c
Update addons/dragging/functions/fnc_canCarry.sqf
johnb432 Aug 28, 2024
5ea5330
Update fnc_canDrag.sqf
johnb432 Aug 28, 2024
0a6ec07
Fix opening backpack of clone while dragging and patient moved warning
PabstMirror Aug 29, 2024
b3abb78
Update addons/dragging/functions/fnc_canCarry.sqf
johnb432 Sep 5, 2024
b5579eb
Update addons/dragging/functions/fnc_canDrag.sqf
johnb432 Sep 5, 2024
7529931
Update addons/medical_status/functions/fnc_addInventoryActions.sqf
johnb432 Sep 5, 2024
46bf462
Merge branch 'master' into pr/9273
johnb432 Sep 5, 2024
ba1bda8
Improve corpse dragging
johnb432 Sep 5, 2024
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
5 changes: 5 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
_object setMass _mass;
}] call CBA_fnc_addEventHandler;

[QGVAR(awake), {
params ["_object", "_awake"];
_object awake _awake;
}] call CBA_fnc_addEventHandler;

[QGVAR(disableWeaponAssembly), {
params ["_object", "_set"];
_object enableWeaponDisassembly (_set < 1);
Expand Down
3 changes: 3 additions & 0 deletions addons/dragging/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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_carry);
PREP(canRun_carry);
PREP(carryObject);
PREP(carryObjectPFH);
PREP(createClone);
PREP(dragObject);
PREP(dragObjectPFH);
PREP(dropClone);
PREP(dropObject);
PREP(dropObject_carry);
PREP(getWeight);
Expand Down
13 changes: 13 additions & 0 deletions addons/dragging/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ if (isNil QGVAR(maxWeightCarryRun)) then {
GVAR(maxWeightCarryRun) = 50;
};

// Extended EH doesn't fire for dead units, so add interactions manually
{
_x call FUNC(initPerson);
} forEach allDeadMen;

["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition);
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);

Expand Down Expand Up @@ -54,6 +59,14 @@ if (isNil QGVAR(maxWeightCarryRun)) then {
// Handle waking up dragged unit and falling unconscious while dragging
["ace_unconscious", LINKFUNC(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
5 changes: 3 additions & 2 deletions addons/dragging/functions/fnc_canCarry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

params ["_unit", "_target"];

if !(alive _target && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false};
if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canCarry), false]} && {isNull objectParent _target}) exitWith {false};

if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};

Expand All @@ -35,7 +35,8 @@ if (_target isKindOf "StaticWeapon") exitWith {
if (_target isKindOf "CAManBase") exitWith {
isAwake _target && // not ragdolled
{lifeState _target == "INCAPACITATED" ||
{_target getHitPointDamage "HitLegs" >= 0.5}}
{_target getHitPointDamage "HitLegs" >= 0.5} ||
{(animationState _target) in ["", "unconscious", "deadstate"]}}
};

// Check max items for WeaponHolders
Expand Down
5 changes: 3 additions & 2 deletions addons/dragging/functions/fnc_canDrag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

params ["_unit", "_target"];

if !(alive _target && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false};
if !((alive _target || {_target isKindOf "CAManBase"}) && {_target getVariable [QGVAR(canDrag), false]} && {isNull objectParent _target}) exitWith {false};

if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};

Expand All @@ -31,7 +31,8 @@ if (_target isKindOf "StaticWeapon") exitWith {
if (_target isKindOf "CAManBase") exitWith {
isAwake _target && // not ragdolled
{lifeState _target == "INCAPACITATED" ||
{_target getHitPointDamage "HitLegs" >= 0.5}}
{_target getHitPointDamage "HitLegs" >= 0.5} ||
{(animationState _target) in ["", "unconscious", "deadstate"]}}
};

// Check max items for WeaponHolders
Expand Down
65 changes: 65 additions & 0 deletions addons/dragging/functions/fnc_createClone.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "..\script_component.hpp"
/*
* Author: BaerMitUmlaut, johnb43
* Creates a draggable / carryable clone of a dead unit.
*
* Arguments:
* 0: Dead unit <OBJECT>
*
* Return Value:
* Cloned unit <OBJECT>
*
* Example:
* [player] call ace_dragging_fnc_createClone;
*
* Public: No
*/
params ["_target"];

// Get current position of unit, -10 m below surface
private _posATL = getPosATL _target;
_posATL set [2, -10];

private _clone = createVehicle [QGVAR(clone), _posATL];

// Clone loadout
[_clone, _target call CBA_fnc_getLoadout] call CBA_fnc_setLoadout;

// Hide unit until it can be moved below terrain
private _isObjectHidden = isObjectHidden _target;

if (_isObjectHidden) then {
[QEGVAR(common,hideObjectGlobal), [_target, true]] call CBA_fnc_serverEvent;
};

private _simulationEnabled = simulationEnabled _target;

if (_simulationEnabled) then {
[QEGVAR(common,enableSimulationGlobal), [_target, false]] call CBA_fnc_serverEvent;
};

private _isInRemainsCollector = isInRemainsCollector _target;

// Make sure corpse isn't deleted by engine's garbage collector
if (_isInRemainsCollector) then {
removeFromRemainsCollector [_target];
};

// Disable all damage
_clone allowDamage false;
_clone setVariable [QGVAR(original), [_target, _isInRemainsCollector, _isObjectHidden, _simulationEnabled], true];

// Turn on PhysX so that unit is not desync when moving with 'setPos' commands
[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent;

[{
params ["_target", "_posATL"];

// Move unit below terrain in order to hide it
_target setPosATL _posATL;
}, [_target, _posATL], 0.1] call CBA_fnc_waitAndExecute;

// Sets the facial expression
[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP;

_clone
67 changes: 67 additions & 0 deletions addons/dragging/functions/fnc_dropClone.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "..\script_component.hpp"
/*
* Author: BaerMitUmlaut, johnb43
* Drops a draggable / carryable clone of a dead unit.
*
* Arguments:
* 0: Unit dragging / carrying <OBJECT>
* 1: Clone <OBJECT>
* 2: If unit is in building <BOOL>
*
* Return Value:
* Original unit <OBJECT>
*
* Example:
* [player, cursorObject, false] call ace_dragging_fnc_dropClone;
*
* Public: No
*/
params ["_unit", "_clone", "_inBuilding"];

(_clone getVariable [QGVAR(original), []]) params [["_target", objNull], ["_isInRemainsCollector", true], ["_isObjectHidden", false], ["_simulationEnabled", true]];

// Check if unit was deleted
if (!isNull _target) then {
// Turn on PhysX so that unit is not desync when moving
[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent;

private _posASL = getPosASL _clone;

if (_inBuilding) then {
_posASL = _posASL vectorAdd [0, 0, 0.05];
};

// Set the unit's direction
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;

[{
params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled", "_posASL"];

// Bring unit back to clone's position
_target setPosASL _posASL;

[{
params ["_target", "_clone", "_isObjectHidden", "_simulationEnabled"];

if (_isObjectHidden) then {
[QEGVAR(common,hideObjectGlobal), [_target, false]] call CBA_fnc_serverEvent;
};

if (_simulationEnabled) then {
[QEGVAR(common,enableSimulationGlobal), [_target, true]] call CBA_fnc_serverEvent;
};

deleteVehicle _clone;
}, _this, 0.1] call CBA_fnc_waitAndExecute;
}, [_target, _clone, _isObjectHidden, _simulationEnabled, _posASL], 0.1] call CBA_fnc_waitAndExecute;

if (_isInRemainsCollector) then {
addToRemainsCollector [_target];
};
};

// Detach first to prevent objNull in attachedObjects
detach _clone;
deleteVehicle _clone;

_target
8 changes: 7 additions & 1 deletion addons/dragging/functions/fnc_dropObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if !(GVAR(dragAndFire)) then {
};

private _inBuilding = _unit call FUNC(isObjectOnObject);
private _isClone = _target isKindOf QGVAR(clone);

// Drop cloned dead units
if (_isClone) then {
_target = [_unit, _target, _inBuilding] call FUNC(dropClone);
};

// Play release animation
if !(_unit getVariable ["ACE_isUnconscious", false]) then {
Expand All @@ -57,7 +63,7 @@ _unit removeWeapon "ACE_FakePrimaryWeapon";
[_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set);

// Prevent object from flipping inside buildings
if (_inBuilding) then {
if (_inBuilding && {!_isClone}) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
TRACE_2("setPos",getPosASL _unit,getPosASL _target);
};
Expand Down
9 changes: 8 additions & 1 deletion addons/dragging/functions/fnc_dropObject_carry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ TRACE_1("params",_this);
_unit setVariable [QGVAR(releaseActionID), nil];

private _inBuilding = _unit call FUNC(isObjectOnObject);
private _isClone = _target isKindOf QGVAR(clone);

// Drop cloned dead units
if (_isClone) then {
_target = [_unit, _target, _inBuilding] call FUNC(dropClone);
};

// Prevent collision damage
[QEGVAR(common,fixCollision), _unit] call CBA_fnc_localEvent;
Expand Down Expand Up @@ -71,8 +77,9 @@ if (_previousWeaponIndex != -1) then {
[_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set);

// Prevent object from flipping inside buildings
if (_inBuilding) then {
if (_inBuilding && {!_isClone}) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
TRACE_2("setPos",getPosASL _unit,getPosASL _target);
};

_unit setVariable [QGVAR(isCarrying), false, true];
Expand Down
2 changes: 1 addition & 1 deletion addons/dragging/functions/fnc_handleAnimChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Animaion <STRING>
* 1: Animation <STRING>
*
* Return Value:
* None
Expand Down
5 changes: 5 additions & 0 deletions addons/dragging/functions/fnc_startCarry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ 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);
};

private _primaryWeapon = primaryWeapon _unit;

// Add a primary weapon if the unit has none
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 @@ -31,6 +31,11 @@ if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
};

// Create clone for dead units
if (!alive _target) then {
_target = _target call FUNC(createClone);
};

private _primaryWeapon = primaryWeapon _unit;

// Add a primary weapon if the unit has none
Expand Down