diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc index 32c7fb58e..cd28a505e 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc @@ -4101,6 +4101,10 @@ function bool HasItemInInventoryOrLoadout(X2ItemTemplate ItemTemplate, optional function bool HasUnModifiedItem(XComGameState AddToGameState, X2ItemTemplate ItemTemplate, out XComGameState_Item ItemState, optional bool bLoot = false, optional XComGameState_Item CombatSimTest) { local int idx; + // Start Issue #1352 - New variables for combat sim stacking behavior + local int idxStatBoost; + local bool hasIdenticalStatBoosts; + // End Issue #1352 if(bLoot) { @@ -4137,6 +4141,7 @@ function bool HasUnModifiedItem(XComGameState AddToGameState, X2ItemTemplate Ite for(idx = 0; idx < Inventory.Length; idx++) { ItemState = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(Inventory[idx].ObjectID)); + hasIdenticalStatBoosts = false; if(ItemState == none) { @@ -4149,10 +4154,27 @@ function bool HasUnModifiedItem(XComGameState AddToGameState, X2ItemTemplate Ite { if(ItemState.GetMyTemplate().ItemCat == 'combatsim') { - if(ItemState.StatBoosts.Length > 0 && CombatSimTest.StatBoosts.Length > 0 && ItemState.StatBoosts[0].Boost == CombatSimTest.StatBoosts[0].Boost && ItemState.StatBoosts[0].StatType == CombatSimTest.StatBoosts[0].StatType) + /// HL-Docs: ref:Bugfixes; issue:1352 + /// Mod-added PCS items which did not provide exactly 1 stat boost were not being properly checked by HasUnModifiedItem + /// New checks added here mean that PCS items with no stat boosts, or more than one stat boost, are properly compared + // Begin Issue #1352 + hasIdenticalStatBoosts = true; + if(CombatSimTest.StatBoosts.Length != 0) + { + for(idxStatBoost = 0; idxStatBoost < ItemState.StatBoosts.Length; idxStatBoost++) + { + If(ItemState.StatBoosts[idxStatBoost].Boost != CombatSimTest.StatBoosts[idxStatBoost].Boost || ItemState.StatBoosts[idxStatBoost].StatType != CombatSimTest.StatBoosts[idxStatBoost].StatType) + { + hasIdenticalStatBoosts = false; + break; + } + } + } + if(hasIdenticalStatBoosts) { return true; } + // End Issue #1352 } else { diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc index cb5191a7f..d45b44f82 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc @@ -792,10 +792,14 @@ simulated function bool HasBeenModified() return true; //end issue #104 - WeaponTemplate = X2WeaponTemplate( m_ItemTemplate ); - - // Single line for Issues #93 and #306 - if ((WeaponTemplate != none) && (GetNumUpgradeSlots() > 0) && (GetMyWeaponUpgradeCount() > 0)) + WeaponTemplate = X2WeaponTemplate( m_ItemTemplate ); + /// HL-Docs: ref:Bugfixes; issue:1429 + /// When checking weapons for HasBeenModified, checking that the number of upgrade slots > 0 gives an incorrect response + /// for weapons which have attachments added by OnAcquired and therefore no slots on the weapon template (e.g. TLE / chosen + /// weapons). Mods which add additional copies of these weapons then cause the items to stack, which interferes with downstream + /// logic in GetItemFromInventory and PutItemInInventory, causing attachments to be stripped when the stacked item is equipped. + // Single line for Issues #93, #306 and #1429 + if ((WeaponTemplate != none) /* && (GetNumUpgradeSlots() > 0)*/ && (GetMyWeaponUpgradeCount() > 0)) return true; return false;