diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 00d1a4406b..8e55a44595 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -120,6 +120,11 @@ _object setMass _mass; }] 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 //This variable is used for isPlayer checks if (isServer) then { diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index 2e93a6f62c..570f787727 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -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}; @@ -33,8 +33,9 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} + lifeState _target isEqualTo "INCAPACITATED" + || {_target getHitPointDamage "HitLegs" >= 0.5} || + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 1478abacf5..7ec7999d36 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -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}; @@ -29,8 +29,9 @@ if (_target isKindOf "StaticWeapon") exitWith { // Units need to be unconscious or limping if (_target isKindOf "CAManBase") exitWith { - lifeState _target == "INCAPACITATED" || - {_target getHitPointDamage "HitLegs" >= 0.5} + lifeState _target isEqualTo "INCAPACITATED" + || {_target getHitPointDamage "HitLegs" >= 0.5} || + {(animationState _target) in ["", "unconscious", "deadstate"]} }; // Check max items for WeaponHolders diff --git a/addons/dragging/functions/fnc_createClone.sqf b/addons/dragging/functions/fnc_createClone.sqf index eca1c2025d..20406c725b 100644 --- a/addons/dragging/functions/fnc_createClone.sqf +++ b/addons/dragging/functions/fnc_createClone.sqf @@ -1,27 +1,41 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Creates a draggable / carryable clone of a dead unit. * * Arguments: * 0: Dead unit * * Return Value: - * Cloned unit. + * Cloned unit * * Example: * [player] call ace_dragging_fnc_createClone; * * Public: No */ -params ["_unit"]; +params ["_target"]; 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 diff --git a/addons/dragging/functions/fnc_dropClone.sqf b/addons/dragging/functions/fnc_dropClone.sqf index d0eeb71d2c..e8c2fe43a3 100644 --- a/addons/dragging/functions/fnc_dropClone.sqf +++ b/addons/dragging/functions/fnc_dropClone.sqf @@ -1,26 +1,47 @@ #include "script_component.hpp" /* - * Author: BaerMitUmlaut + * Author: BaerMitUmlaut, johnb43 * Drops a draggable / carryable clone of a dead unit. * * Arguments: - * 0: Clone + * 0: Unit dragging / carrying + * 1: Clone + * 2: If unit is in building * * Return Value: - * Original unit. + * Original unit * * Example: - * [player] call ace_dragging_fnc_dropClone; + * [player, cursorObject, false] call ace_dragging_fnc_dropClone; * * Public: No */ -params ["_clone"]; +params ["_unit", "_clone", "_inBuilding"]; -private _unit = _clone getVariable [QGVAR(original), objNull]; -_unit setPosASL getPosASL _clone; +private _target = _clone getVariable [QGVAR(original), objNull]; + +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 _clone; deleteVehicle _clone; -_unit +_target diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 895717d1fa..b4e2932964 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -28,10 +28,11 @@ if !(GVAR(dragAndFire)) then { }; private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; 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); // 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); }; diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 1c2dd69cdc..f3b91422d6 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -23,10 +23,11 @@ TRACE_1("params",_this); [_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); private _inBuilding = [_unit] call FUNC(isObjectOnObject); +private _isClone = _target isKindOf QGVAR(clone); -// drop cloned dead units -if (_target isKindOf QGVAR(clone)) then { - _target = [_target] call FUNC(dropClone); +// Drop cloned dead units +if (_isClone) then { + _target = [_unit, _target, _inBuilding] call FUNC(dropClone); }; // prevent collision damage @@ -65,8 +66,9 @@ if (_previousWeaponIndex != -1) then { [_unit, "blockThrow", "ACE_dragging", 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]; diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 194175799e..5e39a05fe3 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -33,9 +33,9 @@ private _timer = CBA_missionTime + 5; // handle objects vs persons if (_target isKindOf "CAManBase") then { - // create clone for dead units + // Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; // add a primary weapon if the unit has none. diff --git a/addons/dragging/functions/fnc_startDrag.sqf b/addons/dragging/functions/fnc_startDrag.sqf index ebcf75a211..3bdbc80538 100644 --- a/addons/dragging/functions/fnc_startDrag.sqf +++ b/addons/dragging/functions/fnc_startDrag.sqf @@ -28,9 +28,9 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && { [localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured); }; -// create clone for dead units +// Create clone for dead units if (!alive _target) then { - _target = [_target] call FUNC(createClone); + _target = _target call FUNC(createClone); }; // Add a primary weapon if the unit has none