diff --git a/sql/scriptdev2/scriptdev2.sql b/sql/scriptdev2/scriptdev2.sql index 4d12cd2247b..eeb8d658777 100644 --- a/sql/scriptdev2/scriptdev2.sql +++ b/sql/scriptdev2/scriptdev2.sql @@ -1480,6 +1480,7 @@ UPDATE gameobject_template SET ScriptName='go_quest_still_at_it_credit' WHERE en UPDATE creature_template SET ScriptName='npc_solenor' WHERE entry IN (14530,14536); /* SILVERMOON */ +UPDATE creature_template SET ScriptName='npc_event_generator_001' WHERE entry IN (2334); /* SILVERPINE FOREST */ UPDATE creature_template SET ScriptName='npc_deathstalker_erland' WHERE entry=1978; diff --git a/src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/silvermoon_city.cpp b/src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/silvermoon_city.cpp index 1f5a145f882..3464fb0ca3a 100644 --- a/src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/silvermoon_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/eastern_kingdoms/silvermoon_city.cpp @@ -26,6 +26,46 @@ EndContentData */ #include "AI/ScriptDevAI/include/sc_common.h" +struct EventGenerator001TurnAI : public ScriptedAI +{ + EventGenerator001TurnAI(Creature* creature) : ScriptedAI(creature), m_ori(false) + { + m_creature->SetCanEnterCombat(false); + AddCustomAction(1, 5000u, [&]() + { + std::vector const* creaturesLeft = m_creature->GetMap()->GetCreatures("SILVERMOON_GUARDIANS_TURN_1"); + if (creaturesLeft) + { + for (Creature* creature : *creaturesLeft) + if (!creature->IsInCombat()) + creature->SetFacingTo(m_ori ? 5.585053443908691406f : 4.014257431030273437f); + } + std::vector const* creaturesRight = m_creature->GetMap()->GetCreatures("SILVERMOON_GUARDIANS_TURN_2"); + if (creaturesRight) + { + for (Creature* creature : *creaturesRight) + if (!creature->IsInCombat()) + creature->SetFacingTo(m_ori ? 2.443460941314697265f : 4.014257431030273437f); + } + m_ori = !m_ori; + ResetTimer(1, 180000); + }); + } + + bool m_ori; +}; + +UnitAI* GetNewAIInstance(Creature* creature) +{ + if (creature->HasStringId("SILVERMOON_GUARDIANS_TURN_EVENT")) + return new EventGenerator001TurnAI(creature); + return nullptr; +} + void AddSC_silvermoon_city() { + Script* pNewScript = new Script; + pNewScript->Name = "npc_event_generator_001"; + pNewScript->GetAI = &GetNewAIInstance; + pNewScript->RegisterSelf(); }