Fix Cancel Action by moving it to MouseButtonDown display EH

This commit is contained in:
jonpas 2016-03-03 17:35:43 +01:00
parent fc54b1180c
commit ef95e278f9
16 changed files with 51 additions and 40 deletions

View File

@ -6,6 +6,7 @@ PREP(addExplosiveActions);
PREP(addToSpeedDial); PREP(addToSpeedDial);
PREP(addTransmitterActions); PREP(addTransmitterActions);
PREP(addTriggerActions); PREP(addTriggerActions);
PREP(cancelPlacement);
PREP(canDefuse); PREP(canDefuse);
PREP(canDetonate); PREP(canDetonate);
PREP(connectExplosive); PREP(connectExplosive);

View File

@ -3,3 +3,4 @@
params ["_display"]; params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelPlacement)}];

View File

@ -0,0 +1,28 @@
/*
* Author: Garth 'L-H' de Wet
* Cancels explosives placement.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Key <NUMBER>
*
* 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;

View File

@ -141,13 +141,6 @@ GVAR(TweakedAngle) = 0;
//Don't allow placing in a bad position: //Don't allow placing in a bad position:
if (_badPosition && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;}; 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 { if (GVAR(placeAction) != PLACE_WAITING) then {
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
GVAR(pfeh_running) = false; GVAR(pfeh_running) = false;

View File

@ -3,3 +3,4 @@
params ["_display"]; params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(deployCancel)}];

View File

@ -52,10 +52,4 @@ _unit setVariable [QGVAR(Deploy), [
{[_this select 0] call FUNC(deployConfirm)} {[_this select 0] call FUNC(deployConfirm)}
] call EFUNC(common,addActionEventHandler)]; ] 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]; _unit setVariable [QGVAR(isDeploying), true, true];

View File

@ -3,7 +3,8 @@
* Cancels sandbag deployment * Cancels sandbag deployment
* *
* Arguments: * Arguments:
* 0: unit <OBJECT> * 0: Unit <OBJECT>
* 1: Key <NUMBER>
* *
* Return Value: * Return Value:
* None * None
@ -15,7 +16,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"]; params ["_unit", "_key"];
if (_key != 1) exitWith {};
// enable running again // enable running again
[_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set); [_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set);

View File

@ -51,7 +51,6 @@ GVAR(deployPFH) = -1;
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler);
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);
// play animation // play animation
_unit playActionNow "PutDown"; _unit playActionNow "PutDown";

View File

@ -3,3 +3,4 @@
params ["_display"]; params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(cancelTLdeploy)}];

View File

@ -3,8 +3,8 @@
* Cancel tactical ladder deployment * Cancel tactical ladder deployment
* *
* Arguments: * Arguments:
* 0: unit <OBJECT> * 0: Unit <OBJECT>
* 1: ladder <OBJECT> * 1: Key <NUMBER>
* *
* Return Value: * Return Value:
* None * 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"] #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 // enable running again
[_unit, "forceWalk", "ACE_Ladder", false] call EFUNC(common,statusEffect_set); [_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; } count __ANIMS;
// remove mouse buttons and hint // remove mouse buttons and hint
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); [_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; GVAR(ladder) = objNull;

View File

@ -34,7 +34,6 @@ detach _ladder;
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); [_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; GVAR(ladder) = objNull;

View File

@ -50,9 +50,3 @@ _unit setVariable [QGVAR(Deploy), [
{!isNull GVAR(ladder)}, {!isNull GVAR(ladder)},
{[_this select 0, GVAR(ladder)] call FUNC(confirmTLdeploy)} {[_this select 0, GVAR(ladder)] call FUNC(confirmTLdeploy)}
] call EFUNC(common,addActionEventHandler)]; ] 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)];

View File

@ -3,3 +3,4 @@
params ["_display"]; params ["_display"];
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; _display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {[ACE_player, _this select 1] call FUNC(placeCancel)}];

View File

@ -3,7 +3,8 @@
* Cancels trench dig * Cancels trench dig
* *
* Arguments: * Arguments:
* 0: unit <OBJECT> * 0: Unit <OBJECT>
* 1: Key <NUMBER>
* *
* Return Value: * Return Value:
* None * None
@ -15,7 +16,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_unit"]; params ["_unit", "_key"];
if (_key != 1) exitWith {};
// enable running again // enable running again
[_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set); [_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set);
@ -31,6 +34,5 @@ GVAR(digPFH) = -1;
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler); [_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]; _unit setVariable [QGVAR(isPlacing), false, true];

View File

@ -28,7 +28,6 @@ GVAR(digPFH) = -1;
call EFUNC(interaction,hideMouseHint); call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler); [_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]; _unit setVariable [QGVAR(isPlacing), false, true];

View File

@ -95,10 +95,4 @@ _unit setVariable [QGVAR(Dig), [
{[_this select 0] call FUNC(placeConfirm)} {[_this select 0] call FUNC(placeConfirm)}
] call EFUNC(common,addActionEventHandler)]; ] 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]; _unit setVariable [QGVAR(isPlacing), true, true];