Skip to content

Commit

Permalink
Silvermoon: Implement guard turning
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Oct 20, 2024
1 parent d411473 commit 5625410
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions sql/scriptdev2/scriptdev2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ UPDATE creature_template SET ScriptName='npc_adal' WHERE entry IN(18481);
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Creature*> 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<Creature*> 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<EventGenerator001TurnAI>;
pNewScript->RegisterSelf();
}

0 comments on commit 5625410

Please sign in to comment.