From cd02ce4fa6020bf30b6c49f230c6a4ea152e864d Mon Sep 17 00:00:00 2001 From: Ken Mikkelsen Date: Sun, 7 Jul 2024 14:02:10 +0200 Subject: [PATCH 1/4] Improve ExplosionEH Adds removeExec to animations on explosions to ensure they actually trigger. --- addons/eventhandlers/functions/fnc_explosionEH.sqf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/eventhandlers/functions/fnc_explosionEH.sqf b/addons/eventhandlers/functions/fnc_explosionEH.sqf index a4a959a4..8aba8194 100644 --- a/addons/eventhandlers/functions/fnc_explosionEH.sqf +++ b/addons/eventhandlers/functions/fnc_explosionEH.sqf @@ -41,11 +41,11 @@ if (RND(0.5)) then { // standing to Right prone if (_dir > 330 && { RND(0.2) }) exitWith { - _unit switchMove "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"; + [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"] remoteExec ["switchMove"]; [ { if (_this call EFUNC(main,isAlive)) then { - _this switchMove "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon" + [_this, "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon"] remoteExec ["switchMove"]; }; }, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3 ] call CBA_fnc_waitAndExecute; @@ -53,11 +53,11 @@ if (_dir > 330 && { RND(0.2) }) exitWith { // standing to Left prone if (_dir < 30 && { RND(0.2) }) exitWith { - _unit switchMove "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"; + [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"] remoteExec ["switchMove"]; [ { if (_this call EFUNC(main,isAlive)) then { - _this switchMove "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon" + [_this, "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon"] remoteExec ["switchMove"]; }; }, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3 ] call CBA_fnc_waitAndExecute; @@ -71,7 +71,7 @@ _unit setDestination [_pos, "FORMATION PLANNED", false]; _unit doWatch _pos; // all others ~ go straight down -_unit switchMove "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"; +[_unit, "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"] remoteExec ["switchMove"]; _unit setUnitPos "DOWN"; // get back From 8ed939d81d019f5de9daa331fb3ac2b7b2b51ba9 Mon Sep 17 00:00:00 2001 From: Ken Mikkelsen Date: Mon, 6 Jan 2025 19:39:31 +0100 Subject: [PATCH 2/4] Added CBA eventhandler for switchmove Snuck in a few more switchMove fixes --- addons/eventhandlers/functions/fnc_explosionEH.sqf | 10 +++++----- addons/main/XEH_postInit.sqf | 5 +++++ addons/main/functions/fnc_doAnimation.sqf | 2 +- addons/wp/functions/fnc_doAssaultUnitReset.sqf | 3 ++- addons/wp/functions/fnc_taskAssault.sqf | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/eventhandlers/functions/fnc_explosionEH.sqf b/addons/eventhandlers/functions/fnc_explosionEH.sqf index 8aba8194..5661793d 100644 --- a/addons/eventhandlers/functions/fnc_explosionEH.sqf +++ b/addons/eventhandlers/functions/fnc_explosionEH.sqf @@ -41,11 +41,11 @@ if (RND(0.5)) then { // standing to Right prone if (_dir > 330 && { RND(0.2) }) exitWith { - [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"] remoteExec ["switchMove"]; + [QEGVAR(main,doSwitchMove), [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"]] call CBA_fnc_globalEvent; [ { if (_this call EFUNC(main,isAlive)) then { - [_this, "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon"] remoteExec ["switchMove"]; + [QEGVAR(main,doSwitchMove), [_this, "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon"]] call CBA_fnc_globalEvent; }; }, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3 ] call CBA_fnc_waitAndExecute; @@ -53,11 +53,11 @@ if (_dir > 330 && { RND(0.2) }) exitWith { // standing to Left prone if (_dir < 30 && { RND(0.2) }) exitWith { - [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"] remoteExec ["switchMove"]; + [QEGVAR(main,doSwitchMove), [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"]] call CBA_fnc_globalEvent; [ { if (_this call EFUNC(main,isAlive)) then { - [_this, "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon"] remoteExec ["switchMove"]; + [QEGVAR(main,doSwitchMove), [_this, "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon"]] call CBA_fnc_globalEvent; }; }, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3 ] call CBA_fnc_waitAndExecute; @@ -71,7 +71,7 @@ _unit setDestination [_pos, "FORMATION PLANNED", false]; _unit doWatch _pos; // all others ~ go straight down -[_unit, "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"] remoteExec ["switchMove"]; +[QEGVAR(main,doSwitchMove), [_unit, "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"]] call CBA_fnc_globalEvent; _unit setUnitPos "DOWN"; // get back diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf index 4da87308..25e2b667 100644 --- a/addons/main/XEH_postInit.sqf +++ b/addons/main/XEH_postInit.sqf @@ -99,3 +99,8 @@ GVAR(debug_TextFactor) = linearConversion [0.55, 0.7, getResolution select 5, 1, [_this select 1, QEGVAR(danger,OnFleeing), _this] call BIS_fnc_callScriptedEventHandler; [QEGVAR(danger,OnFleeing), _this] call CBA_fnc_localEvent; }] call CBA_fnc_addEventHandler; + +[QGVAR(doSwitchMove), { + params [["_unit", objNull, ["_move", ""]]]; + _unit switchMove [_move, 0, 0.5, false]; +}] call CBA_fnc_addEventHandler; diff --git a/addons/main/functions/fnc_doAnimation.sqf b/addons/main/functions/fnc_doAnimation.sqf index 956ffc7e..1b740459 100644 --- a/addons/main/functions/fnc_doAnimation.sqf +++ b/addons/main/functions/fnc_doAnimation.sqf @@ -67,7 +67,7 @@ if (_priority >= 2) then { params ["_unit", "_animation"]; if (animationState _unit != _animation) then { // Execute on all machines. SwitchMove has local effects. - [_unit, _animation] remoteExec ["switchMove", 0]; + [QGVAR(doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; }; }, [_unit, _animation], 0.1] call CBA_fnc_waitAndExecute; }; diff --git a/addons/wp/functions/fnc_doAssaultUnitReset.sqf b/addons/wp/functions/fnc_doAssaultUnitReset.sqf index 88f0269d..a117b40f 100644 --- a/addons/wp/functions/fnc_doAssaultUnitReset.sqf +++ b/addons/wp/functions/fnc_doAssaultUnitReset.sqf @@ -37,7 +37,8 @@ if (!_retreat && {animationState _unit in ["apanpknlmsprsnonwnondf", "apanpercms // retreat if (_retreat) then { - _unit switchMove (["AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon", "AmovPercMsprSnonWnonDf_AmovPpneMstpSnonWnonDnon"] select ((primaryWeapon _unit) isEqualTo "")); + private _animation = ["AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon", "AmovPercMsprSnonWnonDf_AmovPpneMstpSnonWnonDnon"] select ((primaryWeapon _unit) isEqualTo ""); + [QGVAR(doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; _unit enableAI "AUTOTARGET"; _unit doWatch ObjNull; }; diff --git a/addons/wp/functions/fnc_taskAssault.sqf b/addons/wp/functions/fnc_taskAssault.sqf index 5625046d..42235c4c 100644 --- a/addons/wp/functions/fnc_taskAssault.sqf +++ b/addons/wp/functions/fnc_taskAssault.sqf @@ -77,11 +77,13 @@ _group setFormation "LINE"; if (_retreat) then { _x disableAI "AUTOTARGET"; [_x, "ApanPercMrunSnonWnonDf"] remoteExec ["switchMove", 0]; - [_x, selectRandom [ + [QGVAR(doSwitchMove), [_unit, "ApanPercMrunSnonWnonDf"]] call CBA_fnc_globalEvent; + private _animation = selectRandom [ "ApanPknlMsprSnonWnonDf", "ApanPknlMsprSnonWnonDf", "ApanPercMsprSnonWnonDf" - ]] remoteExec["switchMove", 0]; + ]; + [QGVAR(doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; }; // adds frame handler From db2709a1f82a59f02ad3a3c9004fa5e248d4b6ed Mon Sep 17 00:00:00 2001 From: Ken Mikkelsen Date: Mon, 6 Jan 2025 19:47:46 +0100 Subject: [PATCH 3/4] Fixed painful errors doAssaultUnitReset taskAssault --- addons/main/XEH_postInit.sqf | 2 +- addons/wp/functions/fnc_doAssaultUnitReset.sqf | 2 +- addons/wp/functions/fnc_taskAssault.sqf | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/main/XEH_postInit.sqf b/addons/main/XEH_postInit.sqf index 25e2b667..7143c182 100644 --- a/addons/main/XEH_postInit.sqf +++ b/addons/main/XEH_postInit.sqf @@ -101,6 +101,6 @@ GVAR(debug_TextFactor) = linearConversion [0.55, 0.7, getResolution select 5, 1, }] call CBA_fnc_addEventHandler; [QGVAR(doSwitchMove), { - params [["_unit", objNull, ["_move", ""]]]; + params [["_unit", objNull], ["_move", ""]]; _unit switchMove [_move, 0, 0.5, false]; }] call CBA_fnc_addEventHandler; diff --git a/addons/wp/functions/fnc_doAssaultUnitReset.sqf b/addons/wp/functions/fnc_doAssaultUnitReset.sqf index a117b40f..3aa613f8 100644 --- a/addons/wp/functions/fnc_doAssaultUnitReset.sqf +++ b/addons/wp/functions/fnc_doAssaultUnitReset.sqf @@ -38,7 +38,7 @@ if (!_retreat && {animationState _unit in ["apanpknlmsprsnonwnondf", "apanpercms // retreat if (_retreat) then { private _animation = ["AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon", "AmovPercMsprSnonWnonDf_AmovPpneMstpSnonWnonDnon"] select ((primaryWeapon _unit) isEqualTo ""); - [QGVAR(doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; + [QEGVAR(main,doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; _unit enableAI "AUTOTARGET"; _unit doWatch ObjNull; }; diff --git a/addons/wp/functions/fnc_taskAssault.sqf b/addons/wp/functions/fnc_taskAssault.sqf index 42235c4c..99034f7d 100644 --- a/addons/wp/functions/fnc_taskAssault.sqf +++ b/addons/wp/functions/fnc_taskAssault.sqf @@ -77,13 +77,13 @@ _group setFormation "LINE"; if (_retreat) then { _x disableAI "AUTOTARGET"; [_x, "ApanPercMrunSnonWnonDf"] remoteExec ["switchMove", 0]; - [QGVAR(doSwitchMove), [_unit, "ApanPercMrunSnonWnonDf"]] call CBA_fnc_globalEvent; + [QEGVAR(main,doSwitchMove), [_x, "ApanPercMrunSnonWnonDf"]] call CBA_fnc_globalEvent; private _animation = selectRandom [ "ApanPknlMsprSnonWnonDf", "ApanPknlMsprSnonWnonDf", "ApanPercMsprSnonWnonDf" ]; - [QGVAR(doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent; + [QEGVAR(main,doSwitchMove), [_x, _animation]] call CBA_fnc_globalEvent; }; // adds frame handler From eb0211ec4a7cd985d936d79955ec9ba92541e31d Mon Sep 17 00:00:00 2001 From: Ken Mikkelsen Date: Mon, 6 Jan 2025 19:51:06 +0100 Subject: [PATCH 4/4] Removed excess line --- addons/wp/functions/fnc_taskAssault.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/wp/functions/fnc_taskAssault.sqf b/addons/wp/functions/fnc_taskAssault.sqf index 99034f7d..7dfdd0b3 100644 --- a/addons/wp/functions/fnc_taskAssault.sqf +++ b/addons/wp/functions/fnc_taskAssault.sqf @@ -76,7 +76,6 @@ _group setFormation "LINE"; // check retreat if (_retreat) then { _x disableAI "AUTOTARGET"; - [_x, "ApanPercMrunSnonWnonDf"] remoteExec ["switchMove", 0]; [QEGVAR(main,doSwitchMove), [_x, "ApanPercMrunSnonWnonDf"]] call CBA_fnc_globalEvent; private _animation = selectRandom [ "ApanPknlMsprSnonWnonDf",