Skip to content

Instantly share code, notes, and snippets.

@irancore
Created August 9, 2018 12:32
Show Gist options
  • Save irancore/dfacabd72206d3d8f68cfd37ee502404 to your computer and use it in GitHub Desktop.
Save irancore/dfacabd72206d3d8f68cfd37ee502404 to your computer and use it in GitHub Desktop.
From 17f4d78f7c212918b58cde747e5e0e9fc09d2d21 Mon Sep 17 00:00:00 2001
From: irancore <amir.cinderella@gmail.com>
Date: Thu, 9 Aug 2018 17:00:06 +0430
Subject: [PATCH] CCDelay last rev
---
src/server/game/Spells/Spell.cpp | 202 ++++++++++++++++++++++++++++++++++++++-
src/server/game/Spells/Spell.h | 2 +
2 files changed, 202 insertions(+), 2 deletions(-)
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 58c2fa7755..cfb4fd8190 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2148,7 +2148,11 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
}
else
targetInfo.TimeDelay = 0ULL;
-
+ {
+ targetInfo.TimeDelay = GetCCDelay(m_spellInfo);
+ if (m_delayMoment == 0 || m_delayMoment > targetInfo.TimeDelay)
+ m_delayMoment = targetInfo.TimeDelay;
+ }
// If target reflect spell back to caster
if (targetInfo.MissCondition == SPELL_MISS_REFLECT)
{
@@ -3387,7 +3391,8 @@ void Spell::_cast(bool skipCheck)
creatureCaster->ReleaseFocus(this);
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
- if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled()) || m_spellInfo->HasAttribute(SPELL_ATTR4_UNK4))
+ //if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled()) || m_spellInfo->HasAttribute(SPELL_ATTR4_UNK4))
+ if (((m_spellInfo->Speed > 0.0f || GetCCDelay(m_spellInfo) > 0) && !m_spellInfo->IsChanneled()) || m_spellInfo->Id == 14157 || m_spellInfo->Id == 70802)
{
// Remove used for cast item if need (it can be already NULL after TakeReagents call
// in case delayed spell remove item at cast delay start
@@ -5995,6 +6000,199 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
return CheckCast(true);
}
+uint32 Spell::GetCCDelay(SpellInfo const* _spell)
+{
+ // CCD for spell with auras
+ AuraType auraWithCCD[] =
+ {
+ SPELL_AURA_MOD_STUN,
+ SPELL_AURA_MOD_CONFUSE,
+ SPELL_AURA_MOD_FEAR,
+ SPELL_AURA_MOD_SILENCE,
+ SPELL_AURA_MOD_DISARM,
+ SPELL_AURA_MOD_ROOT,
+ SPELL_AURA_MOD_POSSESS
+ };
+ uint8 CCDArraySize = 7;
+
+ const uint32 delayForRoots = 0; // currently unused
+ const uint32 delayForStuns = 50;
+ const uint32 delayForDisarms = 0; // currently unused
+ const uint32 delayForDisorients = 100;
+ const uint32 delayForFears = 100;
+ const uint32 delayForHorrors = 50;
+ const uint32 delayForOpenerStuns = 70;
+ const uint32 delayForScatters = 100;
+ const uint32 delayForBanishes = 50;
+ const uint32 NOdelayForInstantSpells = 0;
+
+ switch(_spell->SpellFamilyName)
+ {
+ case SPELLFAMILY_DEATHKNIGHT:
+ // Death Grip
+ if (_spell->Id == 49576)
+ return NOdelayForInstantSpells;
+ // Hungering Cold
+ if (_spell->Id == 49203)
+ return delayForDisorients;
+ // Gnaw (ghoul's stun)
+ if (_spell->Id == 47481)
+ return delayForStuns;
+ break;
+ case SPELLFAMILY_DRUID:
+ // Bash
+ if (_spell->Id == 5211)
+ return delayForStuns;
+ // Cyclone
+ if (_spell->Id == 33786)
+ return delayForBanishes;
+ // Hibernate
+ if (_spell->Id == 2637)
+ return delayForDisorients;
+ // Feral charge
+ if (_spell->Id == 45334)
+ return NOdelayForInstantSpells;
+ // Maim
+ if (_spell->Id == 22570)
+ return delayForStuns;
+ // Pounce
+ if (_spell->Id == 9005)
+ return delayForOpenerStuns;
+ break;
+ case SPELLFAMILY_HUNTER: // TODO all pet's cc
+ // Traps
+ if (_spell->SpellFamilyFlags[0] & 0x8 || // Frozen trap
+ _spell->Id == 57879 || // Snake Trap
+ _spell->SpellFamilyFlags[2] & 0x00024000) // Explosive and Immolation Trap
+ return 0;
+ // Entrapment
+ if (_spell->SpellIconID == 20)
+ return 0;
+ // Scatter Shot
+ if (_spell->Id == 19503)
+ return delayForScatters;
+ // Wyvern Sting
+ if (_spell->Id == 19386)
+ return delayForDisorients;
+ break;
+ case SPELLFAMILY_MAGE:
+ // Deep Freeze
+ if (_spell->Id == 44572)
+ return delayForStuns;
+ // Dragon Breath
+ if (_spell->Id == 42950)
+ return delayForDisorients;
+ // Impact
+ if (_spell->Id == 64343)
+ return delayForStuns;
+ // Polymorph
+ if (_spell->Id == 12826)
+ return delayForDisorients;
+ break;
+ case SPELLFAMILY_PALADIN:
+ // Hammer of Justice
+ if (_spell->Id == 853)
+ return delayForStuns;
+ // Repentance
+ if (_spell->Id == 20066)
+ return delayForDisorients;
+ // Turn Evil
+ if (_spell->Id == 10326)
+ return delayForFears;
+ break;
+ case SPELLFAMILY_PRIEST:
+ // Psychic Scream
+ if (_spell->Id == 10890)
+ return delayForFears;
+ // Mind Control
+ if (_spell->Id == 605)
+ return delayForBanishes;
+ // Psychic Horror
+ if (_spell->Id == 64044)
+ return delayForHorrors;
+ // Shackle Undead
+ if (_spell->Id == 9484)
+ return delayForDisorients;
+ break;
+ case SPELLFAMILY_ROGUE:
+ // Blind
+ if (_spell->Id == 2094)
+ return delayForDisorients;
+ // CheapShot
+ if (_spell->Id == 1833)
+ return delayForOpenerStuns;
+ // Gouge
+ if (_spell->Id == 1776)
+ return delayForDisorients;
+ // Kidney Shot
+ if (_spell->Id == 408)
+ return delayForStuns;
+ // Sap
+ if (_spell->Id == 6770)
+ return delayForDisorients;
+ break;
+ case SPELLFAMILY_SHAMAN:
+ // Hex
+ if (_spell->Id == 51514)
+ return delayForDisorients;
+ break;
+ case SPELLFAMILY_WARLOCK: // TODO felguard's intercept(27826?), seduction
+ // Banish
+ if (_spell->Id == 710)
+ return delayForBanishes;
+ // DeathCoil
+ if (_spell->Id == 27223)
+ return delayForHorrors;
+ // Demon charge
+ if (_spell->Id == 60995) // might use 54785 - req testing
+ return delayForStuns;
+ // Fear
+ if (_spell->Id == 5782)
+ return delayForFears;
+ // Howl of Terror
+ if (_spell->Id == 5484)
+ return delayForFears;
+ // Shadowfury
+ if (_spell->Id == 30283)
+ return delayForStuns;
+ // Spell Lock - Debuff
+ if (_spell->Id == 24259)
+ return NOdelayForInstantSpells;
+ break;
+ case SPELLFAMILY_WARRIOR:
+ // Charge
+ if (_spell->Id == 7922)
+ return delayForOpenerStuns;
+ // Charge trig.
+ if (_spell->Id == 65929)
+ return delayForStuns;
+ // Concussion Blow
+ if (_spell->Id == 12809)
+ return delayForStuns;
+ // Intercept
+ if (_spell->Id == 20253)
+ return delayForStuns;
+ // Intimidating Shout
+ if (_spell->Id == 20511)
+ return delayForFears;
+ // Shockwave
+ if (_spell->Id == 46968)
+ return delayForStuns;
+ break;
+ case SPELLFAMILY_GENERIC: // is that ok?!
+ // War Stomp - Tauren's racial
+ if (_spell->Id == 46026)
+ return delayForStuns;
+ break;
+ }
+
+ for (uint8 i = 0; i < CCDArraySize; ++i)
+ if (_spell->HasAura(auraWithCCD[i]))
+ return NOdelayForInstantSpells;
+
+ return 0;
+}
+
SpellCastResult Spell::CheckCasterAuras(uint32* param1) const
{
Unit* unitCaster = (m_originalCaster ? m_originalCaster : m_caster->ToUnit());
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 691bddf43f..329db93474 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -429,6 +429,8 @@ class TC_GAME_API Spell
SpellCastResult CheckCast(bool strict, uint32* param1 = nullptr, uint32* param2 = nullptr);
SpellCastResult CheckPetCast(Unit* target);
+
+ static uint32 GetCCDelay(SpellInfo const* _spell);
// handlers
void handle_immediate();
--
2.16.2.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment