diff --git a/addons/explosives/XEH_PREP.hpp b/addons/explosives/XEH_PREP.hpp index b3686a986f..0d8a4eeca5 100644 --- a/addons/explosives/XEH_PREP.hpp +++ b/addons/explosives/XEH_PREP.hpp @@ -6,6 +6,7 @@ PREP(addExplosiveActions); PREP(addToSpeedDial); PREP(addTransmitterActions); PREP(addTriggerActions); +PREP(cancelPlacement); PREP(canDefuse); PREP(canDetonate); PREP(connectExplosive); diff --git a/addons/explosives/XEH_missionDisplayLoad.sqf b/addons/explosives/XEH_missionDisplayLoad.sqf index 289d2f067a..1475f774e8 100644 --- a/addons/explosives/XEH_missionDisplayLoad.sqf +++ b/addons/explosives/XEH_missionDisplayLoad.sqf @@ -3,3 +3,4 @@ params ["_display"]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; +_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelPlacement)}]; diff --git a/addons/explosives/functions/fnc_cancelPlacement.sqf b/addons/explosives/functions/fnc_cancelPlacement.sqf new file mode 100644 index 0000000000..4a7f385a01 --- /dev/null +++ b/addons/explosives/functions/fnc_cancelPlacement.sqf @@ -0,0 +1,28 @@ +/* + * Author: Garth 'L-H' de Wet + * Cancels explosives placement. + * + * Arguments: + * 0: Unit + * 1: Key + * + * Return Value: + * None + * + * Example: + * [unit, 1] call ace_explosives_fnc_cancelPlacement + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_key"]; + +if (_key != 1) exitWith {}; + +if (_unit == ACE_player && + {([_unit, objNull, ["isNotSwimming"]] call EFUNC(common,canInteractWith))} && + {(_magClassname in (magazines _unit))} +) exitWith {}; + +GVAR(placeAction) = PLACE_CANCEL; diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index b1fdf7216b..567bb95db8 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -141,13 +141,6 @@ GVAR(TweakedAngle) = 0; //Don't allow placing in a bad position: if (_badPosition && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;}; - if (((inputAction "zoomTemp") > 0) || //Cancel on RMB, For some reason this works (when held) but AddActionEventHandler doesn't - {_unit != ACE_player} || - {!([_unit, objNull, ["isNotSwimming"]] call EFUNC(common,canInteractWith))} || - {!(_magClassname in (magazines _unit))}) then { - GVAR(placeAction) = PLACE_CANCEL; - }; - if (GVAR(placeAction) != PLACE_WAITING) then { [_pfID] call CBA_fnc_removePerFrameHandler; GVAR(pfeh_running) = false; diff --git a/addons/sandbag/XEH_missionDisplayLoad.sqf b/addons/sandbag/XEH_missionDisplayLoad.sqf index 289d2f067a..cb85ffb9fb 100644 --- a/addons/sandbag/XEH_missionDisplayLoad.sqf +++ b/addons/sandbag/XEH_missionDisplayLoad.sqf @@ -3,3 +3,4 @@ params ["_display"]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; +_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(deployCancel)}]; diff --git a/addons/sandbag/functions/fnc_deploy.sqf b/addons/sandbag/functions/fnc_deploy.sqf index 1a539929ff..735a736bbb 100644 --- a/addons/sandbag/functions/fnc_deploy.sqf +++ b/addons/sandbag/functions/fnc_deploy.sqf @@ -52,10 +52,4 @@ _unit setVariable [QGVAR(Deploy), [ {[_this select 0] call FUNC(deployConfirm)} ] call EFUNC(common,addActionEventHandler)]; -_unit setVariable [QGVAR(Cancel), [ - _unit, "zoomtemp", - {GVAR(deployPFH) != -1}, - {[_this select 0] call FUNC(deployCancel)} -] call EFUNC(common,addActionEventHandler)]; - _unit setVariable [QGVAR(isDeploying), true, true]; diff --git a/addons/sandbag/functions/fnc_deployCancel.sqf b/addons/sandbag/functions/fnc_deployCancel.sqf index bb9d691fa9..e0315d7849 100644 --- a/addons/sandbag/functions/fnc_deployCancel.sqf +++ b/addons/sandbag/functions/fnc_deployCancel.sqf @@ -3,7 +3,8 @@ * Cancels sandbag deployment * * Arguments: - * 0: unit + * 0: Unit + * 1: Key * * Return Value: * None @@ -15,7 +16,9 @@ */ #include "script_component.hpp" -params ["_unit"]; +params ["_unit", "_key"]; + +if (_key != 1) exitWith {}; // enable running again [_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set); diff --git a/addons/sandbag/functions/fnc_deployConfirm.sqf b/addons/sandbag/functions/fnc_deployConfirm.sqf index 8c789fd124..c560bc15ba 100644 --- a/addons/sandbag/functions/fnc_deployConfirm.sqf +++ b/addons/sandbag/functions/fnc_deployConfirm.sqf @@ -51,7 +51,6 @@ GVAR(deployPFH) = -1; call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); // play animation _unit playActionNow "PutDown"; diff --git a/addons/tacticalladder/XEH_missionDisplayLoad.sqf b/addons/tacticalladder/XEH_missionDisplayLoad.sqf index 289d2f067a..05419598b9 100644 --- a/addons/tacticalladder/XEH_missionDisplayLoad.sqf +++ b/addons/tacticalladder/XEH_missionDisplayLoad.sqf @@ -3,3 +3,4 @@ params ["_display"]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; +_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelTLdeploy)}]; diff --git a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf index 940b2b612a..6f9eb5cff9 100644 --- a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf @@ -3,8 +3,8 @@ * Cancel tactical ladder deployment * * Arguments: - * 0: unit - * 1: ladder + * 0: Unit + * 1: Key * * Return Value: * None @@ -18,23 +18,24 @@ #define __ANIMS ["extract_1","extract_2","extract_3","extract_4","extract_5","extract_6","extract_7","extract_8","extract_9","extract_10","extract_11"] -params ["_unit", "_ladder"]; +params ["_unit", "_key"]; + +if (_key != 1) exitWith {}; // enable running again [_unit, "forceWalk", "ACE_Ladder", false] call EFUNC(common,statusEffect_set); -detach _ladder; +detach GVAR(ladder); -_ladder animate ["rotate", 0]; +GVAR(ladder) animate ["rotate", 0]; { - _ladder animate [_x, 0]; + GVAR(ladder) animate [_x, 0]; } count __ANIMS; // remove mouse buttons and hint call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); GVAR(ladder) = objNull; diff --git a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf index 9d5783b327..3703fe1f47 100644 --- a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf @@ -34,7 +34,6 @@ detach _ladder; call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); GVAR(ladder) = objNull; diff --git a/addons/tacticalladder/functions/fnc_positionTL.sqf b/addons/tacticalladder/functions/fnc_positionTL.sqf index 94e28dea33..27ea683b5a 100644 --- a/addons/tacticalladder/functions/fnc_positionTL.sqf +++ b/addons/tacticalladder/functions/fnc_positionTL.sqf @@ -50,9 +50,3 @@ _unit setVariable [QGVAR(Deploy), [ {!isNull GVAR(ladder)}, {[_this select 0, GVAR(ladder)] call FUNC(confirmTLdeploy)} ] call EFUNC(common,addActionEventHandler)]; - -_unit setVariable [QGVAR(Cancel), [ - _unit, "zoomtemp", - {!isNull GVAR(ladder)}, - {[_this select 0, GVAR(ladder)] call FUNC(cancelTLdeploy)} -] call EFUNC(common,addActionEventHandler)]; diff --git a/addons/trenches/XEH_missionDisplayLoad.sqf b/addons/trenches/XEH_missionDisplayLoad.sqf index 289d2f067a..2c4951ec7a 100644 --- a/addons/trenches/XEH_missionDisplayLoad.sqf +++ b/addons/trenches/XEH_missionDisplayLoad.sqf @@ -3,3 +3,4 @@ params ["_display"]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; +_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(placeCancel)}]; diff --git a/addons/trenches/functions/fnc_placeCancel.sqf b/addons/trenches/functions/fnc_placeCancel.sqf index a48d6e3f5b..90c9d6ecc7 100644 --- a/addons/trenches/functions/fnc_placeCancel.sqf +++ b/addons/trenches/functions/fnc_placeCancel.sqf @@ -3,7 +3,8 @@ * Cancels trench dig * * Arguments: - * 0: unit + * 0: Unit + * 1: Key * * Return Value: * None @@ -15,7 +16,9 @@ */ #include "script_component.hpp" -params ["_unit"]; +params ["_unit", "_key"]; + +if (_key != 1) exitWith {}; // enable running again [_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set); @@ -31,6 +34,5 @@ GVAR(digPFH) = -1; call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); _unit setVariable [QGVAR(isPlacing), false, true]; diff --git a/addons/trenches/functions/fnc_placeConfirm.sqf b/addons/trenches/functions/fnc_placeConfirm.sqf index 797499a63f..47f80014f8 100644 --- a/addons/trenches/functions/fnc_placeConfirm.sqf +++ b/addons/trenches/functions/fnc_placeConfirm.sqf @@ -28,7 +28,6 @@ GVAR(digPFH) = -1; call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler); -[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); _unit setVariable [QGVAR(isPlacing), false, true]; diff --git a/addons/trenches/functions/fnc_placeTrench.sqf b/addons/trenches/functions/fnc_placeTrench.sqf index 21c4d92bb9..48a768427f 100644 --- a/addons/trenches/functions/fnc_placeTrench.sqf +++ b/addons/trenches/functions/fnc_placeTrench.sqf @@ -95,10 +95,4 @@ _unit setVariable [QGVAR(Dig), [ {[_this select 0] call FUNC(placeConfirm)} ] call EFUNC(common,addActionEventHandler)]; -_unit setVariable [QGVAR(Cancel), [ - _unit, "zoomtemp", - {GVAR(digPFH) != -1}, - {[_this select 0] call FUNC(placeCancel)} -] call EFUNC(common,addActionEventHandler)]; - _unit setVariable [QGVAR(isPlacing), true, true];