Core/Loot: Store method used at loot generation inside Loot object
Port From (https://github.com/TrinityCore/TrinityCore/commit/9700b2a78680452d80025121a031da340af51348)
This commit is contained in:
@@ -5883,7 +5883,7 @@ namespace Game.Entities
|
|||||||
public void AutoStoreLoot(uint loot_id, LootStore store, ItemContext context = 0, bool broadcast = false, bool createdByPlayer = false) { AutoStoreLoot(ItemConst.NullBag, ItemConst.NullSlot, loot_id, store, context, broadcast); }
|
public void AutoStoreLoot(uint loot_id, LootStore store, ItemContext context = 0, bool broadcast = false, bool createdByPlayer = 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, bool createdByPlayer = false)
|
void AutoStoreLoot(byte bag, byte slot, uint loot_id, LootStore store, ItemContext context = 0, bool broadcast = false, bool createdByPlayer = false)
|
||||||
{
|
{
|
||||||
Loot loot = new(null, ObjectGuid.Empty, LootType.None);
|
Loot loot = new(null, ObjectGuid.Empty, LootType.None, LootMethod.FreeForAll);
|
||||||
loot.FillLoot(loot_id, store, this, true, false, LootModes.Default, context);
|
loot.FillLoot(loot_id, store, this, true, false, LootModes.Default, context);
|
||||||
|
|
||||||
uint max_slot = loot.GetMaxSlotInLootFor(this);
|
uint max_slot = loot.GetMaxSlotInLootFor(this);
|
||||||
@@ -6092,7 +6092,7 @@ namespace Game.Entities
|
|||||||
// Now we must make bones lootable, and send player loot
|
// Now we must make bones lootable, and send player loot
|
||||||
bones.SetCorpseDynamicFlag(CorpseDynFlags.Lootable);
|
bones.SetCorpseDynamicFlag(CorpseDynFlags.Lootable);
|
||||||
|
|
||||||
bones.loot = new Loot(GetMap(), bones.GetGUID(), LootType.Insignia);
|
bones.loot = new Loot(GetMap(), bones.GetGUID(), LootType.Insignia, looterPlr.GetGroup() != null ? looterPlr.GetGroup().GetLootMethod() : LootMethod.FreeForAll);
|
||||||
|
|
||||||
// For AV Achievement
|
// For AV Achievement
|
||||||
Battleground bg = GetBattleground();
|
Battleground bg = GetBattleground();
|
||||||
@@ -6189,7 +6189,10 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loot = new Loot(GetMap(), guid, loot_type);
|
Group group = GetGroup();
|
||||||
|
bool groupRules = (group != null && go.GetGoInfo().type == GameObjectTypes.Chest && go.GetGoInfo().Chest.usegrouplootrules != 0);
|
||||||
|
|
||||||
|
loot = new Loot(GetMap(), guid, loot_type, groupRules ? group.GetLootMethod() : LootMethod.FreeForAll);
|
||||||
if (go.GetMap().Is25ManRaid())
|
if (go.GetMap().Is25ManRaid())
|
||||||
loot.maxDuplicates = 3;
|
loot.maxDuplicates = 3;
|
||||||
|
|
||||||
@@ -6197,9 +6200,6 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (lootid != 0)
|
if (lootid != 0)
|
||||||
{
|
{
|
||||||
Group group = GetGroup();
|
|
||||||
bool groupRules = (group && go.GetGoInfo().type == GameObjectTypes.Chest && go.GetGoInfo().Chest.usegrouplootrules != 0);
|
|
||||||
|
|
||||||
// check current RR player and get next if necessary
|
// check current RR player and get next if necessary
|
||||||
if (groupRules)
|
if (groupRules)
|
||||||
group.UpdateLooterGuid(go, true);
|
group.UpdateLooterGuid(go, true);
|
||||||
@@ -6226,21 +6226,17 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (go.GetGoInfo().type == GameObjectTypes.Chest && go.GetGoInfo().Chest.usegrouplootrules != 0)
|
if (go.GetGoInfo().type == GameObjectTypes.Chest && go.GetGoInfo().Chest.usegrouplootrules != 0)
|
||||||
{
|
{
|
||||||
var group = GetGroup();
|
switch (group.GetLootMethod())
|
||||||
if (group)
|
|
||||||
{
|
{
|
||||||
switch (group.GetLootMethod())
|
case LootMethod.GroupLoot:
|
||||||
{
|
// GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
|
||||||
case LootMethod.GroupLoot:
|
group.GroupLoot(loot, go);
|
||||||
// GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
|
break;
|
||||||
group.GroupLoot(loot, go);
|
case LootMethod.MasterLoot:
|
||||||
break;
|
group.MasterLoot(loot, go);
|
||||||
case LootMethod.MasterLoot:
|
break;
|
||||||
group.MasterLoot(loot, go);
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6252,10 +6248,10 @@ namespace Game.Entities
|
|||||||
Group group = GetGroup();
|
Group group = GetGroup();
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
switch (group.GetLootMethod())
|
switch (loot.GetLootMethod())
|
||||||
{
|
{
|
||||||
case LootMethod.MasterLoot:
|
case LootMethod.MasterLoot:
|
||||||
permission = PermissionTypes.Master;
|
permission = group.GetMasterLooterGuid() == GetGUID() ? PermissionTypes.Master : PermissionTypes.Restricted;
|
||||||
break;
|
break;
|
||||||
case LootMethod.FreeForAll:
|
case LootMethod.FreeForAll:
|
||||||
permission = PermissionTypes.All;
|
permission = PermissionTypes.All;
|
||||||
@@ -6288,7 +6284,7 @@ namespace Game.Entities
|
|||||||
if (!item.m_lootGenerated && !Global.LootItemStorage.LoadStoredLoot(item, this))
|
if (!item.m_lootGenerated && !Global.LootItemStorage.LoadStoredLoot(item, this))
|
||||||
{
|
{
|
||||||
item.m_lootGenerated = true;
|
item.m_lootGenerated = true;
|
||||||
loot = new Loot(GetMap(), guid, loot_type);
|
loot = new Loot(GetMap(), guid, loot_type, LootMethod.FreeForAll);
|
||||||
item.loot = loot;
|
item.loot = loot;
|
||||||
|
|
||||||
switch (loot_type)
|
switch (loot_type)
|
||||||
@@ -6359,7 +6355,7 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
creature.StartPickPocketRefillTimer();
|
creature.StartPickPocketRefillTimer();
|
||||||
|
|
||||||
loot = new Loot(GetMap(), creature.GetGUID(), LootType.Pickpocketing);
|
loot = new Loot(GetMap(), creature.GetGUID(), LootType.Pickpocketing, LootMethod.FreeForAll);
|
||||||
creature.loot = loot;
|
creature.loot = loot;
|
||||||
uint lootid = creature.GetCreatureTemplate().PickPocketId;
|
uint lootid = creature.GetCreatureTemplate().PickPocketId;
|
||||||
if (lootid != 0)
|
if (lootid != 0)
|
||||||
@@ -6402,7 +6398,7 @@ namespace Game.Entities
|
|||||||
Group group = creature.GetLootRecipientGroup();
|
Group group = creature.GetLootRecipientGroup();
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
switch (group.GetLootMethod())
|
switch (loot.GetLootMethod())
|
||||||
{
|
{
|
||||||
case LootMethod.GroupLoot:
|
case LootMethod.GroupLoot:
|
||||||
// GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
|
// GroupLoot: rolls items over threshold. Items with quality < threshold, round robin
|
||||||
@@ -6439,7 +6435,7 @@ namespace Game.Entities
|
|||||||
Group group = GetGroup();
|
Group group = GetGroup();
|
||||||
if (group == creature.GetLootRecipientGroup())
|
if (group == creature.GetLootRecipientGroup())
|
||||||
{
|
{
|
||||||
switch (group.GetLootMethod())
|
switch (loot.GetLootMethod())
|
||||||
{
|
{
|
||||||
case LootMethod.MasterLoot:
|
case LootMethod.MasterLoot:
|
||||||
permission = PermissionTypes.Master;
|
permission = PermissionTypes.Master;
|
||||||
@@ -6465,29 +6461,13 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (permission != PermissionTypes.None)
|
if (permission != PermissionTypes.None)
|
||||||
{
|
{
|
||||||
LootMethod _lootMethod = LootMethod.FreeForAll;
|
|
||||||
Group group = GetGroup();
|
|
||||||
if (group)
|
|
||||||
{
|
|
||||||
Creature creature = GetMap().GetCreature(guid);
|
|
||||||
if (creature)
|
|
||||||
{
|
|
||||||
Player recipient = creature.GetLootRecipient();
|
|
||||||
if (recipient)
|
|
||||||
{
|
|
||||||
if (group == recipient.GetGroup())
|
|
||||||
_lootMethod = group.GetLootMethod();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!guid.IsItem() && !aeLooting)
|
if (!guid.IsItem() && !aeLooting)
|
||||||
SetLootGUID(guid);
|
SetLootGUID(guid);
|
||||||
|
|
||||||
LootResponse packet = new();
|
LootResponse packet = new();
|
||||||
packet.Owner = guid;
|
packet.Owner = guid;
|
||||||
packet.LootObj = loot.GetGUID();
|
packet.LootObj = loot.GetGUID();
|
||||||
packet.LootMethod = _lootMethod;
|
packet.LootMethod = loot.GetLootMethod();
|
||||||
packet.AcquireReason = (byte)SharedConst.GetLootTypeForClient(loot_type);
|
packet.AcquireReason = (byte)SharedConst.GetLootTypeForClient(loot_type);
|
||||||
packet.Acquired = true; // false == No Loot (this too^^)
|
packet.Acquired = true; // false == No Loot (this too^^)
|
||||||
packet.AELooting = aeLooting;
|
packet.AELooting = aeLooting;
|
||||||
|
|||||||
@@ -3133,7 +3133,7 @@ namespace Game.Entities
|
|||||||
else if (thisGroup != creature.GetLootRecipientGroup())
|
else if (thisGroup != creature.GetLootRecipientGroup())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (thisGroup.GetLootMethod())
|
switch (loot.GetLootMethod())
|
||||||
{
|
{
|
||||||
case LootMethod.PersonalLoot:// @todo implement personal loot (http://wow.gamepedia.com/Loot#Personal_Loot)
|
case LootMethod.PersonalLoot:// @todo implement personal loot (http://wow.gamepedia.com/Loot#Personal_Loot)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -774,9 +774,10 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
player.SendPacket(partyKillLog);
|
player.SendPacket(partyKillLog);
|
||||||
|
|
||||||
|
// Generate loot before updating looter
|
||||||
if (creature)
|
if (creature)
|
||||||
{
|
{
|
||||||
creature.loot = new Loot(creature.GetMap(), creature.GetGUID(), LootType.Corpse);
|
creature.loot = new Loot(creature.GetMap(), creature.GetGUID(), LootType.Corpse, group != null ? group.GetLootMethod() : LootMethod.FreeForAll);
|
||||||
Loot loot = creature.loot;
|
Loot loot = creature.loot;
|
||||||
if (creature.GetMap().Is25ManRaid())
|
if (creature.GetMap().Is25ManRaid())
|
||||||
loot.maxDuplicates = 3;
|
loot.maxDuplicates = 3;
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ namespace Game.Groups
|
|||||||
lootList.Owner = creature.GetGUID();
|
lootList.Owner = creature.GetGUID();
|
||||||
lootList.LootObj = creature.loot.GetGUID();
|
lootList.LootObj = creature.loot.GetGUID();
|
||||||
|
|
||||||
if (GetLootMethod() == LootMethod.MasterLoot && creature.loot.HasOverThresholdItem())
|
if (creature.loot.GetLootMethod() == LootMethod.MasterLoot && creature.loot.HasOverThresholdItem())
|
||||||
lootList.Master = GetMasterLooterGuid();
|
lootList.Master = GetMasterLooterGuid();
|
||||||
|
|
||||||
if (groupLooter)
|
if (groupLooter)
|
||||||
@@ -1364,7 +1364,7 @@ namespace Game.Groups
|
|||||||
player.AutoStoreLoot(disenchant.Id, LootStorage.Disenchant, ItemContext.None, 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.
|
else // If the player's inventory is full, send the disenchant result in a mail.
|
||||||
{
|
{
|
||||||
Loot loot = new(allowedMap, roll.GetLoot().GetOwnerGUID(), LootType.Disenchanting);
|
Loot loot = new(allowedMap, roll.GetLoot().GetOwnerGUID(), LootType.Disenchanting, roll.GetLoot().GetLootMethod());
|
||||||
loot.FillLoot(disenchant.Id, LootStorage.Disenchant, player, true);
|
loot.FillLoot(disenchant.Id, LootStorage.Disenchant, player, true);
|
||||||
|
|
||||||
uint max_slot = loot.GetMaxSlotInLootFor(player);
|
uint max_slot = loot.GetMaxSlotInLootFor(player);
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
AELootResult aeResult = new();
|
AELootResult aeResult = new();
|
||||||
|
|
||||||
if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID() || GetPlayer().GetGroup().GetLootMethod() != LootMethod.MasterLoot)
|
if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID())
|
||||||
{
|
{
|
||||||
GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.DidntKill);
|
GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.DidntKill);
|
||||||
return;
|
return;
|
||||||
@@ -417,7 +417,7 @@ namespace Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loot == null)
|
if (loot == null || loot.GetLootMethod() != LootMethod.MasterLoot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte slotid = (byte)(req.LootListID - 1);
|
byte slotid = (byte)(req.LootListID - 1);
|
||||||
|
|||||||
@@ -166,13 +166,14 @@ namespace Game.Loots
|
|||||||
|
|
||||||
public class Loot
|
public class Loot
|
||||||
{
|
{
|
||||||
public Loot(Map map, ObjectGuid owner, LootType type)
|
public Loot(Map map, ObjectGuid owner, LootType type, LootMethod lootMethod)
|
||||||
{
|
{
|
||||||
loot_type = type;
|
loot_type = type;
|
||||||
maxDuplicates = 1;
|
maxDuplicates = 1;
|
||||||
_guid = map ? ObjectGuid.Create(HighGuid.LootObject, map.GetId(), 0, map.GenerateLowGuid(HighGuid.LootObject)) : ObjectGuid.Empty;
|
_guid = map ? ObjectGuid.Create(HighGuid.LootObject, map.GetId(), 0, map.GenerateLowGuid(HighGuid.LootObject)) : ObjectGuid.Empty;
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
_itemContext = ItemContext.None;
|
_itemContext = ItemContext.None;
|
||||||
|
_lootMethod = lootMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserts the item into the loot (called by LootTemplate processors)
|
// Inserts the item into the loot (called by LootTemplate processors)
|
||||||
@@ -338,8 +339,7 @@ namespace Game.Loots
|
|||||||
{
|
{
|
||||||
LootItem item = quest_items[i];
|
LootItem item = quest_items[i];
|
||||||
|
|
||||||
if (!item.is_looted && (item.AllowedForPlayer(player) || (item.follow_loot_rules && player.GetGroup() && ((player.GetGroup().GetLootMethod() == LootMethod.MasterLoot
|
if (!item.is_looted && (item.AllowedForPlayer(player) || (item.follow_loot_rules && player.GetGroup() && ((GetLootMethod() == LootMethod.MasterLoot && player.GetGroup().GetMasterLooterGuid() == player.GetGUID()) || GetLootMethod() != LootMethod.MasterLoot))))
|
||||||
&& player.GetGroup().GetMasterLooterGuid() == player.GetGUID()) || player.GetGroup().GetLootMethod() != LootMethod.MasterLoot))))
|
|
||||||
{
|
{
|
||||||
ql.Add(new NotNormalLootItem(i));
|
ql.Add(new NotNormalLootItem(i));
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ namespace Game.Loots
|
|||||||
// increase once if one looter only, looter-times if free for all
|
// increase once if one looter only, looter-times if free for all
|
||||||
if (item.freeforall || !item.is_blocked)
|
if (item.freeforall || !item.is_blocked)
|
||||||
++unlootedCount;
|
++unlootedCount;
|
||||||
if (!player.GetGroup() || player.GetGroup().GetLootMethod() != LootMethod.GroupLoot)
|
if (!player.GetGroup() || GetLootMethod() != LootMethod.GroupLoot)
|
||||||
item.is_blocked = true;
|
item.is_blocked = true;
|
||||||
|
|
||||||
if (items.Count + ql.Count == SharedConst.MaxNRLootItems)
|
if (items.Count + ql.Count == SharedConst.MaxNRLootItems)
|
||||||
@@ -840,6 +840,7 @@ namespace Game.Loots
|
|||||||
|
|
||||||
public ObjectGuid GetGUID() { return _guid; }
|
public ObjectGuid GetGUID() { return _guid; }
|
||||||
public ObjectGuid GetOwnerGUID() { return _owner; }
|
public ObjectGuid GetOwnerGUID() { return _owner; }
|
||||||
|
public LootMethod GetLootMethod() { return _lootMethod; }
|
||||||
|
|
||||||
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerQuestItems() { return PlayerQuestItems; }
|
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerQuestItems() { return PlayerQuestItems; }
|
||||||
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerFFAItems() { return PlayerFFAItems; }
|
public MultiMap<ObjectGuid, NotNormalLootItem> GetPlayerFFAItems() { return PlayerFFAItems; }
|
||||||
@@ -865,6 +866,7 @@ namespace Game.Loots
|
|||||||
ObjectGuid _guid;
|
ObjectGuid _guid;
|
||||||
ObjectGuid _owner; // The WorldObject that holds this loot
|
ObjectGuid _owner; // The WorldObject that holds this loot
|
||||||
ItemContext _itemContext;
|
ItemContext _itemContext;
|
||||||
|
LootMethod _lootMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AELootResult
|
public class AELootResult
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace Game.Mails
|
|||||||
if (m_mailTemplateId == 123)
|
if (m_mailTemplateId == 123)
|
||||||
m_money = 1000000;
|
m_money = 1000000;
|
||||||
|
|
||||||
Loot mailLoot = new(null, ObjectGuid.Empty, LootType.None);
|
Loot mailLoot = new(null, ObjectGuid.Empty, LootType.None, LootMethod.FreeForAll);
|
||||||
|
|
||||||
// can be empty
|
// can be empty
|
||||||
mailLoot.FillLoot(m_mailTemplateId, LootStorage.Mail, receiver, true, true, LootModes.Default, ItemContext.None);
|
mailLoot.FillLoot(m_mailTemplateId, LootStorage.Mail, receiver, true, true, LootModes.Default, ItemContext.None);
|
||||||
|
|||||||
Reference in New Issue
Block a user