Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Core/Spells): Adding CCDelay #1969

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Spell.cpp - Adding CCDelay
Implementing CCDelay
  • Loading branch information
Shard-MW committed Jun 13, 2019
commit 2ddd5c20806efe06a6c7376849cb8b18f1ad5181
305 changes: 304 additions & 1 deletion src/server/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,12 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
else
targetInfo.timeDelay = 0LL;

{
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)
{
Expand Down Expand Up @@ -3791,7 +3797,7 @@ void Spell::_cast(bool skipCheck)
SendSpellGo();

// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled())/* xinef: we dont need this shit || m_spellInfo->Id == 14157*/)
if (((m_spellInfo->Speed > 0.0f || GetCCDelay(m_spellInfo) > 0) && !m_spellInfo->IsChanneled()))
{
// 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
Expand Down Expand Up @@ -6392,6 +6398,303 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
return CheckCast(true);
}

uint32 Spell::GetCCDelay(SpellInfo const* _spell)
{
// CCDelay for spell with auras
uint8 CCDArraySize = 7;
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
};

const uint32 delayForRoots = 70;
const uint32 delayForStuns = 130;
const uint32 delayForDisarms = 70;
const uint32 delayForDisorients = 130;
const uint32 delayForFears = 130;
const uint32 delayForHorrors = 130;
const uint32 delayForOpenerStuns = 100;
const uint32 delayForScatters = 130;
const uint32 delayForBanishes = 130;
const uint32 delayForSilences = 130;
const uint32 delayForInstantSpells = 100;

switch (_spell->SpellFamilyName)
{
case SPELLFAMILY_WARRIOR:
// Charge
if (_spell->Id == 11578)
return delayForOpenerStuns;
if (_spell->Id == 7922)
return delayForOpenerStuns;
// Intercept
if (_spell->Id == 20252)
return delayForStuns;
if (_spell->Id == 20253)
return delayForStuns;
// Charge triggered
if (_spell->Id == 65929)
return delayForStuns;
// Concussion Blow
if (_spell->Id == 12809)
return delayForStuns;
// Shockwave
if (_spell->Id == 46968)
return delayForStuns;
// Intimidating Shout
if (_spell->Id == 5246)
return delayForFears;
if (_spell->Id == 20511)
return delayForFears;
// Disarm
if (_spell->Id == 676)
return delayForDisarms;
// Talent - Gag order proc
if (_spell->Id == 18498)
return delayForSilences;
break;

case SPELLFAMILY_PALADIN:
// Talent - Shield of the Templar proc
if (_spell->Id == 63529)
return delayForSilences;
// Hammer of Justice
if (_spell->Id == 853 || _spell->Id == 5588 || _spell->Id == 5589 || _spell->Id == 10308)
return delayForStuns;
// Seal of justice stun proc
if (_spell->Id == 20170)
return delayForStuns;
// Repentance
if (_spell->Id == 20066)
return delayForDisorients;
// Turn Evil
if (_spell->Id == 10326)
return delayForFears;
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 || _spell->Id == 24132 || _spell->Id == 24133 || _spell->Id == 27068 || _spell->Id == 49011 || _spell->Id == 49012)
return delayForDisorients;
// Scare beast
if (_spell->Id == 1513 || _spell->Id == 14326 || _spell->Id == 14327)
return delayForFears;
// Silencing shot
if (_spell->Id == 34490)
return delayForSilences;
break;

case SPELLFAMILY_ROGUE:
// Shadowstep
if (_spell->Id == 36554)
return delayForInstantSpells;
// 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 || _spell->Id == 8643)
return delayForStuns;
// Sap
if (_spell->Id == 6770 || _spell->Id == 2070 || _spell->Id == 11297 || _spell->Id == 51724)
return delayForDisorients;
// Dismantle
if (_spell->Id == 51722)
return delayForDisarms;
// Talent - Silenced - Improved Kick
if (_spell->Id == 18425)
return delayForSilences;
break;

case SPELLFAMILY_PRIEST:
// Mind Control
if (_spell->Id == 605)
return 0;
// Psychic Scream
if (_spell->Id == 10890 || _spell->Id == 10888 || _spell->Id == 8124 || _spell->Id == 8122)
return delayForFears;
// Psychic Horror
if (_spell->Id == 64044)
return delayForHorrors;
// Shackle Undead
if (_spell->Id == 10955 || _spell->Id == 9485 || _spell->Id == 9484)
return delayForDisorients;
// Silence
if (_spell->Id == 15487)
return delayForSilences;
break;

case SPELLFAMILY_DEATHKNIGHT:
// Strangulate
if (_spell->Id == 47476)
return delayForSilences;
// Death Grip
if (_spell->Id == 49576)
return delayForInstantSpells;
// Hungering Cold
if (_spell->Id == 49203)
return delayForDisorients;
break;

case SPELLFAMILY_SHAMAN:
// Hex
if (_spell->Id == 51514)
return delayForDisorients;
// Feral bash
if (_spell->Id == 58861)
return delayForStuns;
// Talent - Earth's Grasp root
if (_spell->Id == 64695)
return delayForRoots;
break;

case SPELLFAMILY_MAGE:
// Deep Freeze
if (_spell->Id == 44572)
return delayForStuns;
// Dragon Breath
if (_spell->Id == 42950 || _spell->Id == 42949 || _spell->Id == 33043 || _spell->Id == 33042 || _spell->Id == 33041 || _spell->Id == 31661)
return delayForDisorients;
// Polymorph
if (_spell->Id == 12826 || _spell->Id == 12825 || _spell->Id == 12824 || _spell->Id == 118)
return delayForDisorients;
// Talent - Improved Counter spell silence
if (_spell->Id == 18469)
return delayForSilences;
// Talent - Frostbite
if (_spell->Id == 12494)
return delayForRoots;
// Frostnova
if (_spell->Id == 122 || _spell->Id == 865 || _spell->Id == 6131 || _spell->Id == 10230 || _spell->Id == 27088 || _spell->Id == 42917)
return delayForRoots;
// Pet - Freeze
if (_spell->Id == 33395)
return delayForRoots;
break;

case SPELLFAMILY_WARLOCK:
// Pet - Succubus - Seduction
if (_spell->Id == 6358)
return delayForBanishes;
// Banish
if (_spell->Id == 710 || _spell->Id == 18647)
return delayForBanishes;
// DeathCoil
if (_spell->Id == 6789 || _spell->Id == 17925 || _spell->Id == 17926 || _spell->Id == 27223 || _spell->Id == 47859 || _spell->Id == 47860)
return delayForHorrors;
// Pet - Felguard's intercept
if (_spell->Id == 47996)
return delayForStuns;
// Fear
if (_spell->Id == 5782 || _spell->Id == 6213 || _spell->Id == 6215)
return delayForFears;
// Howl of Terror
if (_spell->Id == 5484 || _spell->Id == 17928)
return delayForFears;
// Shadowfury
if (_spell->Id == 30283 || _spell->Id == 30413 || _spell->Id == 30414 || _spell->Id == 47846 || _spell->Id == 47847)
return delayForStuns;
// Pet - Spell Lock - Silenced
if (_spell->Id == 24259)
return delayForSilences;
break;

case SPELLFAMILY_DRUID:
// Bash
if (_spell->Id == 5211 || _spell->Id == 6798 || _spell->Id == 8983)
return delayForStuns;
// Cyclone
if (_spell->Id == 33786)
return delayForBanishes;
// Hibernate
if (_spell->Id == 2637 || _spell->Id == 18657 || _spell->Id == 18658)
return delayForDisorients;
// Feral charge - Bear
if (_spell->Id == 45334)
return delayForInstantSpells;
// Feral charge - Cat
if (_spell->Id == 49376)
return delayForInstantSpells;
// Maim
if (_spell->Id == 22570 || 49802)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (_spell->Id == 22570 || _spell->Id == 49802)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lineagedr fixed !
And it passed Travis build... Strange

return delayForStuns;
// Pounce
if (_spell->Id == 9005 || _spell->Id == 9823 || _spell->Id == 9827 || _spell->Id == 27006 || _spell->Id == 49803)
return delayForOpenerStuns;
// Entangling roots
if (_spell->Id == 339 || _spell->Id == 1062 || _spell->Id == 5195 || _spell->Id == 5196 || _spell->Id == 9852 || _spell->Id == 9853 || _spell->Id == 26989 || _spell->Id == 53308)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entire code could be improved there's no need to check for all of these spells where you could do:

if (_spell->Mechanic == MECHANIC_ROOT)

And for stuns

if (_spell->Mechanic == MECHANIC_STUN) And so on and so fourth. Take a look at: https://github.com/azerothcore/azerothcore-wotlk/blob/master/src/server/game/Miscellaneous/SharedDefines.h#L1203

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true but some spells like Dragon's Breath, Frost Nova, Mage - Pet - Freeze, Felguard's Intercept and more doesn't have any mechanic assigned, so I prefered to keep the basic functioning by doing case by case.
Plus, there is some spells like hunter traps, or priest's Mind Control that don't require a delay.
I know if there is a delay on Mind Control and the targeted player use Repentance at the same time, priest will get 1min cc instead of 10sec.

Copy link
Contributor

@lineagedr lineagedr Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For spells such as Dragon's Breath you can use
if (_spell->SpellIconID == 1548)
Frost nova:
MECHANIC_ROOT
Water Elemental Freeze:
if (_spell->Id == 33395)

It's fine to use Ids for spells that have no mechanic or special cases such as the hunter traps where they share MECHANIC_STUN, but using this:

// Entangling roots
if (_spell->Id == 339 || _spell->Id == 1062 || _spell->Id == 5195 || _spell->Id == 5196 || _spell->Id == 9852 || _spell->Id == 9853 || _spell->Id == 26989 || _spell->Id == 53308)

Instead of this:

// Entangling roots 
if (_spell->Mechanic == MECHANIC_ROOT)

Is madness.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lineagedr Should be better now

return delayForRoots;
break;

case SPELLFAMILY_GENERIC:
// Warrior - Improved Hamstring
if (_spell->Id == 23694)
return delayForRoots;
// Rogue - Garote silence
if (_spell->Id == 1330)
return delayForSilences;
// War Stomp - Tauren's racial
if (_spell->Id == 46026)
return delayForStuns;
// Mage - Talent - Impact
if (_spell->Id == 12355)
return delayForStuns;
// Warlock - Demon charge
if (_spell->Id == 60995 || _spell->Id == 54785)
return delayForStuns;
// Warlock - Pet - Felguard intercept trigg.
if (_spell->Id == 47995)
return delayForStuns;
// Hunter - Pet - Intimidation
if (_spell->Id == 24394)
return delayForStuns;
// DK - Pet - Gnaw (ghoul's stun)
if (_spell->Id == 47481)
return delayForStuns;


/* --- Other spells --- */
// Custom - Paladin Ret
if (_spell->Id == 100012)
return delayForSilences;
// Custom - Shaman Ele
if (_spell->Id == 100034)
return delayForStuns;
// Custom - DK Frost
if (_spell->Id == 100025)
return delayForRoots;
break;
}

for (uint8 i = 0; i < CCDArraySize; ++i)
if (_spell->HasAura(auraWithCCD[i]))
return delayForInstantSpells;

return 0;
}

SpellCastResult Spell::CheckCasterAuras(bool preventionOnly) const
{
// spells totally immuned to caster auras (wsg flag drop, give marks etc)
Expand Down