mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
88 lines
3.3 KiB
Plaintext
88 lines
3.3 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Tuupertunut
|
|
* Returns information about every magazine that can be rearmed in the vehicle. Multiple mags of
|
|
* same class in the same turret are grouped together for practical reasons.
|
|
*
|
|
* Arguments:
|
|
* 0: Vehicle <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Magazine info <ARRAY of ARRAYs>
|
|
* Child arrays:
|
|
* 0: Magazine class <STRING>
|
|
* 1: Turret path <ARRAY>
|
|
* 2: Is pylon magazine <BOOLEAN>
|
|
* 3: Pylon index (-1 if not pylon) <NUMBER>
|
|
* 4: Max magazines <NUMBER>
|
|
* 5: Current magazines <NUMBER>
|
|
* 6: Max rounds per magazine <NUMBER>
|
|
* 7: Current rounds in magazines <ARRAY of NUMBERs>
|
|
*
|
|
* Example:
|
|
* [tank] call ace_rearm_fnc_getNeedRearmMagazines
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_vehicle"];
|
|
|
|
private _magazineInfo = [];
|
|
|
|
// 1.70 pylons
|
|
private _pylonConfigs = configProperties [configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"];
|
|
{
|
|
private _pylonConfig = _x;
|
|
|
|
// Strangely, a 1-based index.
|
|
private _pylonIndex = _forEachIndex + 1;
|
|
|
|
// Retrieving pylon magazine by index. If the pylon is empty, it is marked with "".
|
|
private _pylonMagazine = (getPylonMagazines _vehicle) select (_pylonIndex - 1);
|
|
|
|
// Only care about pylons that have a magazine.
|
|
if (!(_pylonMagazine isEqualTo "")) then {
|
|
|
|
private _maxRounds = getNumber (configFile >> "CfgMagazines" >> _pylonMagazine >> "count");
|
|
private _currentRounds = _vehicle ammoOnPylon _pylonIndex;
|
|
|
|
if (_currentRounds < _maxRounds) then {
|
|
// getPylonTurret expects 0 based index, and returns driver turret as [-1]
|
|
private _pylonTurret = [_vehicle, (_pylonIndex - 1)] call EFUNC(common,getPylonTurret);
|
|
|
|
_magazineInfo pushBack [_pylonMagazine, _pylonTurret, true, _pylonIndex, 1, 1, _maxRounds, [_currentRounds]];
|
|
};
|
|
};
|
|
} forEach _pylonConfigs;
|
|
|
|
private _turrets = [_vehicle] call FUNC(getAllRearmTurrets);
|
|
{
|
|
private _turretPath = _x;
|
|
private _magazines = [_vehicle, _turretPath] call FUNC(getTurretConfigMagazines);
|
|
|
|
// _magazines without duplicates
|
|
private _magazineClasses = _magazines arrayIntersect _magazines;
|
|
|
|
{
|
|
private _magazineClass = _x;
|
|
|
|
private _maxMagazines = [_vehicle, _turretPath, _magazineClass] call FUNC(getMaxMagazines);
|
|
private _maxRoundsPerMag = getNumber (configFile >> "CfgMagazines" >> _magazineClass >> "count");
|
|
|
|
/* Array of ammo counts in every magazine. Example: [200, 200, 152] means 2 mags with 200
|
|
* rounds and 1 mag with 152 rounds. */
|
|
private _currentRounds = [_vehicle, _turretPath, _magazineClass] call FUNC(getTurretMagazineAmmo);
|
|
private _currentMagazines = count _currentRounds;
|
|
|
|
/* If there is space for new magazines or if some magazines are not full, add the magazine
|
|
* type to _magazineInfo. */
|
|
if ((_currentMagazines < _maxMagazines) || {({_x < _maxRoundsPerMag} count _currentRounds) > 0}) then {
|
|
_magazineInfo pushBack [_magazineClass, _turretPath, false, -1, _maxMagazines, _currentMagazines, _maxRoundsPerMag, _currentRounds];
|
|
};
|
|
|
|
} forEach _magazineClasses;
|
|
} forEach _turrets;
|
|
|
|
TRACE_2("getNeedRearmMagazines",_vehicle,_magazineInfo);
|
|
_magazineInfo
|