Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower
Port From (https://github.com/TrinityCore/TrinityCore/commit/c7306439e7004288fb85890d6a5f730cf1761d71)
This commit is contained in:
@@ -75,7 +75,7 @@ namespace Game
|
||||
|
||||
if (!pet.IsAlive())
|
||||
{
|
||||
SpellInfo spell = (flag == ActiveStates.Enabled || flag == ActiveStates.Passive) ? Global.SpellMgr.GetSpellInfo(spellid) : null;
|
||||
SpellInfo spell = (flag == ActiveStates.Enabled || flag == ActiveStates.Passive) ? Global.SpellMgr.GetSpellInfo(spellid, pet.GetMap().GetDifficultyID()) : null;
|
||||
if (spell == null)
|
||||
return;
|
||||
if (!spell.HasAttribute(SpellAttr0.CastableWhileDead))
|
||||
@@ -285,14 +285,14 @@ namespace Game
|
||||
unit_target = Global.ObjAccessor.GetUnit(GetPlayer(), guid2);
|
||||
|
||||
// do not cast unknown spells
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid, pet.GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WORLD: unknown PET spell id {0}", spellid);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (SpellEffectInfo effect in spellInfo.GetEffectsForDifficulty(Difficulty.None))
|
||||
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
|
||||
{
|
||||
if (effect != null && (effect.TargetA.GetTarget() == Targets.UnitSrcAreaEnemy || effect.TargetA.GetTarget() == Targets.UnitDestAreaEnemy || effect.TargetA.GetTarget() == Targets.DestDynobjEnemy))
|
||||
return;
|
||||
@@ -484,7 +484,7 @@ namespace Game
|
||||
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
|
||||
if (!((act_state == ActiveStates.Enabled || act_state == ActiveStates.Disabled || act_state == ActiveStates.Passive) && spell_id != 0 && !pet.HasSpell(spell_id)))
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell_id);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell_id, pet.GetMap().GetDifficultyID());
|
||||
if (spellInfo != null)
|
||||
{
|
||||
//sign for autocast
|
||||
@@ -607,7 +607,7 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(packet.SpellID);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(packet.SpellID, pet.GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WorldSession.HandlePetSpellAutocast: Unknown spell id {0} used by {1}.", packet.SpellID, packet.PetGUID.ToString());
|
||||
@@ -636,13 +636,6 @@ namespace Game
|
||||
[WorldPacketHandler(ClientOpcodes.PetCastSpell)]
|
||||
void HandlePetCastSpell(PetCastSpell petCastSpell)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(petCastSpell.Cast.SpellID);
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: unknown spell id {0} tried to cast by {1}", petCastSpell.Cast.SpellID, petCastSpell.PetGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
Unit caster = Global.ObjAccessor.GetUnit(GetPlayer(), petCastSpell.PetGUID);
|
||||
if (!caster)
|
||||
{
|
||||
@@ -650,6 +643,13 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(petCastSpell.Cast.SpellID, caster.GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: unknown spell id {0} tried to cast by {1}", petCastSpell.Cast.SpellID, petCastSpell.PetGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
// This opcode is also sent from charmed and possessed units (players and creatures)
|
||||
if (caster != GetPlayer().GetGuardianPet() && caster != GetPlayer().GetCharm())
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Game
|
||||
{
|
||||
foreach (ItemEffectRecord effect in item.GetEffects())
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effect.SpellID);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effect.SpellID, user.GetMap().GetDifficultyID());
|
||||
if (spellInfo != null)
|
||||
{
|
||||
if (!spellInfo.CanBeUsedInCombat())
|
||||
@@ -168,7 +168,7 @@ namespace Game
|
||||
uint lockId = proto.GetLockID();
|
||||
if (lockId != 0)
|
||||
{
|
||||
LockRecord lockInfo = CliDB.LockStorage.LookupByKey(lockId);
|
||||
LockRecord lockInfo = CliDB.LockStorage.LookupByKey(lockId);
|
||||
if (lockInfo == null)
|
||||
{
|
||||
player.SendEquipError(InventoryResult.ItemLocked, item);
|
||||
@@ -274,7 +274,7 @@ namespace Game
|
||||
if (mover != GetPlayer() && mover.IsTypeId(TypeId.Player))
|
||||
return;
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(cast.Cast.SpellID);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(cast.Cast.SpellID, mover.GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WORLD: unknown spell id {0}", cast.Cast.SpellID);
|
||||
@@ -351,7 +351,7 @@ namespace Game
|
||||
[WorldPacketHandler(ClientOpcodes.CancelAura)]
|
||||
void HandleCancelAura(CancelAura cancelAura)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(cancelAura.SpellID);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(cancelAura.SpellID, _player.GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
return;
|
||||
|
||||
@@ -401,14 +401,13 @@ namespace Game
|
||||
[WorldPacketHandler(ClientOpcodes.PetCancelAura)]
|
||||
void HandlePetCancelAura(PetCancelAura packet)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(packet.SpellID);
|
||||
if (spellInfo == null)
|
||||
if (!Global.SpellMgr.HasSpellInfo(packet.SpellID, Difficulty.None))
|
||||
{
|
||||
Log.outError(LogFilter.Network, "WORLD: unknown PET spell id {0}", packet.SpellID);
|
||||
return;
|
||||
}
|
||||
|
||||
Creature pet= ObjectAccessor.GetCreatureOrPetOrVehicle(_player, packet.PetGUID);
|
||||
Creature pet = ObjectAccessor.GetCreatureOrPetOrVehicle(_player, packet.PetGUID);
|
||||
if (pet == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "HandlePetCancelAura: Attempt to cancel an aura for non-existant {0} by player '{1}'", packet.PetGUID.ToString(), GetPlayer().GetName());
|
||||
@@ -480,7 +479,7 @@ namespace Game
|
||||
if (!selfResSpells.Contains(selfRes.SpellId))
|
||||
return;
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(selfRes.SpellId);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(selfRes.SpellId, _player.GetMap().GetDifficultyID());
|
||||
if (spellInfo != null)
|
||||
_player.CastSpell(_player, spellInfo, false, null);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Game
|
||||
if (effect == null)
|
||||
return;
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(packet.Cast.SpellID);
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(packet.Cast.SpellID, Difficulty.None);
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "HandleUseToy: unknown spell id: {0} used by Toy Item entry {1}", packet.Cast.SpellID, itemId);
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace Game
|
||||
uint my_spell_id = my_trade.GetSpell();
|
||||
if (my_spell_id != 0)
|
||||
{
|
||||
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(my_spell_id);
|
||||
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(my_spell_id, _player.GetMap().GetDifficultyID());
|
||||
Item castItem = my_trade.GetSpellCastItem();
|
||||
|
||||
if (spellEntry == null || !his_trade.GetItem(TradeSlots.NonTraded) ||
|
||||
@@ -377,7 +377,7 @@ namespace Game
|
||||
uint his_spell_id = his_trade.GetSpell();
|
||||
if (his_spell_id != 0)
|
||||
{
|
||||
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(his_spell_id);
|
||||
SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(his_spell_id, trader.GetMap().GetDifficultyID());
|
||||
Item castItem = his_trade.GetSpellCastItem();
|
||||
|
||||
if (spellEntry == null || !my_trade.GetItem(TradeSlots.NonTraded) || (his_trade.HasSpellCastItem() && !castItem))
|
||||
|
||||
Reference in New Issue
Block a user