ACE3/addons/hunterkiller/functions/fnc_turretChangedEH.sqf
PabstMirror 981a8ea352
Hunter Killer (Commander Override) (#8496)
* Hunter Killer (Commander Override) - Initial Demo

* Just do a one-time slew

* Update fnc_eachFrame.sqf

* Update addons/hunterkiller/functions/script_component.hpp

Co-authored-by: jonpas <jonpas33@gmail.com>

* Update for ArmA 2.08

* cleanup

* Rework Observe / Control configs

* Add to all 2035 tanks

* Update script_component.hpp

* Use eyeDirection on commander turrets

* Update docs/wiki/framework/hunterkiller-framework.md

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* Add to all 2035, support ture/false setVars

* remove from apcs because mods don't know how to do inheritance

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
2022-09-01 13:38:22 -05:00

53 lines
1.4 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Turret changed event handler. Determine if in a master turret
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Turret <ARRAY>
*
* Return Value:
* None
*
* Example:
* [player, [0]] call ace_hunterkiller_fnc_turretChangedEH
*
* Public: No
*/
params ["_player", "_playerTurret"];
TRACE_2("turretChangedEH",_player,_playerTurret);
GVAR(mode) = 0;
GVAR(targetTurret) = [];
if (_playerTurret isEqualTo []) exitWith {};
private _vehicle = vehicle _player;
private _config = configOf _vehicle;
// setVar can be real array or true/false
private _hkArray = _vehicle getVariable [QUOTE(ADDON), nil];
if (isNil "_hkArray") then {
_hkArray = if (isArray (_config >> QUOTE(ADDON))) then {
getArray (_config >> QUOTE(ADDON))
} else {
((getNumber (_config >> QUOTE(ADDON))) == 1)
};
};
if (_hkArray isEqualTo true) then { _hkArray = [[[0], 1], [[0,0], 3]]; };
if (_hkArray isEqualTo false) then { _hkArray = []; };
TRACE_1("",_hkArray);
if ((count _hkArray) != 2) exitWith {};
{
_x params ["_xTurret", "_xMode"];
TRACE_2("x",_playerTurret,_xTurret);
if (_xTurret isEqualTo _playerTurret) exitWith {
TRACE_3("seat active",typeOf _vehicle,_xTurret,_xMode);
GVAR(mode) = _xMode;
GVAR(targetTurret) = _hkArray # ((_forEachIndex + 1) % 2) # 0;
};
} forEach _hkArray;