From 560c509a3a468082ceee5958549de7f0e129331b Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 14 Feb 2016 13:51:44 +0100 Subject: [PATCH] Changed to using playerVehicleChanged. --- addons/mk6mortar/CfgEventHandlers.hpp | 14 -------------- addons/mk6mortar/XEH_getIn.sqf | 16 ---------------- addons/mk6mortar/XEH_initPost.sqf | 16 ---------------- addons/mk6mortar/config.cpp | 3 ++- .../fnc_handlePlayerVehicleChanged.sqf | 17 +++++++++++++++-- addons/mk6mortar/functions/fnc_mortarInit.sqf | 12 ++++++------ 6 files changed, 23 insertions(+), 55 deletions(-) delete mode 100644 addons/mk6mortar/XEH_getIn.sqf delete mode 100644 addons/mk6mortar/XEH_initPost.sqf diff --git a/addons/mk6mortar/CfgEventHandlers.hpp b/addons/mk6mortar/CfgEventHandlers.hpp index 8a65815e49..3a04fae9f0 100644 --- a/addons/mk6mortar/CfgEventHandlers.hpp +++ b/addons/mk6mortar/CfgEventHandlers.hpp @@ -15,17 +15,3 @@ class Extended_FiredBIS_EventHandlers { }; }; }; -class Extended_InitPost_EventHandlers { - class Mortar_01_base_F { - class ADDON { - init = QUOTE(_this call COMPILE_FILE(XEH_initPost)); - }; - }; -}; -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 deleted file mode 100644 index 2802b54e80..0000000000 --- a/addons/mk6mortar/XEH_getIn.sqf +++ /dev/null @@ -1,16 +0,0 @@ -#include "script_component.hpp" - -params ["_mortar","_crewPosition","_unit","_turretPath"]; -TRACE_4("",_mortar,_crewPosition,_unit,_turretPath); - -if (_unit != player) 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 deleted file mode 100644 index dfcaee61a2..0000000000 --- a/addons/mk6mortar/XEH_initPost.sqf +++ /dev/null @@ -1,16 +0,0 @@ -#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 { - _this call FUNC(mortarInit); - }; - }, _this]; -}; - -_this call FUNC(mortarInit); diff --git a/addons/mk6mortar/config.cpp b/addons/mk6mortar/config.cpp index 3483229087..102875a195 100644 --- a/addons/mk6mortar/config.cpp +++ b/addons/mk6mortar/config.cpp @@ -2,7 +2,8 @@ class CfgPatches { class ADDON { - units[] = {}; + units[] = {"ACE_Box_82mm_Mo_HE","ACE_Box_82mm_Mo_Smoke", + "ACE_Box_82mm_Mo_Illum","ACE_Box_82mm_Mo_Combo"}; weapons[] = {"ACE_RangeTable_82mm","ace_mortar_82mm"}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_interaction"}; diff --git a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf index 4b0e9e634c..02049289aa 100644 --- a/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf +++ b/addons/mk6mortar/functions/fnc_handlePlayerVehicleChanged.sqf @@ -3,7 +3,7 @@ * Handles player getting into new vehicle. Loads PFEG for mortar display if it is a mortar. * * Arguments: - * 0:Player + * 0: Player * 1: New Vehicle * * Return Value: @@ -23,6 +23,19 @@ private["_tubeWeaponName" ,"_fireModes", "_lastFireMode"]; 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); + }; + }, _newVehicle]; +} else { + if (GVAR(useAmmoHandling) && {!(_newVehicle getVariable [QGVAR(initialized),false]) && !(_newVehicle getVariable [QGVAR(exclude),false])}) then { + _newVehicle call FUNC(mortarInit); + }; +}; + _tubeWeaponName = (weapons _newVehicle) select 0; _fireModes = getArray (configFile >> "CfgWeapons" >> _tubeWeaponName >> "modes"); @@ -49,7 +62,7 @@ if (_lastFireMode != -1) then { //Save firemode on vehicle: _mortarVeh setVariable [QGVAR(lastFireMode), _currentChargeMode]; - + if (shownArtilleryComputer && {!GVAR(allowComputerRangefinder)}) then { //Don't like this solution, but it works closeDialog 0; diff --git a/addons/mk6mortar/functions/fnc_mortarInit.sqf b/addons/mk6mortar/functions/fnc_mortarInit.sqf index 09f16090df..7c74cb8249 100644 --- a/addons/mk6mortar/functions/fnc_mortarInit.sqf +++ b/addons/mk6mortar/functions/fnc_mortarInit.sqf @@ -15,23 +15,23 @@ */ #include "script_component.hpp" -if !(GVAR(useAmmoHandling)) exitWith {}; - params ["_mortar"]; -private ["_newWeapon","_currentWeapon"]; 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 { - {_mortar removeMagazineGlobal _x} forEach magazines _mortar; + { + [QGVAR(removeMagazine), [_mortar, _x]] call EFUNC(common,globalEvent); + } forEach magazines _mortar; }; // Replace current weapon with ammo handling weapon -_currentWeapon = _mortar weaponsTurret [0] select 0; +private _currentWeapon = _mortar weaponsTurret [0] select 0; +private _newWeapon = ""; if (_currentWeapon == "mortar_82mm") then { - _newWeapon = "ace_mortar_82mm" + _newWeapon = "ace_mortar_82mm"; } else { _newWeapon = getText (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(replaceWith)); };