Core/Spells: Fixed Heroic Leap

Closes #14807
Closes #14134
This commit is contained in:
Boomper
2016-01-27 21:53:05 +01:00
committed by Shauren
parent 2e2fe86f31
commit 3f503cd1d1
2 changed files with 124 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_warr_heroic_leap', 'spell_warr_heroic_leap_jump');
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(6544,'spell_warr_heroic_leap'),
(178368,'spell_warr_heroic_leap_jump');
UPDATE `creature_template` SET `flags_extra`=`flags_extra`|0x80 WHERE `entry`=47319;

View File

@@ -62,7 +62,11 @@ enum WarriorSpells
SPELL_WARRIOR_UNRELENTING_ASSAULT_TRIGGER_1 = 64849,
SPELL_WARRIOR_UNRELENTING_ASSAULT_TRIGGER_2 = 64850,
SPELL_WARRIOR_VIGILANCE_PROC = 50725,
SPELL_WARRIOR_VENGEANCE = 76691
SPELL_WARRIOR_VENGEANCE = 76691,
SPELL_WARRIOR_HEROIC_LEAP_JUMP = 178368,
SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP = 159708,
SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP_BUFF = 133278,
SPELL_WARRIOR_IMPROVED_HEROIC_LEAP = 157449,
};
enum WarriorSpellIcons
@@ -948,6 +952,117 @@ class spell_warr_vigilance_trigger : public SpellScriptLoader
}
};
// Heroic leap - 6544
class spell_warr_heroic_leap : public SpellScriptLoader
{
public:
spell_warr_heroic_leap() : SpellScriptLoader("spell_warr_heroic_leap") { }
class spell_warr_heroic_leap_SpellScript : public SpellScript
{
PrepareSpellScript(spell_warr_heroic_leap_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_HEROIC_LEAP_JUMP))
return false;
return true;
}
SpellCastResult CheckElevation()
{
if (WorldLocation const* dest = GetExplTargetDest())
{
if (GetCaster()->HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
return SPELL_FAILED_ROOTED;
if (GetCaster()->GetMap()->Instanceable())
{
float range = GetSpellInfo()->GetMaxRange(true, GetCaster()) * 1.5f;
PathGenerator generatedPath(GetCaster());
generatedPath.SetPathLengthLimit(range);
bool result = generatedPath.CalculatePath(dest->GetPositionX(), dest->GetPositionY(), dest->GetPositionZ(), false, true);
if (generatedPath.GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
else if (!result || generatedPath.GetPathType() & PATHFIND_NOPATH)
{
result = generatedPath.CalculatePath(dest->GetPositionX(), dest->GetPositionY(), dest->GetPositionZ(), false, false);
if (generatedPath.GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
else if (!result || generatedPath.GetPathType() & PATHFIND_NOPATH)
return SPELL_FAILED_NOPATH;
}
}
else if (dest->GetPositionZ() > GetCaster()->GetPositionZ() + 4.0f)
return SPELL_FAILED_NOPATH;
return SPELL_CAST_OK;
}
return SPELL_FAILED_NO_VALID_TARGETS;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (WorldLocation* dest = GetHitDest())
GetCaster()->CastSpell(dest->GetPositionX(), dest->GetPositionY(), dest->GetPositionZ(), SPELL_WARRIOR_HEROIC_LEAP_JUMP, true);
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_warr_heroic_leap_SpellScript::CheckElevation);
OnEffectHit += SpellEffectFn(spell_warr_heroic_leap_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_warr_heroic_leap_SpellScript();
}
};
// Heroic Leap (triggered by Heroic Leap (6544)) - 178368
class spell_warr_heroic_leap_jump : public SpellScriptLoader
{
public:
spell_warr_heroic_leap_jump() : SpellScriptLoader("spell_warr_heroic_leap_jump") { }
class spell_warr_heroic_leap_jump_SpellScript : public SpellScript
{
PrepareSpellScript(spell_warr_heroic_leap_jump_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP) ||
!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP_BUFF) ||
!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_IMPROVED_HEROIC_LEAP) ||
!sSpellMgr->GetSpellInfo(SPELL_WARRIOR_TAUNT))
return false;
return true;
}
void AfterJump(SpellEffIndex /*effIndex*/)
{
if (GetCaster()->HasAura(SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP))
GetCaster()->CastSpell(GetCaster(), SPELL_WARRIOR_GLYPH_OF_HEROIC_LEAP_BUFF, true);
if (GetCaster()->HasAura(SPELL_WARRIOR_IMPROVED_HEROIC_LEAP))
GetCaster()->GetSpellHistory()->ResetCooldown(SPELL_WARRIOR_TAUNT, true);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_warr_heroic_leap_jump_SpellScript::AfterJump, EFFECT_1, SPELL_EFFECT_JUMP_DEST);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_warr_heroic_leap_jump_SpellScript();
}
};
void AddSC_warrior_spell_scripts()
{
new spell_warr_bloodthirst();
@@ -972,4 +1087,6 @@ void AddSC_warrior_spell_scripts()
new spell_warr_victorious();
new spell_warr_vigilance();
new spell_warr_vigilance_trigger();
new spell_warr_heroic_leap();
new spell_warr_heroic_leap_jump();
}