diff --git a/addons/interaction/CfgEventHandlers.hpp b/addons/interaction/CfgEventHandlers.hpp index 17200056b8..380867183f 100644 --- a/addons/interaction/CfgEventHandlers.hpp +++ b/addons/interaction/CfgEventHandlers.hpp @@ -6,7 +6,7 @@ class Extended_PreInit_EventHandlers { class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) ); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index e85300f301..bd36f42703 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -260,12 +260,11 @@ class CfgVehicles { icon = PATHTOF(UI\team\team_white_ca.paa); hotkey = "N"; }; - class ACE_BecomeLeader { displayName = "$STR_ACE_Interaction_BecomeLeader"; - condition = QUOTE(count (units group _player) > 1 && {leader group _player != _player}); + condition = QUOTE(_this call FUNC(canBecomeLeader)); exceptions[] = {"isNotInside"}; - statement = QUOTE(_newGroup = createGroup side group _player; (units group _player) joinSilent _newGroup; _newGroup selectLeader _player;); + statement = QUOTE(_this call FUNC(doBecomeLeader)); showDisabled = 1; priority = 1.0; icon = PATHTOF(UI\team\team_white_ca.paa); diff --git a/addons/interaction/XEH_clientInit.sqf b/addons/interaction/XEH_clientInit.sqf index 1ed3883f02..d252cd6aa1 100644 --- a/addons/interaction/XEH_clientInit.sqf +++ b/addons/interaction/XEH_clientInit.sqf @@ -4,6 +4,12 @@ ACE_Modifier = 0; +//SelectLeader Event Handler for BecomeLeader action: +[QGVAR(selectLeader), { + PARAMS_2(_group,_leader); + _group selectLeader _leader; +}] call EFUNC(common,addEventHandler); + if (!hasInterface) exitWith {}; GVAR(isOpeningDoor) = false; diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf new file mode 100644 index 0000000000..1ed3883f02 --- /dev/null +++ b/addons/interaction/XEH_postInit.sqf @@ -0,0 +1,70 @@ +// by commy2 and esteldunedain + +#include "script_component.hpp" + +ACE_Modifier = 0; + +if (!hasInterface) exitWith {}; + +GVAR(isOpeningDoor) = false; + +// restore global fire teams for JIP +{ + _team = _x getVariable [QGVAR(assignedFireTeam), ""]; + if (_team != "") then {_x assignTeam _team}; +} forEach allUnits; + + +// Add keybinds +["ACE3", QGVAR(openDoor), localize "STR_ACE_Interaction_OpenDoor", +{ + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + // Conditions: specific + if (GVAR(isOpeningDoor) || {[2] call FUNC(getDoor) select 1 == ''}) exitWith {false}; + + // Statement + call EFUNC(interaction,openDoor); + true +}, +{ + //Probably don't want any condidtions 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", QGVAR(tapShoulder), localize "STR_ACE_Interaction_TapShoulder", +{ + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + // Conditions: specific + if !([ACE_player, cursorTarget] call FUNC(canTapShoulder)) exitWith {false}; + + // Statement + [ACE_player, cursorTarget] call FUNC(tapShoulder); + true +}, +{false}, +[20, [true, false, false]], false] call cba_fnc_addKeybind; + +["ACE3", QGVAR(modifierKey), localize "STR_ACE_Interaction_ModifierKey", +{ + // Conditions: canInteract + //if !([ACE_player, objNull, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false}; // not needed + + // Statement + ACE_Modifier = 1; + // Return false so it doesn't block other actions + false +}, +{ + //Probably don't want any condidtions here, so variable never gets locked down + ACE_Modifier = 0; + false; +}, +[29, [false, false, false]], false] call cba_fnc_addKeybind; + +["isNotSwimming", {!underwater (_this select 0)}] call EFUNC(common,addCanInteractWithCondition); diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf index 671535c36d..6f10a4e834 100644 --- a/addons/interaction/XEH_preInit.sqf +++ b/addons/interaction/XEH_preInit.sqf @@ -6,8 +6,10 @@ PREP(addPassengerActions); PREP(addPassengersActions); PREP(addSelectableItem); PREP(applyButtons); +PREP(canBecomeLeader); PREP(canInteractWithCivilian); PREP(canTapShoulder); +PREP(doBecomeLeader); PREP(getDoor); PREP(getDoorAnimations); PREP(getDown); diff --git a/addons/interaction/functions/fnc_canBecomeLeader.sqf b/addons/interaction/functions/fnc_canBecomeLeader.sqf new file mode 100644 index 0000000000..11234ad6d7 --- /dev/null +++ b/addons/interaction/functions/fnc_canBecomeLeader.sqf @@ -0,0 +1,21 @@ +/* + * Author: PabstMirror + * Test if can Become Leader of group + * + * Arguments: + * 0: target + * 1: player + * + * Return Value: + * + * + * Example: + * [player, player] call ace_interaction_fnc_canBecomeLeader + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_target,_player); + +(count (units group _player) > 1) && {leader group _player != _player} diff --git a/addons/interaction/functions/fnc_doBecomeLeader.sqf b/addons/interaction/functions/fnc_doBecomeLeader.sqf new file mode 100644 index 0000000000..24bfa66c11 --- /dev/null +++ b/addons/interaction/functions/fnc_doBecomeLeader.sqf @@ -0,0 +1,21 @@ + /* + * Author: PabstMirror + * Become Leader of group + * + * Arguments: + * 0: target + * 1: player + * + * Return Value: + * None + * + * Example: + * [player, player] call ace_interaction_fnc_doBecomeLeader + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_target,_player); + +[QGVAR(selectLeader), (units group _player), [(group _player), _player]] call EFUNC(common,targetEvent);