Last active
August 29, 2015 14:23
-
-
Save sirikfoll/74dc0363b7926b9e2aff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TorchSpells | |
{ | |
SPELL_TORCH_TOSSING_TRAINING = 45716, | |
SPELL_TORCH_TOSSING_PRACTICE = 46630, | |
SPELL_TORCH_TOSSING_TRAINING_SUCCESS_ALLIANCE = 45719, | |
SPELL_TORCH_TOSSING_TRAINING_SUCCESS_HORDE = 46651, | |
SPELL_BRAZIERS_HIT = 45724 | |
}; | |
// 45724 - Braziers Hit! | |
class spell_midsummer_braziers_hit : public SpellScriptLoader | |
{ | |
public: | |
spell_midsummer_braziers_hit() : SpellScriptLoader("spell_midsummer_braziers_hit") { } | |
class spell_midsummer_braziers_hit_AuraScript : public AuraScript | |
{ | |
PrepareAuraScript(spell_midsummer_braziers_hit_AuraScript); | |
bool Validate(SpellInfo const* /*spellInfo*/) override | |
{ | |
if (!sSpellMgr->GetSpellInfo(SPELL_TORCH_TOSSING_TRAINING) || !sSpellMgr->GetSpellInfo(SPELL_TORCH_TOSSING_PRACTICE)) | |
return false; | |
return true; | |
} | |
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) | |
{ | |
Player* player = GetTarget()->ToPlayer(); | |
if (!player) | |
return; | |
if ((player->HasAura(SPELL_TORCH_TOSSING_TRAINING) && GetStackAmount() == 8) || (player->HasAura(SPELL_TORCH_TOSSING_PRACTICE) && GetStackAmount() == 20)) | |
{ | |
if (player->GetTeam() == ALLIANCE) | |
player->CastSpell(player, SPELL_TORCH_TOSSING_TRAINING_SUCCESS_ALLIANCE, true); | |
else if (player->GetTeam() == HORDE) | |
player->CastSpell(player, SPELL_TORCH_TOSSING_TRAINING_SUCCESS_HORDE, true); | |
Remove(); | |
} | |
} | |
void Register() override | |
{ | |
AfterEffectApply += AuraEffectApplyFn(spell_midsummer_braziers_hit_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AuraEffectHandleModes(AURA_EFFECT_HANDLE_REAPPLY)); | |
} | |
}; | |
AuraScript* GetAuraScript() const override | |
{ | |
return new spell_midsummer_braziers_hit_AuraScript(); | |
} | |
}; | |
enum TorchCatchingData | |
{ | |
SPELL_FLING_TORCH_MISSILE = 45669, | |
SPELL_TOSS_TORCH_SHADOW = 46105, | |
SPELL_TORCH_TARGET_PICKER = 45907, | |
SPELL_TORCHES_COUGHT = 45693, | |
SPELL_JUGGLE_TORCH_MISSED = 45676, | |
SPELL_TORCH_CATCHING_SUCCESS = 46081, | |
SPELL_TORCH_DAILY_SUCCESS = 46654, | |
NPC_JUGGLE_TARGET = 25515, | |
QUEST_TORCH_CATCHING_A = 11657, | |
QUEST_TORCH_CATCHING_H = 11923, | |
QUEST_MORE_TORCH_CATCHING_A = 11924, | |
QUEST_MORE_TORCH_CATCHING_H = 11925 | |
}; | |
class spell_midsummer_torch_target_picker : public SpellScriptLoader | |
{ | |
public: | |
spell_midsummer_torch_target_picker() : SpellScriptLoader("spell_midsummer_torch_target_picker") { } | |
class spell_midsummer_torch_target_picker_SpellScript : public SpellScript | |
{ | |
PrepareSpellScript(spell_midsummer_torch_target_picker_SpellScript); | |
bool Validate(SpellInfo const* /*spellInfo*/) | |
{ | |
if (!sSpellMgr->GetSpellInfo(SPELL_FLING_TORCH_MISSILE) || !sSpellMgr->GetSpellInfo(SPELL_TOSS_TORCH_SHADOW)) | |
return false; | |
return true; | |
} | |
void FilterTargets(std::list<WorldObject*>& targets) | |
{ | |
Unit* caster = GetCaster(); | |
if (!caster) | |
return; | |
std::list<Creature*> JuggleList; | |
caster->GetCreatureListWithEntryInGrid(JuggleList, NPC_JUGGLE_TARGET, 15.0f); | |
if (!JuggleList.empty()) | |
for (std::list<Creature*>::iterator itr = JuggleList.begin(); itr != JuggleList.end(); ++itr) | |
targets.remove(*itr); | |
if (targets.empty()) | |
return; | |
WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets); | |
targets.clear(); | |
targets.push_back(target); | |
} | |
void HandleDummy(SpellEffIndex /*effIndex*/) | |
{ | |
Unit* caster = GetCaster(); | |
Unit* target = GetHitUnit(); | |
if (!caster || !target) | |
return; | |
caster->CastSpell(target, SPELL_FLING_TORCH_MISSILE, true); | |
caster->CastSpell(target, SPELL_TOSS_TORCH_SHADOW, true); | |
} | |
void Register() | |
{ | |
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_midsummer_torch_target_picker_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY); | |
OnEffectHitTarget += SpellEffectFn(spell_midsummer_torch_target_picker_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); | |
} | |
}; | |
SpellScript* GetSpellScript() const override | |
{ | |
return new spell_midsummer_torch_target_picker_SpellScript(); | |
} | |
}; | |
class spell_midsummer_juggle_torch_catch : public SpellScriptLoader | |
{ | |
public: | |
spell_midsummer_juggle_torch_catch() : SpellScriptLoader("spell_midsummer_juggle_torch_catch") { } | |
class spell_midsummer_juggle_torch_catch_SpellScript : public SpellScript | |
{ | |
PrepareSpellScript(spell_midsummer_juggle_torch_catch_SpellScript); | |
bool Validate(SpellInfo const* /*spellInfo*/) | |
{ | |
if (!sSpellMgr->GetSpellInfo(SPELL_TORCH_TARGET_PICKER) | |
|| !sSpellMgr->GetSpellInfo(SPELL_TORCHES_COUGHT) | |
|| !sSpellMgr->GetSpellInfo(SPELL_JUGGLE_TORCH_MISSED)) | |
return false; | |
return true; | |
} | |
void FilterTargets(std::list<WorldObject*>& targets) | |
{ | |
Unit* caster = GetCaster(); | |
Unit* juggleTarget = NULL; | |
bool missed = true; | |
if (targets.empty() || !caster || !caster->ToPlayer()) | |
return; | |
for (std::list<WorldObject*>::iterator iter = targets.begin(); iter != targets.end(); ++iter) | |
{ | |
if (*iter == caster) | |
missed = false; | |
if ((*iter)->ToUnit()) | |
juggleTarget = (*iter)->ToUnit(); | |
} | |
if (missed) | |
{ | |
if (juggleTarget) | |
juggleTarget->CastSpell(juggleTarget, SPELL_JUGGLE_TORCH_MISSED, true); | |
caster->RemoveAurasDueToSpell(SPELL_TORCHES_COUGHT); | |
} | |
else | |
{ | |
uint8 neededCatches; | |
if (caster->ToPlayer()->GetQuestStatus(QUEST_TORCH_CATCHING_A) == QUEST_STATUS_INCOMPLETE | |
|| caster->ToPlayer()->GetQuestStatus(QUEST_TORCH_CATCHING_H) == QUEST_STATUS_INCOMPLETE) | |
{ | |
neededCatches = 4; | |
} | |
else if (caster->ToPlayer()->GetQuestStatus(QUEST_MORE_TORCH_CATCHING_A) == QUEST_STATUS_INCOMPLETE | |
|| caster->ToPlayer()->GetQuestStatus(QUEST_MORE_TORCH_CATCHING_H) == QUEST_STATUS_INCOMPLETE) | |
{ | |
neededCatches = 10; | |
} | |
else | |
{ | |
caster->RemoveAurasDueToSpell(SPELL_TORCHES_COUGHT); | |
return; | |
} | |
caster->CastSpell(caster, SPELL_TORCH_TARGET_PICKER, true); | |
caster->CastSpell(caster, SPELL_TORCHES_COUGHT, true); | |
// reward quest | |
if (caster->GetAuraCount(SPELL_TORCHES_COUGHT) >= neededCatches) | |
{ | |
caster->CastSpell(caster, SPELL_TORCH_CATCHING_SUCCESS, true); | |
caster->CastSpell(caster, SPELL_TORCH_DAILY_SUCCESS, true); | |
caster->RemoveAurasDueToSpell(SPELL_TORCHES_COUGHT); | |
} | |
} | |
} | |
void Register() | |
{ | |
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_midsummer_juggle_torch_catch_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENTRY); | |
} | |
}; | |
SpellScript* GetSpellScript() const override | |
{ | |
return new spell_midsummer_juggle_torch_catch_SpellScript(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment