Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ExplosionEH animations with CBA Events #402

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions addons/eventhandlers/functions/fnc_explosionEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ if (RND(0.5)) then {

// standing to Right prone
if (_dir > 330 && { RND(0.2) }) exitWith {
_unit switchMove "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft";
[QEGVAR(main,doSwitchMove), [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft"]] call CBA_fnc_globalEvent;
[
{
if (_this call EFUNC(main,isAlive)) then {
_this switchMove "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon"
[QEGVAR(main,doSwitchMove), [_this, "AadjPpneMstpSrasWrflDleft_AmovPercMstpSrasWrflDnon"]] call CBA_fnc_globalEvent;
};
}, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3
] call CBA_fnc_waitAndExecute;
};

// standing to Left prone
if (_dir < 30 && { RND(0.2) }) exitWith {
_unit switchMove "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright";
[QEGVAR(main,doSwitchMove), [_unit, "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright"]] call CBA_fnc_globalEvent;
[
{
if (_this call EFUNC(main,isAlive)) then {
_this switchMove "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon"
[QEGVAR(main,doSwitchMove), [_this, "AadjPpneMstpSrasWrflDright_AmovPercMstpSrasWrflDnon"]] call CBA_fnc_globalEvent;
};
}, _unit, (GVAR(ExplosionReactionTime) - 4) + random 3
] call CBA_fnc_waitAndExecute;
Expand All @@ -71,7 +71,7 @@ _unit setDestination [_pos, "FORMATION PLANNED", false];
_unit doWatch _pos;

// all others ~ go straight down
_unit switchMove "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon";
[QEGVAR(main,doSwitchMove), [_unit, "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon"]] call CBA_fnc_globalEvent;
_unit setUnitPos "DOWN";

// get back
Expand Down
5 changes: 5 additions & 0 deletions addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_doAnimation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
3 changes: 2 additions & 1 deletion addons/wp/functions/fnc_doAssaultUnitReset.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 "");
[QEGVAR(main,doSwitchMove), [_unit, _animation]] call CBA_fnc_globalEvent;
_unit enableAI "AUTOTARGET";
_unit doWatch ObjNull;
};
Expand Down
7 changes: 4 additions & 3 deletions addons/wp/functions/fnc_taskAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ _group setFormation "LINE";
// check retreat
if (_retreat) then {
_x disableAI "AUTOTARGET";
[_x, "ApanPercMrunSnonWnonDf"] remoteExec ["switchMove", 0];
[_x, selectRandom [
[QEGVAR(main,doSwitchMove), [_x, "ApanPercMrunSnonWnonDf"]] call CBA_fnc_globalEvent;
private _animation = selectRandom [
"ApanPknlMsprSnonWnonDf",
"ApanPknlMsprSnonWnonDf",
"ApanPercMsprSnonWnonDf"
]] remoteExec["switchMove", 0];
];
[QEGVAR(main,doSwitchMove), [_x, _animation]] call CBA_fnc_globalEvent;
};

// adds frame handler
Expand Down
Loading