From 87d9adca9a8b2cff7a8035b8423f9dbfe8fbdc07 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 11 May 2018 11:40:29 -0400 Subject: [PATCH] Core/Misc: Fixes --- Source/Game/Chat/Commands/CastCommands.cs | 2 +- Source/Game/Chat/Commands/CheatCommands.cs | 8 +-- Source/Game/Handlers/SceneHandler.cs | 2 + Source/Game/Spells/Spell.cs | 8 +-- Source/Game/Spells/SpellEffects.cs | 62 +++++++++++----------- 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Source/Game/Chat/Commands/CastCommands.cs b/Source/Game/Chat/Commands/CastCommands.cs index 9026c4b5a..558ed61ef 100644 --- a/Source/Game/Chat/Commands/CastCommands.cs +++ b/Source/Game/Chat/Commands/CastCommands.cs @@ -141,7 +141,7 @@ namespace Game.Chat if (spellId == 0) return false; - if (CheckSpellExistsAndIsValid(handler, spellId)) + if (!CheckSpellExistsAndIsValid(handler, spellId)) return false; target.CastSpell(target, spellId, false); diff --git a/Source/Game/Chat/Commands/CheatCommands.cs b/Source/Game/Chat/Commands/CheatCommands.cs index 27fb224ce..5a1a2d7e7 100644 --- a/Source/Game/Chat/Commands/CheatCommands.cs +++ b/Source/Game/Chat/Commands/CheatCommands.cs @@ -53,7 +53,7 @@ namespace Game.Chat.Commands [Command("casttime", RBACPermissions.CommandCheatCasttime)] static bool HandleCasttimeCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null || handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || !handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -80,7 +80,7 @@ namespace Game.Chat.Commands [Command("cooldown", RBACPermissions.CommandCheatCooldown)] static bool HandleCoolDownCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null || handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || !handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -107,7 +107,7 @@ namespace Game.Chat.Commands [Command("power", RBACPermissions.CommandCheatPower)] static bool HandlePowerCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null || handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || !handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -152,7 +152,7 @@ namespace Game.Chat.Commands [Command("waterwalk", RBACPermissions.CommandCheatWaterwalk)] static bool HandleWaterWalkCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null || handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || !handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); diff --git a/Source/Game/Handlers/SceneHandler.cs b/Source/Game/Handlers/SceneHandler.cs index dc0419f57..1a39a0f87 100644 --- a/Source/Game/Handlers/SceneHandler.cs +++ b/Source/Game/Handlers/SceneHandler.cs @@ -31,6 +31,7 @@ namespace Game GetPlayer().GetSceneMgr().OnSceneTrigger(sceneTriggerEvent.SceneInstanceID, sceneTriggerEvent._Event); } + [WorldPacketHandler(ClientOpcodes.ScenePlaybackComplete)] void HandleScenePlaybackComplete(ScenePlaybackComplete scenePlaybackComplete) { Log.outDebug(LogFilter.Scenes, "HandleScenePlaybackComplete: SceneInstanceID: {0}", scenePlaybackComplete.SceneInstanceID); @@ -38,6 +39,7 @@ namespace Game GetPlayer().GetSceneMgr().OnSceneComplete(scenePlaybackComplete.SceneInstanceID); } + [WorldPacketHandler(ClientOpcodes.ScenePlaybackCanceled)] void HandleScenePlaybackCanceled(ScenePlaybackCanceled scenePlaybackCanceled) { Log.outDebug(LogFilter.Scenes, "HandleScenePlaybackCanceled: SceneInstanceID: {0}", scenePlaybackCanceled.SceneInstanceID); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 127401a2c..378124e09 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -97,7 +97,7 @@ namespace Game.Spells // Patch 1.2 notes: Spell Reflection no longer reflects abilities m_canReflect = m_spellInfo.DmgClass == SpellDmgClass.Magic && !m_spellInfo.HasAttribute(SpellAttr0.Ability) && !m_spellInfo.HasAttribute(SpellAttr1.CantBeReflected) && !m_spellInfo.HasAttribute(SpellAttr0.UnaffectedByInvulnerability) - && !m_spellInfo.IsPassive() && !m_spellInfo.IsPositive(); + && !m_spellInfo.IsPassive(); CleanupTargetList(); @@ -1657,7 +1657,7 @@ namespace Game.Spells // Calculate hit result if (m_originalCaster != null) { - targetInfo.missCondition = m_originalCaster.SpellHitResult(target, m_spellInfo, m_canReflect); + targetInfo.missCondition = m_originalCaster.SpellHitResult(target, m_spellInfo, m_canReflect && !(m_spellInfo.IsPositive() && m_caster.IsFriendlyTo(target))); if (m_skipCheck && targetInfo.missCondition != SpellMissInfo.Immune) targetInfo.missCondition = SpellMissInfo.None; } @@ -7495,14 +7495,16 @@ namespace Game.Spells { public ObjectGuid targetGUID; public ulong timeDelay; + public int damage; + public SpellMissInfo missCondition; public SpellMissInfo reflectResult; + public uint effectMask; public bool processed; public bool alive; public bool crit; public bool scaleAura; - public int damage; } public class GOTargetInfo diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index cb1a24648..f065b3061 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1920,7 +1920,7 @@ namespace Game.Spells for (int count = 0; count < damage && remaining > 0;) { // Random select buff for dispel - var dispelableAura = dispelList[RandomHelper.IRand(0, dispelList.Count - 1)]; + var dispelableAura = dispelList[RandomHelper.IRand(0, remaining - 1)]; if (dispelableAura.RollDispel()) { @@ -4708,7 +4708,7 @@ namespace Game.Spells if (unitTarget == null || unitTarget == m_caster) // can't steal from self return; - List> steal_list = new List>(); + List stealList = new List(); // Create dispel mask by dispel type uint dispelMask = SpellInfo.GetDispelMask((DispelType)effectInfo.MiscValue); @@ -4726,21 +4726,29 @@ namespace Game.Spells if (!aurApp.IsPositive() || aura.IsPassive() || aura.GetSpellInfo().HasAttribute(SpellAttr4.NotStealable)) continue; + // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance." + int chance = aura.CalcDispelChance(unitTarget, !unitTarget.IsFriendlyTo(m_caster)); + if (chance == 0) + continue; + // The charges / stack amounts don't count towards the total number of auras that can be dispelled. - // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) . 50% chance to dispell - // Polymorph instead of 1 / (5 + 1) . 16%. + // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell + // Polymorph instead of 1 / (5 + 1) -> 16%. bool dispelCharges = aura.GetSpellInfo().HasAttribute(SpellAttr7.DispelCharges); byte charges = dispelCharges ? aura.GetCharges() : aura.GetStackAmount(); if (charges > 0) - steal_list.Add(Tuple.Create(aura, charges)); + stealList.Add(new DispelableAura(aura, chance, charges)); } } - if (steal_list.Empty()) + if (stealList.Empty()) return; + int remaining = stealList.Count; + // Ok if exist some buffs for dispel try dispel it - List> success_list = new List>(); + uint failCount = 0; + List> successList = new List>(); DispelFailed dispelFailed = new DispelFailed(); dispelFailed.CasterGUID = m_caster.GetGUID(); @@ -4748,40 +4756,32 @@ namespace Game.Spells dispelFailed.SpellID = m_spellInfo.Id; // dispel N = damage buffs (or while exist buffs for dispel) - for (int count = 0; count < damage && !steal_list.Empty();) + for (int count = 0; count < damage && remaining > 0;) { // Random select buff for dispel - var pair = steal_list[RandomHelper.IRand(0, steal_list.Count - 1)]; + var dispelableAura = stealList[RandomHelper.IRand(0, remaining - 1)]; - int chance = pair.Item1.CalcDispelChance(unitTarget, !unitTarget.IsFriendlyTo(m_caster)); - // 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance." - if (chance == 0) + if (dispelableAura.RollDispel()) { - steal_list.Remove(pair); - continue; + successList.Add(Tuple.Create(dispelableAura.GetAura().GetId(), dispelableAura.GetAura().GetCasterGUID())); + if (!dispelableAura.DecrementCharge()) + { + --remaining; + stealList[remaining] = dispelableAura; + } } else { - if (RandomHelper.randChance(chance)) - { - success_list.Add(new KeyValuePair(pair.Item1.GetId(), pair.Item1.GetCasterGUID())); - var temp = pair.Item2; - --temp; - pair = Tuple.Create(pair.Item1, temp); - if (pair.Item2 <= 0) - steal_list.Remove(pair); - } - else - dispelFailed.FailedSpells.Add(pair.Item1.GetId()); - - ++count; + ++failCount; + dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId()); } + ++count; } if (!dispelFailed.FailedSpells.Empty()) m_caster.SendMessageToSet(dispelFailed, true); - if (success_list.Empty()) + if (successList.Empty()) return; SpellDispellLog spellDispellLog = new SpellDispellLog(); @@ -4792,15 +4792,15 @@ namespace Game.Spells spellDispellLog.CasterGUID = m_caster.GetGUID(); spellDispellLog.DispelledBySpellID = m_spellInfo.Id; - foreach (var dispell in success_list) + foreach (var dispell in successList) { var dispellData = new SpellDispellData(); - dispellData.SpellID = dispell.Key; + dispellData.SpellID = dispell.Item1; dispellData.Harmful = false; // TODO: use me //dispellData.Rolled = none; // TODO: use me //dispellData.Needed = none; // TODO: use me - unitTarget.RemoveAurasDueToSpellBySteal(dispell.Key, dispell.Value, m_caster); + unitTarget.RemoveAurasDueToSpellBySteal(dispell.Item1, dispell.Item2, m_caster); spellDispellLog.DispellData.Add(dispellData); }