ACE3/addons/mk6mortar/functions/fnc_canLoadMagazine.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

53 lines
1.9 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Grey
* Checks whether magazine can be loaded into static weapon
*
* Arguments:
* 0: static <OBJECT>
* 1: unit <OBJECT>
* 2: magazine class to check; if not given having any compatible magazine returns true <STRING> (default: "")
*
* Return Value:
* canLoadMagazine <BOOL>
*
* Example:
* [_target,_player,"ACE_1Rnd_82mm_Mo_HE"] call ace_mk6mortar_fnc_canLoadMagazine
*
* Public: Yes
*/
params ["_static","_unit",["_magazineClassOptional","",[""]]];
if !(alive _static && GVAR(useAmmoHandling)) exitWith {false};
if (_static getVariable [QGVAR(inUse), false]) exitWith {false};
private _canLoadMagazine = false;
private _hasCompatibleMagazine = false;
private _currentMagazine = (magazinesAllTurrets _static) select 1;
private _weapon = (_static weaponsTurret [0]) select 0;
private _listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
private _count = 0;
//If function is called with an optional string then check if player has that magzine otherwise check all magazines of the player to see if they are compatible with the static weapon
if (_magazineClassOptional != "") then {
if ([_unit,_magazineClassOptional] call EFUNC(common,hasMagazine)) then {
_hasCompatibleMagazine = true;
};
} else {
{
if ([_unit,_x] call EFUNC(common,hasMagazine)) exitWith {_hasCompatibleMagazine = true};
} forEach _listOfMagNames;
};
//If static weapon has a magazine then find the ammo count
if (count (_static magazinesTurret [0]) > 0) then {
_count = _currentMagazine select 2;
};
//If the static weapon doesn't have a magzine or a magazine with no bullets, the player has a compatible magazine and the static weapon has a barrel then you can load a magazine
if ((count (_static magazinesTurret [0]) == 0 || _count == 0) && _hasCompatibleMagazine) then {
_canLoadMagazine = true;
};
_canLoadMagazine