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

Add launcher support to infantry Switch Weapon actions #717

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
[QGVAR(doWatch), {
params ["_unit", "_target"];
_unit doWatch _target;
{
if !(_x checkAIFeature "ANIM") then {
_x setDir (_x getDir _target);
};
} forEach flatten [_unit];
}] call CBA_fnc_addEventHandler;

[QGVAR(doTarget), {
Expand Down Expand Up @@ -199,6 +204,17 @@
_unit selectWeapon _muzzle;
}] call CBA_fnc_addEventHandler;

[QGVAR(switchWeapon), {
params ["_unit", "_muzzle"];
_unit selectWeapon _muzzle;
if (_muzzle == secondaryWeapon _unit) then {
_unit playMove "amovpercmstpsraswlnrdnon";
_unit disableAI "ANIM";
} else {
_unit enableAI "ANIM";
};
Comment on lines +210 to +215
Copy link
Member

@mharis001 mharis001 Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a decent workaround. However, IMO would be better placed in the switchWeapon function itself (since it is specifically used for that).

Copy link
Member Author

@ampersand38 ampersand38 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switchWeapon function is local to the curator, and these need to be local to the AI. should I make a separate switchWeapon[Curator/Local] event?

}] call CBA_fnc_addEventHandler;

[QGVAR(selectWeaponTurret), {
params ["_vehicle", "_weapon", "_turretPath", ["_muzzle", ""], ["_fireMode", ""]];
_vehicle selectWeaponTurret [_weapon, _turretPath, _muzzle, _fireMode];
Expand Down
9 changes: 7 additions & 2 deletions addons/context_actions/CfgContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,20 @@ class EGVAR(context_menu,actions) {
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\primaryWeapon_ca.paa";
args = 0;
};
class Launcher: Primary {
displayName = "$STR_A3_RSCDisplayArsenal_Tab_SecondaryWeapon";
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\secondaryWeapon_ca.paa";
args = 1;
};
class Handgun: Primary {
displayName = "$STR_A3_RSCDisplayArsenal_Tab_Handgun";
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\handgun_ca.paa";
args = 1;
args = 2;
};
class Binoculars: Primary {
displayName = "$STR_A3_RSCDisplayArsenal_Tab_Binoculars";
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\binoculars_ca.paa";
args = 2;
args = 3;
};
};
};
Expand Down
5 changes: 3 additions & 2 deletions addons/context_actions/functions/fnc_switchWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@

params ["_unit", "_weaponIndex"];

private _weapon = [primaryWeapon _unit, handgunWeapon _unit, binocular _unit] select _weaponIndex;
[QEGVAR(common,selectWeapon), [_unit, _weapon], _unit] call CBA_fnc_targetEvent;
private _weapon = [primaryWeapon _unit, secondaryWeapon _unit, handgunWeapon _unit, binocular _unit] select _weaponIndex;

[QEGVAR(common,switchWeapon), [_unit, _weapon], _unit] call CBA_fnc_targetEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ _actionParams params ["", "", "", "", "", "_hoveredEntity"];

private _weapon = [
primaryWeapon _hoveredEntity,
secondaryWeapon _hoveredEntity,
handgunWeapon _hoveredEntity,
binocular _hoveredEntity
] select _args;
Expand Down
Loading