From 78a55d44363dcfca38e99bcec859fcfaa38ebd93 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 10 Feb 2017 13:01:17 -0600 Subject: [PATCH] Generic cycle attack profile key for missile guidance (#4787) * Generic cycle attack profile key for missile guidance * Add hint for weapons without huds * Fix Korean strings * Cleanup --- addons/javelin/XEH_PREP.hpp | 1 - .../javelin/functions/fnc_cycleFireMode.sqf | 30 --------- addons/javelin/initKeybinds.sqf | 8 --- addons/javelin/stringtable.xml | 16 +---- addons/missileguidance/XEH_PREP.hpp | 2 + addons/missileguidance/XEH_post_init.sqf | 10 +++ .../fnc_cycleAttackProfileKeyDown.sqf | 67 +++++++++++++++++++ addons/missileguidance/stringtable.xml | 14 ++++ 8 files changed, 94 insertions(+), 54 deletions(-) delete mode 100644 addons/javelin/functions/fnc_cycleFireMode.sqf create mode 100644 addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf diff --git a/addons/javelin/XEH_PREP.hpp b/addons/javelin/XEH_PREP.hpp index cce2482932..76d658d90d 100644 --- a/addons/javelin/XEH_PREP.hpp +++ b/addons/javelin/XEH_PREP.hpp @@ -1,5 +1,4 @@ -PREP(cycleFireMode); PREP(getTarget); PREP(mapHelperDraw); PREP(onOpticDraw); diff --git a/addons/javelin/functions/fnc_cycleFireMode.sqf b/addons/javelin/functions/fnc_cycleFireMode.sqf deleted file mode 100644 index 5eeb4dd9b3..0000000000 --- a/addons/javelin/functions/fnc_cycleFireMode.sqf +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Author: jaynus - * Cycles fire mode (top/dir) - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call ace_javelin_fnc_cycleFireMode - * - * Public: No - */ -// #define DEBUG_MODE_FULL -#include "script_component.hpp" - -TRACE_1("cycle fire mode", _this); - -private _currentShooter = if (ACE_player call CBA_fnc_canUseWeapon) then {ACE_player} else {vehicle ACE_player}; -private _currentFireMode = _currentShooter getVariable ["ace_missileguidance_attackProfile", "JAV_TOP"]; - -if (_currentFireMode == "JAV_DIR") then { - _currentFireMode = "JAV_TOP"; -} else { - _currentFireMode = "JAV_DIR"; -}; -_currentShooter setVariable ["ace_missileguidance_attackProfile", _currentFireMode, false]; -TRACE_2("set",_currentFireMode,_currentShooter); diff --git a/addons/javelin/initKeybinds.sqf b/addons/javelin/initKeybinds.sqf index ec5c9a27ac..7652f2fd57 100644 --- a/addons/javelin/initKeybinds.sqf +++ b/addons/javelin/initKeybinds.sqf @@ -18,11 +18,3 @@ false }, [15, [false, false, false]], false] call CBA_fnc_addKeybind; //Tab Key - -["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), -{ false }, -{ - [ACE_player] call FUNC(cycleFireMode); - false -}, -[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key diff --git a/addons/javelin/stringtable.xml b/addons/javelin/stringtable.xml index 4e5614e106..ece03b3699 100644 --- a/addons/javelin/stringtable.xml +++ b/addons/javelin/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -15,19 +15,5 @@ 目標を捕捉 (押しっぱ) 표적 획득 (누르기) - - Cycle Fire Mode - Wechsle Feuermodus - Переключение режимов огня - Přepínání režimů palby - Przełącz tryb ognia - Cycle mode de tir - Tüzelési mód váltása - Alterna le modalità di fuoco - Cambiar modo de disparo - Alterar Modo de Disparo - 発射モード切り替え - 발사 방식 순환 - diff --git a/addons/missileguidance/XEH_PREP.hpp b/addons/missileguidance/XEH_PREP.hpp index 8d13e2b499..ee2b7328cb 100644 --- a/addons/missileguidance/XEH_PREP.hpp +++ b/addons/missileguidance/XEH_PREP.hpp @@ -1,3 +1,5 @@ +LOG("prep"); +PREP(cycleAttackProfileKeyDown); PREP(changeMissileDirection); diff --git a/addons/missileguidance/XEH_post_init.sqf b/addons/missileguidance/XEH_post_init.sqf index 282aac5503..cc09b1f0ac 100644 --- a/addons/missileguidance/XEH_post_init.sqf +++ b/addons/missileguidance/XEH_post_init.sqf @@ -1,3 +1,13 @@ #include "script_component.hpp" [QGVAR(handoff), {_this call FUNC(handleHandoff)}] call CBA_fnc_addEventHandler; + +["ACE3 Weapons", QGVAR(cycleFireMode), localize LSTRING(CycleFireMode), +{ + [] call FUNC(cycleAttackProfileKeyDown); + false +}, +{ + false +}, +[15, [false, true, false]], false] call CBA_fnc_addKeybind; //Ctrl+Tab Key diff --git a/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf b/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf new file mode 100644 index 0000000000..05db3748da --- /dev/null +++ b/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf @@ -0,0 +1,67 @@ +/* + * Author: PabstMirror + * Cycles fire mode for any missileGuidance enabled ammo that has multiple attack profiles + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_missileguidance_fnc_cycleAttackProfileKeyDown + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +TRACE_1("cycle fire mode",_this); + +if (!alive ACE_player) exitWith {}; +if (!([ACE_player, objNull, ["isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {}; + + +private ["_currentShooter", "_currentMagazine"]; +if (((vehicle ACE_player) == ACE_player) || {ACE_player call CBA_fnc_canUseWeapon}) then { + _currentShooter = ACE_player; + _currentMagazine = currentMagazine ACE_player; +} else { + _currentShooter = vehicle ACE_player; + _currentMagazine = _currentShooter currentMagazineTurret (ACE_player call CBA_fnc_turretPath); +}; +if (_currentMagazine == "") exitWith {TRACE_1("no magazine",_currentMagazine)}; + +private _ammo = getText (configFile >> "CfgMagazines" >> _currentMagazine >> "ammo"); + +TRACE_3("",_currentShooter,_currentMagazine,_ammo); + +// Bail if guidance is disabled for this ammo +if ((getNumber (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "enabled")) != 1) exitWith {TRACE_1("not enabled",_ammo)}; + +// Verify ammo has explicity added guidance config (ignore inheritances) +private _configs = configProperties [(configFile >> "CfgAmmo" >> _ammo), QUOTE(configName _x == QUOTE(QUOTE(ADDON))), false]; +if ((count _configs) < 1) exitWith {TRACE_2("not explicity enabled",_ammo,_configs)}; + +private _attackProfiles = getArray (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "attackProfiles"); +if ((count _attackProfiles) <= 1) exitWith {TRACE_1("no choices for attack profile",_attackProfiles)}; + +private _currentFireMode = _currentShooter getVariable [QGVAR(attackProfile), "#undefined"]; + +// Just like onFired, this is case sensitive! +private _index = _attackProfiles find _currentFireMode; +if (_index == -1) then { + _index = _attackProfiles find (getText (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "defaultAttackProfile")); +}; +_index = (_index + 1) % (count _attackProfiles); +private _nextFireMode = _attackProfiles select _index; +TRACE_4("",_currentFireMode,_nextFireMode,_index,_attackProfiles); + +_currentShooter setVariable [QGVAR(attackProfile), _nextFireMode, false]; + +playSound "ACE_Sound_Click"; + +if ((getNumber (configFile >> "CfgAmmo" >> _ammo >> QUOTE(ADDON) >> "showHintOnCycle")) == 1) then { + private _localizedName = getText (configFile >> QGVAR(AttackProfiles) >> _nextFireMode >> "name"); + [_localizedName] call EFUNC(common,displayTextStructured); +}; diff --git a/addons/missileguidance/stringtable.xml b/addons/missileguidance/stringtable.xml index f1177ef36f..54cc4e9757 100644 --- a/addons/missileguidance/stringtable.xml +++ b/addons/missileguidance/stringtable.xml @@ -154,5 +154,19 @@ Giocatore ed IA プレイヤーと AI + + Cycle Fire Mode + Wechsle Feuermodus + Переключение режимов огня + Přepínání režimů palby + Przełącz tryb ognia + Cycle mode de tir + Tüzelési mód váltása + Alterna le modalità di fuoco + Cambiar modo de disparo + Alterar Modo de Disparo + 発射モード切り替え + 발사 방식 순환 +