Core/Loot: Fixed items some not being lootable on second opening of a lootable item
Port From (https://github.com/TrinityCore/TrinityCore/commit/00cb775558d19209630850bb148748ed4c3836c7)
This commit is contained in:
@@ -115,6 +115,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
Loot loot = new(player.GetMap(), item.GetGUID(), LootType.Item, null);
|
Loot loot = new(player.GetMap(), item.GetGUID(), LootType.Item, null);
|
||||||
item.loot = loot;
|
item.loot = loot;
|
||||||
|
item.m_lootGenerated = true;
|
||||||
loot.GenerateMoneyLoot(item.GetTemplate().MinMoneyLoot, item.GetTemplate().MaxMoneyLoot);
|
loot.GenerateMoneyLoot(item.GetTemplate().MinMoneyLoot, item.GetTemplate().MaxMoneyLoot);
|
||||||
loot.FillLoot(item.GetEntry(), LootStorage.Items, player, true, loot.gold != 0);
|
loot.FillLoot(item.GetEntry(), LootStorage.Items, player, true, loot.gold != 0);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Framework.Database;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Game.Loots
|
namespace Game.Loots
|
||||||
@@ -127,6 +128,25 @@ namespace Game.Loots
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!loot.items.Empty())
|
||||||
|
{
|
||||||
|
loot.items = loot.items.OrderBy(p => p.LootListId).ToList();
|
||||||
|
|
||||||
|
int lootListId = 0;
|
||||||
|
// add dummy loot items to ensure items are indexable by their LootListId
|
||||||
|
while (loot.items.Count <= loot.items.Last().LootListId)
|
||||||
|
{
|
||||||
|
if (loot.items[lootListId].LootListId != lootListId)
|
||||||
|
{
|
||||||
|
loot.items.Add(loot.items[lootListId]);
|
||||||
|
loot.items.Last().LootListId = (uint)lootListId;
|
||||||
|
loot.items.Last().is_looted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
++lootListId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mark the item if it has loot so it won't be generated again on open
|
// Mark the item if it has loot so it won't be generated again on open
|
||||||
item.loot = loot;
|
item.loot = loot;
|
||||||
item.m_lootGenerated = true;
|
item.m_lootGenerated = true;
|
||||||
@@ -280,7 +300,7 @@ namespace Game.Loots
|
|||||||
var bounds = _lootItems.LookupByKey(itemId);
|
var bounds = _lootItems.LookupByKey(itemId);
|
||||||
foreach (var itr in bounds)
|
foreach (var itr in bounds)
|
||||||
{
|
{
|
||||||
if (itr.Count == count)
|
if (itr.ItemIndex == itemIndex)
|
||||||
{
|
{
|
||||||
_lootItems.Remove(itr.ItemId);
|
_lootItems.Remove(itr.ItemId);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user