diff --git a/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf b/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf index adfd1b5e01..cffc0e28cd 100644 --- a/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf +++ b/addons/missileguidance/functions/fnc_cycleAttackProfileKeyDown.sqf @@ -78,14 +78,13 @@ TRACE_4("",_currentFireMode,_nextFireMode,_index,_attackProfiles); private _currentFireMode = if (_useModeForAttackProfile) then { TRACE_2("setting fire mode",_weaponStateToken,_nextFireMode); - for "_weaponIndex" from 0 to 299 do { - ACE_player action ["SwitchWeapon", _currentShooter, ACE_player, _weaponIndex]; - (weaponState _weaponStateToken) params ["_xWeapon", "", "_xMode"]; + { + _x params ["_xIndex", "", "_xWeapon", "", "_xMode"]; if ((_xWeapon == _weapon) && {(getText (configFile >> "CfgWeapons" >> _weapon >> _xMode >> QGVAR(attackProfile))) == _nextFireMode}) exitWith { - TRACE_2("Restoring",_weaponIndex,weaponState _currentShooter); + ACE_player action ["SwitchWeapon", _currentShooter, ACE_player, _xIndex]; + TRACE_2("Restoring",weaponState _currentShooter,_x); }; - if ((weaponState _weaponStateToken) isEqualTo ["","","","",0]) exitWith {ERROR_2("weaponState not found",_weapon,_nextFireMode);}; - }; + } forEach (ACE_player weaponsInfo [_weapon, false]); } else { TRACE_2("setVariable attackProfile",_currentShooter,_nextFireMode); _currentShooter setVariable [QGVAR(attackProfile), _nextFireMode, false];