mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Scripts/Westfall: fixed quest "It's alive!"
This commit is contained in:
21
sql/updates/world/custom/custom_2020_01_30_02_world.sql
Normal file
21
sql/updates/world/custom/custom_2020_01_30_02_world.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
UPDATE `creature_template` SET `VehicleId`= 907, `spell1`= 79425, `spell2`= 79430, `ScriptName`= 'npc_westfall_overloaded_harvest_golem' WHERE `entry`= 42601;
|
||||
|
||||
DELETE FROM `npc_spellclick_spells` WHERE `npc_entry`= 42601;
|
||||
INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `cast_flags`, `user_type`) VALUES
|
||||
(42601, 46598, 1, 0);
|
||||
|
||||
DELETE FROM `conditions` WHERE `SourceEntry`= 79436 AND `SourceTypeOrReferenceId`= 13;
|
||||
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ScriptName`, `Comment`) VALUES
|
||||
(13, 2, 79436, 0, 0, 31, 0, 3, 42381, 0, 0, 0, '', 'Wake Harvest Golem - Target Overloaded Harvest Golem');
|
||||
|
||||
DELETE FROM `spell_script_names` WHERE `ScriptName` IN
|
||||
('spell_westfall_reaping_blows',
|
||||
'spell_westfall_wake_harvest_golem');
|
||||
|
||||
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
|
||||
(79425, 'spell_westfall_reaping_blows'),
|
||||
(79436, 'spell_westfall_wake_harvest_golem');
|
||||
|
||||
DELETE FROM `creature_text` WHERE `CreatureID`= 42601;
|
||||
INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `Comment`) VALUES
|
||||
(42601, 0, 0, 'You may only ride the Overloaded Harvest Golem at the Molsen Farm.', 42, 0, 100, 0, 0, 0, 42475, '');
|
||||
@@ -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