2017-02-10 19:01:17 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2017-02-10 19:01:17 +00:00
|
|
|
// #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 {};
|
|
|
|
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _currentShooter = objNull;
|
|
|
|
private _currentMagazine = "";
|
2017-08-22 21:07:45 +00:00
|
|
|
if (isNull (ACE_controlledUAV param [0, objNull])) then {
|
|
|
|
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;
|
|
|
|
private _turretPath = if (ACE_player == (driver _currentShooter)) then {[-1]} else {ACE_player call CBA_fnc_turretPath};
|
|
|
|
_currentMagazine = _currentShooter currentMagazineTurret _turretPath;
|
|
|
|
};
|
2017-02-10 19:01:17 +00:00
|
|
|
} else {
|
2017-08-22 21:07:45 +00:00
|
|
|
_currentShooter = ACE_controlledUAV select 0;
|
|
|
|
private _turretPath = ACE_controlledUAV select 2;
|
2017-06-02 21:51:38 +00:00
|
|
|
_currentMagazine = _currentShooter currentMagazineTurret _turretPath;
|
2017-02-10 19:01:17 +00:00
|
|
|
};
|
2017-08-22 21:07:45 +00:00
|
|
|
|
2017-02-10 19:01:17 +00:00
|
|
|
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);
|
|
|
|
};
|