mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
3e6fc52733
Todo: Implement in module (Choose new or old/don't break old missions) Magazine UI+model Add preparing delay Fix function readmes Cleanup in functions? Credits MP Testing
56 lines
1.9 KiB
Plaintext
56 lines
1.9 KiB
Plaintext
/*
|
|
* Author: Grey
|
|
* Checks whether magazine can be loaded into static weapon
|
|
*
|
|
* Arguments:
|
|
* 0: static <OBJECT>
|
|
* 1: unit <OBJECT>
|
|
* 2: magazineClassOptional <OPTIONAL><STRING>
|
|
*
|
|
* Return Value:
|
|
* canLoadMagazine <BOOL>
|
|
*
|
|
* Example:
|
|
* [_target,_player,'16aa_static_magazine_1Rnd_105mm_HE'] call lsr_staticweapons_canLoadMagazine
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
params ["_unit","_static",["_magazineClassOptional","",[""]]];
|
|
private ["_canLoadMagazine","_currentMagazine","_weapon","_magazines","_listOfMagNames",
|
|
"_hasCompatibleMagazine","_count"];
|
|
|
|
if !(alive _static) exitWith {false};
|
|
|
|
_canLoadMagazine = false;
|
|
|
|
_currentMagazine = (magazinesAllTurrets _static) select 1;
|
|
_weapon = (_static weaponsTurret [0]) select 0;
|
|
|
|
_magazines = magazines _unit;
|
|
_listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
|
|
_hasCompatibleMagazine = false;
|
|
_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
|