2015-03-16 18:25:29 +00:00
|
|
|
// by PabstMirror, commy2
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Release object on disconnection. Function is identical to killed
|
2015-09-26 01:16:55 +00:00
|
|
|
if (isServer) then {
|
2023-07-22 04:01:30 +00:00
|
|
|
// 'HandleDisconnect' EH triggers too late
|
|
|
|
addMissionEventHandler ["PlayerDisconnected", {
|
|
|
|
private _unit = (getUserInfo (_this select 5)) select 10;
|
|
|
|
|
|
|
|
_unit call FUNC(handleKilled);
|
|
|
|
}];
|
2023-07-23 04:49:08 +00:00
|
|
|
|
|
|
|
// Handle surrending and handcuffing
|
|
|
|
["ace_captiveStatusChanged", {
|
|
|
|
params ["_unit", "_state"];
|
|
|
|
|
|
|
|
// If surrended or handcuffed, drop dragged/carried object
|
|
|
|
if (_state) then {
|
|
|
|
_unit call FUNC(handleKilled);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
2015-09-26 01:16:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2015-03-18 13:14:16 +00:00
|
|
|
if (isNil "ACE_maxWeightDrag") then {
|
|
|
|
ACE_maxWeightDrag = 800;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isNil "ACE_maxWeightCarry") then {
|
|
|
|
ACE_maxWeightCarry = 600;
|
2015-03-16 18:25:29 +00:00
|
|
|
};
|
2023-07-23 23:07:37 +00:00
|
|
|
|
2023-06-28 11:43:10 +00:00
|
|
|
if (isNil QGVAR(maxWeightCarryRun)) then {
|
|
|
|
GVAR(maxWeightCarryRun) = 50;
|
|
|
|
};
|
2015-03-16 18:25:29 +00:00
|
|
|
|
|
|
|
["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition);
|
2015-03-17 14:42:25 +00:00
|
|
|
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);
|
2015-03-17 12:47:07 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Release object on player change. This does work when returning to lobby, but not when hard disconnecting.
|
|
|
|
["unit", LINKFUNC(handlePlayerChanged)] call CBA_fnc_addPlayerEventHandler;
|
2016-08-03 20:26:36 +00:00
|
|
|
["vehicle", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call CBA_fnc_addPlayerEventHandler;
|
2023-07-23 23:07:37 +00:00
|
|
|
["weapon", LINKFUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
|
2015-03-24 18:07:39 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Handle waking up dragged unit and falling unconscious while dragging
|
|
|
|
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
2015-03-24 18:07:39 +00:00
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Display event handler
|
|
|
|
["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler;
|
2020-04-20 15:45:59 +00:00
|
|
|
|
2023-07-22 03:30:40 +00:00
|
|
|
[QGVAR(carryingContainerClosed), {
|
|
|
|
params ["_container", "_owner"];
|
|
|
|
TRACE_2("carryingContainerClosed EH",_container,_owner);
|
|
|
|
if !(_owner getVariable [QGVAR(isCarrying), false]) exitWith { ERROR_1("not carrying - %1",_this) };
|
|
|
|
|
|
|
|
private _weight = 0;
|
|
|
|
if !(_container getVariable [QGVAR(ignoreWeightCarry), false]) then {
|
|
|
|
_weight = [_container] call FUNC(getWeight);
|
|
|
|
};
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Drop the object if overweight
|
2023-07-22 03:30:40 +00:00
|
|
|
if (_weight > ACE_maxWeightCarry) exitWith {
|
|
|
|
[_owner, _container] call FUNC(dropObject_carry);
|
|
|
|
};
|
|
|
|
private _canRun = [_weight] call FUNC(canRun_carry);
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Force walking based on weight
|
2023-07-22 03:30:40 +00:00
|
|
|
[_owner, "forceWalk", QUOTE(ADDON), !_canRun] call EFUNC(common,statusEffect_set);
|
|
|
|
[_owner, "blockSprint", QUOTE(ADDON), _canRun] call EFUNC(common,statusEffect_set);
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
[QGVAR(draggingContainerClosed), {
|
|
|
|
params ["_container", "_owner"];
|
|
|
|
TRACE_2("draggingContainerClosed EH",_container,_owner);
|
|
|
|
if !(_owner getVariable [QGVAR(isDragging), false]) exitWith { ERROR_1("not dragging - %1",_this) };
|
|
|
|
|
|
|
|
private _weight = 0;
|
|
|
|
if !(_container getVariable [QGVAR(ignoreWeightDrag), false]) then {
|
|
|
|
_weight = [_container] call FUNC(getWeight);
|
|
|
|
};
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
// Drop the object if overweight
|
2023-07-22 03:30:40 +00:00
|
|
|
if (_weight > ACE_maxWeightDrag) exitWith {
|
|
|
|
[_owner, _container] call FUNC(dropObject);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
2023-07-23 23:07:37 +00:00
|
|
|
#include "initKeybinds.sqf"
|