2015-12-19 01:18:35 +00:00
|
|
|
/*
|
|
|
|
* Author: VKing
|
|
|
|
* Initializes mortar for use with ammunition handling magazines.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Mortar <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [mortar1] call ace_mk6mortar_fnc_mortarInit
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-12-19 15:30:01 +00:00
|
|
|
params ["_mortar"];
|
2015-12-19 01:18:35 +00:00
|
|
|
|
2015-12-19 18:54:45 +00:00
|
|
|
if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {TRACE_1("Exit",_mortar)};
|
2015-12-19 01:18:35 +00:00
|
|
|
|
|
|
|
// Remove all magazines
|
|
|
|
if (count magazines _mortar > 0) then {
|
2016-02-14 12:51:44 +00:00
|
|
|
{
|
|
|
|
[QGVAR(removeMagazine), [_mortar, _x]] call EFUNC(common,globalEvent);
|
|
|
|
} forEach magazines _mortar;
|
2015-12-19 01:18:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Replace current weapon with ammo handling weapon
|
2016-02-14 12:51:44 +00:00
|
|
|
private _currentWeapon = _mortar weaponsTurret [0] select 0;
|
|
|
|
private _newWeapon = "";
|
2015-12-19 17:22:54 +00:00
|
|
|
|
|
|
|
if (_currentWeapon == "mortar_82mm") then {
|
2016-02-14 12:51:44 +00:00
|
|
|
_newWeapon = "ace_mortar_82mm";
|
2015-12-19 17:22:54 +00:00
|
|
|
} else {
|
|
|
|
_newWeapon = getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith));
|
|
|
|
};
|
|
|
|
|
2015-12-19 11:10:12 +00:00
|
|
|
if (_newWeapon != "") then {
|
2015-12-19 01:18:35 +00:00
|
|
|
_mortar removeWeaponGlobal _currentWeapon;
|
|
|
|
_mortar addWeaponGlobal _newWeapon;
|
|
|
|
};
|
|
|
|
|
|
|
|
_mortar setVariable [QGVAR(initialized),true,true];
|
|
|
|
TRACE_1("Init complete",_mortar);
|