Scripts/Spells: Generic spell script for quest portals (#27305)
(cherry picked from commit 251304b19c2fc42ee330b9a533b54f7b80df5d4a)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
--
|
||||
DELETE FROM `spell_scripts` WHERE `id` = 53099;
|
||||
|
||||
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_teleport_leaders_blessing','spell_59064_59439_portals');
|
||||
DELETE FROM `spell_script_names` WHERE `spell_id` IN (53099,57896,58418,58420,59064,59065,59439,60900,60940) AND `ScriptName` = 'spell_quest_portal_with_condition';
|
||||
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
|
||||
(53099,'spell_quest_portal_with_condition'),
|
||||
(57896,'spell_quest_portal_with_condition'),
|
||||
(58418,'spell_quest_portal_with_condition'),
|
||||
(58420,'spell_quest_portal_with_condition'),
|
||||
(59064,'spell_quest_portal_with_condition'),
|
||||
(59065,'spell_quest_portal_with_condition'),
|
||||
(59439,'spell_quest_portal_with_condition'),
|
||||
(60900,'spell_quest_portal_with_condition'),
|
||||
(60940,'spell_quest_portal_with_condition');
|
||||
@@ -1672,41 +1672,8 @@ public:
|
||||
|
||||
};
|
||||
|
||||
// 58418 - Portal to Orgrimmar
|
||||
// 58420 - Portal to Stormwind
|
||||
class spell_teleport_leaders_blessing : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_teleport_leaders_blessing);
|
||||
|
||||
bool Validate(SpellInfo const* spellInfo) override
|
||||
{
|
||||
return spellInfo->GetEffects().size() > EFFECT_1
|
||||
&& ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) })
|
||||
&& sObjectMgr->GetQuestTemplate(spellInfo->GetEffect(EFFECT_1).CalcValue()) != nullptr;
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /* effIndex */)
|
||||
{
|
||||
Player* target = GetHitPlayer();
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
uint32 spellID = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue();
|
||||
uint32 questID = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue();
|
||||
|
||||
if (target->GetQuestStatus(questID) == QUEST_STATUS_COMPLETE)
|
||||
target->CastSpell(target, spellID, true);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_teleport_leaders_blessing::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_the_scarlet_enclave_c5()
|
||||
{
|
||||
new npc_highlord_darion_mograine();
|
||||
new npc_the_lich_king_tirion_dawn();
|
||||
RegisterSpellScript(spell_teleport_leaders_blessing);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "CreatureAIImpl.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
@@ -2156,24 +2157,6 @@ class spell_q13665_q13790_bested_trigger : public SpellScript
|
||||
}
|
||||
};
|
||||
|
||||
// herald of war and life without regret portal spells
|
||||
// 59064 - Portal to Orgrimmar
|
||||
// 59439 - Portal to Undercity
|
||||
class spell_59064_59439_portals : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_59064_59439_portals);
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValue()));
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_59064_59439_portals::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
enum ApplyHeatAndStir
|
||||
{
|
||||
SPELL_SPURTS_AND_SMOKE = 38594,
|
||||
@@ -2406,6 +2389,38 @@ class spell_quest_taming_the_beast : public AuraScript
|
||||
}
|
||||
};
|
||||
|
||||
// 53099, 57896, 58418, 58420, 59064, 59065, 59439, 60900, 60940
|
||||
class spell_quest_portal_with_condition : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_quest_portal_with_condition);
|
||||
|
||||
bool Validate(SpellInfo const* spellInfo) override
|
||||
{
|
||||
return spellInfo->GetEffects().size() > EFFECT_1
|
||||
&& ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) })
|
||||
&& sObjectMgr->GetQuestTemplate(uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()));
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /* effIndex */)
|
||||
{
|
||||
Player* target = GetHitPlayer();
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
uint32 spellId = GetEffectInfo().CalcValue();
|
||||
uint32 questId = GetEffectInfo(EFFECT_1).CalcValue();
|
||||
|
||||
// This probably should be a way to throw error in SpellCastResult
|
||||
if (target->IsActiveQuest(questId))
|
||||
target->CastSpell(target, spellId, true);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectHitTarget += SpellEffectFn(spell_quest_portal_with_condition::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
/*######
|
||||
## Quest 14386 Leader of the Pack
|
||||
######*/
|
||||
@@ -2509,11 +2524,11 @@ void AddSC_quest_spell_scripts()
|
||||
new spell_q28813_set_health_random();
|
||||
RegisterSpellScript(spell_q12414_hand_over_reins);
|
||||
RegisterSpellScript(spell_q13665_q13790_bested_trigger);
|
||||
RegisterSpellScript(spell_59064_59439_portals);
|
||||
RegisterSpellScript(spell_q11306_mixing_blood);
|
||||
RegisterSpellScript(spell_q11306_mixing_vrykul_blood);
|
||||
RegisterSpellScript(spell_q11306_failed_mix_43376);
|
||||
RegisterSpellScript(spell_q11306_failed_mix_43378);
|
||||
RegisterSpellScript(spell_quest_taming_the_beast);
|
||||
RegisterSpellScript(spell_quest_portal_with_condition);
|
||||
RegisterSpellScript(spell_q14386_call_attack_mastiffs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user