Core/Loot: Implemented dungeon encounter personal loot

Port From (https://github.com/TrinityCore/TrinityCore/commit/010e6f7f49744b16e3ecececb7d9605f8b8db4d5)
This commit is contained in:
hondacrx
2022-10-26 01:36:15 -04:00
parent 32960df381
commit 744e9c1c19
9 changed files with 314 additions and 115 deletions
+27 -10
View File
@@ -1749,17 +1749,34 @@ namespace Game.Entities
{
if (info.Chest.chestPersonalLoot != 0)
{
Loot personalLoot = new(GetMap(), GetGUID(), LootType.Chest, null);
m_personalLoot[player.GetGUID()] = personalLoot;
personalLoot.SetDungeonEncounterId(info.Chest.DungeonEncounter);
personalLoot.FillLoot(info.Chest.chestPersonalLoot, LootStorage.Gameobject, player, true, false, GetLootMode(), GetMap().GetDifficultyLootItemContext());
if (GetLootMode() > 0)
GameObjectTemplateAddon addon = GetTemplateAddon();
if (info.Chest.DungeonEncounter != 0)
{
GameObjectTemplateAddon addon = GetTemplateAddon();
if (addon != null)
personalLoot.GenerateMoneyLoot(addon.Mingold, addon.Maxgold);
List<Player> tappers = new();
foreach (ObjectGuid tapperGuid in GetTapList())
{
Player tapper = Global.ObjAccessor.GetPlayer(this, tapperGuid);
if (tapper != null)
tappers.Add(tapper);
}
if (tappers.Empty())
tappers.Add(player);
m_personalLoot = LootManager.GenerateDungeonEncounterPersonalLoot(info.Chest.DungeonEncounter, info.Chest.chestPersonalLoot,
LootStorage.Gameobject, LootType.Chest, this, addon != null ? addon.Mingold : 0, addon != null ? addon.Maxgold : 0,
(ushort)GetLootMode(), GetMap().GetDifficultyLootItemContext(), tappers);
}
else
{
Loot loot = new(GetMap(), GetGUID(), LootType.Chest, null);
m_personalLoot[player.GetGUID()] = loot;
loot.SetDungeonEncounterId(info.Chest.DungeonEncounter);
loot.FillLoot(info.Chest.chestPersonalLoot, LootStorage.Gameobject, player, true, false, GetLootMode(), GetMap().GetDifficultyLootItemContext());
if (GetLootMode() > 0 && addon != null)
loot.GenerateMoneyLoot(addon.Mingold, addon.Maxgold);
}
}
}
@@ -335,6 +335,8 @@ namespace Game.Entities
public bool IsWeapon() { return GetClass() == ItemClass.Weapon; }
public bool IsArmor() { return GetClass() == ItemClass.Armor; }
public bool IsRangedWeapon()
{
return IsWeapon() && (GetSubClass() == (uint)ItemSubClassWeapon.Bow ||
+13 -37
View File
@@ -2959,14 +2959,17 @@ namespace Game.Entities
}
}
public InventoryResult CanRollForItemInLFG(ItemTemplate proto, Map map)
public InventoryResult CanRollNeedForItem(ItemTemplate proto, Map map, bool restrictOnlyLfg)
{
if (!GetGroup() || !GetGroup().IsLFGGroup())
return InventoryResult.Ok; // not in LFG group
if (restrictOnlyLfg)
{
if (!GetGroup() || !GetGroup().IsLFGGroup())
return InventoryResult.Ok; // not in LFG group
// check if looted object is inside the lfg dungeon
if (!Global.LFGMgr.InLfgDungeonMap(GetGroup().GetGUID(), map.GetId(), map.GetDifficultyID()))
return InventoryResult.Ok;
// check if looted object is inside the lfg dungeon
if (!Global.LFGMgr.InLfgDungeonMap(GetGroup().GetGUID(), map.GetId(), map.GetDifficultyID()))
return InventoryResult.Ok;
}
if (proto == null)
return InventoryResult.ItemNotFound;
@@ -2986,41 +2989,14 @@ namespace Game.Entities
return InventoryResult.CantEquipSkill;
}
Class _class = GetClass();
if (proto.GetClass() == ItemClass.Weapon && GetSkillValue(proto.GetSkill()) == 0)
return InventoryResult.ProficiencyNeeded;
if (proto.GetClass() == ItemClass.Armor && proto.GetSubClass() > (uint)ItemSubClassArmor.Miscellaneous
&& proto.GetSubClass() < (uint)ItemSubClassArmor.Cosmetic && proto.GetInventoryType() != InventoryType.Cloak)
if (proto.GetClass() == ItemClass.Armor && proto.GetInventoryType() != InventoryType.Cloak)
{
if (_class == Class.Warrior || _class == Class.Paladin || _class == Class.Deathknight)
{
if (GetLevel() < 40)
{
if (proto.GetSubClass() != (uint)ItemSubClassArmor.Mail)
return InventoryResult.ClientLockedOut;
}
else if (proto.GetSubClass() != (uint)ItemSubClassArmor.Plate)
return InventoryResult.ClientLockedOut;
}
else if (_class == Class.Hunter || _class == Class.Shaman)
{
if (GetLevel() < 40)
{
if (proto.GetSubClass() != (uint)ItemSubClassArmor.Leather)
return InventoryResult.ClientLockedOut;
}
else if (proto.GetSubClass() != (uint)ItemSubClassArmor.Mail)
return InventoryResult.ClientLockedOut;
}
if (_class == Class.Rogue || _class == Class.Druid)
if (proto.GetSubClass() != (uint)ItemSubClassArmor.Leather)
return InventoryResult.ClientLockedOut;
if (_class == Class.Mage || _class == Class.Priest || _class == Class.Warlock)
if (proto.GetSubClass() != (uint)ItemSubClassArmor.Cloth)
return InventoryResult.ClientLockedOut;
ChrClassesRecord classesEntry = CliDB.ChrClassesStorage.LookupByKey(GetClass());
if ((classesEntry.ArmorTypeMask & 1 << (int)proto.GetSubClass()) == 0)
return InventoryResult.ClientLockedOut;
}
return InventoryResult.Ok;
+1 -2
View File
@@ -3141,8 +3141,7 @@ namespace Game.Entities
switch (loot.GetLootMethod())
{
case LootMethod.PersonalLoot:// @todo implement personal loot (http://wow.gamepedia.com/Loot#Personal_Loot)
return false;
case LootMethod.PersonalLoot:
case LootMethod.FreeForAll:
return true;
case LootMethod.RoundRobin:
+35 -27
View File
@@ -704,9 +704,9 @@ namespace Game.Entities
Creature creature = victim.ToCreature();
bool isRewardAllowed = true;
bool isRewardAllowed = attacker != victim;
if (creature != null)
isRewardAllowed = !creature.GetTapList().Empty();
isRewardAllowed = isRewardAllowed && !creature.GetTapList().Empty();
List<Player> tappers = new();
if (isRewardAllowed && creature)
@@ -727,11 +727,6 @@ namespace Game.Entities
// call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop)
if (isRewardAllowed)
{
PartyKillLog partyKillLog = new();
partyKillLog.Player = player.GetGUID();
partyKillLog.Victim = victim.GetGUID();
partyKillLog.Write();
HashSet<Group> groups = new();
foreach (Player tapper in tappers)
{
@@ -740,6 +735,11 @@ namespace Game.Entities
{
if (groups.Add(tapperGroup))
{
PartyKillLog partyKillLog = new();
partyKillLog.Player = player && tapperGroup.IsMember(player.GetGUID()) ? player.GetGUID() : tapper.GetGUID();
partyKillLog.Victim = victim.GetGUID();
partyKillLog.Write();
tapperGroup.BroadcastPacket(partyKillLog, tapperGroup.GetMemberGroup(tapper.GetGUID()) != 0);
if (creature)
@@ -747,7 +747,12 @@ namespace Game.Entities
}
}
else
{
PartyKillLog partyKillLog = new();
partyKillLog.Player = tapper.GetGUID();
partyKillLog.Victim = victim.GetGUID();
tapper.SendPacket(partyKillLog);
}
}
// Generate loot before updating looter
@@ -763,30 +768,33 @@ namespace Game.Entities
Group group = !groups.Empty() ? groups.First() : null;
Player looter = group ? Global.ObjAccessor.GetPlayer(creature, group.GetLooterGuid()) : tappers[0];
Loot loot = new(creature.GetMap(), creature.GetGUID(), LootType.Corpse, dungeonEncounter != null ? group : null);
if (dungeonEncounter != null)
loot.SetDungeonEncounterId(dungeonEncounter.Id);
uint lootid = creature.GetCreatureTemplate().LootId;
if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, dungeonEncounter != null, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext());
if (creature.GetLootMode() > 0)
loot.GenerateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
if (group)
loot.NotifyLootList(creature.GetMap());
if (dungeonEncounter != null || groups.Empty())
creature._loot = loot; // TODO: personal boss loot
{
creature.m_personalLoot = LootManager.GenerateDungeonEncounterPersonalLoot(dungeonEncounter.Id, creature.GetCreatureTemplate().LootId,
LootStorage.Creature, LootType.Corpse, creature, creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold,
(ushort)creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext(), tappers);
}
else
{
Loot loot = new(creature.GetMap(), creature.GetGUID(), LootType.Corpse, dungeonEncounter != null ? group : null);
uint lootid = creature.GetCreatureTemplate().LootId;
if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, dungeonEncounter != null, false, creature.GetLootMode(), creature.GetMap().GetDifficultyLootItemContext());
if (creature.GetLootMode() > 0)
loot.GenerateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
if (group)
loot.NotifyLootList(creature.GetMap());
creature.m_personalLoot[looter.GetGUID()] = loot; // trash mob loot is personal, generated with round robin rules
// Update round robin looter only if the creature had loot
if (!loot.IsLooted())
foreach (Group tapperGroup in groups)
tapperGroup.UpdateLooterGuid(creature);
// Update round robin looter only if the creature had loot
if (!loot.IsLooted())
foreach (Group tapperGroup in groups)
tapperGroup.UpdateLooterGuid(creature);
}
}
else
{