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
63 lines
2.5 KiB
Plaintext
63 lines
2.5 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Grey
|
|
* Loads Magazine into static weapon
|
|
*
|
|
* Arguments:
|
|
* 0: static <OBJECT>
|
|
* 1: unit <OBJECT>
|
|
* 2: magazine class to load; if not given the first compatible magazine is loaded <STRING> (default: "")
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [_target,_player,"ACE_1Rnd_82mm_Mo_HE"] call ace_mk6mortar_fnc_loadMagazine
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params ["_static","_unit",["_magazineClassOptional","",[""]]];
|
|
|
|
//If function has been called with an optional classname hten add that magazine to the static weapon. Otherwise add the compatible magazine
|
|
if(_magazineClassOptional != "") then {
|
|
_unit removeMagazine _magazineClassOptional;
|
|
[QGVAR(addMagazine), [_static, _magazineClassOptional]] call CBA_fnc_globalEvent;
|
|
} else {
|
|
//Get weapon & magazine information of static weapon
|
|
private _weapon = (_static weaponsTurret [0]) select 0;
|
|
private _currentMagazine = (magazinesAllTurrets _static) select 1;
|
|
private _currentMagazineClass = _currentMagazine select 0;
|
|
private _count = _currentMagazine select 2;
|
|
|
|
//Check all of the players magazines to see if they are compatible with the static weapon. First magazine that is compatible is chosen
|
|
//VKing: This section ought to be double checked.
|
|
private _magazines = magazines _unit;
|
|
private _magazineDetails = magazinesDetail _unit;
|
|
private _listOfMagNames = getArray(configFile >> "cfgWeapons" >> _weapon >> "magazines");
|
|
private _magazineClass = "";
|
|
private _magazineClassDetails = "";
|
|
private _roundsLeft = 0;
|
|
{
|
|
if (_x in _listOfMagNames) exitWith {
|
|
_magazineClass = _x;
|
|
_magazineClassDetails = _magazineDetails select _forEachIndex;
|
|
};
|
|
} forEach _magazines;
|
|
//If the static weapon already has an empty magazine then remove it
|
|
if (_count == 0) then {
|
|
[QGVAR(removeMagazine), [_static, _currentMagazineClass]] call CBA_fnc_globalEvent;
|
|
};
|
|
//Find out the ammo count of the compatible magazine found
|
|
if (_magazineClassDetails != "") then{
|
|
private _parsed = _magazineClassDetails splitString "([]/: )";
|
|
_parsed params ["_type", "", "", "_roundsLeftText", "_maxRoundsText"];
|
|
_roundsLeft = parseNumber _roundsLeftText;
|
|
_magType = _type;
|
|
};
|
|
|
|
_unit removeMagazine _magazineClass;
|
|
[QGVAR(addMagazine), [_static, _magazineClass]] call CBA_fnc_globalEvent;
|
|
[QGVAR(setAmmo), [_static, _magazineClass,_roundsLeft], _static] call CBA_fnc_targetEvent;
|
|
};
|