Core/Loot: Refactored Player::SendLoot to accept Loot object directly
Port From (https://github.com/TrinityCore/TrinityCore/commit/cbf2064c62137d9f0c0397956592f3ab9700480c)
This commit is contained in:
@@ -1900,13 +1900,13 @@ namespace Game.Entities
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loot = GetFishLoot(player);
|
loot = GetFishLoot(player);
|
||||||
player.SendLoot(GetGUID(), LootType.Fishing);
|
player.SendLoot(loot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else// If fishing skill is too low, send junk loot.
|
else// If fishing skill is too low, send junk loot.
|
||||||
{
|
{
|
||||||
loot = GetFishLootJunk(player);
|
loot = GetFishLootJunk(player);
|
||||||
player.SendLoot(GetGUID(), LootType.FishingJunk);
|
player.SendLoot(loot);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2121,7 +2121,7 @@ namespace Game.Entities
|
|||||||
loot.FillLoot(GetGoInfo().GetLootId(), LootStorage.Gameobject, player, true);
|
loot.FillLoot(GetGoInfo().GetLootId(), LootStorage.Gameobject, player, true);
|
||||||
m_personalLoot[player.GetGUID()] = loot;
|
m_personalLoot[player.GetGUID()] = loot;
|
||||||
|
|
||||||
player.SendLoot(GetGUID(), LootType.Fishinghole);
|
player.SendLoot(loot);
|
||||||
player.UpdateCriteria(CriteriaType.CatchFishInFishingHole, GetGoInfo().entry);
|
player.UpdateCriteria(CriteriaType.CatchFishInFishingHole, GetGoInfo().entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6082,7 +6082,7 @@ namespace Game.Entities
|
|||||||
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
|
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
|
||||||
bones.loot.gold = (uint)(RandomHelper.URand(50, 150) * 0.016f * Math.Pow((float)GetLevel() / 5.76f, 2.5f) * WorldConfig.GetFloatValue(WorldCfg.RateDropMoney));
|
bones.loot.gold = (uint)(RandomHelper.URand(50, 150) * 0.016f * Math.Pow((float)GetLevel() / 5.76f, 2.5f) * WorldConfig.GetFloatValue(WorldCfg.RateDropMoney));
|
||||||
bones.lootRecipient = looterPlr;
|
bones.lootRecipient = looterPlr;
|
||||||
looterPlr.SendLoot(bones.GetGUID(), LootType.Insignia);
|
looterPlr.SendLoot(bones.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendLootRelease(ObjectGuid guid)
|
public void SendLootRelease(ObjectGuid guid)
|
||||||
@@ -6098,71 +6098,21 @@ namespace Game.Entities
|
|||||||
SendPacket(new LootReleaseAll());
|
SendPacket(new LootReleaseAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendLoot(ObjectGuid guid, LootType loot_type, bool aeLooting = false)
|
public void SendLoot(Loot loot, bool aeLooting = false)
|
||||||
{
|
{
|
||||||
if (!GetLootGUID().IsEmpty() && !aeLooting)
|
if (!GetLootGUID().IsEmpty() && !aeLooting)
|
||||||
Session.DoLootReleaseAll();
|
Session.DoLootReleaseAll();
|
||||||
|
|
||||||
Loot loot;
|
Log.outDebug(LogFilter.Loot, $"Player::SendLoot: Player: '{GetName()}' ({GetGUID()}), Loot: {loot.GetOwnerGUID()}");
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Loot, "Player.SendLoot");
|
if (!loot.GetOwnerGUID().IsItem() && !aeLooting)
|
||||||
if (guid.IsGameObject())
|
SetLootGUID(loot.GetOwnerGUID());
|
||||||
{
|
|
||||||
GameObject go = GetMap().GetGameObject(guid);
|
|
||||||
if (go == null)
|
|
||||||
{
|
|
||||||
SendLootRelease(guid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loot = go.GetLootForPlayer(this);
|
|
||||||
}
|
|
||||||
else if (guid.IsItem())
|
|
||||||
{
|
|
||||||
Item item = GetItemByGuid(guid);
|
|
||||||
|
|
||||||
if (item == null)
|
|
||||||
{
|
|
||||||
SendLootRelease(guid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loot = item.GetLootForPlayer(this);
|
|
||||||
}
|
|
||||||
else if (guid.IsCorpse()) // remove insignia
|
|
||||||
{
|
|
||||||
Corpse bones = ObjectAccessor.GetCorpse(this, guid);
|
|
||||||
if (bones == null)
|
|
||||||
{
|
|
||||||
SendLootRelease(guid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loot = bones.GetLootForPlayer(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Creature creature = GetMap().GetCreature(guid);
|
|
||||||
|
|
||||||
// must be in range and creature must be alive for pickpocket and must be dead for another loot
|
|
||||||
if (creature == null)
|
|
||||||
{
|
|
||||||
SendLootRelease(guid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
loot = creature.GetLootForPlayer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!guid.IsItem() && !aeLooting)
|
|
||||||
SetLootGUID(guid);
|
|
||||||
|
|
||||||
LootResponse packet = new();
|
LootResponse packet = new();
|
||||||
packet.Owner = guid;
|
packet.Owner = loot.GetOwnerGUID();
|
||||||
packet.LootObj = loot.GetGUID();
|
packet.LootObj = loot.GetGUID();
|
||||||
packet.LootMethod = loot.GetLootMethod();
|
packet.LootMethod = loot.GetLootMethod();
|
||||||
packet.AcquireReason = (byte)SharedConst.GetLootTypeForClient(loot_type);
|
packet.AcquireReason = (byte)SharedConst.GetLootTypeForClient(loot.loot_type);
|
||||||
packet.Acquired = true; // false == No Loot (this too^^)
|
packet.Acquired = true; // false == No Loot (this too^^)
|
||||||
packet.AELooting = aeLooting;
|
packet.AELooting = aeLooting;
|
||||||
loot.BuildLootResponse(packet, this);
|
loot.BuildLootResponse(packet, this);
|
||||||
@@ -6172,7 +6122,7 @@ namespace Game.Entities
|
|||||||
loot.OnLootOpened(GetMap(), GetGUID());
|
loot.OnLootOpened(GetMap(), GetGUID());
|
||||||
m_AELootView[loot.GetGUID()] = loot;
|
m_AELootView[loot.GetGUID()] = loot;
|
||||||
|
|
||||||
if (loot_type == LootType.Corpse && !guid.IsItem())
|
if (loot.loot_type == LootType.Corpse && !loot.GetOwnerGUID().IsItem())
|
||||||
SetUnitFlag(UnitFlags.Looting);
|
SetUnitFlag(UnitFlags.Looting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ namespace Game
|
|||||||
if (!corpses.Empty())
|
if (!corpses.Empty())
|
||||||
SendPacket(new AELootTargets((uint)corpses.Count + 1));
|
SendPacket(new AELootTargets((uint)corpses.Count + 1));
|
||||||
|
|
||||||
GetPlayer().SendLoot(packet.Unit, LootType.Corpse);
|
GetPlayer().SendLoot(lootTarget.GetLootForPlayer(GetPlayer()));
|
||||||
|
|
||||||
if (!corpses.Empty())
|
if (!corpses.Empty())
|
||||||
{
|
{
|
||||||
@@ -243,7 +243,7 @@ namespace Game
|
|||||||
|
|
||||||
foreach (Creature creature in corpses)
|
foreach (Creature creature in corpses)
|
||||||
{
|
{
|
||||||
GetPlayer().SendLoot(creature.GetGUID(), LootType.Corpse, true);
|
GetPlayer().SendLoot(creature.GetLootForPlayer(GetPlayer()), true);
|
||||||
SendPacket(new AELootTargetsAck());
|
SendPacket(new AELootTargetsAck());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,10 @@ namespace Game
|
|||||||
if (loot.gold > 0 || loot.unlootedCount > 0)
|
if (loot.gold > 0 || loot.unlootedCount > 0)
|
||||||
Global.LootItemStorage.AddNewStoredLoot(item.GetGUID().GetCounter(), loot, player);
|
Global.LootItemStorage.AddNewStoredLoot(item.GetGUID().GetCounter(), loot, player);
|
||||||
}
|
}
|
||||||
player.SendLoot(item.GetGUID(), LootType.Item);
|
if (item.loot != null)
|
||||||
|
player.SendLoot(item.loot);
|
||||||
|
else
|
||||||
|
player.SendLootError(ObjectGuid.Empty, item.GetGUID(), LootError.NoLoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,11 +99,12 @@ namespace Game.Loots
|
|||||||
|
|
||||||
public bool LoadStoredLoot(Item item, Player player)
|
public bool LoadStoredLoot(Item item, Player player)
|
||||||
{
|
{
|
||||||
Loot loot = item.GetLootForPlayer(player);
|
|
||||||
if (!_lootItemStorage.ContainsKey(item.GetGUID().GetCounter()))
|
if (!_lootItemStorage.ContainsKey(item.GetGUID().GetCounter()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var container = _lootItemStorage[item.GetGUID().GetCounter()];
|
var container = _lootItemStorage[item.GetGUID().GetCounter()];
|
||||||
|
|
||||||
|
Loot loot = new(player.GetMap(), item.GetGUID(), LootType.Item, null);
|
||||||
loot.gold = container.GetMoney();
|
loot.gold = container.GetMoney();
|
||||||
|
|
||||||
LootTemplate lt = LootStorage.Items.GetLootFor(item.GetEntry());
|
LootTemplate lt = LootStorage.Items.GetLootFor(item.GetEntry());
|
||||||
@@ -141,6 +142,7 @@ namespace Game.Loots
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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.m_lootGenerated = true;
|
item.m_lootGenerated = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1245,6 +1245,7 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loot loot = null;
|
||||||
if (gameObjTarget.GetLootState() == LootState.Ready)
|
if (gameObjTarget.GetLootState() == LootState.Ready)
|
||||||
{
|
{
|
||||||
uint lootId = gameObjTarget.GetGoInfo().GetLootId();
|
uint lootId = gameObjTarget.GetGoInfo().GetLootId();
|
||||||
@@ -1255,7 +1256,7 @@ namespace Game.Spells
|
|||||||
Group group = player.GetGroup();
|
Group group = player.GetGroup();
|
||||||
bool groupRules = group != null && gameObjTarget.GetGoInfo().Chest.usegrouplootrules != 0;
|
bool groupRules = group != null && gameObjTarget.GetGoInfo().Chest.usegrouplootrules != 0;
|
||||||
|
|
||||||
Loot loot = new(gameObjTarget.GetMap(), guid, loottype, groupRules ? group : null);
|
loot = new(gameObjTarget.GetMap(), guid, loottype, groupRules ? group : null);
|
||||||
gameObjTarget.loot = loot;
|
gameObjTarget.loot = loot;
|
||||||
|
|
||||||
loot.FillLoot(lootId, LootStorage.Gameobject, player, !groupRules, false, gameObjTarget.GetLootMode(), gameObjTarget.GetMap().GetDifficultyLootItemContext());
|
loot.FillLoot(lootId, LootStorage.Gameobject, player, !groupRules, false, gameObjTarget.GetLootMode(), gameObjTarget.GetMap().GetDifficultyLootItemContext());
|
||||||
@@ -1282,16 +1283,18 @@ namespace Game.Spells
|
|||||||
|
|
||||||
gameObjTarget.SetLootState(LootState.Activated, player);
|
gameObjTarget.SetLootState(LootState.Activated, player);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
loot = gameObjTarget.GetLootForPlayer(player);
|
||||||
|
|
||||||
|
// Send loot
|
||||||
|
if (loot != null)
|
||||||
|
player.SendLoot(loot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Don't return, let loots been taken
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send loot
|
|
||||||
player.SendLoot(guid, loottype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.OpenLock)]
|
[SpellEffectHandler(SpellEffectName.OpenLock)]
|
||||||
@@ -1980,7 +1983,7 @@ namespace Game.Spells
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.SendLoot(unitTarget.GetGUID(), LootType.Pickpocketing);
|
player.SendLoot(creature.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.AddFarsight)]
|
[SpellEffectHandler(SpellEffectName.AddFarsight)]
|
||||||
@@ -3240,7 +3243,7 @@ namespace Game.Spells
|
|||||||
caster.UpdateCraftSkill(m_spellInfo);
|
caster.UpdateCraftSkill(m_spellInfo);
|
||||||
itemTarget.loot = new Loot(caster.GetMap(), itemTarget.GetGUID(), LootType.Disenchanting, null);
|
itemTarget.loot = new Loot(caster.GetMap(), itemTarget.GetGUID(), LootType.Disenchanting, null);
|
||||||
itemTarget.loot.FillLoot(itemTarget.GetDisenchantLoot(caster).Id, LootStorage.Disenchant, caster, true);
|
itemTarget.loot.FillLoot(itemTarget.GetDisenchantLoot(caster).Id, LootStorage.Disenchant, caster, true);
|
||||||
caster.SendLoot(itemTarget.GetGUID(), LootType.Disenchanting);
|
caster.SendLoot(itemTarget.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// item will be removed at disenchanting end
|
// item will be removed at disenchanting end
|
||||||
@@ -3616,7 +3619,7 @@ namespace Game.Spells
|
|||||||
creature.loot = new Loot(creature.GetMap(), creature.GetGUID(), LootType.Skinning, null);
|
creature.loot = new Loot(creature.GetMap(), creature.GetGUID(), LootType.Skinning, null);
|
||||||
creature.loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, player, true);
|
creature.loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, player, true);
|
||||||
creature.SetLootRecipient(player, false);
|
creature.SetLootRecipient(player, false);
|
||||||
player.SendLoot(creature.GetGUID(), LootType.Skinning);
|
player.SendLoot(creature.loot);
|
||||||
|
|
||||||
if (skill == SkillType.Skinning)
|
if (skill == SkillType.Skinning)
|
||||||
{
|
{
|
||||||
@@ -4329,7 +4332,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
itemTarget.loot = new Loot(player.GetMap(), itemTarget.GetGUID(), LootType.Prospecting, null);
|
itemTarget.loot = new Loot(player.GetMap(), itemTarget.GetGUID(), LootType.Prospecting, null);
|
||||||
itemTarget.loot.FillLoot(itemTarget.GetEntry(), LootStorage.Prospecting, player, true);
|
itemTarget.loot.FillLoot(itemTarget.GetEntry(), LootStorage.Prospecting, player, true);
|
||||||
player.SendLoot(itemTarget.GetGUID(), LootType.Prospecting);
|
player.SendLoot(itemTarget.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.Milling)]
|
[SpellEffectHandler(SpellEffectName.Milling)]
|
||||||
@@ -4357,7 +4360,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
itemTarget.loot = new Loot(player.GetMap(), itemTarget.GetGUID(), LootType.Milling, null);
|
itemTarget.loot = new Loot(player.GetMap(), itemTarget.GetGUID(), LootType.Milling, null);
|
||||||
itemTarget.loot.FillLoot(itemTarget.GetEntry(), LootStorage.Milling, player, true);
|
itemTarget.loot.FillLoot(itemTarget.GetEntry(), LootStorage.Milling, player, true);
|
||||||
player.SendLoot(itemTarget.GetGUID(), LootType.Milling);
|
player.SendLoot(itemTarget.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.Skill)]
|
[SpellEffectHandler(SpellEffectName.Skill)]
|
||||||
|
|||||||
Reference in New Issue
Block a user