mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 10:56:38 +01:00
Scripts/Westfall: fixed quest "It's alive!"
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellScript.h"
|
||||
#include "CombatAI.h"
|
||||
|
||||
class spell_westfall_unbound_energy : public SpellScript
|
||||
{
|
||||
@@ -43,7 +44,119 @@ class spell_westfall_unbound_energy : public SpellScript
|
||||
}
|
||||
};
|
||||
|
||||
enum ItsAlive
|
||||
{
|
||||
// Events
|
||||
EVENT_CHECK_AREA = 1,
|
||||
EVENT_DESPAWN_HARVESTER = 2,
|
||||
|
||||
// Texts
|
||||
SAY_ANNOUNCE_OUT_OF_AREA = 0,
|
||||
|
||||
// Area Ids
|
||||
AREA_ID_THE_MOEST_FARM = 918,
|
||||
|
||||
// Creatures
|
||||
NPC_ENERGIZED_HARVEST_REAPER = 42342,
|
||||
NPC_OVERLOADED_HARVEST_GOLEM = 42601
|
||||
};
|
||||
|
||||
struct npc_westfall_overloaded_harvest_golem : public VehicleAI
|
||||
{
|
||||
npc_westfall_overloaded_harvest_golem(Creature* creature) : VehicleAI(creature) { }
|
||||
|
||||
void JustAppeared() override
|
||||
{
|
||||
_events.ScheduleEvent(EVENT_CHECK_AREA, 1s);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
_events.Update(diff);
|
||||
while (uint32 eventId = _events.ExecuteEvent())
|
||||
{
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_CHECK_AREA:
|
||||
if (me->GetAreaId() != AREA_ID_THE_MOEST_FARM)
|
||||
{
|
||||
if (Unit* owner = me->GetCharmerOrOwner())
|
||||
Talk(SAY_ANNOUNCE_OUT_OF_AREA, owner);
|
||||
_events.ScheduleEvent(EVENT_DESPAWN_HARVESTER, 8s);
|
||||
}
|
||||
else
|
||||
_events.Repeat(1s);
|
||||
break;
|
||||
case EVENT_DESPAWN_HARVESTER:
|
||||
if (me->GetAreaId() != AREA_ID_THE_MOEST_FARM)
|
||||
me->DespawnOrUnsummon();
|
||||
else
|
||||
_events.ScheduleEvent(EVENT_CHECK_AREA, 1s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EventMap _events;
|
||||
};
|
||||
|
||||
class spell_westfall_reaping_blows : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_westfall_reaping_blows);
|
||||
|
||||
void HandlePeriodic(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
if (Creature* reaper = GetTarget()->FindNearestCreature(NPC_ENERGIZED_HARVEST_REAPER, 5.f, true))
|
||||
GetTarget()->CastSpell(reaper, GetSpellInfo()->Effects[EFFECT_1].TriggerSpell, true);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnEffectPeriodic += AuraEffectPeriodicFn(spell_westfall_reaping_blows::HandlePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_westfall_wake_harvest_golem : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_westfall_wake_harvest_golem);
|
||||
|
||||
SpellCastResult CheckTarget()
|
||||
{
|
||||
Unit* target = GetExplTargetUnit();
|
||||
if (!target || !target->IsCreature())
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (!caster || !caster->IsPlayer())
|
||||
return;
|
||||
|
||||
if (Creature* target = GetHitCreature())
|
||||
{
|
||||
caster->ToPlayer()->KilledMonsterCredit(NPC_OVERLOADED_HARVEST_GOLEM);
|
||||
target->DespawnOrUnsummon(100ms);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
{
|
||||
OnCheckCast += SpellCheckCastFn(spell_westfall_wake_harvest_golem::CheckTarget);
|
||||
OnEffectHitTarget += SpellEffectFn(spell_westfall_wake_harvest_golem::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_westfall()
|
||||
{
|
||||
RegisterSpellScript(spell_westfall_unbound_energy);
|
||||
RegisterCreatureAI(npc_westfall_overloaded_harvest_golem);
|
||||
RegisterAuraScript(spell_westfall_reaping_blows);
|
||||
RegisterSpellScript(spell_westfall_wake_harvest_golem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user