mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
11664b0040
* Update XEH_postInit.sqf * Update XEH_postInit.sqf * Update XEH_postInit.sqf * Different approach * Updated to new script_component * fix variable lookup --------- Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
108 lines
3.8 KiB
Plaintext
108 lines
3.8 KiB
Plaintext
// by PabstMirror, commy2
|
|
#include "script_component.hpp"
|
|
|
|
if (isServer) then {
|
|
// Release object on disconnection. Function is identical to killed
|
|
addMissionEventHandler ["HandleDisconnect", LINKFUNC(handleKilled)];
|
|
|
|
// 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;
|
|
};
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
if (isNil "ACE_maxWeightDrag") then {
|
|
ACE_maxWeightDrag = 800;
|
|
};
|
|
|
|
if (isNil "ACE_maxWeightCarry") then {
|
|
ACE_maxWeightCarry = 600;
|
|
};
|
|
|
|
if (isNil QGVAR(maxWeightCarryRun)) then {
|
|
GVAR(maxWeightCarryRun) = 50;
|
|
};
|
|
|
|
["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition);
|
|
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);
|
|
|
|
// Release object on player change. This does work when returning to lobby, but not when hard disconnecting.
|
|
["unit", LINKFUNC(handlePlayerChanged)] call CBA_fnc_addPlayerEventHandler;
|
|
["vehicle", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call CBA_fnc_addPlayerEventHandler;
|
|
["weapon", LINKFUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
// Handle waking up dragged unit and falling unconscious while dragging
|
|
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
|
|
|
// Display event handler
|
|
["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}] call CBA_fnc_addDisplayHandler;
|
|
|
|
[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);
|
|
};
|
|
|
|
// Drop the object if overweight
|
|
if (_weight > ACE_maxWeightCarry) exitWith {
|
|
[_owner, _container] call FUNC(dropObject_carry);
|
|
};
|
|
private _canRun = [_weight] call FUNC(canRun_carry);
|
|
|
|
// Force walking based on weight
|
|
[_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);
|
|
};
|
|
|
|
// Drop the object if overweight
|
|
if (_weight > ACE_maxWeightDrag) exitWith {
|
|
[_owner, _container] call FUNC(dropObject);
|
|
};
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
// When changing cameras, drop carried and dragged objects
|
|
["featureCamera", {
|
|
params ["_unit", "_camera"];
|
|
|
|
// Unit can either drag or carry, functions themselves handle which ones are executed
|
|
switch (_camera) do {
|
|
// Default camera
|
|
case "": {
|
|
_unit call FUNC(resumeDrag);
|
|
_unit call FUNC(resumeCarry);
|
|
};
|
|
// Arsenals make the unit change animations, which makes the unit drop dragged/carried objects regardless
|
|
case "arsenal";
|
|
case "ace_arsenal": {
|
|
_unit call FUNC(handleKilled);
|
|
};
|
|
default {
|
|
_unit call FUNC(pauseDrag);
|
|
_unit call FUNC(pauseCarry);
|
|
};
|
|
};
|
|
}] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
#include "initKeybinds.sqf"
|