mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fix ammo handling init on dedicated
This commit is contained in:
parent
1ffd23c193
commit
32846014a1
@ -15,6 +15,8 @@
|
||||
_static setMagazineTurretAmmo [_magazine, _ammoCount, [0]];
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
["initMortar", {_this call FUNC(mortarInit);}] call EFUNC(common,addEventHandler);
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
["playerVehicleChanged", {_this call FUNC(handlePlayerVehicleChanged);}] call EFUNC(common,addEventHandler);
|
||||
|
@ -16,31 +16,30 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_player,_newVehicle);
|
||||
|
||||
private["_tubeWeaponName" ,"_fireModes", "_lastFireMode"];
|
||||
params ["_player", "_newVehicle"];
|
||||
|
||||
if (isNull _newVehicle) exitWith {};
|
||||
if (!(_newVehicle isKindOf "Mortar_01_base_F")) exitWith {};
|
||||
|
||||
// Run magazine handling initialization if enabled
|
||||
if (!EGVAR(common,settingsInitFinished)) then {
|
||||
EGVAR(common,runAtSettingsInitialized) pushBack [{
|
||||
if (GVAR(useAmmoHandling) && {!(_this getVariable [QGVAR(initialized),false]) && !(_this getVariable [QGVAR(exclude),false])}) then {
|
||||
_this call FUNC(mortarInit);
|
||||
if (!(_newVehicle getVariable [QGVAR(initialized),false]) && !(_newVehicle getVariable [QGVAR(exclude),false])) then {
|
||||
// Make sure that mortar init is executed after settings init
|
||||
[{
|
||||
params ["_mortar"];
|
||||
if (GVAR(useAmmoHandling) && {!(_mortar getVariable [QGVAR(initialized),false]) && !(_mortar getVariable [QGVAR(exclude),false])}) then {
|
||||
//wait for proper turret locality change
|
||||
[{
|
||||
["initMortar", [_this], [_this]] call EFUNC(common,globalEvent);
|
||||
}, _mortar, 0.05] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
}, _newVehicle];
|
||||
} else {
|
||||
if (GVAR(useAmmoHandling) && {!(_newVehicle getVariable [QGVAR(initialized),false]) && !(_newVehicle getVariable [QGVAR(exclude),false])}) then {
|
||||
_newVehicle call FUNC(mortarInit);
|
||||
};
|
||||
}, _newVehicle] call EFUNC(common,runAfterSettingsInit);
|
||||
};
|
||||
|
||||
_tubeWeaponName = (weapons _newVehicle) select 0;
|
||||
_fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes");
|
||||
private _tubeWeaponName = (weapons _newVehicle) select 0;
|
||||
private _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes");
|
||||
|
||||
//Restore last firemode:
|
||||
_lastFireMode = _newVehicle getVariable [QGVAR(lastFireMode), -1];
|
||||
private _lastFireMode = _newVehicle getVariable [QGVAR(lastFireMode), -1];
|
||||
if (_lastFireMode != -1) then {
|
||||
_player action ["SwitchWeapon", _newVehicle, _player, _lastFireMode];
|
||||
};
|
||||
|
@ -18,27 +18,28 @@
|
||||
params ["_mortar"];
|
||||
|
||||
if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {TRACE_1("Exit",_mortar)};
|
||||
if (!(_mortar turretLocal [0])) exitWith {TRACE_1("Exit - turret not local",_mortar)};
|
||||
|
||||
// Remove all magazines
|
||||
// Remove all magazines from turret
|
||||
if (count magazines _mortar > 0) then {
|
||||
{
|
||||
[QGVAR(removeMagazine), [_mortar, _x]] call EFUNC(common,globalEvent);
|
||||
_mortar removeMagazineTurret [_x,[0]];
|
||||
} forEach magazines _mortar;
|
||||
};
|
||||
|
||||
// Replace current weapon with ammo handling weapon
|
||||
// Replace current turret weapon with ammo handling weapon
|
||||
private _currentWeapon = _mortar weaponsTurret [0] select 0;
|
||||
private _newWeapon = "";
|
||||
|
||||
if (_currentWeapon == "mortar_82mm") then {
|
||||
if (tolower _currentWeapon == "mortar_82mm") then {
|
||||
_newWeapon = "ace_mortar_82mm";
|
||||
} else {
|
||||
_newWeapon = getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith));
|
||||
};
|
||||
|
||||
if (_newWeapon != "") then {
|
||||
_mortar removeWeaponGlobal _currentWeapon;
|
||||
_mortar addWeaponGlobal _newWeapon;
|
||||
_mortar removeWeaponTurret [_currentWeapon,[0]];
|
||||
_mortar addWeaponTurret [_newWeapon,[0]];
|
||||
};
|
||||
|
||||
_mortar setVariable [QGVAR(initialized),true,true];
|
||||
|
Loading…
Reference in New Issue
Block a user