2016-08-22 13:09:08 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-09-23 17:48:25 +00:00
|
|
|
// Fired XEH
|
2023-10-19 23:25:44 +00:00
|
|
|
GVAR(ammoEventHandlers) = createHashMap;
|
2016-09-23 17:48:25 +00:00
|
|
|
[QGVAR(throwFiredXEH), FUNC(throwFiredXEH)] call CBA_fnc_addEventHandler;
|
|
|
|
|
2016-08-22 13:09:08 +00:00
|
|
|
// Exit on HC
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
|
|
|
// Ammo/Magazines look-up hash for correctness of initSpeed
|
|
|
|
GVAR(ammoMagLookup) = call CBA_fnc_createNamespace;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo");
|
2016-12-02 18:44:39 +00:00
|
|
|
if (_ammo != "") then { GVAR(ammoMagLookup) setVariable [_ammo, _x]; };
|
2016-08-22 13:09:08 +00:00
|
|
|
} count (getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"));
|
|
|
|
nil
|
|
|
|
} count getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");
|
|
|
|
|
|
|
|
|
|
|
|
// Add keybinds
|
|
|
|
["ACE3 Weapons", QGVAR(prepare), localize LSTRING(Prepare), {
|
|
|
|
// Condition
|
|
|
|
if (!([ACE_player] call FUNC(canPrepare))) exitWith {false};
|
2017-07-10 19:44:02 +00:00
|
|
|
if (EGVAR(common,isReloading)) exitWith {true};
|
2016-08-22 13:09:08 +00:00
|
|
|
|
|
|
|
// Statement
|
|
|
|
[ACE_player] call FUNC(prepare);
|
|
|
|
|
|
|
|
true
|
|
|
|
}, {false}, [34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G
|
|
|
|
|
|
|
|
["ACE3 Weapons", QGVAR(dropModeToggle), localize LSTRING(DropModeToggle), {
|
|
|
|
// Condition
|
2017-08-22 18:30:56 +00:00
|
|
|
if (!(ACE_player getVariable [QGVAR(inHand), false]) || {underwater ACE_player}) exitWith {false};
|
2016-08-22 13:09:08 +00:00
|
|
|
|
|
|
|
// Statement
|
|
|
|
private _currentDropMode = ACE_player getVariable [QGVAR(dropMode), false];
|
|
|
|
ACE_player setVariable [QGVAR(dropMode), !_currentDropMode];
|
|
|
|
|
|
|
|
ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening
|
|
|
|
call FUNC(updateControlsHint); // Change controls hint for MMB
|
|
|
|
true
|
|
|
|
}, {false}, [34, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + G
|
|
|
|
|
|
|
|
["ACE3 Weapons", QGVAR(dropModeHold), localize LSTRING(DropModeHold), {
|
|
|
|
// Condition
|
|
|
|
if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false};
|
|
|
|
|
|
|
|
// Statement
|
|
|
|
ACE_player setVariable [QGVAR(dropMode), true];
|
|
|
|
ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening
|
|
|
|
call FUNC(updateControlsHint); // Change controls hint for MMB
|
|
|
|
true
|
|
|
|
}, {
|
|
|
|
// Condition
|
|
|
|
if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false};
|
|
|
|
|
|
|
|
// Statement
|
|
|
|
ACE_player setVariable [QGVAR(dropMode), false];
|
|
|
|
call FUNC(updateControlsHint); // Change controls hint for MMB
|
|
|
|
true
|
|
|
|
}, [0, [false, false, false]], false] call CBA_fnc_addKeybind; // Empty
|
|
|
|
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
["unit", {
|
|
|
|
[_this select 1, "Player changed"] call FUNC(exitThrowMode);
|
|
|
|
}] call CBA_fnc_addPlayerEventhandler;
|
|
|
|
|
2016-09-23 17:48:25 +00:00
|
|
|
["visibleMap", {
|
2017-02-10 19:03:12 +00:00
|
|
|
params ["", "_visibleMap"]; // command visibleMap is updated one frame later
|
|
|
|
if (_visibleMap && {ACE_player getVariable [QGVAR(inHand), false]}) then {
|
2016-09-23 17:48:25 +00:00
|
|
|
[ACE_player, "Opened Map"] call FUNC(exitThrowMode);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addPlayerEventhandler;
|
|
|
|
|
|
|
|
|
2016-08-22 13:09:08 +00:00
|
|
|
["ace_interactMenuOpened", {
|
|
|
|
// Exit if advanced throwing is disabled (pick up only supports advanced throwing)
|
|
|
|
if (!GVAR(enabled)) exitWith {};
|
|
|
|
|
|
|
|
if (ACE_player getVariable [QGVAR(inHand), false]) then {
|
|
|
|
[ACE_player, "Interact menu opened"] call FUNC(exitThrowMode);
|
|
|
|
} else {
|
|
|
|
params ["_interactionType"];
|
|
|
|
// Ignore self-interaction menu, when in vehicle and when pick up is disabled
|
|
|
|
if (GVAR(enablePickUp) && {_interactionType == 0} && {vehicle ACE_player == ACE_player}) then {
|
|
|
|
// Show pick up actions on CfgAmmo's
|
|
|
|
call FUNC(renderPickUpInteraction);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
|
2016-09-09 09:00:30 +00:00
|
|
|
// Set last thrown time on Vanilla Throwing and Advanced Throwing
|
|
|
|
["ace_firedPlayer", {
|
2017-05-31 21:09:36 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon"];
|
2016-09-09 09:00:30 +00:00
|
|
|
if (_weapon == "Throw") then {
|
|
|
|
_unit setVariable [QGVAR(lastThrownTime), CBA_missionTime];
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
2016-08-22 13:09:08 +00:00
|
|
|
|
|
|
|
// Display handlers
|
|
|
|
["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler;
|
|
|
|
["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}] call CBA_fnc_addDisplayHandler;
|
|
|
|
["MouseZChanged", {_this call FUNC(onMouseScroll)}] call CBA_fnc_addDisplayHandler;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DRAW_THROW_PATH
|
|
|
|
GVAR(predictedPath) = [];
|
|
|
|
GVAR(flightPath) = [];
|
|
|
|
|
|
|
|
addMissionEventHandler ["Draw3D", { // Blue is predicted before throw, red is real
|
|
|
|
{
|
|
|
|
_x params ["", "_newTrajAGL"];
|
|
|
|
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [0,0,1,1], _newTrajAGL, 1, 1, 0, "", 2];
|
|
|
|
} forEach GVAR(predictedPath);
|
|
|
|
{
|
2017-10-15 18:06:18 +00:00
|
|
|
_x params ["_pos", "_vectorUp"];
|
|
|
|
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _pos, 1, 1, 0, "", 2];
|
|
|
|
drawLine3D [_pos, _pos vectorAdd _vectorUp, [1,0,1,1]];
|
|
|
|
} forEach GVAR(flightPath);
|
2016-08-22 13:09:08 +00:00
|
|
|
}];
|
|
|
|
#endif
|