diff --git a/addons/disposable/CfgEventHandlers.hpp b/addons/disposable/CfgEventHandlers.hpp index d91d142259..304f304774 100644 --- a/addons/disposable/CfgEventHandlers.hpp +++ b/addons/disposable/CfgEventHandlers.hpp @@ -13,7 +13,6 @@ class Extended_PostInit_EventHandlers { class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - // firedBIS = "if (local (_this select 0)) then {_this call AGM_Disposable_fnc_replaceATWeapon};"; firedBIS = QUOTE( _this call FUNC(replaceATWeapon) ); }; }; @@ -23,7 +22,6 @@ class Extended_FiredBIS_EventHandlers { class Extended_Init_EventHandlers { class CAManBase { class ADDON { - // init = "if (local (_this select 0)) then {_this spawn {[_this select 0, secondaryWeapon (_this select 0)] call AGM_Disposable_fnc_takeLoadedATWeapon}};"; init = QUOTE( _this call FUNC(takeLoadedATWeapon) ); }; }; @@ -32,8 +30,7 @@ class Extended_Init_EventHandlers { class Extended_Take_EventHandlers { class CAManBase { class ADDON { - // take = "if (local (_this select 0)) then {[_this select 0, _this select 2] call AGM_Disposable_fnc_takeLoadedATWeapon; [_this select 0, findDisplay 602] call AGM_Disposable_fnc_updateInventoryDisplay};"; - take = QUOTE( _this call FUNC(takeLoadedATWeapon); _this call FUNC(updateInventoryDisplay); ); + take = QUOTE( _this call FUNC(takeLoadedATWeapon); [_this select 0] call FUNC(updateInventoryDisplay); ); }; }; }; @@ -41,8 +38,7 @@ class Extended_Take_EventHandlers { class Extended_Put_EventHandlers { class CAManBase { class ADDON { - // put = "if (local (_this select 0)) then {[_this select 0, findDisplay 602] call AGM_Disposable_fnc_updateInventoryDisplay};"; - take = QUOTE( _this call FUNC(updateInventoryDisplay); ); + put = QUOTE( [_this select 0] call FUNC(updateInventoryDisplay); ); }; }; }; diff --git a/addons/disposable/XEH_postInitClient.sqf b/addons/disposable/XEH_postInitClient.sqf index 9075155952..5ff5752f69 100644 --- a/addons/disposable/XEH_postInitClient.sqf +++ b/addons/disposable/XEH_postInitClient.sqf @@ -8,6 +8,6 @@ if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then { GVAR(UpdateInventoryDisplay_EHID) = [{ _player = ACE_player; [_player, secondaryWeapon _player] call FUNC(takeLoadedATWeapon); - [_player, _this select 0] spawn FUNC(updateInventoryDisplay); + [_player, (_this select 0)] call FUNC(updateInventoryDisplay); }] call EFUNC(common,addInventoryDisplayLoadedEventHandler); }; diff --git a/addons/disposable/XEH_preInit.sqf b/addons/disposable/XEH_preInit.sqf index 5bcdc6dc7c..3f2c3a4f9a 100644 --- a/addons/disposable/XEH_preInit.sqf +++ b/addons/disposable/XEH_preInit.sqf @@ -1,5 +1,6 @@ #include "script_component.hpp" +PREP(aiDropWeaponCallback); PREP(replaceATWeapon); PREP(takeLoadedATWeapon); PREP(updateInventoryDisplay); diff --git a/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf b/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf new file mode 100644 index 0000000000..b388a57b56 --- /dev/null +++ b/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf @@ -0,0 +1,29 @@ +/* +* Author: bux, commy2 +* +* Remove the ai's missle launcher tube +* +* Return value: +* Nothing +*/ + +#include "script_component.hpp" + +private ["_unit", "_tube", "_projectile", "_logic"]; + +_unit = (_this select 0) select 0; +_tube = (_this select 0) select 1; +_projectile = (_this select 0) select 2; + +if (!isNull _projectile) exitWith {}; + +//remove frameEH +[(_this select 1)] call cba_fnc_removePerFrameHandler; + +//If AI still has tube, throw it on ground +if (secondaryWeapon _unit == _tube) then { + _logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; + _logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items + + _unit removeWeapon _tube; +}; diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index 9d8621001d..dcaf8c1c01 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -33,19 +33,6 @@ _unit selectWeapon _tube; // AI if !([_unit] call EFUNC(common,isPlayer)) then { - [_unit, _tube, _projectile] spawn { - _unit = _this select 0; - _tube = _this select 1; - _projectile = _this select 2; - - waitUntil {isNull _projectile}; - sleep 1; - - if (secondaryWeapon _unit == _tube) then { - _logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; - _logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items - - _unit removeWeapon _tube; - }; - }; + //waits until _projectile is null, so random 0-2 seconds after that + [FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf index cb8c1ffd99..f33ed0dc73 100644 --- a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf +++ b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf @@ -9,20 +9,19 @@ * Return value: * Nothing */ - + #include "script_component.hpp" private ["_player", "_display"]; _player = _this select 0; -if (!local _player) exitWith {}; _player removeMagazines "ACE_PreloadedMissileDummy"; _player removeMagazines "ACE_FiredMissileDummy"; disableSerialization; -_display = findDisplay 602; -if (isNull _display) exitWith {systemChat "null";}; +_display = [_this, 1, (findDisplay 602)] call BIS_fnc_param; +if (isNull _display) exitWith {}; private ["_launcher", "_control", "_config"];