mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Improve getPylonTurret by using getAllPylonsInfo (#8087)
* Improve getPylonTurret by using getAllPylonsInfo * Fix indentation Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
0570c0b861
commit
5bc43fe247
@ -1,14 +1,14 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Finds turret owner of a pylon.
|
||||
* Returns the turret path that owns the given pylon.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 1: Pylon Index (starting at 0) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* * Turret index (either [-1] or [0]) <ARRAY>
|
||||
* Turret Path (either [-1] or [0]) <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [cursorObject, 0] call ace_common_fnc_getPylonTurret
|
||||
@ -18,46 +18,4 @@
|
||||
|
||||
params ["_vehicle", "_pylonIndex"];
|
||||
|
||||
// See if index is in ace_pylonTurrets setVar on vehicle
|
||||
private _pylonTurrets = _vehicle getVariable ["ace_pylonTurrets", []];
|
||||
private _returnValue = _pylonTurrets param [_pylonIndex, []];
|
||||
|
||||
if (!(_returnValue isEqualTo [])) then {
|
||||
TRACE_1("Using ace_pylonTurrets value",_returnValue);
|
||||
} else {
|
||||
// Attempt to determine turret owner based on magazines in the vehicle
|
||||
private _pyMags = getPylonMagazines _vehicle;
|
||||
private _pylonConfigs = configProperties [configOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"];
|
||||
if (_pylonIndex >= (count _pyMags)) exitWith {ERROR("out of bounds");};
|
||||
if (_pylonIndex >= (count _pylonConfigs)) exitWith {ERROR("out of bounds");};
|
||||
|
||||
private _targetMag = _pyMags select _pylonIndex;
|
||||
private _inPilot = _targetMag in (_vehicle magazinesTurret [-1]);
|
||||
private _inGunner = _targetMag in (_vehicle magazinesTurret [0]);
|
||||
|
||||
if (_inPilot) then {
|
||||
if (_inGunner) then {
|
||||
TRACE_3("ambiguous - in both",_targetMag,_inPilot,_inGunner);
|
||||
} else {
|
||||
TRACE_3("Pilot Mag",_targetMag,_inPilot,_inGunner);
|
||||
_returnValue = [-1];
|
||||
};
|
||||
} else {
|
||||
if (_inGunner) then {
|
||||
TRACE_3("Gunner Mag",_targetMag,_inPilot,_inGunner);
|
||||
_returnValue = [0];
|
||||
} else {
|
||||
TRACE_3("ambiguous - in neither",_targetMag,_inPilot,_inGunner);
|
||||
};
|
||||
};
|
||||
|
||||
if (_returnValue isEqualTo []) then { // If not sure, just use config value
|
||||
_returnValue = getArray ((_pylonConfigs select _pylonIndex) >> "turret");
|
||||
if (_returnValue isEqualTo []) then {
|
||||
_returnValue = [-1];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
TRACE_3("",_vehicle,_pylonIndex,_returnValue);
|
||||
_returnValue
|
||||
getAllPylonsInfo _vehicle param [_pylonIndex, []] param [2, [-1]]
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
|
||||
|
||||
// MINIMAL required version for the Mod. Components can specify others..
|
||||
#define REQUIRED_VERSION 2.00
|
||||
#define REQUIRED_VERSION 2.02
|
||||
#define REQUIRED_CBA_VERSION {3,15,0}
|
||||
|
||||
#ifdef COMPONENT_BEAUTIFIED
|
||||
|
@ -48,7 +48,7 @@ private _pylonConfigs = configProperties [configOf _vehicle >> "Components" >> "
|
||||
|
||||
if (_currentRounds < _maxRounds) then {
|
||||
// getPylonTurret expects 0 based index, and returns driver turret as [-1]
|
||||
private _pylonTurret = [_vehicle, (_pylonIndex - 1)] call EFUNC(common,getPylonTurret);
|
||||
private _pylonTurret = [_vehicle, _forEachIndex] call EFUNC(common,getPylonTurret);
|
||||
|
||||
_magazineInfo pushBack [_pylonMagazine, _pylonTurret, true, _pylonIndex, 1, 1, _maxRounds, [_currentRounds]];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user