ACE3/addons/cookoff/functions/fnc_getVehicleAmmo.sqf
Dedmen Miller e2ac18a05d [WIP] Fix script errors reporting wrong line numbers (#6407)
* 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
2018-09-17 14:19:29 -05:00

62 lines
1.8 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Gets all magazines inside of a vehicle.
*
* Arguments:
* 0: Vehicle <Object>
*
* Return Value:
* 0: Ammo Array <ARRAY>
* 0: Magazine Classname <STRING>
* 1: Ammo Count <NUMBER>
* 1: Total Ammo Count <NUMBER>
*
* Example:
* [vehicle player] call ace_cookoff_fnc_getVehicleAmmo
*
* Public: No
*/
params ["_vehicle"];
TRACE_1("getVehicleAmmo",_vehicle);
private _ammoToDetonate = [];
private _totalAmmo = 0;
// Get ammo from turrets
{
_x params ["_mag", "", "_count"];
if (_count > 0) then {
private _ammo = getText (configFile >> "CfgMagazines" >> _mag >> "ammo");
private _model = getText (configFile >> "CfgAmmo" >> _ammo >> "model");
if (_model == "\A3\weapons_f\empty") exitWith {TRACE_3("skipping",_mag,_ammo,_model);};
_ammoToDetonate pushBack [_mag, _count];
_totalAmmo = _totalAmmo + _count;
};
} forEach (magazinesAllTurrets _vehicle);
// Get ammo from cargo space
{
_x params ["_mag", "_count"];
if (_count > 0) then {
_ammoToDetonate pushBack [_mag, _count];
_totalAmmo = _totalAmmo + _count;
};
} forEach (magazinesAmmoCargo _vehicle);
// Get ammo from transportAmmo / ace_rearm
private _vehCfg = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _configSupply = (getNumber (_vehCfg >> "transportAmmo")) max (getNumber (_vehCfg >> QEGVAR(rearm,defaultSupply)));
if (_vehicle getVariable [QEGVAR(rearm,isSupplyVehicle), (_configSupply > 0)]) then {
TRACE_1("transportAmmo vehicle - adding virtual ammo",typeOf _vehicle);
_ammoToDetonate pushBack ["2000Rnd_65x39_belt", 2000];
_totalAmmo = _totalAmmo + 2000;
_ammoToDetonate pushBack ["20Rnd_105mm_HEAT_MP", 100];
_totalAmmo = _totalAmmo + 100;
};
[_ammoToDetonate, _totalAmmo]