ACE3/addons/interaction/XEH_postInit.sqf
jonpas 711e1fc026 Fix Underwater interactions (magrepack, loading, refuel, medical legs, dragging) (#5521)
* Fix Magazine Repack underwater - fix #5513
Also prevent common goKneeling function underwater

* Fix loading patients underwater - fix #5515

* Fix load object underwater

* Fix take nozzle on jerry can underwater

* Fix refuel underwater conditions further

* Use isTouchingGround, Make refuel semi-compatible
 reports false if head is out of the water, we want true even if we are not diving

* Less interact exceptions duplication

* Use animationState to determine if unit is swimming, create common function and use it instead of isTouchingGround

* Fix condition

* Support dragging underwater
No carrying due to animation timing issues and other misc things

* Allow Medical Legs SelfActions underwater

* Fix fixPosition function underwater (use getPosATL instead of getPos)

* Fix fixPosition's slope adjustment for non-gravity objects, Do the same for objects without simulation as well
2017-10-01 13:38:11 -05:00

119 lines
4.0 KiB
Plaintext

// by commy2 and esteldunedain
#include "script_component.hpp"
ACE_Modifier = 0;
[QGVAR(pardon), {(_this select 0) addRating -rating (_this select 0)}] call CBA_fnc_addEventHandler;
[QGVAR(getDown), {
params ["_target"];
_target setUnitPos "DOWN";
}] call CBA_fnc_addEventHandler;
[QGVAR(sendAway), {
params ["_unit", "_position"];
_unit setUnitPos "AUTO";
_unit doMove _position;
}] call CBA_fnc_addEventHandler;
[QGVAR(setLampOn), {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{if((_x select 1) == _disabledLampDMG) then {_lamp setHit [_x select 0, 0];};nil} count _hitPointsDamage;
}] call CBA_fnc_addEventHandler;
[QGVAR(setLampOff), {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{_lamp setHit [_x select 0, (_x select 1) max _disabledLampDMG];nil} count _hitPointsDamage;
}] call CBA_fnc_addEventHandler;
// Zeus action events
[QGVAR(zeusStance),{
{ _x setUnitPos (_this select 0); } forEach (_this select 1);
}] call CBA_fnc_addEventHandler;
// The following 3 events handle both waypoints and groups
[QGVAR(zeusBehaviour),{
if (param [2,false]) then {
{ _x setWaypointBehaviour (_this select 0); } forEach (_this select 1);
} else {
{ _x setBehaviour (_this select 0); } forEach (_this select 1);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(zeusSpeed),{
if (param [2,false]) then {
{ _x setWaypointSpeed (_this select 0); } forEach (_this select 1);
} else {
{ _x setSpeedMode (_this select 0); } forEach (_this select 1);
};
}] call CBA_fnc_addEventHandler;
[QGVAR(zeusFormation),{
if (param [2,false]) then {
{ _x setWaypointFormation (_this select 0); } forEach (_this select 1);
} else {
{ _x setFormation (_this select 0); } forEach (_this select 1);
};
}] call CBA_fnc_addEventHandler;
if (!hasInterface) exitWith {};
GVAR(isOpeningDoor) = false;
[QGVAR(tapShoulder), {
params ["_unit", "_shoulderNum"];
if (_unit == ACE_player) then {
addCamShake [4, 0.5, 5];
private _message = parseText format ([["%1 >", localize LSTRING(YouWereTappedRight)], ["< %1", localize LSTRING(YouWereTappedLeft)]] select (_shoulderNum == 1));
[_message] call EFUNC(common,displayTextStructured);
};
}] call CBA_fnc_addEventHandler;
// add keybinds
["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), {
// Conditions: canInteract
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if (GVAR(isOpeningDoor) || {[MACRO_DOOR_REACH_DISTANCE] call FUNC(getDoor) select 1 == ''}) exitWith {false};
// Statement
call EFUNC(interaction,openDoor);
true
}, {
//Probably don't want any conditions here, so variable never gets locked down
// Statement
GVAR(isOpeningDoor) = false;
true
},
[57, [false, true, false]], false] call CBA_fnc_addKeybind; //Key CTRL+Space
["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), {
// Conditions: canInteract
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !([ACE_player, cursorTarget] call FUNC(canTapShoulder)) exitWith {false};
//Tap whichever shoulder is closest
private _shoulderNum = [0, 1] select (([cursorTarget, ACE_player] call BIS_fnc_relativeDirTo) > 180);
// Statement
[ACE_player, cursorTarget, _shoulderNum] call FUNC(tapShoulder);
true
},
{false},
[20, [true, false, false]], false] call CBA_fnc_addKeybind;
["isNotSwimming", {!(_this call EFUNC(common,isSwimming))}] call EFUNC(common,addCanInteractWithCondition);
["isNotOnLadder", {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "ACE_isLadder") != 1}] call EFUNC(common,addCanInteractWithCondition);
["ace_settingsInitialized", {
if (GVAR(disableNegativeRating)) then {
player addEventHandler ["HandleRating", {
(_this select 1) max 0
}];
};
}] call CBA_fnc_addEventHandler;