Continue corpse carry

This commit is contained in:
johnb432 2023-07-20 19:42:35 +02:00
parent ccbf48030f
commit fb065d1098
9 changed files with 79 additions and 34 deletions

View File

@ -120,6 +120,11 @@
_object setMass _mass; _object setMass _mass;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
[QGVAR(awake), {
params ["_object", "_awake"];
_object awake _awake;
}] call CBA_fnc_addEventHandler;
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit //Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
//This variable is used for isPlayer checks //This variable is used for isPlayer checks
if (isServer) then { if (isServer) then {

View File

@ -18,7 +18,7 @@
params ["_unit", "_target"]; 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}; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
@ -33,8 +33,9 @@ if (_target isKindOf "StaticWeapon") exitWith {
// Units need to be unconscious or limping // Units need to be unconscious or limping
if (_target isKindOf "CAManBase") exitWith { if (_target isKindOf "CAManBase") exitWith {
lifeState _target == "INCAPACITATED" || lifeState _target isEqualTo "INCAPACITATED"
{_target getHitPointDamage "HitLegs" >= 0.5} || {_target getHitPointDamage "HitLegs" >= 0.5} ||
{(animationState _target) in ["", "unconscious", "deadstate"]}
}; };
// Check max items for WeaponHolders // Check max items for WeaponHolders

View File

@ -18,7 +18,7 @@
params ["_unit", "_target"]; 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}; if !([_unit, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
@ -29,8 +29,9 @@ if (_target isKindOf "StaticWeapon") exitWith {
// Units need to be unconscious or limping // Units need to be unconscious or limping
if (_target isKindOf "CAManBase") exitWith { if (_target isKindOf "CAManBase") exitWith {
lifeState _target == "INCAPACITATED" || lifeState _target isEqualTo "INCAPACITATED"
{_target getHitPointDamage "HitLegs" >= 0.5} || {_target getHitPointDamage "HitLegs" >= 0.5} ||
{(animationState _target) in ["", "unconscious", "deadstate"]}
}; };
// Check max items for WeaponHolders // Check max items for WeaponHolders

View File

@ -1,27 +1,41 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: BaerMitUmlaut * Author: BaerMitUmlaut, johnb43
* Creates a draggable / carryable clone of a dead unit. * Creates a draggable / carryable clone of a dead unit.
* *
* Arguments: * Arguments:
* 0: Dead unit <OBJECT> * 0: Dead unit <OBJECT>
* *
* Return Value: * Return Value:
* Cloned unit. * Cloned unit <OBJECT>
* *
* Example: * Example:
* [player] call ace_dragging_fnc_createClone; * [player] call ace_dragging_fnc_createClone;
* *
* Public: No * Public: No
*/ */
params ["_unit"]; params ["_target"];
private _clone = QGVAR(clone) createVehicle [0, 0, 0]; private _clone = QGVAR(clone) createVehicle [0, 0, 0];
_clone setUnitLoadout getUnitLoadout _unit;
_clone allowDamage false;
_clone setVariable [QGVAR(original), _unit];
_unit setPosATL [0, 0, -10];
[QGVAR(cloneCreated), [_unit, _clone]] call CBA_fnc_globalEvent; // Clone loadout
_clone setUnitLoadout getUnitLoadout _target;
[_clone, _target call BIS_fnc_getUnitInsignia] call BIS_fnc_setUnitInsignia;
// Disable all damage
_clone allowDamage false;
_clone setVariable [QGVAR(original), _target, true];
// Turn on PhysX so that unit is not desync when moving with 'setPos' commands
[QEGVAR(common,awake), [_target, true]] call CBA_fnc_globalEvent;
// Move unit below terrain in order to hide it
_target setPosATL [0, 0, -10];
// Turn off PhysX
[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent;
// Sets the facial expression
[[QGVAR(cloneCreated), [_target, _clone]] call CBA_fnc_globalEventJIP, _clone] call CBA_fnc_removeGlobalEventJIP;
_clone _clone

View File

@ -1,26 +1,47 @@
#include "script_component.hpp" #include "script_component.hpp"
/* /*
* Author: BaerMitUmlaut * Author: BaerMitUmlaut, johnb43
* Drops a draggable / carryable clone of a dead unit. * Drops a draggable / carryable clone of a dead unit.
* *
* Arguments: * Arguments:
* 0: Clone <OBJECT> * 0: Unit dragging / carrying <OBJECT>
* 1: Clone <OBJECT>
* 2: If unit is in building <BOOL>
* *
* Return Value: * Return Value:
* Original unit. * Original unit <OBJECT>
* *
* Example: * Example:
* [player] call ace_dragging_fnc_dropClone; * [player, cursorObject, false] call ace_dragging_fnc_dropClone;
* *
* Public: No * Public: No
*/ */
params ["_clone"]; params ["_unit", "_clone", "_inBuilding"];
private _unit = _clone getVariable [QGVAR(original), objNull]; private _target = _clone getVariable [QGVAR(original), objNull];
_unit setPosASL getPosASL _clone;
if (isNull _target) exitWith {objNull};
// 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;
// Bring unit back to clone's position
_target setPosASL _posASL;
// Turn off PhysX
[QEGVAR(common,awake), [_target, false]] call CBA_fnc_globalEvent;
// Detach first to prevent objNull in attachedObjects // Detach first to prevent objNull in attachedObjects
detach _clone; detach _clone;
deleteVehicle _clone; deleteVehicle _clone;
_unit _target

View File

@ -28,10 +28,11 @@ if !(GVAR(dragAndFire)) then {
}; };
private _inBuilding = [_unit] call FUNC(isObjectOnObject); private _inBuilding = [_unit] call FUNC(isObjectOnObject);
private _isClone = _target isKindOf QGVAR(clone);
// drop cloned dead units // Drop cloned dead units
if (_target isKindOf QGVAR(clone)) then { if (_isClone) then {
_target = [_target] call FUNC(dropClone); _target = [_unit, _target, _inBuilding] call FUNC(dropClone);
}; };
if !(_unit getVariable ["ACE_isUnconscious", false]) then { if !(_unit getVariable ["ACE_isUnconscious", false]) then {
@ -59,7 +60,7 @@ _unit removeWeapon "ACE_FakePrimaryWeapon";
[_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
// prevent object from flipping inside buildings // prevent object from flipping inside buildings
if (_inBuilding) then { if (_inBuilding && {!_isClone}) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
TRACE_2("setPos",getPosASL _unit,getPosASL _target); TRACE_2("setPos",getPosASL _unit,getPosASL _target);
}; };

View File

@ -23,10 +23,11 @@ TRACE_1("params",_this);
[_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); [_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler);
private _inBuilding = [_unit] call FUNC(isObjectOnObject); private _inBuilding = [_unit] call FUNC(isObjectOnObject);
private _isClone = _target isKindOf QGVAR(clone);
// drop cloned dead units // Drop cloned dead units
if (_target isKindOf QGVAR(clone)) then { if (_isClone) then {
_target = [_target] call FUNC(dropClone); _target = [_unit, _target, _inBuilding] call FUNC(dropClone);
}; };
// prevent collision damage // prevent collision damage
@ -65,8 +66,9 @@ if (_previousWeaponIndex != -1) then {
[_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set); [_unit, "blockThrow", "ACE_dragging", false] call EFUNC(common,statusEffect_set);
// prevent object from flipping inside buildings // prevent object from flipping inside buildings
if (_inBuilding) then { if (_inBuilding && {!_isClone}) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
TRACE_2("setPos",getPosASL _unit,getPosASL _target);
}; };
_unit setVariable [QGVAR(isCarrying), false, true]; _unit setVariable [QGVAR(isCarrying), false, true];

View File

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

View File

@ -28,9 +28,9 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && {
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
}; };
// create clone for dead units // Create clone for dead units
if (!alive _target) then { if (!alive _target) then {
_target = [_target] call FUNC(createClone); _target = _target call FUNC(createClone);
}; };
// Add a primary weapon if the unit has none // Add a primary weapon if the unit has none