From 9935ac57bdb38b4dd8bc2037e297120a605b0726 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 Feb 2015 19:32:41 -0600 Subject: [PATCH 1/4] Base Cleanup Headers Formating Small optimizations --- addons/disposable/CfgEventHandlers.hpp | 44 +-- addons/disposable/CfgMagazines.hpp | 44 +-- addons/disposable/CfgVehicles.hpp | 268 +++++++++--------- addons/disposable/CfgWeapons.hpp | 32 +-- addons/disposable/README.md | 2 +- addons/disposable/XEH_postInitClient.sqf | 10 +- addons/disposable/config.cpp | 18 +- .../functions/fnc_aiDropWeaponCallback.sqf | 40 +-- .../functions/fnc_replaceATWeapon.sqf | 38 ++- .../functions/fnc_takeLoadedATWeapon.sqf | 54 ++-- .../functions/fnc_updateInventoryDisplay.sqf | 52 ++-- 11 files changed, 310 insertions(+), 292 deletions(-) diff --git a/addons/disposable/CfgEventHandlers.hpp b/addons/disposable/CfgEventHandlers.hpp index 304f304774..02d0cb625f 100644 --- a/addons/disposable/CfgEventHandlers.hpp +++ b/addons/disposable/CfgEventHandlers.hpp @@ -1,44 +1,44 @@ class Extended_PreInit_EventHandlers { - class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); - }; + class ADDON { + init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + }; }; class Extended_PostInit_EventHandlers { - class ADDON { - clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) ); - }; + class ADDON { + clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) ); + }; }; class Extended_FiredBIS_EventHandlers { - class CAManBase { - class ADDON { - firedBIS = QUOTE( _this call FUNC(replaceATWeapon) ); + class CAManBase { + class ADDON { + firedBIS = QUOTE( _this call FUNC(replaceATWeapon) ); + }; }; - }; }; // handle preloaded missile class Extended_Init_EventHandlers { - class CAManBase { - class ADDON { - init = QUOTE( _this call FUNC(takeLoadedATWeapon) ); + class CAManBase { + class ADDON { + init = QUOTE( _this call FUNC(takeLoadedATWeapon) ); + }; }; - }; }; class Extended_Take_EventHandlers { - class CAManBase { - class ADDON { - take = QUOTE( _this call FUNC(takeLoadedATWeapon); [_this select 0] call FUNC(updateInventoryDisplay); ); + class CAManBase { + class ADDON { + take = QUOTE( _this call FUNC(takeLoadedATWeapon); [_this select 0] call FUNC(updateInventoryDisplay); ); + }; }; - }; }; class Extended_Put_EventHandlers { - class CAManBase { - class ADDON { - put = QUOTE( [_this select 0] call FUNC(updateInventoryDisplay); ); + class CAManBase { + class ADDON { + put = QUOTE( [_this select 0] call FUNC(updateInventoryDisplay); ); + }; }; - }; }; diff --git a/addons/disposable/CfgMagazines.hpp b/addons/disposable/CfgMagazines.hpp index 993d53f46c..8fbae08dfd 100644 --- a/addons/disposable/CfgMagazines.hpp +++ b/addons/disposable/CfgMagazines.hpp @@ -1,24 +1,24 @@ class CfgMagazines { - class NLAW_F; - class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine - author = "$STR_ACE_Common_ACETeam"; - scope = 1; - displayName = "$STR_ACE_Disposable_PreloadedMissileDummy"; - picture = PATHTOEF(common,UI\blank_CO.paa); - weaponPoolAvailable = 0; - mass = 0; - }; - class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy { - count = 0; - }; - class ACE_UsedTube_F: NLAW_F { - author = "$STR_ACE_Common_ACETeam"; - displayName = "$STR_ACE_Disposable_UsedTube"; - descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription"; - displayNameShort = "-"; - count = 0; - weaponPoolAvailable = 0; - modelSpecial = ""; - mass = 0; - }; + class NLAW_F; + class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine + author = "$STR_ACE_Common_ACETeam"; + scope = 1; + displayName = "$STR_ACE_Disposable_PreloadedMissileDummy"; + picture = PATHTOEF(common,UI\blank_CO.paa); + weaponPoolAvailable = 0; + mass = 0; + }; + class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy { + count = 0; + }; + class ACE_UsedTube_F: NLAW_F { + author = "$STR_ACE_Common_ACETeam"; + displayName = "$STR_ACE_Disposable_UsedTube"; + descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription"; + displayNameShort = "-"; + count = 0; + weaponPoolAvailable = 0; + modelSpecial = ""; + mass = 0; + }; }; diff --git a/addons/disposable/CfgVehicles.hpp b/addons/disposable/CfgVehicles.hpp index b3b9436484..13d4cedf4b 100644 --- a/addons/disposable/CfgVehicles.hpp +++ b/addons/disposable/CfgVehicles.hpp @@ -1,146 +1,146 @@ class CfgVehicles { - #define MACRO_NONLAW \ - class TransportMagazines { \ - class _xx_NLAW_F { \ - count = 0; \ - }; \ +#define MACRO_NONLAW \ + class TransportMagazines { \ + class _xx_NLAW_F { \ + count = 0; \ + }; \ + }; + + class ReammoBox_F; + class NATO_Box_Base: ReammoBox_F {}; + class Box_NATO_Ammo_F: NATO_Box_Base { + MACRO_NONLAW + }; + class Box_NATO_WpsLaunch_F: NATO_Box_Base { + MACRO_NONLAW }; - class ReammoBox_F; - class NATO_Box_Base: ReammoBox_F {}; - class Box_NATO_Ammo_F: NATO_Box_Base { - MACRO_NONLAW - }; - class Box_NATO_WpsLaunch_F: NATO_Box_Base { - MACRO_NONLAW - }; + class IND_Box_Base: ReammoBox_F {}; + class Box_IND_WpsLaunch_F: IND_Box_Base { + MACRO_NONLAW + }; + class Box_IND_Ammo_F: IND_Box_Base { + MACRO_NONLAW + }; - class IND_Box_Base: ReammoBox_F {}; - class Box_IND_WpsLaunch_F: IND_Box_Base { - MACRO_NONLAW - }; - class Box_IND_Ammo_F: IND_Box_Base { - MACRO_NONLAW - }; + class B_supplyCrate_F: ReammoBox_F { + MACRO_NONLAW + }; + class I_supplyCrate_F: B_supplyCrate_F { + MACRO_NONLAW + }; + class C_supplyCrate_F: ReammoBox_F { + MACRO_NONLAW + }; - class B_supplyCrate_F: ReammoBox_F { - MACRO_NONLAW - }; - class I_supplyCrate_F: B_supplyCrate_F { - MACRO_NONLAW - }; - class C_supplyCrate_F: ReammoBox_F { - MACRO_NONLAW - }; + class B_AssaultPack_rgr; + class B_AssaultPack_rgr_LAT: B_AssaultPack_rgr { + MACRO_NONLAW + }; + class B_AssaultPack_rgr_ReconLAT: B_AssaultPack_rgr { + MACRO_NONLAW + }; - class B_AssaultPack_rgr; - class B_AssaultPack_rgr_LAT: B_AssaultPack_rgr { - MACRO_NONLAW - }; - class B_AssaultPack_rgr_ReconLAT: B_AssaultPack_rgr { - MACRO_NONLAW - }; + class B_Carryall_mcamo; + class B_AssaultPack_mcamo_Ammo: B_Carryall_mcamo { + MACRO_NONLAW + }; + class B_Carryall_oli; + class I_Fieldpack_oli_Ammo: B_Carryall_oli { + MACRO_NONLAW + }; - class B_Carryall_mcamo; - class B_AssaultPack_mcamo_Ammo: B_Carryall_mcamo { - MACRO_NONLAW - }; - class B_Carryall_oli; - class I_Fieldpack_oli_Ammo: B_Carryall_oli { - MACRO_NONLAW - }; + class B_AssaultPack_dgtl; + class I_Fieldpack_oli_LAT: B_AssaultPack_dgtl { + MACRO_NONLAW + }; - class B_AssaultPack_dgtl; - class I_Fieldpack_oli_LAT: B_AssaultPack_dgtl { - MACRO_NONLAW - }; + class CargoNet_01_ammo_base_F; + class B_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F { + MACRO_NONLAW + }; + class I_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F { + MACRO_NONLAW + }; - class CargoNet_01_ammo_base_F; - class B_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F { - MACRO_NONLAW - }; - class I_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F { - MACRO_NONLAW - }; + class Slingload_01_Base_F; + class B_Slingload_01_Cargo_F: Slingload_01_Base_F { + MACRO_NONLAW + }; - class Slingload_01_Base_F; - class B_Slingload_01_Cargo_F: Slingload_01_Base_F { + class Tank_F; + class APC_Tracked_01_base_F: Tank_F { + MACRO_NONLAW + }; + /*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F { MACRO_NONLAW - }; - - class Tank_F; - class APC_Tracked_01_base_F: Tank_F { - MACRO_NONLAW - }; - /*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F { - MACRO_NONLAW - }; - class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F { - MACRO_NONLAW - }; - class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { - MACRO_NONLAW - }; - class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F { - MACRO_NONLAW - };*/ - - class Car_F; - class MRAP_01_base_F: Car_F { - MACRO_NONLAW - }; - /*class MRAP_01_gmg_base_F: MRAP_01_base_F { - MACRO_NONLAW - }; - class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F { - MACRO_NONLAW - }; - class B_MRAP_01_F: MRAP_01_base_F { - MACRO_NONLAW - }; - class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F { - MACRO_NONLAW - }; - class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F { - MACRO_NONLAW - };*/ - - class MRAP_03_base_F: Car_F { - MACRO_NONLAW - }; - /*class MRAP_03_hmg_base_F: MRAP_03_base_F { - MACRO_NONLAW - }; - class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F { - MACRO_NONLAW - }; - class I_MRAP_03_F: MRAP_03_base_F { - MACRO_NONLAW - }; - class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F { - MACRO_NONLAW - }; - class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F { - MACRO_NONLAW - };*/ - - class Wheeled_APC_F: Car_F {}; - class APC_Wheeled_03_base_F: Wheeled_APC_F { - MACRO_NONLAW - }; - class APC_Wheeled_01_base_F: Wheeled_APC_F { - MACRO_NONLAW - }; - /*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F { - MACRO_NONLAW - }; - class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F { - MACRO_NONLAW - }; - class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F { - MACRO_NONLAW - }; - class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F { - MACRO_NONLAW - };*/ +}; +class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F { + MACRO_NONLAW +}; +class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { + MACRO_NONLAW +}; +class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F { + MACRO_NONLAW +};*/ + + class Car_F; + class MRAP_01_base_F: Car_F { + MACRO_NONLAW + }; + /*class MRAP_01_gmg_base_F: MRAP_01_base_F { + MACRO_NONLAW +}; +class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F { + MACRO_NONLAW +}; +class B_MRAP_01_F: MRAP_01_base_F { + MACRO_NONLAW +}; +class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F { + MACRO_NONLAW +}; +class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F { + MACRO_NONLAW +};*/ + + class MRAP_03_base_F: Car_F { + MACRO_NONLAW + }; + /*class MRAP_03_hmg_base_F: MRAP_03_base_F { + MACRO_NONLAW +}; +class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F { + MACRO_NONLAW +}; +class I_MRAP_03_F: MRAP_03_base_F { + MACRO_NONLAW +}; +class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F { + MACRO_NONLAW +}; +class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F { + MACRO_NONLAW +};*/ + + class Wheeled_APC_F: Car_F {}; + class APC_Wheeled_03_base_F: Wheeled_APC_F { + MACRO_NONLAW + }; + class APC_Wheeled_01_base_F: Wheeled_APC_F { + MACRO_NONLAW + }; + /*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F { + MACRO_NONLAW +}; +class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F { + MACRO_NONLAW +}; +class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F { + MACRO_NONLAW +}; +class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F { + MACRO_NONLAW +};*/ }; diff --git a/addons/disposable/CfgWeapons.hpp b/addons/disposable/CfgWeapons.hpp index 4bd36ce3ed..965d97521c 100644 --- a/addons/disposable/CfgWeapons.hpp +++ b/addons/disposable/CfgWeapons.hpp @@ -1,18 +1,18 @@ class CfgWeapons { - class Launcher_Base_F; - class launch_NLAW_F: Launcher_Base_F { - ACE_UsedTube = "ACE_launch_NLAW_Used_F"; // The class name of the used tube. - magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine - }; - class ACE_launch_NLAW_Used_F: launch_NLAW_F { // the used tube should be a sub class of the disposable launcher - scope = 1; - ACE_isUsedLauncher = 1; - author = "$STR_ACE_Common_ACETeam"; - displayName = "$STR_ACE_Disposable_UsedTube"; - descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription"; - magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again. - //picture = ""; @todo - //model = ""; @todo - weaponPoolAvailable = 0; - }; + class Launcher_Base_F; + class launch_NLAW_F: Launcher_Base_F { + ACE_UsedTube = "ACE_launch_NLAW_Used_F"; // The class name of the used tube. + magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine + }; + class ACE_launch_NLAW_Used_F: launch_NLAW_F { // the used tube should be a sub class of the disposable launcher + scope = 1; + ACE_isUsedLauncher = 1; + author = "$STR_ACE_Common_ACETeam"; + displayName = "$STR_ACE_Disposable_UsedTube"; + descriptionShort = "$STR_ACE_Disposable_UsedTubeDescription"; + magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again. + //picture = ""; @todo + //model = ""; @todo + weaponPoolAvailable = 0; + }; }; diff --git a/addons/disposable/README.md b/addons/disposable/README.md index 7dd85fff32..73418cd49d 100644 --- a/addons/disposable/README.md +++ b/addons/disposable/README.md @@ -1,7 +1,7 @@ ace_disposable ============== -Makes the NLAW a disposable one-way weapon. +Makes the NLAW a disposable one-shot weapon. ## Maintainers diff --git a/addons/disposable/XEH_postInitClient.sqf b/addons/disposable/XEH_postInitClient.sqf index 17911f5da5..76e8a03067 100644 --- a/addons/disposable/XEH_postInitClient.sqf +++ b/addons/disposable/XEH_postInitClient.sqf @@ -5,9 +5,9 @@ #include "script_component.hpp" if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then { - GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{ - _player = ACE_player; - [_player, secondaryWeapon _player] call FUNC(takeLoadedATWeapon); - [_player, (_this select 0)] call FUNC(updateInventoryDisplay); - }] call EFUNC(common,addEventHandler); + GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{ + _player = ACE_player; + [_player] call FUNC(takeLoadedATWeapon); + [_player, (_this select 0)] call FUNC(updateInventoryDisplay); + }] call EFUNC(common,addEventHandler); }; diff --git a/addons/disposable/config.cpp b/addons/disposable/config.cpp index be2b52735a..0f256824d7 100644 --- a/addons/disposable/config.cpp +++ b/addons/disposable/config.cpp @@ -1,15 +1,15 @@ #include "script_component.hpp" class CfgPatches { - class ADDON { - units[] = {}; - weapons[] = {}; - requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common"}; - author[] = {"commy2"}; - authorUrl = "https://github.com/commy2/"; - VERSION_CONFIG; - }; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"commy2"}; + authorUrl = "https://github.com/commy2/"; + VERSION_CONFIG; + }; }; #include "CfgEventHandlers.hpp" diff --git a/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf b/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf index f6947f7e44..a92ddd7da0 100644 --- a/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf +++ b/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf @@ -1,32 +1,36 @@ /* -* Author: bux, commy2 -* -* Remove the ai's missle launcher tube -* -* Return value: -* Nothing -*/ - + * Author: bux, commy2 + * Remove the ai's missle launcher tube after the missle has exploded + * + * Arguments: + * 0: Params [unit, Tube, Projectile] + * 1: CBA PFH ID + * + * Return Value: + * Nothing + * + * Example: + * [[someAI, "emptyTube", theRocket], 55] call ace_disposable_fnc_aiDropWeaponCallback; + * + * Public: No + */ #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; +EXPLODE_2_PVT(_this,_params,_pfhId); +EXPLODE_3_PVT(_params,_unit,_tube,_projectile); if (!isNull _projectile) exitWith {}; //remove frameEH -[(_this select 1)] call cba_fnc_removePerFrameHandler; +[_pfhId] call cba_fnc_removePerFrameHandler; if ([_unit] call EFUNC(common,isPlayer)) exitWith {}; //Just in case a player took control if (!alive _unit) exitWith {}; //No point doing this for dead //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 removeWeaponGlobal _tube; + private ["_logic"]; + _logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; + _logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items + _unit removeWeaponGlobal _tube; }; diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index ea107d1643..bdb4995701 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -1,26 +1,36 @@ /* - * Author: commy2 - * + * Author: bux, commy2 * Replace the disposable launcher with the used dummy. - * - * Argument: - * Input from "Fired" eventhandler - * - * Return value: + * + * Arguments: + * 0: unit - Object the event handler is assigned to + * 1: weapon - Fired weapon + * 2: muzzle - Muzzle that was used + * 3: mode - Current mode of the fired weapon + * 4: ammo - Ammo used + * 5: magazine - magazine name which was used + * 6: projectile - Object of the projectile that was shot + * + * Return Value: * Nothing + * + * Example: + * [fromBisFiredEH] call ace_disposable_fnc_replaceATWeapon; + * + * Public: No */ - #include "script_component.hpp" private ["_unit", "_tube", "_projectile"]; _unit = _this select 0; -_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube"); -_projectile = _this select 6; - if (!local _unit) exitWith {}; + +_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube"); if (_tube == "") exitWith {}; +_projectile = _this select 6; + private "_items"; _items = secondaryWeaponItems _unit; @@ -28,11 +38,11 @@ _items = secondaryWeaponItems _unit; _unit addWeapon _tube; _unit selectWeapon _tube; { - if (_x != "") then {_unit addSecondaryWeaponItem _x}; + if (_x != "") then {_unit addSecondaryWeaponItem _x}; } forEach _items; // AI if !([_unit] call EFUNC(common,isPlayer)) then { - //waits until _projectile is null, so random 0-2 tickTime seconds after that - [FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler; + //waits until _projectile is null, so random 0-2 tickTime seconds after that + [FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf index ea1b1fb379..eacaa820c2 100644 --- a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf +++ b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf @@ -1,48 +1,50 @@ /* * Author: commy2 - * * Handle the take event. Add a dummy magazine if a disposable rocket launcher is taken. - * - * Argument: - * Input from "Take" eventhandler - * - * Return value: + * + * Arguments: + * 0: unit - Object the event handler is assigned to + * + * Return Value: * Nothing + * + * Example: + * [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon; + * + * Public: No */ - #include "script_component.hpp" private ["_unit", "_launcher", "_config"]; -_unit = _this select 0; -_launcher = secondaryWeapon _unit; - +PARAMS_1(_unit); if (!local _unit) exitWith {}; +_launcher = secondaryWeapon _unit; _config = configFile >> "CfgWeapons" >> _launcher; if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then { - private ["_magazine", "_isLauncherSelected"]; + private ["_magazine", "_isLauncherSelected"]; - _magazine = getArray (_config >> "magazines") select 0; + _magazine = getArray (_config >> "magazines") select 0; - _isLauncherSelected = currentWeapon _unit == _launcher; + _isLauncherSelected = currentWeapon _unit == _launcher; - _unit removeMagazines _magazine; + _unit removeMagazines _magazine; - if (backpack _unit == "") then { - _unit addBackpack "Bag_Base"; + if (backpack _unit == "") then { + _unit addBackpack "Bag_Base"; - _unit addMagazine _magazine; - _unit addWeapon _launcher; + _unit addMagazine _magazine; + _unit addWeapon _launcher; - removeBackpack _unit; - } else { - _unit addMagazine _magazine; - _unit addWeapon _launcher; - }; + removeBackpack _unit; + } else { + _unit addMagazine _magazine; + _unit addWeapon _launcher; + }; - if (_isLauncherSelected) then { - _unit selectWeapon _launcher; - }; + if (_isLauncherSelected) then { + _unit selectWeapon _launcher; + }; }; diff --git a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf index f33ed0dc73..e98e446fe2 100644 --- a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf +++ b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf @@ -1,26 +1,28 @@ /* * Author: bux, commy2 - * * Hide or show the secondary weapon magazine inventory slot to prevent unloading of dummy magazines. - * - * Argument: - * 0: The player. (Object) - * - * Return value: + * + * Arguments: + * 0: unit - Object the event handler is assigned to + * + * Return Value: * Nothing + * + * Example: + * [player] call ace_disposable_fnc_updateInventoryDisplay; + * + * Public: No */ - #include "script_component.hpp" -private ["_player", "_display"]; +disableSerialization; -_player = _this select 0; +PARAMS_1(_player); +DEFAULT_PARAM(1,_display,(findDisplay 602)); _player removeMagazines "ACE_PreloadedMissileDummy"; _player removeMagazines "ACE_FiredMissileDummy"; -disableSerialization; -_display = [_this, 1, (findDisplay 602)] call BIS_fnc_param; if (isNull _display) exitWith {}; private ["_launcher", "_control", "_config"]; @@ -28,21 +30,21 @@ private ["_launcher", "_control", "_config"]; _launcher = secondaryWeapon _player; if (_launcher == "" || {getText (configFile >> "CfgWeapons" >> _launcher >> "ACE_UsedTube") == ""}) then { - _control = _display displayCtrl 627; - _config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine"; - _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; - _control ctrlCommit 0; + _control = _display displayCtrl 627; + _config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine"; + _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; + _control ctrlCommit 0; - _control = _display displayCtrl 1251; - _config = configFile >> "RscDisplayInventory" >> "controls" >> "BackgroundSlotSecondaryMagazine"; - _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; - _control ctrlCommit 0; + _control = _display displayCtrl 1251; + _config = configFile >> "RscDisplayInventory" >> "controls" >> "BackgroundSlotSecondaryMagazine"; + _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; + _control ctrlCommit 0; } else { - _control = _display displayCtrl 627; - _control ctrlSetPosition [0, 0, 0, 0]; - _control ctrlCommit 0; + _control = _display displayCtrl 627; + _control ctrlSetPosition [0, 0, 0, 0]; + _control ctrlCommit 0; - _control = _display displayCtrl 1251; - _control ctrlSetPosition [0, 0, 0, 0]; - _control ctrlCommit 0; + _control = _display displayCtrl 1251; + _control ctrlSetPosition [0, 0, 0, 0]; + _control ctrlCommit 0; }; From 0c88b92ebaebec07d16c240480304b16368edab7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 Mar 2015 20:24:14 -0500 Subject: [PATCH 2/4] Condense AI func, and drop attachements --- addons/disposable/XEH_postInitClient.sqf | 12 ++--- addons/disposable/XEH_preInit.sqf | 1 - .../functions/fnc_aiDropWeaponCallback.sqf | 36 ------------- .../functions/fnc_replaceATWeapon.sqf | 53 ++++++++++++++----- .../functions/fnc_takeLoadedATWeapon.sqf | 2 +- .../functions/fnc_updateInventoryDisplay.sqf | 2 +- 6 files changed, 47 insertions(+), 59 deletions(-) delete mode 100644 addons/disposable/functions/fnc_aiDropWeaponCallback.sqf diff --git a/addons/disposable/XEH_postInitClient.sqf b/addons/disposable/XEH_postInitClient.sqf index 76e8a03067..1fe598137f 100644 --- a/addons/disposable/XEH_postInitClient.sqf +++ b/addons/disposable/XEH_postInitClient.sqf @@ -4,10 +4,8 @@ #include "script_component.hpp" -if (isNil QGVAR(UpdateInventoryDisplay_EHID)) then { - GVAR(UpdateInventoryDisplay_EHID) = ["inventoryDisplayLoaded",{ - _player = ACE_player; - [_player] call FUNC(takeLoadedATWeapon); - [_player, (_this select 0)] call FUNC(updateInventoryDisplay); - }] call EFUNC(common,addEventHandler); -}; +["inventoryDisplayLoaded",{ + _player = ACE_player; + [_player] call FUNC(takeLoadedATWeapon); + [_player, (_this select 0)] call FUNC(updateInventoryDisplay); +}] call EFUNC(common,addEventHandler); \ No newline at end of file diff --git a/addons/disposable/XEH_preInit.sqf b/addons/disposable/XEH_preInit.sqf index 26543c369a..020187b730 100644 --- a/addons/disposable/XEH_preInit.sqf +++ b/addons/disposable/XEH_preInit.sqf @@ -2,7 +2,6 @@ ADDON = false; -PREP(aiDropWeaponCallback); PREP(replaceATWeapon); PREP(takeLoadedATWeapon); PREP(updateInventoryDisplay); diff --git a/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf b/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf deleted file mode 100644 index a92ddd7da0..0000000000 --- a/addons/disposable/functions/fnc_aiDropWeaponCallback.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Author: bux, commy2 - * Remove the ai's missle launcher tube after the missle has exploded - * - * Arguments: - * 0: Params [unit, Tube, Projectile] - * 1: CBA PFH ID - * - * Return Value: - * Nothing - * - * Example: - * [[someAI, "emptyTube", theRocket], 55] call ace_disposable_fnc_aiDropWeaponCallback; - * - * Public: No - */ -#include "script_component.hpp" - -EXPLODE_2_PVT(_this,_params,_pfhId); -EXPLODE_3_PVT(_params,_unit,_tube,_projectile); - -if (!isNull _projectile) exitWith {}; - -//remove frameEH -[_pfhId] call cba_fnc_removePerFrameHandler; - -if ([_unit] call EFUNC(common,isPlayer)) exitWith {}; //Just in case a player took control -if (!alive _unit) exitWith {}; //No point doing this for dead - -//If AI still has tube, throw it on ground -if (secondaryWeapon _unit == _tube) then { - private ["_logic"]; - _logic = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; - _logic addWeaponCargoGlobal [_tube, 1]; // @todo secondary weapon items - _unit removeWeaponGlobal _tube; -}; diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index bdb4995701..89426873a0 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -21,28 +21,55 @@ */ #include "script_component.hpp" -private ["_unit", "_tube", "_projectile"]; +private ["_unit", "_weapon", "_projectile", "_replacementTube", "_items"]; _unit = _this select 0; -if (!local _unit) exitWith {}; - -_tube = getText (configFile >> "CfgWeapons" >> (_this select 1) >> "ACE_UsedTube"); -if (_tube == "") exitWith {}; - +_weapon = _this select 1; _projectile = _this select 6; -private "_items"; +if (!local _unit) exitWith {}; +_replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube"); +if (_replacementTube == "") exitWith {}; //If no replacement defined just exit +if (_weapon != (secondaryWeapon _unit)) exitWith {}; //just to be sure + + +//Save array of items attached to launcher _items = secondaryWeaponItems _unit; - -_unit addWeapon _tube; -_unit selectWeapon _tube; +//Replace the orginal weapon with the 'usedTube' weapon +_unit addWeapon _replacementTube; +//Makes sure the used tube is still equiped +_unit selectWeapon _replacementTube; +//Re-add all attachments to the used tube { if (_x != "") then {_unit addSecondaryWeaponItem _x}; } forEach _items; -// AI + +// AI - Remove the ai's missle launcher tube after the missle has exploded if !([_unit] call EFUNC(common,isPlayer)) then { - //waits until _projectile is null, so random 0-2 tickTime seconds after that - [FUNC(aiDropWeaponCallback), 2, [_unit, _tube, _projectile]] call CBA_fnc_addPerFrameHandler; + [{ + EXPLODE_2_PVT(_this,_params,_pfhId); + EXPLODE_3_PVT(_params,_unit,_tube,_projectile); + + //don't do anything until projectile is null (exploded/max range) + if (isNull _projectile) then { + //Remove PFEH: + [_pfhId] call cba_fnc_removePerFrameHandler; + + //If (tube is dropped) OR (is dead) OR (is player) just exit + if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {}; + + private ["_items", "_container"]; + + _items = secondaryWeaponItems _unit; + _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; + _container setPosAsl (getPosAsl _unit); + _container addWeaponCargoGlobal [_tube, 1]; + { + if (_x != "") then {_container addItemCargoGlobal [_x, 1];}; + } forEach _items; + _unit removeWeaponGlobal _tube; + }; + }, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf index eacaa820c2..de3875dfa0 100644 --- a/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf +++ b/addons/disposable/functions/fnc_takeLoadedATWeapon.sqf @@ -6,7 +6,7 @@ * 0: unit - Object the event handler is assigned to * * Return Value: - * Nothing + * None * * Example: * [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon; diff --git a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf index e98e446fe2..3f9d6f9802 100644 --- a/addons/disposable/functions/fnc_updateInventoryDisplay.sqf +++ b/addons/disposable/functions/fnc_updateInventoryDisplay.sqf @@ -6,7 +6,7 @@ * 0: unit - Object the event handler is assigned to * * Return Value: - * Nothing + * None * * Example: * [player] call ace_disposable_fnc_updateInventoryDisplay; From ad12904ca4e285aaf8e026970b77e726d5dcc8cb Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 19 Mar 2015 20:37:36 -0500 Subject: [PATCH 3/4] minor formating --- addons/disposable/functions/fnc_replaceATWeapon.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index 89426873a0..41a58d2bd8 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -61,8 +61,8 @@ if !([_unit] call EFUNC(common,isPlayer)) then { if (((secondaryWeapon _unit) != _tube) || {!alive _unit} || {([_unit] call EFUNC(common,isPlayer))}) exitWith {}; private ["_items", "_container"]; - - _items = secondaryWeaponItems _unit; + + _items = secondaryWeaponItems _unit; _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; _container setPosAsl (getPosAsl _unit); _container addWeaponCargoGlobal [_tube, 1]; From 0e6f76b50bd2d8af99286943a4a35fef2d7a2083 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 21 Mar 2015 10:35:21 -0500 Subject: [PATCH 4/4] Cannot drop attachements because of duplication --- addons/disposable/functions/fnc_replaceATWeapon.sqf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/disposable/functions/fnc_replaceATWeapon.sqf b/addons/disposable/functions/fnc_replaceATWeapon.sqf index 41a58d2bd8..8c55209123 100644 --- a/addons/disposable/functions/fnc_replaceATWeapon.sqf +++ b/addons/disposable/functions/fnc_replaceATWeapon.sqf @@ -62,13 +62,17 @@ if !([_unit] call EFUNC(common,isPlayer)) then { private ["_items", "_container"]; - _items = secondaryWeaponItems _unit; + // _items = secondaryWeaponItems _unit; _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"]; _container setPosAsl (getPosAsl _unit); _container addWeaponCargoGlobal [_tube, 1]; - { - if (_x != "") then {_container addItemCargoGlobal [_x, 1];}; - } forEach _items; + + //This will duplicate attachements, because we will be adding a weapon that may already have attachments on it + //We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container: + // { + // if (_x != "") then {_container addItemCargoGlobal [_x, 1];}; + // } forEach _items; + _unit removeWeaponGlobal _tube; }; }, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;