Core/Player: Recast lost by death item obtain spells of any items held in the inventory when resurrecting

This commit is contained in:
hondacrx
2018-03-18 12:36:04 -04:00
parent 95eb49f5de
commit 5fa0556edf
7 changed files with 68 additions and 34 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ namespace Game.DataStorage
public sealed class ItemEffectRecord
{
public uint Id;
public uint SpellID;
public int SpellID;
public int CoolDownMSec;
public int CategoryCoolDownMSec;
public short Charges;
+1 -1
View File
@@ -77,7 +77,7 @@ namespace Game.Entities
if (i < 5)
SetSpellCharges(i, itemProto.Effects[i].Charges);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemProto.Effects[i].SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)itemProto.Effects[i].SpellID);
if (spellInfo != null)
{
if (spellInfo.HasEffect(SpellEffectName.GiveArtifactPower))
+12 -24
View File
@@ -1156,13 +1156,8 @@ namespace Game.Entities
AddEnchantmentDurations(pItem);
AddItemDurations(pItem);
ItemTemplate proto = pItem.GetTemplate();
for (byte i = 0; i < proto.Effects.Count; ++i)
if (proto.Effects[i].TriggerType == ItemSpelltriggerType.OnObtain && proto.Effects[i].SpellID > 0) // On obtain trigger
if (bag == InventorySlots.Bag0 || (bag >= InventorySlots.BagStart && bag < InventorySlots.BagEnd))
if (!HasAura(proto.Effects[i].SpellID))
CastSpell(this, proto.Effects[i].SpellID, true, pItem);
if (bag == InventorySlots.Bag0 || (bag >= InventorySlots.BagStart && bag < InventorySlots.BagEnd))
ApplyItemObtainSpells(pItem, true);
return pItem;
}
@@ -1200,12 +1195,8 @@ namespace Game.Entities
pItem2.SetState(ItemUpdateState.Changed, this);
ItemTemplate proto = pItem2.GetTemplate();
for (byte i = 0; i < proto.Effects.Count; ++i)
if (proto.Effects[i].TriggerType == ItemSpelltriggerType.OnObtain && proto.Effects[i].SpellID > 0) // On obtain trigger
if (bag == InventorySlots.Bag0 || (bag >= InventorySlots.BagStart && bag < InventorySlots.BagEnd))
if (!HasAura(proto.Effects[i].SpellID))
CastSpell(this, proto.Effects[i].SpellID, true, pItem2);
if (bag == InventorySlots.Bag0 || (bag >= InventorySlots.BagStart && bag < InventorySlots.BagEnd))
ApplyItemObtainSpells(pItem2, true);
return pItem2;
}
@@ -1504,7 +1495,7 @@ namespace Game.Entities
if (proto.Effects.Count >= 2)
{
if (proto.Effects[0].SpellID == 483 || proto.Effects[0].SpellID == 55884)
if (HasSpell(proto.Effects[1].SpellID))
if (HasSpell((uint)proto.Effects[1].SpellID))
return InventoryResult.InternalBagError;
}
@@ -4267,7 +4258,7 @@ namespace Game.Entities
continue;
// check if it is valid spell
SpellInfo spellproto = Global.SpellMgr.GetSpellInfo(spellData.SpellID);
SpellInfo spellproto = Global.SpellMgr.GetSpellInfo((uint)spellData.SpellID);
if (spellproto == null)
continue;
@@ -4337,11 +4328,11 @@ namespace Game.Entities
// apply proc cooldown to equip auras if we have any
if (effectData.TriggerType == ItemSpelltriggerType.OnEquip)
{
SpellProcEntry procEntry = Global.SpellMgr.GetSpellProcEntry(effectData.SpellID);
SpellProcEntry procEntry = Global.SpellMgr.GetSpellProcEntry((uint)effectData.SpellID);
if (procEntry == null)
continue;
Aura itemAura = GetAura(effectData.SpellID, GetGUID(), pItem.GetGUID());
Aura itemAura = GetAura((uint)effectData.SpellID, GetGUID(), pItem.GetGUID());
if (itemAura != null)
itemAura.AddProcCooldown(now + TimeSpan.FromMilliseconds(procEntry.Cooldown));
continue;
@@ -4356,14 +4347,14 @@ namespace Game.Entities
continue;
// Don't replace longer cooldowns by equip cooldown if we have any.
if (GetSpellHistory().GetRemainingCooldown(Global.SpellMgr.GetSpellInfo(effectData.SpellID)) > 30 * Time.InMilliseconds)
if (GetSpellHistory().GetRemainingCooldown(Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID)) > 30 * Time.InMilliseconds)
continue;
GetSpellHistory().AddCooldown(effectData.SpellID, pItem.GetEntry(), TimeSpan.FromSeconds(30));
GetSpellHistory().AddCooldown((uint)effectData.SpellID, pItem.GetEntry(), TimeSpan.FromSeconds(30));
ItemCooldown data = new ItemCooldown();
data.ItemGuid = pItem.GetGUID();
data.SpellID = effectData.SpellID;
data.SpellID = (uint)effectData.SpellID;
data.Cooldown = 30 * Time.InMilliseconds; //Always 30secs?
SendPacket(data);
}
@@ -5648,10 +5639,7 @@ namespace Game.Entities
pItem.ClearSoulboundTradeable(this);
RemoveTradeableItem(pItem);
ItemTemplate proto = pItem.GetTemplate();
for (byte i = 0; i < proto.Effects.Count; ++i)
if (proto.Effects[i].TriggerType == ItemSpelltriggerType.OnObtain && proto.Effects[i].SpellID > 0) // On obtain trigger
RemoveAurasDueToSpell(proto.Effects[i].SpellID);
ApplyItemObtainSpells(pItem, false);
ItemRemovedQuestCheck(pItem.GetEntry(), pItem.GetCount());
Bag pBag;
+51 -5
View File
@@ -1066,7 +1066,7 @@ namespace Game.Entities
{
if (proto.Effects[idx].SpellID != 0 && proto.Effects[idx].TriggerType == ItemSpelltriggerType.OnUse)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(proto.Effects[idx].SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)proto.Effects[idx].SpellID);
if (spellInfo != null)
GetSpellHistory().SendCooldownEvent(spellInfo, m_lastPotionId);
}
@@ -1471,8 +1471,8 @@ namespace Game.Entities
{
if (proto.Effects[0].SpellID == 483 || proto.Effects[0].SpellID == 55884)
{
uint learn_spell_id = proto.Effects[0].SpellID;
uint learning_spell_id = proto.Effects[1].SpellID;
uint learn_spell_id = (uint)proto.Effects[0].SpellID;
uint learning_spell_id = (uint)proto.Effects[1].SpellID;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(learn_spell_id);
if (spellInfo == null)
@@ -1510,7 +1510,7 @@ namespace Game.Entities
if (spellData.TriggerType != ItemSpelltriggerType.OnUse)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellData.SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)spellData.SpellID);
if (spellInfo == null)
{
Log.outError(LogFilter.Player, "Player.CastItemUseSpell: Item (Entry: {0}) in have wrong spell id {1}, ignoring", proto.GetId(), spellData.SpellID);
@@ -1709,6 +1709,52 @@ namespace Game.Entities
public Dictionary<uint, PlayerSpell> GetSpellMap() { return m_spells; }
void CastAllObtainSpells()
{
for (byte slot = InventorySlots.ItemStart; slot < InventorySlots.ItemEnd; ++slot)
{
Item item = GetItemByPos(InventorySlots.Bag0, slot);
if (item)
ApplyItemObtainSpells(item, true);
}
for (byte i = InventorySlots.BagStart; i < InventorySlots.BagEnd; ++i)
{
Bag bag = GetBagByPos(i);
if (!bag)
continue;
for (byte slot = 0; slot < bag.GetBagSize(); ++slot)
{
Item item = bag.GetItemByPos(slot);
if (item)
ApplyItemObtainSpells(item, true);
}
}
}
void ApplyItemObtainSpells(Item item, bool apply)
{
ItemTemplate itemTemplate = item.GetTemplate();
for (byte i = 0; i < itemTemplate.Effects.Count; ++i)
{
if (itemTemplate.Effects[i].TriggerType != ItemSpelltriggerType.OnObtain) // On obtain trigger
continue;
int spellId = itemTemplate.Effects[i].SpellID;
if (spellId <= 0)
continue;
if (apply)
{
if (!HasAura((uint)spellId))
CastSpell(this, (uint)spellId, true, item);
}
else
RemoveAurasDueToSpell((uint)spellId);
}
}
public void ApplyItemDependentAuras(Item item, bool apply)
{
if (apply)
@@ -3055,7 +3101,7 @@ namespace Game.Entities
if (spellData.TriggerType != ItemSpelltriggerType.ChanceOnHit)
continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellData.SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)spellData.SpellID);
if (spellInfo == null)
{
Log.outError(LogFilter.Player, "WORLD: unknown Item spellid {0}", spellData.SpellID);
+1 -1
View File
@@ -1057,7 +1057,7 @@ namespace Game
if (item.GetTemplate().Effects.Count < 2)
return;
uint spellToLearn = item.GetTemplate().Effects[1].SpellID;
uint spellToLearn = (uint)item.GetTemplate().Effects[1].SpellID;
foreach (BattlePetSpeciesRecord entry in CliDB.BattlePetSpeciesStorage.Values)
{
if (entry.SummonSpellID == spellToLearn)
+1 -1
View File
@@ -92,7 +92,7 @@ namespace Game
{
for (int i = 0; i < proto.Effects.Count; ++i)
{
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(proto.Effects[i].SpellID);
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)proto.Effects[i].SpellID);
if (spellInfo != null)
{
if (!spellInfo.CanBeUsedInCombat())
+1 -1
View File
@@ -62,7 +62,7 @@ namespace Game.Loots
return false;
// not show loot for players without profession or those who already know the recipe
if (pProto.GetFlags().HasAnyFlag(ItemFlags.HideUnusableRecipe) && (!player.HasSkill((SkillType)pProto.GetRequiredSkill()) || player.HasSpell(pProto.Effects[1].SpellID)))
if (pProto.GetFlags().HasAnyFlag(ItemFlags.HideUnusableRecipe) && (!player.HasSkill((SkillType)pProto.GetRequiredSkill()) || player.HasSpell((uint)pProto.Effects[1].SpellID)))
return false;
// not show loot for not own team