Core/Items: Add ItemContext param to Item::Create function
Port From (https://github.com/TrinityCore/TrinityCore/commit/0a2d9ad2f7673e2b7ee62b7cc6f1a19639d37864)
This commit is contained in:
@@ -348,7 +348,7 @@ namespace Framework.Constants
|
||||
OverrideRequiredLevel = 18
|
||||
}
|
||||
|
||||
enum ItemContext : byte
|
||||
public enum ItemContext : byte
|
||||
{
|
||||
None = 0,
|
||||
DungeonNormal = 1,
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Game.Achievements
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
Item item = reward.ItemId != 0 ? Item.CreateItem(reward.ItemId, 1, _owner) : null;
|
||||
Item item = reward.ItemId != 0 ? Item.CreateItem(reward.ItemId, 1, ItemContext.None, _owner) : null;
|
||||
if (item)
|
||||
{
|
||||
// save new item before send
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Game.BlackMarket
|
||||
|
||||
// Create item
|
||||
BlackMarketTemplate templ = entry.GetTemplate();
|
||||
Item item = Item.CreateItem(templ.Item.ItemID, templ.Quantity);
|
||||
Item item = Item.CreateItem(templ.Item.ItemID, templ.Quantity, ItemContext.BlackMarket);
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId), null, 0, bonusListIDs);
|
||||
Item item = playerTarget.StoreNewItem(dest, itemId, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(itemId), null, ItemContext.None, bonusListIDs);
|
||||
|
||||
// remove binding (let GM give it to another player later)
|
||||
if (player == playerTarget)
|
||||
@@ -420,7 +420,7 @@ namespace Game.Chat
|
||||
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
|
||||
if (msg == InventoryResult.Ok)
|
||||
{
|
||||
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, 0, bonusListIDs);
|
||||
Item item = playerTarget.StoreNewItem(dest, template.Value.GetId(), true, 0, null, ItemContext.None, bonusListIDs);
|
||||
|
||||
// remove binding (let GM give it to another player later)
|
||||
if (player == playerTarget)
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Game.Chat.Commands
|
||||
|
||||
foreach (var pair in items)
|
||||
{
|
||||
Item item = Item.CreateItem(pair.Key, pair.Value, handler.GetSession() ? handler.GetSession().GetPlayer() : null);
|
||||
Item item = Item.CreateItem(pair.Key, pair.Value, ItemContext.None, handler.GetSession() ? handler.GetSession().GetPlayer() : null);
|
||||
if (item)
|
||||
{
|
||||
item.SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
|
||||
@@ -1144,17 +1144,11 @@ namespace Game.DataStorage
|
||||
return _itemLevelDeltaToBonusListContainer.LookupByKey(delta);
|
||||
}
|
||||
|
||||
public List<uint> GetItemBonusTree(uint itemId, uint itemContext)
|
||||
void VisitItemBonusTree(uint itemId, Action<ItemBonusTreeNodeRecord> visitor)
|
||||
{
|
||||
List<uint> bonusListIDs = new List<uint>();
|
||||
|
||||
ItemSparseRecord proto = CliDB.ItemSparseStorage.LookupByKey(itemId);
|
||||
if (proto == null)
|
||||
return bonusListIDs;
|
||||
|
||||
var itemIdRange = _itemToBonusTree.LookupByKey(itemId);
|
||||
if (itemIdRange.Empty())
|
||||
return bonusListIDs;
|
||||
return;
|
||||
|
||||
foreach (var itemTreeId in itemIdRange)
|
||||
{
|
||||
@@ -1163,47 +1157,59 @@ namespace Game.DataStorage
|
||||
continue;
|
||||
|
||||
foreach (ItemBonusTreeNodeRecord bonusTreeNode in treeList)
|
||||
visitor(bonusTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
public List<uint> GetItemBonusTree(uint itemId, ItemContext itemContext)
|
||||
{
|
||||
List<uint> bonusListIDs = new List<uint>();
|
||||
|
||||
ItemSparseRecord proto = CliDB.ItemSparseStorage.LookupByKey(itemId);
|
||||
if (proto == null)
|
||||
return bonusListIDs;
|
||||
|
||||
VisitItemBonusTree(itemId, bonusTreeNode =>
|
||||
{
|
||||
if ((ItemContext)bonusTreeNode.ItemContext != itemContext)
|
||||
return;
|
||||
|
||||
if (bonusTreeNode.ChildItemBonusListID != 0)
|
||||
{
|
||||
if (bonusTreeNode.ItemContext != itemContext)
|
||||
continue;
|
||||
bonusListIDs.Add(bonusTreeNode.ChildItemBonusListID);
|
||||
}
|
||||
else if (bonusTreeNode.ChildItemLevelSelectorID != 0)
|
||||
{
|
||||
ItemLevelSelectorRecord selector = CliDB.ItemLevelSelectorStorage.LookupByKey(bonusTreeNode.ChildItemLevelSelectorID);
|
||||
if (selector == null)
|
||||
return;
|
||||
|
||||
if (bonusTreeNode.ChildItemBonusListID != 0)
|
||||
short delta = (short)(selector.MinItemLevel - proto.ItemLevel);
|
||||
|
||||
uint bonus = GetItemBonusListForItemLevelDelta(delta);
|
||||
if (bonus != 0)
|
||||
bonusListIDs.Add(bonus);
|
||||
|
||||
ItemLevelSelectorQualitySetRecord selectorQualitySet = CliDB.ItemLevelSelectorQualitySetStorage.LookupByKey(selector.ItemLevelSelectorQualitySetID);
|
||||
if (selectorQualitySet != null)
|
||||
{
|
||||
bonusListIDs.Add(bonusTreeNode.ChildItemBonusListID);
|
||||
}
|
||||
else if (bonusTreeNode.ChildItemLevelSelectorID != 0)
|
||||
{
|
||||
ItemLevelSelectorRecord selector = CliDB.ItemLevelSelectorStorage.LookupByKey(bonusTreeNode.ChildItemLevelSelectorID);
|
||||
if (selector == null)
|
||||
continue;
|
||||
|
||||
short delta = (short)(selector.MinItemLevel - proto.ItemLevel);
|
||||
|
||||
uint bonus = GetItemBonusListForItemLevelDelta(delta);
|
||||
if (bonus != 0)
|
||||
bonusListIDs.Add(bonus);
|
||||
|
||||
ItemLevelSelectorQualitySetRecord selectorQualitySet = CliDB.ItemLevelSelectorQualitySetStorage.LookupByKey(selector.ItemLevelSelectorQualitySetID);
|
||||
if (selectorQualitySet != null)
|
||||
var itemSelectorQualities = _itemLevelQualitySelectorQualities.LookupByKey(selector.ItemLevelSelectorQualitySetID);
|
||||
if (itemSelectorQualities != null)
|
||||
{
|
||||
var itemSelectorQualities = _itemLevelQualitySelectorQualities.LookupByKey(selector.ItemLevelSelectorQualitySetID);
|
||||
if (itemSelectorQualities != null)
|
||||
{
|
||||
ItemQuality quality = ItemQuality.Uncommon;
|
||||
if (selector.MinItemLevel >= selectorQualitySet.IlvlEpic)
|
||||
quality = ItemQuality.Epic;
|
||||
else if (selector.MinItemLevel >= selectorQualitySet.IlvlRare)
|
||||
quality = ItemQuality.Rare;
|
||||
ItemQuality quality = ItemQuality.Uncommon;
|
||||
if (selector.MinItemLevel >= selectorQualitySet.IlvlEpic)
|
||||
quality = ItemQuality.Epic;
|
||||
else if (selector.MinItemLevel >= selectorQualitySet.IlvlRare)
|
||||
quality = ItemQuality.Rare;
|
||||
|
||||
var itemSelectorQuality = itemSelectorQualities.FirstOrDefault(p => p.Quality < (byte)quality);
|
||||
var itemSelectorQuality = itemSelectorQualities.FirstOrDefault(p => p.Quality < (byte)quality);
|
||||
|
||||
if (itemSelectorQuality != null)
|
||||
bonusListIDs.Add(itemSelectorQuality.QualityItemBonusListID);
|
||||
}
|
||||
if (itemSelectorQuality != null)
|
||||
bonusListIDs.Add(itemSelectorQuality.QualityItemBonusListID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return bonusListIDs;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ namespace Game.Entities
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.DEBUGknowledgeWeek), -1);
|
||||
}
|
||||
|
||||
public override bool Create(ulong guidlow, uint itemId, Player owner)
|
||||
public override bool Create(ulong guidlow, uint itemId, ItemContext context, Player owner)
|
||||
{
|
||||
if (!base.Create(guidlow, itemId, owner))
|
||||
if (!base.Create(guidlow, itemId, context, owner))
|
||||
return false;
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.Level), 1u);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Game.Entities
|
||||
base.RemoveFromWorld();
|
||||
}
|
||||
|
||||
public override bool Create(ulong guidlow, uint itemid, Player owner)
|
||||
public override bool Create(ulong guidlow, uint itemid, ItemContext context, Player owner)
|
||||
{
|
||||
var itemProto = Global.ObjectMgr.GetItemTemplate(itemid);
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace Game.Entities
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.MaxDurability), itemProto.MaxDurability);
|
||||
SetDurability(itemProto.MaxDurability);
|
||||
SetCount(1);
|
||||
SetContext(context);
|
||||
|
||||
// Setting the number of Slots the Container has
|
||||
SetBagSize(itemProto.GetContainerSlots());
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Game.Entities
|
||||
loot = new Loot();
|
||||
}
|
||||
|
||||
public virtual bool Create(ulong guidlow, uint itemid, Player owner)
|
||||
public virtual bool Create(ulong guidlow, uint itemid, ItemContext context, Player owner)
|
||||
{
|
||||
_Create(ObjectGuid.Create(HighGuid.Item, guidlow));
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace Game.Entities
|
||||
|
||||
SetExpiration(itemProto.GetDuration());
|
||||
SetCreatePlayedTime(0);
|
||||
SetContext(context);
|
||||
|
||||
if (itemProto.GetArtifactID() != 0)
|
||||
{
|
||||
@@ -442,7 +443,7 @@ namespace Game.Entities
|
||||
SetModifier(ItemModifier.BattlePetLevel, fields.Read<ushort>(14));
|
||||
SetModifier(ItemModifier.BattlePetDisplayId, fields.Read<uint>(16));
|
||||
|
||||
SetContext(fields.Read<byte>(17));
|
||||
SetContext((ItemContext)fields.Read<byte>(17));
|
||||
|
||||
var bonusListString = new StringArray(fields.Read<string>(18), ' ');
|
||||
List<uint> bonusListIDs = new List<uint>();
|
||||
@@ -1110,7 +1111,7 @@ namespace Game.Entities
|
||||
owner.SendPacket(itemTimeUpdate);
|
||||
}
|
||||
|
||||
public static Item CreateItem(uint item, uint count, Player player = null)
|
||||
public static Item CreateItem(uint item, uint count, ItemContext context, Player player = null)
|
||||
{
|
||||
if (count < 1)
|
||||
return null; //don't create item at zero count
|
||||
@@ -1122,7 +1123,7 @@ namespace Game.Entities
|
||||
count = pProto.GetMaxStackSize();
|
||||
|
||||
Item pItem = Bag.NewItemOrBag(pProto);
|
||||
if (pItem.Create(Global.ObjectMgr.GetGenerator(HighGuid.Item).Generate(), item, player))
|
||||
if (pItem.Create(Global.ObjectMgr.GetGenerator(HighGuid.Item).Generate(), item, context, player))
|
||||
{
|
||||
pItem.SetCount(count);
|
||||
return pItem;
|
||||
@@ -1134,7 +1135,7 @@ namespace Game.Entities
|
||||
|
||||
public Item CloneItem(uint count, Player player = null)
|
||||
{
|
||||
Item newItem = CreateItem(GetEntry(), count, player);
|
||||
Item newItem = CreateItem(GetEntry(), count, GetContext(), player);
|
||||
if (newItem == null)
|
||||
return null;
|
||||
|
||||
@@ -1802,7 +1803,7 @@ namespace Game.Entities
|
||||
loot_item.is_underthreshold = item_result.Read<bool>(6);
|
||||
loot_item.needs_quest = item_result.Read<bool>(7);
|
||||
loot_item.randomBonusListId = item_result.Read<uint>(8);
|
||||
loot_item.context = item_result.Read<byte>(9);
|
||||
loot_item.context = (ItemContext)item_result.Read<byte>(9);
|
||||
|
||||
StringArray bonusLists = new StringArray(item_result.Read<string>(10), ' ');
|
||||
if (!bonusLists.IsEmpty())
|
||||
@@ -2358,7 +2359,9 @@ namespace Game.Entities
|
||||
SetState(ItemUpdateState.Changed, owner);
|
||||
}
|
||||
|
||||
public void SetContext(int context) { SetUpdateFieldValue(m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.Context), context); }
|
||||
public ItemContext GetContext() { return (ItemContext)(int)m_itemData.Context; }
|
||||
public void SetContext(ItemContext context) { SetUpdateFieldValue(m_values.ModifyValue(m_itemData).ModifyValue(m_itemData.Context), (int)context); }
|
||||
|
||||
public void SetPetitionId(uint petitionId)
|
||||
{
|
||||
SetUpdateFieldValue(m_itemData.ModifyValue(m_itemData.Enchantment, 0).ModifyValue((ItemEnchantment itemEnchantment) => itemEnchantment.ID), petitionId);
|
||||
|
||||
@@ -1089,7 +1089,7 @@ namespace Game.Entities
|
||||
uint randomBonusListId = result.Read<uint>(4);
|
||||
uint fixedScalingLevel = result.Read<uint>(5);
|
||||
uint artifactKnowledgeLevel = result.Read<uint>(6);
|
||||
byte context = result.Read<byte>(7);
|
||||
ItemContext context = (ItemContext)result.Read<byte>(7);
|
||||
List<uint> bonusListIDs = new List<uint>();
|
||||
var bonusListIdTokens = new StringArray(result.Read<string>(8), ' ');
|
||||
for (var i = 0; i < bonusListIdTokens.Length; ++i)
|
||||
@@ -2266,7 +2266,7 @@ namespace Game.Entities
|
||||
stmt.AddValue(5, (byte)_voidStorageItems[i].RandomBonusListId);
|
||||
stmt.AddValue(6, _voidStorageItems[i].FixedScalingLevel);
|
||||
stmt.AddValue(7, _voidStorageItems[i].ArtifactKnowledgeLevel);
|
||||
stmt.AddValue(8, _voidStorageItems[i].Context);
|
||||
stmt.AddValue(8, (byte)_voidStorageItems[i].Context);
|
||||
|
||||
StringBuilder bonusListIDs = new StringBuilder();
|
||||
foreach (uint bonusListID in _voidStorageItems[i].BonusListIDs)
|
||||
|
||||
@@ -445,7 +445,7 @@ namespace Game.Entities
|
||||
|
||||
public class VoidStorageItem
|
||||
{
|
||||
public VoidStorageItem(ulong id, uint entry, ObjectGuid creator, uint randomBonusListId, uint fixedScalingLevel, uint artifactKnowledgeLevel, byte context, List<uint> bonuses)
|
||||
public VoidStorageItem(ulong id, uint entry, ObjectGuid creator, uint randomBonusListId, uint fixedScalingLevel, uint artifactKnowledgeLevel, ItemContext context, List<uint> bonuses)
|
||||
{
|
||||
ItemId = id;
|
||||
ItemEntry = entry;
|
||||
@@ -465,7 +465,7 @@ namespace Game.Entities
|
||||
public uint RandomBonusListId;
|
||||
public uint FixedScalingLevel;
|
||||
public uint ArtifactKnowledgeLevel;
|
||||
public byte Context;
|
||||
public ItemContext Context;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
}
|
||||
|
||||
|
||||
@@ -1238,7 +1238,7 @@ namespace Game.Entities
|
||||
if (msg != InventoryResult.Ok)
|
||||
break;
|
||||
|
||||
EquipNewItem(eDest, titem_id, true);
|
||||
EquipNewItem(eDest, titem_id, ItemContext.None, true);
|
||||
AutoUnequipOffhandIfNeed();
|
||||
titem_amount--;
|
||||
}
|
||||
@@ -1260,13 +1260,13 @@ namespace Game.Entities
|
||||
Log.outError(LogFilter.Player, "STORAGE: Can't equip or store initial item {0} for race {1} class {2}, error msg = {3}", titem_id, GetRace(), GetClass(), msg);
|
||||
return false;
|
||||
}
|
||||
public Item StoreNewItem(List<ItemPosCount> pos, uint itemId, bool update, uint randomPropertyId = 0, List<ObjectGuid> allowedLooters = null, byte context = 0, List<uint> bonusListIDs = null, bool addToCollection = true)
|
||||
public Item StoreNewItem(List<ItemPosCount> pos, uint itemId, bool update, uint randomPropertyId = 0, List<ObjectGuid> allowedLooters = null, ItemContext context = 0, List<uint> bonusListIDs = null, bool addToCollection = true)
|
||||
{
|
||||
uint count = 0;
|
||||
foreach (var itemPosCount in pos)
|
||||
count += itemPosCount.count;
|
||||
|
||||
Item item = Item.CreateItem(itemId, count, this);
|
||||
Item item = Item.CreateItem(itemId, count, context, this);
|
||||
if (item != null)
|
||||
{
|
||||
ItemAddedQuestCheck(itemId, count);
|
||||
@@ -1275,7 +1275,6 @@ namespace Game.Entities
|
||||
|
||||
item.AddItemFlag(ItemFieldFlags.NewItem);
|
||||
|
||||
item.SetContext(context);
|
||||
item.SetBonuses(bonusListIDs);
|
||||
|
||||
item = StoreItem(pos, item, update);
|
||||
@@ -1598,9 +1597,9 @@ namespace Game.Entities
|
||||
// not found req. item count and have unequippable items
|
||||
return res;
|
||||
}
|
||||
Item EquipNewItem(ushort pos, uint item, bool update)
|
||||
Item EquipNewItem(ushort pos, uint item, ItemContext context, bool update)
|
||||
{
|
||||
Item pItem = Item.CreateItem(item, 1, this);
|
||||
Item pItem = Item.CreateItem(item, 1, context, this);
|
||||
if (pItem != null)
|
||||
{
|
||||
ItemAddedQuestCheck(item, 1);
|
||||
@@ -2509,7 +2508,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(item), null, 0, crItem.BonusListIDs, false) : EquipNewItem(uiDest, item, true);
|
||||
Item it = bStore ? StoreNewItem(vDest, item, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(item), null, ItemContext.Vendor, crItem.BonusListIDs, false) : EquipNewItem(uiDest, item, ItemContext.Vendor, true);
|
||||
if (it != null)
|
||||
{
|
||||
uint new_count = pVendor.UpdateVendorItemCurrentCount(crItem, count);
|
||||
@@ -3831,13 +3830,13 @@ namespace Game.Entities
|
||||
return max_personal_rating;
|
||||
}
|
||||
|
||||
public void SendItemRetrievalMail(uint itemEntry, uint count)
|
||||
public void SendItemRetrievalMail(uint itemEntry, uint count, ItemContext context)
|
||||
{
|
||||
MailSender sender = new MailSender(MailMessageType.Creature, 34337);
|
||||
MailDraft draft = new MailDraft("Recovered Item", "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed."); // This is the text used in Cataclysm, it probably wasn't changed.
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
Item item = Item.CreateItem(itemEntry, count, null);
|
||||
Item item = Item.CreateItem(itemEntry, count, context, null);
|
||||
if (item)
|
||||
{
|
||||
item.SaveToDB(trans);
|
||||
@@ -5090,7 +5089,7 @@ namespace Game.Entities
|
||||
InventoryResult CanEquipNewItem(byte slot, out ushort dest, uint item, bool swap)
|
||||
{
|
||||
dest = 0;
|
||||
Item pItem = Item.CreateItem(item, 1, this);
|
||||
Item pItem = Item.CreateItem(item, 1, ItemContext.None, this);
|
||||
if (pItem != null)
|
||||
{
|
||||
InventoryResult result = CanEquipItem(slot, out dest, pItem, swap);
|
||||
@@ -6065,11 +6064,11 @@ namespace Game.Entities
|
||||
pItem.SetState(ItemUpdateState.Changed, this);
|
||||
}
|
||||
}
|
||||
public void AutoStoreLoot(uint loot_id, LootStore store, bool broadcast = false) { AutoStoreLoot(ItemConst.NullBag, ItemConst.NullSlot, loot_id, store, broadcast); }
|
||||
void AutoStoreLoot(byte bag, byte slot, uint loot_id, LootStore store, bool broadcast = false)
|
||||
public void AutoStoreLoot(uint loot_id, LootStore store, ItemContext context = 0, bool broadcast = false) { AutoStoreLoot(ItemConst.NullBag, ItemConst.NullSlot, loot_id, store, context, broadcast); }
|
||||
void AutoStoreLoot(byte bag, byte slot, uint loot_id, LootStore store, ItemContext context = 0, bool broadcast = false)
|
||||
{
|
||||
Loot loot = new Loot();
|
||||
loot.FillLoot(loot_id, store, this, true);
|
||||
loot.FillLoot(loot_id, store, this, true, false, LootModes.Default, context);
|
||||
|
||||
uint max_slot = loot.GetMaxSlotInLootFor(this);
|
||||
for (uint i = 0; i < max_slot; ++i)
|
||||
@@ -6351,7 +6350,7 @@ namespace Game.Entities
|
||||
if (groupRules)
|
||||
group.UpdateLooterGuid(go, true);
|
||||
|
||||
loot.FillLoot(lootid, LootStorage.Gameobject, this, !groupRules, false, go.GetLootMode());
|
||||
loot.FillLoot(lootid, LootStorage.Gameobject, this, !groupRules, false, go.GetLootMode(), GetMap().GetDifficultyLootItemContext());
|
||||
go.SetLootGenerationTime();
|
||||
|
||||
// get next RR player (for next loot)
|
||||
|
||||
@@ -995,7 +995,7 @@ namespace Game.Entities
|
||||
SendNewItem(item, quest.RewardItemCount[i], true, false);
|
||||
}
|
||||
else if (quest.IsDFQuest())
|
||||
SendItemRetrievalMail(quest.RewardItemId[i], quest.RewardItemCount[i]);
|
||||
SendItemRetrievalMail(quest.RewardItemId[i], quest.RewardItemCount[i], ItemContext.QuestReward);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1477,7 +1477,7 @@ namespace Game.Entities
|
||||
loot.Clear();
|
||||
uint lootid = creature.GetCreatureTemplate().LootId;
|
||||
if (lootid != 0)
|
||||
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode());
|
||||
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode(), GetMap().GetDifficultyLootItemContext());
|
||||
|
||||
if (creature.GetLootMode() > 0)
|
||||
loot.GenerateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
|
||||
|
||||
@@ -1269,7 +1269,7 @@ namespace Game.Groups
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, roll.itemid, item.count);
|
||||
if (msg == InventoryResult.Ok)
|
||||
player.AutoStoreLoot(disenchant.Id, LootStorage.Disenchant, true);
|
||||
player.AutoStoreLoot(disenchant.Id, LootStorage.Disenchant, ItemContext.None, true);
|
||||
else // If the player's inventory is full, send the disenchant result in a mail.
|
||||
{
|
||||
Loot loot = new Loot();
|
||||
@@ -1280,7 +1280,7 @@ namespace Game.Groups
|
||||
{
|
||||
LootItem lootItem = loot.LootItemInSlot(i, player);
|
||||
player.SendEquipError(msg, null, null, lootItem.itemid);
|
||||
player.SendItemRetrievalMail(lootItem.itemid, lootItem.count);
|
||||
player.SendItemRetrievalMail(lootItem.itemid, lootItem.count, lootItem.context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ namespace Game
|
||||
}
|
||||
|
||||
Item bodyItem = new Item(); // This is not bag and then can be used new Item.
|
||||
if (!bodyItem.Create(Global.ObjectMgr.GetGenerator(HighGuid.Item).Generate(), 8383, player))
|
||||
if (!bodyItem.Create(Global.ObjectMgr.GetGenerator(HighGuid.Item).Generate(), 8383, ItemContext.None, player))
|
||||
return;
|
||||
|
||||
// in mail template case we need create new item text
|
||||
|
||||
@@ -696,7 +696,7 @@ namespace Game
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
if (_player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.Id, (uint)item.Quantity) == InventoryResult.Ok)
|
||||
{
|
||||
Item newItem = _player.StoreNewItem(dest, item.Id, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(item.Id), null, 0, item.BonusListIDs);
|
||||
Item newItem = _player.StoreNewItem(dest, item.Id, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(item.Id), null, ItemContext.QuestReward, item.BonusListIDs);
|
||||
_player.SendNewItem(newItem, (uint)item.Quantity, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Game
|
||||
|
||||
VoidStorageItem itemVS = new VoidStorageItem(Global.ObjectMgr.GenerateVoidStorageItemId(), item.GetEntry(), item.GetCreator(),
|
||||
item.GetItemRandomBonusListId(), item.GetModifier(ItemModifier.TimewalkerLevel), item.GetModifier(ItemModifier.ArtifactKnowledgeLevel),
|
||||
(byte)item.m_itemData.Context, item.m_itemData.BonusListIDs);
|
||||
item.GetContext(), item.m_itemData.BonusListIDs);
|
||||
|
||||
VoidItem voidItem;
|
||||
voidItem.Guid = ObjectGuid.Create(HighGuid.Item, itemVS.ItemId);
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Game.Loots
|
||||
public uint itemid;
|
||||
public uint randomBonusListId;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
public byte context;
|
||||
public ItemContext context;
|
||||
public List<Condition> conditions = new List<Condition>(); // additional loot condition
|
||||
public List<ObjectGuid> allowedGUIDs = new List<ObjectGuid>();
|
||||
public ObjectGuid rollWinnerGUID; // Stores the guid of person who won loot, if his bags are full only he can see the item in loot list!
|
||||
@@ -198,7 +198,7 @@ namespace Game.Loots
|
||||
}
|
||||
|
||||
// Calls processor of corresponding LootTemplate (which handles everything including references)
|
||||
public bool FillLoot(uint lootId, LootStore store, Player lootOwner, bool personal, bool noEmptyError = false, LootModes lootMode = LootModes.Default)
|
||||
public bool FillLoot(uint lootId, LootStore store, Player lootOwner, bool personal, bool noEmptyError = false, LootModes lootMode = LootModes.Default, ItemContext context = 0)
|
||||
{
|
||||
// Must be provided
|
||||
if (lootOwner == null)
|
||||
@@ -212,7 +212,7 @@ namespace Game.Loots
|
||||
return false;
|
||||
}
|
||||
|
||||
_itemContext = (byte)lootOwner.GetMap().GetDifficultyLootItemContext();
|
||||
_itemContext = context;
|
||||
|
||||
tab.Process(this, store.IsRatesAllowed(), (byte)lootMode); // Processing is done there, callback via Loot.AddItem()
|
||||
|
||||
@@ -866,7 +866,7 @@ namespace Game.Loots
|
||||
|
||||
// Loot GUID
|
||||
ObjectGuid _GUID;
|
||||
byte _itemContext;
|
||||
ItemContext _itemContext;
|
||||
}
|
||||
|
||||
public class AELootResult
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Game.Mails
|
||||
Loot mailLoot = new Loot();
|
||||
|
||||
// can be empty
|
||||
mailLoot.FillLoot(m_mailTemplateId, LootStorage.Mail, receiver, true, true);
|
||||
mailLoot.FillLoot(m_mailTemplateId, LootStorage.Mail, receiver, true, true, LootModes.Default, ItemContext.None);
|
||||
|
||||
uint max_slot = mailLoot.GetMaxSlotInLootFor(receiver);
|
||||
for (uint i = 0; m_items.Count < SharedConst.MaxMailItems && i < max_slot; ++i)
|
||||
@@ -67,7 +67,7 @@ namespace Game.Mails
|
||||
LootItem lootitem = mailLoot.LootItemInSlot(i, receiver);
|
||||
if (lootitem != null)
|
||||
{
|
||||
Item item = Item.CreateItem(lootitem.itemid, lootitem.count, receiver);
|
||||
Item item = Item.CreateItem(lootitem.itemid, lootitem.count, lootitem.context, receiver);
|
||||
if (item != null)
|
||||
{
|
||||
item.SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
|
||||
@@ -3017,17 +3017,17 @@ namespace Game.Maps
|
||||
return Global.DB2Mgr.GetMapDifficultyData(GetId(), GetDifficultyID());
|
||||
}
|
||||
|
||||
public int GetDifficultyLootItemContext()
|
||||
public ItemContext GetDifficultyLootItemContext()
|
||||
{
|
||||
MapDifficultyRecord mapDifficulty = GetMapDifficulty();
|
||||
if (mapDifficulty != null && mapDifficulty.ItemContext != 0)
|
||||
return mapDifficulty.ItemContext;
|
||||
return (ItemContext)mapDifficulty.ItemContext;
|
||||
|
||||
DifficultyRecord difficulty = CliDB.DifficultyStorage.LookupByKey(GetDifficultyID());
|
||||
if (difficulty != null)
|
||||
return difficulty.ItemContext;
|
||||
return (ItemContext)difficulty.ItemContext;
|
||||
|
||||
return 0;
|
||||
return ItemContext.None;
|
||||
}
|
||||
|
||||
public uint GetId()
|
||||
|
||||
@@ -682,7 +682,7 @@ namespace Game.Network.Packets
|
||||
{
|
||||
public void Write(WorldPacket data)
|
||||
{
|
||||
data.WriteUInt8(Context);
|
||||
data.WriteUInt8((byte)Context);
|
||||
data.WriteInt32(BonusListIDs.Count);
|
||||
foreach (uint bonusID in BonusListIDs)
|
||||
data.WriteUInt32(bonusID);
|
||||
@@ -690,7 +690,7 @@ namespace Game.Network.Packets
|
||||
|
||||
public void Read(WorldPacket data)
|
||||
{
|
||||
Context = data.ReadUInt8();
|
||||
Context = (ItemContext)data.ReadUInt8();
|
||||
uint bonusListIdSize = data.ReadUInt32();
|
||||
|
||||
BonusListIDs = new List<uint>();
|
||||
@@ -730,7 +730,7 @@ namespace Game.Network.Packets
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public byte Context;
|
||||
public ItemContext Context;
|
||||
public List<uint> BonusListIDs = new List<uint>();
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ namespace Game.Network.Packets
|
||||
{
|
||||
ItemBonus.HasValue = true;
|
||||
ItemBonus.Value.BonusListIDs.AddRange(bonusListIds);
|
||||
ItemBonus.Value.Context = (byte)item.m_itemData.Context;
|
||||
ItemBonus.Value.Context = item.GetContext();
|
||||
}
|
||||
|
||||
uint mask = item.m_itemData.ModifiersMask;
|
||||
@@ -802,7 +802,7 @@ namespace Game.Network.Packets
|
||||
ItemID = gem.ItemId;
|
||||
|
||||
ItemBonusInstanceData bonus = new ItemBonusInstanceData();
|
||||
bonus.Context = gem.Context;
|
||||
bonus.Context = (ItemContext)(byte)gem.Context;
|
||||
foreach (ushort bonusListId in gem.BonusListIDs)
|
||||
if (bonusListId != 0)
|
||||
bonus.BonusListIDs.Add(bonusListId);
|
||||
|
||||
@@ -734,7 +734,7 @@ namespace Game.Scripting
|
||||
public Item GetCastItem() { return m_spell.m_CastItem; }
|
||||
|
||||
// Creates item. Calls Spell.DoCreateItem method.
|
||||
public void CreateItem(uint effIndex, uint itemId) { m_spell.DoCreateItem(effIndex, itemId); }
|
||||
public void CreateItem(uint effIndex, uint itemId, ItemContext context) { m_spell.DoCreateItem(effIndex, itemId, context); }
|
||||
|
||||
// Returns SpellInfo from the spell that triggered the current one
|
||||
public SpellInfo GetTriggeringSpell() { return m_spell.m_triggeredByAuraSpell; }
|
||||
|
||||
@@ -5031,7 +5031,7 @@ namespace Game.Spells
|
||||
if (creature.GetCreatureTemplate().SkinLootId == 0)
|
||||
return;
|
||||
|
||||
player.AutoStoreLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, true);
|
||||
player.AutoStoreLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, ItemContext.None, true);
|
||||
|
||||
creature.DespawnOrUnsummon();
|
||||
}
|
||||
|
||||
@@ -1042,7 +1042,7 @@ namespace Game.Spells
|
||||
}
|
||||
}
|
||||
|
||||
public void DoCreateItem(uint i, uint itemtype, byte context = 0, List<uint> bonusListIds = null)
|
||||
public void DoCreateItem(uint i, uint itemtype, ItemContext context = 0, List<uint> bonusListIds = null)
|
||||
{
|
||||
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
|
||||
return;
|
||||
@@ -1146,7 +1146,7 @@ namespace Game.Spells
|
||||
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
|
||||
return;
|
||||
|
||||
DoCreateItem(effIndex, effectInfo.ItemType);
|
||||
DoCreateItem(effIndex, effectInfo.ItemType, m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None);
|
||||
ExecuteLogEffectCreateItem(effIndex, effectInfo.ItemType);
|
||||
}
|
||||
|
||||
@@ -1162,9 +1162,10 @@ namespace Game.Spells
|
||||
Player player = unitTarget.ToPlayer();
|
||||
|
||||
uint item_id = effectInfo.ItemType;
|
||||
ItemContext context = m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None;
|
||||
|
||||
if (item_id != 0)
|
||||
DoCreateItem(effIndex, item_id);
|
||||
DoCreateItem(effIndex, item_id, context);
|
||||
|
||||
// special case: fake item replaced by generate using spell_loot_template
|
||||
if (m_spellInfo.IsLootCrafting())
|
||||
@@ -1179,10 +1180,10 @@ namespace Game.Spells
|
||||
player.DestroyItemCount(item_id, count, true);
|
||||
|
||||
// create some random items
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell);
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell, context);
|
||||
}
|
||||
else
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell); // create some random items
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell, context); // create some random items
|
||||
|
||||
player.UpdateCraftSkill(m_spellInfo.Id);
|
||||
}
|
||||
@@ -1200,7 +1201,7 @@ namespace Game.Spells
|
||||
Player player = unitTarget.ToPlayer();
|
||||
|
||||
// create some random items
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell);
|
||||
player.AutoStoreLoot(m_spellInfo.Id, LootStorage.Spell, m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None);
|
||||
// @todo ExecuteLogEffectCreateItem(i, GetEffect(i].ItemType);
|
||||
}
|
||||
|
||||
@@ -1511,7 +1512,7 @@ namespace Game.Spells
|
||||
|
||||
ushort pos = m_CastItem.GetPos();
|
||||
|
||||
Item pNewItem = Item.CreateItem(newitemid, 1, player);
|
||||
Item pNewItem = Item.CreateItem(newitemid, 1, m_CastItem.GetContext(), player);
|
||||
if (pNewItem == null)
|
||||
return;
|
||||
|
||||
@@ -2112,7 +2113,7 @@ namespace Game.Spells
|
||||
player.DestroyItemCount(itemTarget, ref count, true);
|
||||
unitTarget = player;
|
||||
// and add a scroll
|
||||
DoCreateItem(effIndex, effectInfo.ItemType);
|
||||
DoCreateItem(effIndex, effectInfo.ItemType, m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None);
|
||||
itemTarget = null;
|
||||
m_targets.SetItemTarget(null);
|
||||
}
|
||||
@@ -5497,7 +5498,7 @@ namespace Game.Spells
|
||||
List<uint> bonusList = new List<uint>();
|
||||
bonusList.Add(collectionMgr.GetHeirloomBonus(m_misc.Data0));
|
||||
|
||||
DoCreateItem(effIndex, m_misc.Data0, 0, bonusList);
|
||||
DoCreateItem(effIndex, m_misc.Data0, ItemContext.None, bonusList);
|
||||
ExecuteLogEffectCreateItem(effIndex, m_misc.Data0);
|
||||
}
|
||||
|
||||
|
||||
@@ -2703,7 +2703,7 @@ namespace Scripts.Spells.Generic
|
||||
return;
|
||||
}
|
||||
|
||||
CreateItem(effIndex, itemId[RandomHelper.URand(0, 4)]);
|
||||
CreateItem(effIndex, itemId[RandomHelper.URand(0, 4)], ItemContext.None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1345,7 +1345,7 @@ namespace Scripts.Spells.Items
|
||||
return;
|
||||
}
|
||||
|
||||
CreateItem(effIndex, newitemid);
|
||||
CreateItem(effIndex, newitemid, ItemContext.None);
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
|
||||
Reference in New Issue
Block a user