mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dragging - Prevent multiple units carrying the same object (#9730)
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
parent
676a4b97a6
commit
8bc5f513b4
@ -1,7 +1,7 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2, PabstMirror
|
||||
* Unit claims the ownership over an object. This is used to prevent multiple players from draging the same ammo box or using up the same wheel when repairing etc.
|
||||
* Unit claims the ownership over an object. This is used to prevent multiple players from dragging the same ammo box or using up the same wheel when repairing etc.
|
||||
* This function only runs on the server and handles the "ace_common_claimSafe" event. It provides a network safe way claiming objects as all claims are run on server.
|
||||
* Return event is passed [_unit, _target, _success] for new claims, no event on claim release
|
||||
*
|
||||
|
@ -26,6 +26,8 @@ PREP(resumeDrag);
|
||||
PREP(setCarryable);
|
||||
PREP(setDraggable);
|
||||
PREP(startCarry);
|
||||
PREP(startCarryLocal);
|
||||
PREP(startCarryPFH);
|
||||
PREP(startDrag);
|
||||
PREP(startDragLocal);
|
||||
PREP(startDragPFH);
|
||||
|
@ -67,6 +67,9 @@ if (isNil QGVAR(maxWeightCarryRun)) then {
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(startCarry), LINKFUNC(startCarryLocal)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(startDrag), LINKFUNC(startDragLocal)] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(carryingContainerClosed), {
|
||||
params ["_container", "_owner"];
|
||||
TRACE_2("carryingContainerClosed EH",_container,_owner);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: johnb43
|
||||
* Removes user input affecting dragging.
|
||||
* Removes user input affecting carrying.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
|
@ -56,8 +56,25 @@ GVAR(initializedClasses_carry) = _initializedClasses;
|
||||
|
||||
private _icon = [QPATHTOF(UI\icons\box_carry.paa), QPATHTOF(UI\icons\person_carry.paa)] select (_object isKindOf "CAManBase");
|
||||
|
||||
private _carryAction = [QGVAR(carry), LLSTRING(Carry), _icon, {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
|
||||
private _dropAction = [QGVAR(drop_carry), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
|
||||
private _carryAction = [
|
||||
QGVAR(carry),
|
||||
LLSTRING(Carry),
|
||||
_icon,
|
||||
{
|
||||
[_player, _target] call FUNC(startCarry)
|
||||
}, {
|
||||
[_player, _target] call FUNC(canCarry)
|
||||
}] call EFUNC(interact_menu,createAction);
|
||||
|
||||
private _dropAction = [
|
||||
QGVAR(drop_carry),
|
||||
LLSTRING(Drop),
|
||||
"",
|
||||
{
|
||||
[_player, _target] call FUNC(dropObject_carry)
|
||||
}, {
|
||||
[_player, _target] call FUNC(canDrop_carry)
|
||||
}] call EFUNC(interact_menu,createAction);
|
||||
|
||||
[_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass);
|
||||
[_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass);
|
||||
|
@ -56,8 +56,25 @@ GVAR(initializedClasses) = _initializedClasses;
|
||||
|
||||
private _icon = [QPATHTOF(UI\icons\box_drag.paa), QPATHTOF(UI\icons\person_drag.paa)] select (_object isKindOf "CAManBase");
|
||||
|
||||
private _dragAction = [QGVAR(drag), LLSTRING(Drag), _icon, {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}] call EFUNC(interact_menu,createAction);
|
||||
private _dropAction = [QGVAR(drop), LLSTRING(Drop), "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction);
|
||||
private _dragAction = [
|
||||
QGVAR(drag),
|
||||
LLSTRING(Drag),
|
||||
_icon,
|
||||
{
|
||||
[_player, _target] call FUNC(startDrag)
|
||||
}, {
|
||||
[_player, _target] call FUNC(canDrag)
|
||||
}] call EFUNC(interact_menu,createAction);
|
||||
|
||||
private _dropAction = [
|
||||
QGVAR(drop),
|
||||
LLSTRING(Drop),
|
||||
"",
|
||||
{
|
||||
[_player, _target] call FUNC(dropObject);
|
||||
}, {
|
||||
[_player, _target] call FUNC(canDrop)
|
||||
}] call EFUNC(interact_menu,createAction);
|
||||
|
||||
[_type, 0, ["ACE_MainActions"], _dragAction] call EFUNC(interact_menu,addActionToClass);
|
||||
[_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2, PiZZADOX
|
||||
* Starts the carrying process.
|
||||
* Author: johnb43
|
||||
* Starts the carrying process safely.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
@ -11,82 +11,11 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, cursorTarget] call ace_dragging_fnc_startCarry;
|
||||
* [player, cursorTarget] call ace_dragging_fnc_startCarry
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_target"];
|
||||
TRACE_2("params",_unit,_target);
|
||||
|
||||
// Exempt from weight check if object has override variable set
|
||||
private _weight = 0;
|
||||
|
||||
if !(_target getVariable [QGVAR(ignoreWeightCarry), false]) then {
|
||||
_weight = _target call FUNC(getWeight);
|
||||
};
|
||||
|
||||
// Exit if object weight is over global var value
|
||||
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
||||
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
private _timer = CBA_missionTime + 5;
|
||||
|
||||
// Handle objects vs. persons
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
private _primaryWeapon = primaryWeapon _unit;
|
||||
|
||||
// Add a primary weapon if the unit has none
|
||||
if (_primaryWeapon == "") then {
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
// Select primary, otherwise the drag animation actions don't work
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
|
||||
// Move a bit closer and adjust direction when trying to pick up a person
|
||||
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;
|
||||
_target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit));
|
||||
|
||||
[_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
||||
[_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2] call EFUNC(common,doAnimation);
|
||||
|
||||
_timer = CBA_missionTime + 10;
|
||||
} else {
|
||||
// Select no weapon and stop sprinting
|
||||
private _previousWeaponIndex = [_unit] call EFUNC(common,getFiremodeIndex);
|
||||
_unit setVariable [QGVAR(previousWeapon), _previousWeaponIndex, true];
|
||||
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 299];
|
||||
|
||||
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
||||
|
||||
private _canRun = _weight call FUNC(canRun_carry);
|
||||
|
||||
// Only force walking if we're overweight
|
||||
[_unit, "forceWalk", QUOTE(ADDON), !_canRun] call EFUNC(common,statusEffect_set);
|
||||
[_unit, "blockSprint", QUOTE(ADDON), _canRun] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
|
||||
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// Prevent multiple players from accessing the same object
|
||||
[_unit, _target, true] call EFUNC(common,claim);
|
||||
|
||||
// Prevents dragging and carrying at the same time
|
||||
_unit setVariable [QGVAR(isCarrying), true, true];
|
||||
|
||||
// Required for aborting animation
|
||||
_unit setVariable [QGVAR(carriedObject), _target, true];
|
||||
|
||||
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Disable collisions by setting the PhysX mass to almost zero
|
||||
private _mass = getMass _target;
|
||||
|
||||
if (_mass > 1) then {
|
||||
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||
[QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync
|
||||
};
|
||||
// Try to claim the object
|
||||
[QEGVAR(common,claimSafe), [_unit, _target, true, QGVAR(startCarry)]] call CBA_fnc_serverEvent;
|
||||
|
92
addons/dragging/functions/fnc_startCarryLocal.sqf
Normal file
92
addons/dragging/functions/fnc_startCarryLocal.sqf
Normal file
@ -0,0 +1,92 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2, PiZZADOX
|
||||
* Starts the carrying process.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
* 1: Object to carry <OBJECT>
|
||||
* 2: If object was successfully claimed <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, cursorTarget, true] call ace_dragging_fnc_startCarryLocal
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_target", "_claimed"];
|
||||
TRACE_3("params",_unit,_target,_claimed);
|
||||
|
||||
if (!_claimed) exitWith {};
|
||||
|
||||
// Exempt from weight check if object has override variable set
|
||||
private _weight = 0;
|
||||
|
||||
if !(_target getVariable [QGVAR(ignoreWeightCarry), false]) then {
|
||||
_weight = _target call FUNC(getWeight);
|
||||
};
|
||||
|
||||
// Exit if object weight is over global var value
|
||||
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
||||
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
private _timer = CBA_missionTime + 5;
|
||||
|
||||
// Handle objects vs. persons
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
private _primaryWeapon = primaryWeapon _unit;
|
||||
|
||||
// Add a primary weapon if the unit has none
|
||||
if (_primaryWeapon == "") then {
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
// Select primary, otherwise the drag animation actions don't work
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
|
||||
// Move a bit closer and adjust direction when trying to pick up a person
|
||||
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;
|
||||
_target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit));
|
||||
|
||||
[_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2] call EFUNC(common,doAnimation);
|
||||
[_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2] call EFUNC(common,doAnimation);
|
||||
|
||||
_timer = CBA_missionTime + 10;
|
||||
} else {
|
||||
// Select no weapon and stop sprinting
|
||||
private _previousWeaponIndex = [_unit] call EFUNC(common,getFiremodeIndex);
|
||||
_unit setVariable [QGVAR(previousWeapon), _previousWeaponIndex, true];
|
||||
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 299];
|
||||
|
||||
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
||||
|
||||
private _canRun = _weight call FUNC(canRun_carry);
|
||||
|
||||
// Only force walking if we're overweight
|
||||
[_unit, "forceWalk", QUOTE(ADDON), !_canRun] call EFUNC(common,statusEffect_set);
|
||||
[_unit, "blockSprint", QUOTE(ADDON), _canRun] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
|
||||
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// Prevents dragging and carrying at the same time
|
||||
_unit setVariable [QGVAR(isCarrying), true, true];
|
||||
|
||||
// Required for aborting animation
|
||||
_unit setVariable [QGVAR(carriedObject), _target, true];
|
||||
|
||||
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Disable collisions by setting the PhysX mass to almost zero
|
||||
private _mass = getMass _target;
|
||||
|
||||
if (_mass > 1) then {
|
||||
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||
[QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync
|
||||
};
|
@ -1,104 +1,21 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2, PiZZADOX, Malbryn
|
||||
* Starts the dragging process.
|
||||
* Author: johnb43
|
||||
* Starts the dragging process safely.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that should do the dragging <OBJECT>
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
* 1: Object to drag <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, cursorTarget] call ace_dragging_fnc_startDrag;
|
||||
* [player, cursorTarget] call ace_dragging_fnc_startDrag
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_target"];
|
||||
TRACE_2("params",_unit,_target);
|
||||
|
||||
// Exempt from weight check if object has override variable set
|
||||
private _weight = 0;
|
||||
|
||||
if !(_target getVariable [QGVAR(ignoreWeightDrag), false]) then {
|
||||
_weight = _target call FUNC(getWeight);
|
||||
};
|
||||
|
||||
// Exit if object weight is over global var value
|
||||
if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
|
||||
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
private _primaryWeapon = primaryWeapon _unit;
|
||||
|
||||
// Add a primary weapon if the unit has none
|
||||
if !(GVAR(dragAndFire)) then {
|
||||
if (_primaryWeapon == "") then {
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
} else { // Making sure the unit is holding a primary weapon or handgun
|
||||
private _handgunWeapon = handgunWeapon _unit;
|
||||
|
||||
if !(currentWeapon _unit in [_primaryWeapon, _handgunWeapon]) then {
|
||||
if (_primaryWeapon != "") then {
|
||||
// Use primary if possible
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
} else {
|
||||
if (_handgunWeapon != "") then {
|
||||
// Use pistol if unit has no primary
|
||||
_unit selectWeapon _handgunWeapon;
|
||||
} else {
|
||||
// Add fake weapon if no weapons besides launcher are available
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_unit selectWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Save the weapon so we can monitor if it changes
|
||||
_unit setVariable [QGVAR(currentWeapon), currentWeapon _unit];
|
||||
|
||||
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// Prevent multiple players from accessing the same object
|
||||
[_unit, _target, true] call EFUNC(common,claim);
|
||||
|
||||
// Can't play action that depends on weapon if it was added the same frame
|
||||
if !(_unit call EFUNC(common,isSwimming)) then {
|
||||
[{
|
||||
private _unitWeapon = _this getVariable [QGVAR(currentWeapon), ""];
|
||||
|
||||
if (_unitWeapon isKindOf ["Pistol", configFile >> "CfgWeapons"]) then {
|
||||
[_this, "ACE_dragWithPistol"] call EFUNC(common,doGesture);
|
||||
} else {
|
||||
[_this, "ACE_dragWithRifle"] call EFUNC(common,doGesture);
|
||||
};
|
||||
}, _unit] call CBA_fnc_execNextFrame;
|
||||
};
|
||||
|
||||
// Move a bit closer and adjust direction when trying to pick up a person
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;
|
||||
_target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit vectorMultiply 1.5));
|
||||
|
||||
[_target, "AinjPpneMrunSnonWnonDb_grab", 2] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
// Prevents dragging and carrying at the same time
|
||||
_unit setVariable [QGVAR(isDragging), true, true];
|
||||
|
||||
[FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Disable collisions by setting the physx mass to almost zero
|
||||
private _mass = getMass _target;
|
||||
|
||||
if (_mass > 1) then {
|
||||
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||
[QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync
|
||||
};
|
||||
// Try to claim the object
|
||||
[QEGVAR(common,claimSafe), [_unit, _target, true, QGVAR(startDrag)]] call CBA_fnc_serverEvent;
|
||||
|
104
addons/dragging/functions/fnc_startDragLocal.sqf
Normal file
104
addons/dragging/functions/fnc_startDragLocal.sqf
Normal file
@ -0,0 +1,104 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2, PiZZADOX, Malbryn
|
||||
* Starts the dragging process.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit that should do the dragging <OBJECT>
|
||||
* 1: Object to drag <OBJECT>
|
||||
* 2: If object was successfully claimed <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, cursorTarget, true] call ace_dragging_fnc_startDragLocal
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_target", "_claimed"];
|
||||
TRACE_3("params",_unit,_target,_claimed);
|
||||
|
||||
if (!_claimed) exitWith {};
|
||||
|
||||
// Exempt from weight check if object has override variable set
|
||||
private _weight = 0;
|
||||
|
||||
if !(_target getVariable [QGVAR(ignoreWeightDrag), false]) then {
|
||||
_weight = _target call FUNC(getWeight);
|
||||
};
|
||||
|
||||
// Exit if object weight is over global var value
|
||||
if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
|
||||
[LLSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
private _primaryWeapon = primaryWeapon _unit;
|
||||
|
||||
// Add a primary weapon if the unit has none
|
||||
if !(GVAR(dragAndFire)) then {
|
||||
if (_primaryWeapon == "") then {
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_primaryWeapon = "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
} else { // Making sure the unit is holding a primary weapon or handgun
|
||||
private _handgunWeapon = handgunWeapon _unit;
|
||||
|
||||
if !(currentWeapon _unit in [_primaryWeapon, _handgunWeapon]) then {
|
||||
if (_primaryWeapon != "") then {
|
||||
// Use primary if possible
|
||||
_unit selectWeapon _primaryWeapon;
|
||||
} else {
|
||||
if (_handgunWeapon != "") then {
|
||||
// Use pistol if unit has no primary
|
||||
_unit selectWeapon _handgunWeapon;
|
||||
} else {
|
||||
// Add fake weapon if no weapons besides launcher are available
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
_unit selectWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Save the weapon so we can monitor if it changes
|
||||
_unit setVariable [QGVAR(currentWeapon), currentWeapon _unit];
|
||||
|
||||
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// Can't play action that depends on weapon if it was added the same frame
|
||||
if !(_unit call EFUNC(common,isSwimming)) then {
|
||||
[{
|
||||
private _unitWeapon = _this getVariable [QGVAR(currentWeapon), ""];
|
||||
|
||||
if (_unitWeapon isKindOf ["Pistol", configFile >> "CfgWeapons"]) then {
|
||||
[_this, "ACE_dragWithPistol"] call EFUNC(common,doGesture);
|
||||
} else {
|
||||
[_this, "ACE_dragWithRifle"] call EFUNC(common,doGesture);
|
||||
};
|
||||
}, _unit] call CBA_fnc_execNextFrame;
|
||||
};
|
||||
|
||||
// Move a bit closer and adjust direction when trying to pick up a person
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
[QEGVAR(common,setDir), [_target, getDir _unit + 180], _target] call CBA_fnc_targetEvent;
|
||||
_target setPosASL (getPosASL _unit vectorAdd (vectorDir _unit vectorMultiply 1.5));
|
||||
|
||||
[_target, "AinjPpneMrunSnonWnonDb_grab", 2] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
// Prevents dragging and carrying at the same time
|
||||
_unit setVariable [QGVAR(isDragging), true, true];
|
||||
|
||||
[FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// Disable collisions by setting the physx mass to almost zero
|
||||
private _mass = getMass _target;
|
||||
|
||||
if (_mass > 1) then {
|
||||
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||
[QEGVAR(common,setMass), [_target, 1e-12]] call CBA_fnc_globalEvent; // Force global sync
|
||||
};
|
@ -5,7 +5,7 @@
|
||||
if (!alive _player) exitWith {false};
|
||||
if !([_player, objNull, ["isNotDragging", "isNotCarrying", "isNotSwimming"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
// If we are drag/carrying something right now then just drop it:
|
||||
// If we are dragging/carrying something right now then just drop it
|
||||
if (_player getVariable [QGVAR(isDragging), false]) exitWith {
|
||||
[_player, _player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
if (!alive _player) exitWith {false};
|
||||
if !([_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
// If we are drag/carrying something right now then just drop it:
|
||||
// If we are dragging/carrying something right now then just drop it
|
||||
if (_player getVariable [QGVAR(isDragging), false]) exitWith {
|
||||
[_player, _player getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
|
||||
|
||||
|
@ -32,7 +32,7 @@ GVAR(actions) = [];
|
||||
|
||||
if ("ace_dragging" call EFUNC(common,isModLoaded)) then {
|
||||
GVAR(actions) pushBack [
|
||||
localize ELSTRING(dragging,Drag), "drag",
|
||||
LELSTRING(dragging,Drag), "drag",
|
||||
{ACE_player != GVAR(target) && {[ACE_player, GVAR(target)] call EFUNC(dragging,canDrag)}},
|
||||
{
|
||||
GVAR(pendingReopen) = false;
|
||||
@ -41,7 +41,7 @@ if ("ace_dragging" call EFUNC(common,isModLoaded)) then {
|
||||
];
|
||||
|
||||
GVAR(actions) pushBack [
|
||||
localize ELSTRING(dragging,Carry), "drag",
|
||||
LELSTRING(dragging,Carry), "drag",
|
||||
{ACE_player != GVAR(target) && {[ACE_player, GVAR(target)] call EFUNC(dragging,canCarry)}},
|
||||
{
|
||||
GVAR(pendingReopen) = false;
|
||||
|
Loading…
Reference in New Issue
Block a user