Merge pull request #2102 from acemod/disposableFixes

Disposable fixes
This commit is contained in:
PabstMirror 2015-08-13 15:13:03 -05:00
commit 7c60375105
8 changed files with 28 additions and 33 deletions

View File

@ -22,7 +22,7 @@ class Extended_FiredBIS_EventHandlers {
class Extended_InitPost_EventHandlers { class Extended_InitPost_EventHandlers {
class CAManBase { class CAManBase {
class ADDON { class ADDON {
init = QUOTE([ARR_2(_this select 0, secondaryWeapon (_this select 0))] call FUNC(takeLoadedATWeapon)); init = QUOTE([_this select 0] call FUNC(takeLoadedATWeapon));
}; };
}; };
}; };

View File

@ -1,6 +1,6 @@
class CfgMagazines { class CfgMagazines {
class NLAW_F; class NLAW_F;
class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
scope = 1; scope = 1;
scopeArsenal = 1; scopeArsenal = 1;
@ -12,14 +12,4 @@ class CfgMagazines {
class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy { class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy {
count = 0; count = 0;
}; };
class ACE_UsedTube_F: NLAW_F {
author = ECSTRING(common,ACETeam);
displayName = CSTRING(UsedTube);
descriptionShort = CSTRING(UsedTubeDescription);
displayNameShort = "-";
count = 0;
weaponPoolAvailable = 0;
modelSpecial = "";
mass = 0;
};
}; };

View File

@ -3,9 +3,12 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
["inventoryDisplayLoaded", {[ACE_player, _this select 0] call FUNC(updateInventoryDisplay)}] call EFUNC(common,addEventHandler); ["inventoryDisplayLoaded", {
[ACE_player, _this select 0] call FUNC(updateInventoryDisplay)
}] call EFUNC(common,addEventHandler);
["playerInventoryChanged", { ["playerInventoryChanged", {
params ["_unit", "_items"]; params ["_unit"];
[_unit, _items select 11] call FUNC(takeLoadedATWeapon); [_unit] call FUNC(takeLoadedATWeapon);
[_unit] call FUNC(updateInventoryDisplay); [_unit] call FUNC(updateInventoryDisplay);
}] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler);

View File

@ -1,10 +0,0 @@
// by commy2
// The Arma InventoryOpened EH fires actually before the inventory dialog is opened (findDisplay 602 => displayNull).
#include "script_component.hpp"
["inventoryDisplayLoaded",{
[ACE_player] call FUNC(takeLoadedATWeapon);
[ACE_player, (_this select 0)] call FUNC(updateInventoryDisplay);
}] call EFUNC(common,addEventHandler);

View File

@ -21,14 +21,14 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_replacementTube", "_items"];
params ["_unit", "_weapon", "", "", "", "", "_projectile"]; params ["_unit", "_weapon", "", "", "", "", "_projectile"];
TRACE_3("params",_unit,_weapon,_projectile);
if (!local _unit) exitWith {}; if ((!local _unit) || {_weapon != (secondaryWeapon _unit)}) exitWith {};
private ["_replacementTube", "_items"];
_replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube"); _replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit 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 //Save array of items attached to launcher

View File

@ -15,17 +15,18 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_launcher", "_config"];
params ["_unit"]; params ["_unit"];
TRACE_1("params",_unit);
if (!local _unit) exitWith {}; if (!local _unit) exitWith {};
private ["_launcher", "_config"];
_launcher = secondaryWeapon _unit; _launcher = secondaryWeapon _unit;
_config = configFile >> "CfgWeapons" >> _launcher; _config = configFile >> "CfgWeapons" >> _launcher;
if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then { if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then {
private ["_magazine", "_isLauncherSelected"]; private ["_magazine", "_isLauncherSelected", "_didAdd"];
_magazine = getArray (_config >> "magazines") select 0; _magazine = getArray (_config >> "magazines") select 0;
@ -35,14 +36,22 @@ if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber
if (backpack _unit == "") then { if (backpack _unit == "") then {
_unit addBackpack "Bag_Base"; _unit addBackpack "Bag_Base";
_unit addMagazine _magazine; _unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
_unit addWeapon _launcher; _unit addWeapon _launcher;
if (!_didAdd) then {
TRACE_1("Failed To Add Disposable Magazine Normally, doing backup method (no backpack)",_unit);
_unit addSecondaryWeaponItem _magazine;
};
removeBackpack _unit; removeBackpack _unit;
} else { } else {
_unit addMagazine _magazine; _unit addMagazine _magazine;
_didAdd = _magazine in (magazines _unit);
_unit addWeapon _launcher; _unit addWeapon _launcher;
if (!_didAdd) then {
TRACE_2("Failed To Add Disposable Magazine Normally, doing backup method",_unit,(backpack _unit));
_unit addSecondaryWeaponItem _magazine;
};
}; };
if (_isLauncherSelected) then { if (_isLauncherSelected) then {

View File

@ -17,6 +17,7 @@
disableSerialization; disableSerialization;
params ["_player", ["_display",(findDisplay 602),[displayNull]]]; params ["_player", ["_display",(findDisplay 602),[displayNull]]];
TRACE_2("params",_player,_display);
_player removeMagazines "ACE_PreloadedMissileDummy"; _player removeMagazines "ACE_PreloadedMissileDummy";
_player removeMagazines "ACE_FiredMissileDummy"; _player removeMagazines "ACE_FiredMissileDummy";

View File

@ -1,6 +1,8 @@
#define COMPONENT disposable #define COMPONENT disposable
#include "\z\ace\addons\main\script_mod.hpp" #include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
#ifdef DEBUG_ENABLED_ATTACH #ifdef DEBUG_ENABLED_ATTACH
#define DEBUG_MODE_FULL #define DEBUG_MODE_FULL
#endif #endif