Scripts/Northrend: talk event for quest A Suitable Test Subject

Ported from: fda99b2972

Credits to @Wyreth and Trinitycore
This commit is contained in:
sucofog
2017-10-29 11:15:00 +01:00
parent d0af1c812b
commit b56d3de7d9
2 changed files with 117 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
INSERT INTO version_db_world (`sql_rev`) VALUES ('1509271997120618300');
-- Quest: A Suitable Test Subject (11719)
DELETE FROM `spell_script_names` WHERE `ScriptName`="spell_q11719_bloodspore_ruination_45997";
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(45997, "spell_q11719_bloodspore_ruination_45997");
UPDATE `creature_template` SET `ScriptName`="npc_bloodmage_laurith" WHERE `entry`=25381;
DELETE FROM `creature_text` WHERE `entry`=25381;
INSERT INTO `creature_text` (`entry`,`GroupID`,`ID`,`Text`,`Type`,`Language`,`Probability`,`Emote`,`Duration`,`Sound`,`BroadcastTextId`,`TextRange`,`comment`) VALUES
(25381, 0, 0, "How positively awful! You were totally incapacitated? Weak? Hot flashes?", 15, 0, 100, 21, 0, 0, 24992, 0, "Bloodmage Laurith");

View File

@@ -1264,6 +1264,108 @@ public:
};
enum BloodsporeRuination
{
NPC_BLOODMAGE_LAURITH = 25381,
SAY_BLOODMAGE_LAURITH = 0,
EVENT_TALK = 1,
EVENT_RESET_ORIENTATION
};
class spell_q11719_bloodspore_ruination_45997 : public SpellScriptLoader
{
public:
spell_q11719_bloodspore_ruination_45997() : SpellScriptLoader("spell_q11719_bloodspore_ruination_45997") { }
class spell_q11719_bloodspore_ruination_45997_SpellScript : public SpellScript
{
PrepareSpellScript(spell_q11719_bloodspore_ruination_45997_SpellScript);
void HandleEffect(SpellEffIndex /*effIndex*/)
{
if (Unit* caster = GetCaster())
if (Creature* laurith = caster->FindNearestCreature(NPC_BLOODMAGE_LAURITH, 100.0f))
laurith->AI()->SetGUID(caster->GetGUID());
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_q11719_bloodspore_ruination_45997_SpellScript::HandleEffect, EFFECT_1, SPELL_EFFECT_SEND_EVENT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_q11719_bloodspore_ruination_45997_SpellScript();
}
};
class npc_bloodmage_laurith : public CreatureScript
{
public:
npc_bloodmage_laurith() : CreatureScript("npc_bloodmage_laurith") { }
struct npc_bloodmage_laurithAI : public ScriptedAI
{
npc_bloodmage_laurithAI(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
_events.Reset();
_playerGUID = 0;
}
void SetGUID(uint64 guid, int32 /*action*/) override
{
if (_playerGUID)
return;
_playerGUID = guid;
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
me->SetFacingToObject(player);
_events.ScheduleEvent(EVENT_TALK, 1000);
}
void UpdateAI(uint32 diff) override
{
if (UpdateVictim())
{
DoMeleeAttackIfReady();
return;
}
_events.Update(diff);
if (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_TALK:
if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID))
Talk(SAY_BLOODMAGE_LAURITH, player);
_playerGUID = 0;
_events.ScheduleEvent(EVENT_RESET_ORIENTATION, 5000);
break;
case EVENT_RESET_ORIENTATION:
me->SetFacingTo(me->GetHomePosition().GetOrientation());
break;
}
}
}
private:
EventMap _events;
uint64 _playerGUID;
};
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_bloodmage_laurithAI(creature);
}
};
void AddSC_borean_tundra()
{
// Ours
@@ -1283,4 +1385,6 @@ void AddSC_borean_tundra()
new npc_valiance_keep_cannoneer();
new npc_warmage_coldarra();
new npc_hidden_cultist();
}
new spell_q11719_bloodspore_ruination_45997();
new npc_bloodmage_laurith();
}