Fixing item stacking
This commit is contained in:
@@ -3746,7 +3746,8 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
/// <summary>
|
||||
/// Checks if two items can be stacked together.
|
||||
/// Items without crafted data can always stack (if same definition and stackable).
|
||||
/// Items with crafted data can only stack if they have the same CraftedItem.Id.
|
||||
/// Items with crafted data can stack if both have no actual rolled stats (all bonuses are 0),
|
||||
/// or if they have the same CraftedItem.Id.
|
||||
/// </summary>
|
||||
private static bool CanStackItems(DungeonCharacterItem source, DungeonCharacterItem target)
|
||||
{
|
||||
@@ -3754,12 +3755,38 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
if (source.CraftedItem == null && target.CraftedItem == null)
|
||||
return true;
|
||||
|
||||
// If one has crafted data and the other doesn't, they can't stack
|
||||
if (source.CraftedItem == null || target.CraftedItem == null)
|
||||
return false;
|
||||
// If one has crafted data and the other doesn't, check if the crafted one has no actual stats
|
||||
if (source.CraftedItem == null)
|
||||
return !HasRolledStats(target.CraftedItem);
|
||||
if (target.CraftedItem == null)
|
||||
return !HasRolledStats(source.CraftedItem);
|
||||
|
||||
// Both have crafted data - they can only stack if it's the same crafted item
|
||||
return source.CraftedItem.Id == target.CraftedItem.Id;
|
||||
// Both have crafted data - they can stack if neither has rolled stats, or if same crafted item
|
||||
if (source.CraftedItem.Id == target.CraftedItem.Id)
|
||||
return true;
|
||||
|
||||
// Different crafted items can stack if neither has actual rolled stats
|
||||
return !HasRolledStats(source.CraftedItem) && !HasRolledStats(target.CraftedItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a crafted item has any non-zero rolled stats.
|
||||
/// </summary>
|
||||
private static bool HasRolledStats(DungeonCraftedItem crafted)
|
||||
{
|
||||
return crafted.RolledBonusStrength != 0 ||
|
||||
crafted.RolledBonusIntelligence != 0 ||
|
||||
crafted.RolledBonusWisdom != 0 ||
|
||||
crafted.RolledBonusEndurance != 0 ||
|
||||
crafted.RolledBonusDexterity != 0 ||
|
||||
crafted.RolledBonusHealth != 0 ||
|
||||
crafted.RolledBonusMana != 0 ||
|
||||
crafted.RolledBonusArmor != 0 ||
|
||||
crafted.RolledBonusMagicResist != 0 ||
|
||||
crafted.RolledBonusMinDamage != 0 ||
|
||||
crafted.RolledBonusMaxDamage != 0 ||
|
||||
crafted.RolledBonusHealAmount != 0 ||
|
||||
crafted.RolledBonusManaRestore != 0;
|
||||
}
|
||||
|
||||
private async Task HandleAutoStackInventory(IConnection connection, DungeonPlayerSession session, CancellationToken ct)
|
||||
|
||||
Reference in New Issue
Block a user