Core/Misc: Fixed player corpse looting, added player corpse loot and some more

Port From (https://github.com/TrinityCore/TrinityCore/commit/89f728cd5b6ae3041fdae3c853ac4b0ac5f0a848)
This commit is contained in:
hondacrx
2019-08-17 11:42:16 -04:00
parent 2d2a72ce3e
commit 0a29281557
13 changed files with 121 additions and 35 deletions
-1
View File
@@ -281,7 +281,6 @@ namespace Game.Entities
public Loot loot = new Loot();
public Player lootRecipient;
public bool lootForBody;
CorpseType m_type;
long m_time;
@@ -93,7 +93,6 @@ namespace Game.Entities
public ObjectGuid lootingGroupLowGUID; // used to find group which is looting corpse
ObjectGuid m_lootRecipient;
ObjectGuid m_lootRecipientGroup;
ObjectGuid _skinner;
}
public enum ObjectCellMoveState
+10 -6
View File
@@ -940,8 +940,7 @@ namespace Game.Entities
}
public void ResetPickPocketRefillTimer() { _pickpocketLootRestore = 0; }
public bool CanGeneratePickPocketLoot() { return _pickpocketLootRestore <= Time.UnixTime; }
public void SetSkinner(ObjectGuid guid) { _skinner = guid; }
public ObjectGuid GetSkinner() { return _skinner; } // Returns the player who skinned this creature
public ObjectGuid GetLootRecipientGUID() { return m_lootRecipient; }
public Player GetLootRecipient()
{
@@ -958,7 +957,7 @@ namespace Game.Entities
return Global.GroupMgr.GetGroupByGUID(m_lootRecipientGroup);
}
public void SetLootRecipient(Unit unit)
public void SetLootRecipient(Unit unit, bool withGroup = true)
{
// set the player whose group should receive the right
// to loot the creature after it dies
@@ -980,9 +979,14 @@ namespace Game.Entities
return;
m_lootRecipient = player.GetGUID();
Group group = player.GetGroup();
if (group)
m_lootRecipientGroup = group.GetGUID();
if (withGroup)
{
Group group = player.GetGroup();
if (group)
m_lootRecipientGroup = group.GetGUID();
}
else
m_lootRecipientGroup = ObjectGuid.Empty;
AddDynamicFlag(UnitDynFlags.Tapped);
}
@@ -1015,6 +1015,19 @@ namespace Game.Entities
GetMap().GetZoneAndAreaId(GetPhaseShift(), out zoneid, out areaid, posX, posY, posZ);
}
public bool IsInWorldPvpZone()
{
switch (GetZoneId())
{
case 4197: // Wintergrasp
case 5095: // Tol Barad
case 6941: // Ashran
return true;
default:
return false;
}
}
public InstanceScript GetInstanceScript()
{
Map map = GetMap();
+41 -12
View File
@@ -31,6 +31,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Game.BattleFields;
namespace Game.Entities
{
@@ -6164,7 +6165,8 @@ namespace Game.Entities
/// <param name="looterPlr"></param>
public void RemovedInsignia(Player looterPlr)
{
if (GetBattlegroundId() == 0)
// If player is not in battleground and not in worldpvpzone
if (GetBattlegroundId() == 0 && !IsInWorldPvpZone())
return;
// If not released spirit, do it !
@@ -6262,9 +6264,12 @@ namespace Game.Entities
group.UpdateLooterGuid(go);
}
GameObjectTemplateAddon addon = go.GetTemplateAddon();
if (addon != null)
loot.generateMoneyLoot(addon.mingold, addon.maxgold);
if (go.GetLootMode() > 0)
{
GameObjectTemplateAddon addon = go.GetTemplateAddon();
if (addon != null)
loot.generateMoneyLoot(addon.mingold, addon.maxgold);
}
if (loot_type == LootType.Fishing)
go.getFishLoot(loot, this);
@@ -6373,15 +6378,21 @@ namespace Game.Entities
loot = bones.loot;
if (!bones.lootForBody)
if (loot.loot_type == LootType.None)
{
bones.lootForBody = true;
uint pLevel = bones.loot.gold;
bones.loot.clear();
// For AV Achievement
Battleground bg = GetBattleground();
if (bg)
{
if (bg.GetTypeID(true) == BattlegroundTypeId.AV)
loot.FillLoot(1, LootStorage.Creature, this, true);
loot.FillLoot(SharedConst.PlayerCorpseLootEntry, LootStorage.Creature, this, true);
}
else if (GetZoneId() == WintergraspAreaIds.Wintergrasp)
loot.FillLoot(SharedConst.PlayerCorpseLootEntry, LootStorage.Creature, this, true);
// It may need a better formula
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
bones.loot.gold = (uint)(RandomHelper.URand(50, 150) * 0.016f * Math.Pow(pLevel / 5.76f, 2.5f) * WorldConfig.GetFloatValue(WorldCfg.RateDropMoney));
@@ -6439,6 +6450,22 @@ namespace Game.Entities
}
else
{
// exploit fix
if (!creature.HasDynamicFlag(UnitDynFlags.Lootable))
{
SendLootError(loot.GetGUID(), guid, LootError.DidntKill);
return;
}
// the player whose group may loot the corpse
Player recipient = creature.GetLootRecipient();
Group recipientGroup = creature.GetLootRecipientGroup();
if (!recipient && !recipientGroup)
{
SendLootError(loot.GetGUID(), guid, LootError.DidntKill);
return;
}
if (loot.loot_type == LootType.None)
{
// for creature, loot is filled when creature is killed.
@@ -6463,14 +6490,16 @@ namespace Game.Entities
if (loot.loot_type == LootType.Skinning)
{
loot_type = LootType.Skinning;
permission = creature.GetSkinner() == GetGUID() ? PermissionTypes.Owner : PermissionTypes.None;
permission = creature.GetLootRecipientGUID() == GetGUID() ? PermissionTypes.Owner : PermissionTypes.None;
}
else if (loot_type == LootType.Skinning)
{
loot.clear();
loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, this, true);
creature.SetSkinner(GetGUID());
permission = PermissionTypes.Owner;
// Set new loot recipient
creature.SetLootRecipient(this, false);
}
// set group rights only for loot_type != LOOT_SKINNING
else
@@ -6554,12 +6583,12 @@ namespace Game.Entities
// add 'this' player as one of the players that are looting 'loot'
loot.AddLooter(GetGUID());
m_AELootView[loot.GetGUID()] = guid;
if (loot_type == LootType.Corpse && !guid.IsItem())
SetUnitFlags(UnitFlags.Looting);
}
else
SendLootError(loot.GetGUID(), guid, LootError.DidntKill);
if (loot_type == LootType.Corpse && !guid.IsItem())
AddUnitFlag(UnitFlags.Looting);
}
public void SendLootError(ObjectGuid lootObj, ObjectGuid owner, LootError error)
+1 -1
View File
@@ -3664,7 +3664,7 @@ namespace Game.Entities
return false;
if (loot.loot_type == LootType.Skinning)
return creature.GetSkinner() == GetGUID();
return creature.GetLootRecipientGUID() == GetGUID();
Group thisGroup = GetGroup();
if (!thisGroup)
+2 -1
View File
@@ -1422,7 +1422,8 @@ namespace Game.Entities
if (lootid != 0)
loot.FillLoot(lootid, LootStorage.Creature, looter, false, false, creature.GetLootMode());
loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
if (creature.GetLootMode() > 0)
loot.generateMoneyLoot(creature.GetCreatureTemplate().MinGold, creature.GetCreatureTemplate().MaxGold);
if (group)
{