diff --git a/addons/mk6mortar/CfgEventHandlers.hpp b/addons/mk6mortar/CfgEventHandlers.hpp index 1e5de1815e..8a65815e49 100644 --- a/addons/mk6mortar/CfgEventHandlers.hpp +++ b/addons/mk6mortar/CfgEventHandlers.hpp @@ -22,3 +22,10 @@ class Extended_InitPost_EventHandlers { }; }; }; +class Extended_GetIn_EventHandlers { + class Mortar_01_base_F { + class ADDON { + getIn = QUOTE(_this call COMPILE_FILE(XEH_getIn)); + }; + }; +}; diff --git a/addons/mk6mortar/XEH_getIn.sqf b/addons/mk6mortar/XEH_getIn.sqf new file mode 100644 index 0000000000..16a14ee9f7 --- /dev/null +++ b/addons/mk6mortar/XEH_getIn.sqf @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +params ["_mortar","_crewPosition","_unit","_turretPath"]; +TRACE_4("",_mortar,_crewPosition,_unit,_turretPath); + +if (_unit != player || {_crewPosition != "GUNNER"}) exitWith {LOG("Exit")}; + +if (!EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [{ + if (GVAR(useAmmoHandling)) then { + _this call FUNC(mortarInit); + }; + }, _mortar]; +}; +_mortar call FUNC(mortarInit); diff --git a/addons/mk6mortar/XEH_initPost.sqf b/addons/mk6mortar/XEH_initPost.sqf index 5f0482d600..08c8edde6c 100644 --- a/addons/mk6mortar/XEH_initPost.sqf +++ b/addons/mk6mortar/XEH_initPost.sqf @@ -1,5 +1,10 @@ #include "script_component.hpp" +params ["_mortar"]; +TRACE_1("",_mortar); + +if (gunner _mortar != player) exitWith {LOG("Exit")}; + if (!EGVAR(common,settingsInitFinished)) exitWith { EGVAR(common,runAtSettingsInitialized) pushBack [{ if (GVAR(useAmmoHandling)) then { diff --git a/addons/mk6mortar/functions/fnc_handleFired.sqf b/addons/mk6mortar/functions/fnc_handleFired.sqf index b212b04fc6..e14fd77f6a 100644 --- a/addons/mk6mortar/functions/fnc_handleFired.sqf +++ b/addons/mk6mortar/functions/fnc_handleFired.sqf @@ -23,11 +23,11 @@ PARAMS_7(_vehicle,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); -if (GVAR(useAmmoHandling)) then { - if !(_vehicle getVariable [QGVAR(exclude),false]) then { +if (GVAR(useAmmoHandling) && {_vehicle getVariable [QGVAR(initialized),false] && !(_vehicle getVariable [QGVAR(exclude),false])}) then { + // if !(_vehicle getVariable [QGVAR(exclude),false]) then { _vehicle removeMagazineGlobal (_vehicle magazinesTurret [0] select 0); TRACE_1("",_vehicle magazinesTurret [0]); - }; + // }; }; if (!GVAR(airResistanceEnabled)) exitWith {}; diff --git a/addons/mk6mortar/functions/fnc_mortarInit.sqf b/addons/mk6mortar/functions/fnc_mortarInit.sqf index ec41c03b19..0bb7756418 100644 --- a/addons/mk6mortar/functions/fnc_mortarInit.sqf +++ b/addons/mk6mortar/functions/fnc_mortarInit.sqf @@ -18,7 +18,7 @@ params ["_mortar"]; private ["_newWeapon","_currentWeapon"]; -if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {}; +if (_mortar getVariable [QGVAR(initialized),false] || _mortar getVariable [QGVAR(exclude),false]) exitWith {TRACE_1("Exit",_mortar)}; // Remove all magazines if (count magazines _mortar > 0) then {