From 060bc0b7a88cdccb4d41bb0860aade7c6809bc60 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 12 Mar 2018 13:24:16 -0400 Subject: [PATCH] Core/Spell: Undefined SPELL_ATTR7_USABLE_IN_STUN_FEAR_CONFUSION attr for now - Some function renames - Used in some client checks but not 100% sure of its usage (eg in CGUnit_C::CheckAndReportSpellInhibitFlags but not in Spell_C::IsUsableAction) --- .../Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/DataStorage/DB2Manager.cs | 2 +- Source/Game/Entities/Player/PlayerTaxi.cs | 4 +- Source/Game/Handlers/CharacterHandler.cs | 2 +- Source/Game/Spells/Spell.cs | 64 +++++++++---------- Source/Game/Spells/SpellInfo.cs | 3 +- 6 files changed, 35 insertions(+), 42 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 9081038f7..f61289405 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1553,7 +1553,7 @@ namespace Framework.Constants Unk17 = 0x20000, // 17 Only 27965 (Suicide) Spell. HasChargeEffect = 0x40000, // 18 Only Spells That Have Charge Among Effects. ZoneTeleport = 0x80000, // 19 Teleports To Specific Zones. - UsableInStunFearConfusion = 0x100000, // 20 Blink, Divine Shield, Ice Block + Unk20 = 0x100000, // 20 Blink, Divine Shield, Ice Block Unk21 = 0x200000, // 21 Not Set Unk22 = 0x400000, // 22 Unk23 = 0x800000, // 23 Motivate, Mutilate, Shattering Throw diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index 5c0bed071..2422090e3 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -98,7 +98,7 @@ namespace Game.DataStorage CliDB.CharSectionsStorage.Clear(); foreach (var outfit in CliDB.CharStartOutfitStorage.Values) - _charStartOutfits[(uint)(outfit.RaceID | (outfit.ClassID << 8) | (outfit.GenderID << 16))] = outfit; + _charStartOutfits[(uint)((byte)outfit.RaceID | (outfit.ClassID << 8) | (outfit.GenderID << 16))] = outfit; var powers = new List(); foreach (var chrClasses in CliDB.ChrClassesXPowerTypesStorage.Values) diff --git a/Source/Game/Entities/Player/PlayerTaxi.cs b/Source/Game/Entities/Player/PlayerTaxi.cs index ab087ca53..20209f2d2 100644 --- a/Source/Game/Entities/Player/PlayerTaxi.cs +++ b/Source/Game/Entities/Player/PlayerTaxi.cs @@ -34,7 +34,7 @@ namespace Game.Entities { case Class.Deathknight: { - for (byte i = 0; i < PlayerConst.TaxiMaskSize; ++i) + for (int i = 0; i < PlayerConst.TaxiMaskSize; ++i) m_taximask[i] |= (byte)(CliDB.OldContinentsNodesMask[i] & factionMask[i]); break; } @@ -105,7 +105,7 @@ namespace Game.Entities { var split = new StringArray(data, ' '); - byte index = 0; + int index = 0; for (var i = 0; index < PlayerConst.TaxiMaskSize && i != split.Length; ++i, ++index) { // load and set bits only for existing taxi nodes diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index 046a36070..a6cb36b2c 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -1703,7 +1703,7 @@ namespace Game var factionMask = newTeamId == TeamId.Horde ? CliDB.HordeTaxiNodesMask : CliDB.AllianceTaxiNodesMask; - for (byte i = 0; i < PlayerConst.TaxiMaskSize; ++i) + for (int i = 0; i < PlayerConst.TaxiMaskSize; ++i) { // i = (315 - 1) / 8 = 39 // m = 1 << ((315 - 1) % 8) = 4 diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index e8eefc763..9f876f207 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -5469,13 +5469,6 @@ namespace Game.Spells bool usableWhileStunned = m_spellInfo.HasAttribute(SpellAttr5.UsableWhileStunned); bool usableWhileFeared = m_spellInfo.HasAttribute(SpellAttr5.UsableWhileFeared); bool usableWhileConfused = m_spellInfo.HasAttribute(SpellAttr5.UsableWhileConfused); - if (m_spellInfo.HasAttribute(SpellAttr7.UsableInStunFearConfusion)) - { - usableWhileStunned = true; - usableWhileFeared = true; - usableWhileConfused = true; - } - // Check whether the cast should be prevented by any state you might have. SpellCastResult result = SpellCastResult.SpellCastOk; @@ -5485,18 +5478,18 @@ namespace Game.Spells { Unit charmer = m_caster.GetCharmer(); if (charmer) - if (charmer.GetUnitBeingMoved() != m_caster && CheckCasterNotImmunedCharmAuras(ref param1)) + if (charmer.GetUnitBeingMoved() != m_caster && !CheckSpellCancelsCharm(ref param1)) result = SpellCastResult.Charmed; } - else if (unitflag.HasAnyFlag(UnitFlags.Stunned) && !usableWhileStunned && CheckCasterNotImmunedStunAuras(ref param1)) + else if (unitflag.HasAnyFlag(UnitFlags.Stunned) && !usableWhileStunned && !CheckSpellCancelsStun(ref param1)) result = SpellCastResult.Stunned; - else if (unitflag.HasAnyFlag(UnitFlags.Silenced) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && CheckCasterNotImmunedSilenceAuras(ref param1)) + else if (unitflag.HasAnyFlag(UnitFlags.Silenced) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Silence) && !CheckSpellCancelsSilence(ref param1)) result = SpellCastResult.Silenced; - else if (unitflag.HasAnyFlag(UnitFlags.Pacified) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && CheckCasterNotImmunedPacifyAuras(ref param1)) + else if (unitflag.HasAnyFlag(UnitFlags.Pacified) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.Pacify) && !CheckSpellCancelsPacify(ref param1)) result = SpellCastResult.Pacified; - else if (unitflag.HasAnyFlag(UnitFlags.Fleeing) && !usableWhileFeared && CheckCasterNotImmunedFearAuras(ref param1)) + else if (unitflag.HasAnyFlag(UnitFlags.Fleeing) && !usableWhileFeared && !CheckSpellCancelsFear(ref param1)) result = SpellCastResult.Fleeing; - else if (unitflag.HasAnyFlag(UnitFlags.Confused) && !usableWhileConfused && CheckCasterNotImmunedDisorientAuras(ref param1)) + else if (unitflag.HasAnyFlag(UnitFlags.Confused) && !usableWhileConfused && !CheckSpellCancelsConfuse(ref param1)) result = SpellCastResult.Confused; else if (m_caster.HasFlag(UnitFields.Flags2, UnitFlags2.NoActions) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.NoActions)) result = SpellCastResult.NoActions; @@ -5507,60 +5500,61 @@ namespace Game.Spells return SpellCastResult.SpellCastOk; } - // based on sub_00804430 from 12340 client - bool CheckCasterHasNotImmunedAuraType(AuraType auraType, ref uint param1) + bool CheckSpellCancelsAuraEffect(AuraType auraType, ref uint param1) { // Checking auras is needed now, because you are prevented by some state but the spell grants immunity. var auraEffects = m_caster.GetAuraEffectsByType(auraType); if (auraEffects.Empty()) - return false; + return true; foreach (AuraEffect aurEff in auraEffects) { - if (m_spellInfo.CanSpellCastOverrideAuraEffect(aurEff)) + if (m_spellInfo.SpellCancelsAuraEffect(aurEff)) continue; param1 = (uint)aurEff.GetSpellEffectInfo().Mechanic; if (param1 == 0) param1 = (uint)aurEff.GetSpellInfo().Mechanic; - return true; + + return false; } - return false; + return true; } - bool CheckCasterNotImmunedCharmAuras(ref uint param1) + bool CheckSpellCancelsCharm(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModCharm, ref param1) || - CheckCasterHasNotImmunedAuraType(AuraType.AoeCharm, ref param1) || - CheckCasterHasNotImmunedAuraType(AuraType.ModPossess, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModCharm, ref param1) || + CheckSpellCancelsAuraEffect(AuraType.AoeCharm, ref param1) || + CheckSpellCancelsAuraEffect(AuraType.ModPossess, ref param1); } - bool CheckCasterNotImmunedStunAuras(ref uint param1) + bool CheckSpellCancelsStun(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModStun, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModStun, ref param1) && + CheckSpellCancelsAuraEffect(AuraType.Strangulate, ref param1); } - bool CheckCasterNotImmunedSilenceAuras(ref uint param1) + bool CheckSpellCancelsSilence(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModSilence, ref param1) || - CheckCasterHasNotImmunedAuraType(AuraType.ModPacifySilence, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModSilence, ref param1) || + CheckSpellCancelsAuraEffect(AuraType.ModPacifySilence, ref param1); } - bool CheckCasterNotImmunedPacifyAuras(ref uint param1) + bool CheckSpellCancelsPacify(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModPacify, ref param1) || - CheckCasterHasNotImmunedAuraType(AuraType.ModPacifySilence, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModPacify, ref param1) || + CheckSpellCancelsAuraEffect(AuraType.ModPacifySilence, ref param1); } - bool CheckCasterNotImmunedFearAuras(ref uint param1) + bool CheckSpellCancelsFear(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModFear, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModFear, ref param1); } - bool CheckCasterNotImmunedDisorientAuras(ref uint param1) + bool CheckSpellCancelsConfuse(ref uint param1) { - return CheckCasterHasNotImmunedAuraType(AuraType.ModConfuse, ref param1); + return CheckSpellCancelsAuraEffect(AuraType.ModConfuse, ref param1); } SpellCastResult CheckArenaAndRatedBattlegroundCastRules() diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index cb01d9785..aa9ebf6e2 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -2465,8 +2465,7 @@ namespace Game.Spells return false; } - // based on client sub_007FDFA0 - public bool CanSpellCastOverrideAuraEffect(AuraEffect aurEff) + public bool SpellCancelsAuraEffect(AuraEffect aurEff) { if (!HasAttribute(SpellAttr1.DispelAurasOnImmunity)) return false;