Core/Loot: Implemented currency loot
Port From (https://github.com/TrinityCore/TrinityCore/commit/3e28ee080a1cf3c7cd332a8d1e0808505b4ea9d4)
This commit is contained in:
@@ -6066,55 +6066,64 @@ namespace Game.Entities
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
|
||||
if (msg == InventoryResult.Ok)
|
||||
switch (item.type)
|
||||
{
|
||||
Item newitem = StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context);
|
||||
if (ffaItem != null)
|
||||
{
|
||||
//freeforall case, notify only one player of the removal
|
||||
ffaItem.is_looted = true;
|
||||
SendNotifyLootItemRemoved(loot.GetGUID(), loot.GetOwnerGUID(), lootSlot);
|
||||
}
|
||||
else //not freeforall, notify everyone
|
||||
loot.NotifyItemRemoved(lootSlot, GetMap());
|
||||
case LootItemType.Item:
|
||||
List<ItemPosCount> dest = new();
|
||||
InventoryResult msg = CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
|
||||
if (msg != InventoryResult.Ok)
|
||||
{
|
||||
SendEquipError(msg, null, null, item.itemid);
|
||||
return;
|
||||
}
|
||||
|
||||
//if only one person is supposed to loot the item, then set it to looted
|
||||
if (!item.freeforall)
|
||||
item.is_looted = true;
|
||||
Item newitem = StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context);
|
||||
if (newitem != null && (newitem.GetQuality() > ItemQuality.Epic || (newitem.GetQuality() == ItemQuality.Epic && newitem.GetItemLevel(this) >= GuildConst.MinNewsItemLevel)))
|
||||
{
|
||||
Guild guild = GetGuild();
|
||||
if (guild != null)
|
||||
guild.AddGuildNews(GuildNews.ItemLooted, GetGUID(), 0, item.itemid);
|
||||
}
|
||||
|
||||
--loot.unlootedCount;
|
||||
// if aeLooting then we must delay sending out item so that it appears properly stacked in chat
|
||||
if (aeResult == null || newitem == null)
|
||||
{
|
||||
SendNewItem(newitem, item.count, false, false, true, loot.GetDungeonEncounterId());
|
||||
UpdateCriteria(CriteriaType.LootItem, item.itemid, item.count);
|
||||
UpdateCriteria(CriteriaType.GetLootByType, item.itemid, item.count, (uint)SharedConst.GetLootTypeForClient(loot.loot_type));
|
||||
UpdateCriteria(CriteriaType.LootAnyItem, item.itemid, item.count);
|
||||
}
|
||||
else
|
||||
aeResult.Add(newitem, (byte)item.count, SharedConst.GetLootTypeForClient(loot.loot_type), loot.GetDungeonEncounterId());
|
||||
|
||||
if (newitem != null && (newitem.GetQuality() > ItemQuality.Epic || (newitem.GetQuality() == ItemQuality.Epic && newitem.GetItemLevel(this) >= GuildConst.MinNewsItemLevel)))
|
||||
{
|
||||
Guild guild = GetGuild();
|
||||
if (guild != null)
|
||||
guild.AddGuildNews(GuildNews.ItemLooted, GetGUID(), 0, item.itemid);
|
||||
}
|
||||
|
||||
// if aeLooting then we must delay sending out item so that it appears properly stacked in chat
|
||||
if (aeResult == null || newitem == null)
|
||||
{
|
||||
SendNewItem(newitem, item.count, false, false, true, loot.GetDungeonEncounterId());
|
||||
UpdateCriteria(CriteriaType.LootItem, item.itemid, item.count);
|
||||
UpdateCriteria(CriteriaType.GetLootByType, item.itemid, item.count, (uint)SharedConst.GetLootTypeForClient(loot.loot_type));
|
||||
UpdateCriteria(CriteriaType.LootAnyItem, item.itemid, item.count);
|
||||
}
|
||||
else
|
||||
aeResult.Add(newitem, item.count, SharedConst.GetLootTypeForClient(loot.loot_type), loot.GetDungeonEncounterId());
|
||||
|
||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||
if (loot.loot_type == LootType.Item)
|
||||
Global.LootItemStorage.RemoveStoredLootItemForContainer(lootWorldObjectGuid.GetCounter(), item.itemid, item.count, item.LootListId);
|
||||
|
||||
if (newitem != null)
|
||||
ApplyItemLootedSpell(newitem, true);
|
||||
else
|
||||
ApplyItemLootedSpell(Global.ObjectMgr.GetItemTemplate(item.itemid));
|
||||
if (newitem != null)
|
||||
ApplyItemLootedSpell(newitem, true);
|
||||
else
|
||||
ApplyItemLootedSpell(Global.ObjectMgr.GetItemTemplate(item.itemid));
|
||||
break;
|
||||
case LootItemType.Currency:
|
||||
ModifyCurrency(item.itemid, (int)item.count, CurrencyGainSource.Loot);
|
||||
break;
|
||||
}
|
||||
else
|
||||
SendEquipError(msg, null, null, item.itemid);
|
||||
|
||||
if (ffaItem != null)
|
||||
{
|
||||
//freeforall case, notify only one player of the removal
|
||||
ffaItem.is_looted = true;
|
||||
SendNotifyLootItemRemoved(loot.GetGUID(), loot.GetOwnerGUID(), lootSlot);
|
||||
}
|
||||
else //not freeforall, notify everyone
|
||||
loot.NotifyItemRemoved(lootSlot, GetMap());
|
||||
|
||||
//if only one person is supposed to loot the item, then set it to looted
|
||||
if (!item.freeforall)
|
||||
item.is_looted = true;
|
||||
|
||||
--loot.unlootedCount;
|
||||
|
||||
// LootItem is being removed (looted) from the container, delete it from the DB.
|
||||
if (loot.loot_type == LootType.Item)
|
||||
Global.LootItemStorage.RemoveStoredLootItemForContainer(lootWorldObjectGuid.GetCounter(), item.type, item.itemid, item.count, item.LootListId);
|
||||
}
|
||||
|
||||
public Dictionary<ObjectGuid, Loot> GetAELootView() { return m_AELootView; }
|
||||
|
||||
@@ -2873,6 +2873,39 @@ namespace Game.Entities
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool HasQuestForCurrency(uint currencyId)
|
||||
{
|
||||
bool isCompletableObjective(QuestObjectiveStatusData objectiveStatus)
|
||||
{
|
||||
Quest qInfo = Global.ObjectMgr.GetQuestTemplate(objectiveStatus.QuestStatusPair.QuestID);
|
||||
QuestObjective objective = Global.ObjectMgr.GetQuestObjective(objectiveStatus.ObjectiveId);
|
||||
if (qInfo == null || objective == null || !IsQuestObjectiveCompletable(objectiveStatus.QuestStatusPair.Status.Slot, qInfo, objective))
|
||||
return false;
|
||||
|
||||
// hide quest if player is in raid-group and quest is no raid quest
|
||||
if (GetGroup() != null && GetGroup().IsRaidGroup() && !qInfo.IsAllowedInRaid(GetMap().GetDifficultyID()))
|
||||
if (!InBattleground()) //there are two ways.. we can make every bg-quest a raidquest, or add this code here.. i don't know if this can be exploited by other quests, but i think all other quests depend on a specific area.. but keep this in mind, if something strange happens later
|
||||
return false;
|
||||
|
||||
if (!IsQuestObjectiveComplete(objectiveStatus.QuestStatusPair.Status.Slot, qInfo, objective))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bool hasObjectiveTypeForCurrency(QuestObjectiveType type) => m_questObjectiveStatus.LookupByKey((type, currencyId)).Any(isCompletableObjective);
|
||||
if (hasObjectiveTypeForCurrency(QuestObjectiveType.Currency))
|
||||
return true;
|
||||
|
||||
if (hasObjectiveTypeForCurrency(QuestObjectiveType.HaveCurrency))
|
||||
return true;
|
||||
|
||||
if (hasObjectiveTypeForCurrency(QuestObjectiveType.ObtainCurrency))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int GetQuestObjectiveData(QuestObjective objective)
|
||||
{
|
||||
ushort slot = FindQuestSlot(objective.QuestID);
|
||||
|
||||
Reference in New Issue
Block a user