From 81dbede84f3ed477103ed644d14863d38149c4c4 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 19 Feb 2022 04:25:02 +0100 Subject: [PATCH 01/13] add shattrath trainee ai --- .../scripts/outland/shattrath_city.cpp | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 0adb2b4fbd2..406498a0f4d 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -28,8 +28,11 @@ npc_khadgars_servant npc_salsalabim EndContentData */ +#include "AI/BaseAI/AIDefines.h" +#include "AI/ScriptDevAI/ScriptDevAIMgr.h" #include "AI/ScriptDevAI/include/sc_common.h" #include "AI/ScriptDevAI/base/escort_ai.h" +#include "Entities/Unit.h" #include "World/WorldState.h" #include "AI/ScriptDevAI/base/TimerAI.h" #include "Spells/Scripts/SpellScript.h" @@ -699,6 +702,61 @@ bool QuestRewarded_npc_adal(Player* player, Creature* creature, Quest const* que return false; // unhandled } +struct npc_shattered_sun_traineeAI : public ScriptedAI +{ + npc_shattered_sun_traineeAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } + + const float radian = M_PI_F/2; + const float forward = 5.497790; + + void ReceiveAIEvent(AIEventType type, Unit* sender, Unit* invoker, uint32 miscValue) override + { + if (!sender || (sender->GetEntry() != 25141 && sender->GetEntry() != 19216)) + return; + //sLog.outError("type: %d, miscV: %d", type, miscValue); + switch (type) + { + case AI_EVENT_CUSTOM_EVENTAI_A: + if (miscValue == 26) + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + else if (miscValue == 68) + m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + else + m_creature->HandleEmote(miscValue); + + break; + case AI_EVENT_CUSTOM_EVENTAI_B: + { + switch (miscValue) + { + case 0: + m_creature->SetOrientation(forward); + break; + case 1: + m_creature->SetOrientation(forward - radian); + break; + case 2: + m_creature->SetOrientation(forward - 2 * radian); + break; + case 3: + m_creature->SetOrientation(forward + radian); + break; + } + m_creature->SendHeartBeat(); + } + break; + case AI_EVENT_CUSTOM_EVENTAI_C: + //0: Trainees Outside + //10: Summon Soldiers Inside + //11: Dismiss Soldiers inside + //Placeholder: Send trainee away + break; + default: + break; + } + } +}; + enum { SPELL_DEMON_BROILED_SURPRISE = 43753, @@ -747,6 +805,12 @@ void AddSC_shattrath_city() pNewScript->pGossipSelect = &GossipSelect_npc_salsalabim; pNewScript->RegisterSelf(); + pNewScript = new Script; + pNewScript->Name = "npc_shattered_sun_trainee"; + pNewScript->GetAI = &GetNewAIInstance; + pNewScript->RegisterSelf(); + + pNewScript = new Script; pNewScript->Name = "npc_adal"; pNewScript->pQuestRewardedNPC = &QuestRewarded_npc_adal; From 9e814f9015ae73c4be24c0ed045df19b3724e618 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 19 Feb 2022 09:43:05 +0100 Subject: [PATCH 02/13] add initial spawning code --- .../scripts/outland/shattrath_city.cpp | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 406498a0f4d..5219bc3da94 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -32,6 +32,8 @@ EndContentData */ #include "AI/ScriptDevAI/ScriptDevAIMgr.h" #include "AI/ScriptDevAI/include/sc_common.h" #include "AI/ScriptDevAI/base/escort_ai.h" +#include "AI/ScriptDevAI/include/sc_creature.h" +#include "Entities/Creature.h" #include "Entities/Unit.h" #include "World/WorldState.h" #include "AI/ScriptDevAI/base/TimerAI.h" @@ -757,6 +759,92 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } }; +struct npc_commander_steeleAI: public ScriptedAI +{ + npc_commander_steeleAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } + + void HandleRecruitSpawn(bool despawn) + { + if (despawn) + { + for (int x=0; x<4; x++) + { + for (int y=0; y<4; y++) + { + if (recruitMatrix[x][y]){ + Unit* crRecruit = m_creature->GetMap()->GetUnit(recruitMatrix[x][y]); + if (crRecruit && crRecruit->IsAlive()) + { + crRecruit->GetMotionMaster()->MovePoint(3, recruitExitPositions[x][y]); + } + } + } + } + Unit* crVeteran = m_creature->GetMap()->GetUnit(veteran); + if (crVeteran && crVeteran->IsAlive()) + crVeteran->GetMotionMaster()->MovePoint(3, veteranExitPosition); + //crVeteran->GetMotionMaster()->UnpauseWaypoints(); + } + else + { + uint32 pathIdCounter = 0; + for (int x=0; x<4; x++) + { + for (int y=0; y<4; y++) + { + std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; + TempSpawnSettings spawnSettings; + spawnSettings.x = recruitEntryPositions[x][y].x; + spawnSettings.y = recruitEntryPositions[x][y].y; + spawnSettings.z = recruitEntryPositions[x][y].z; + spawnSettings.ori = recruitEntryPositions[x][y].o; + spawnSettings.spawnType = TEMPSPAWN_MANUAL_DESPAWN; + spawnSettings.setRun = true; + spawnSettings.entry = entries[urand(0,3)]; + spawnSettings.activeObject = true; + spawnSettings.spawner = m_creature; + //spawnSettings.ownerGuid = m_creature->GetObjectGuid(); + //spawnSettings.pathId = pathIdCounter; + Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); + recruitMatrix[x][y] = summoned->GetObjectGuid(); + //summoned->GetMotionMaster()->MovePath(pathIdCounter++, PATH_FROM_ENTRY, FORCED_MOVEMENT_RUN); + } + } + TempSpawnSettings spawnSettings; + spawnSettings.x = veteranEntryPosition.x; + spawnSettings.y = veteranEntryPosition.y; + spawnSettings.z = veteranEntryPosition.z; + spawnSettings.ori = veteranEntryPosition.o; + spawnSettings.spawnType = TEMPSPAWN_MANUAL_DESPAWN; + spawnSettings.setRun = true; + spawnSettings.entry = NPC_BLOODELF_VETERAN; + spawnSettings.activeObject = true; + spawnSettings.spawner = m_creature; + //spawnSettings.ownerGuid = m_creature->GetObjectGuid(); + Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); + veteran = summoned->GetObjectGuid(); + //Testing + //summoned->GetMotionMaster()->MovePath(0, PATH_FROM_ENTRY, FORCED_MOVEMENT_RUN); + summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition); + //Testing + //Spawn recruits, make them run to their positions, start the emote event. synchronize first shout to the saluting + } + } + + void SummonedMovementInform(Creature* summoned, uint32 motionType, uint32 uiPointId) override + { + sLog.outError("SummonedMovementInform called"); + if (summoned->GetEntry() == NPC_BLOODELF_VETERAN) + { + sLog.outError("Veteran Point ID: %u", uiPointId); + } + switch (uiPointId) { + case 2: summoned->GetMotionMaster()->Clear(); summoned->GetMotionMaster()->MoveIdle(); summoned->SetFacingTo(5.5); break;//summoned->SendHeartBeat(); break; //Get real Facing value + case 3: summoned->ForcedDespawn(); break;// dynamic_cast(summoned)->UnSummon(); + } + } +} + enum { SPELL_DEMON_BROILED_SURPRISE = 43753, From 830d2ec34e92888b01569f7f9efbc2cba2e23d34 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 19 Feb 2022 09:45:22 +0100 Subject: [PATCH 03/13] add spawn info --- .../scripts/outland/shattrath_city.cpp | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 5219bc3da94..22fadac0895 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -759,6 +759,69 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } }; +static const ObjectGuid recruitMatrix[4][4]; +static const ObjectGuid veteran; + +static const Position recruitEntryPositions[4][4] = +{ + { + {-1792.35,5337.14,-12.42,5.5}, + {-1790.15,5335.14,-12.42,5.5}, + {-1787.79,5333.10,-12.42,5.5}, + {-1785.90,5331.25,-12.42,5.5}, + }, + { + {-1789.79,5339.68,-12.42,5.5}, + {-1787.73,5337.60,-12.42,5.5}, + {-1785.66,5335.26,-12.42,5.5}, + {-1783.63,5333.44,-12.42,5.5}, + }, + { + {-1787.64,5341.81,-12.42,5.5}, + {-1785.46,5339.81,-12.42,5.5}, + {-1783.16,5337.67,-12.42,5.5}, + {-1781.29,5335.79,-12.42,5.5}, + }, + { + {-1785.31,5344.09,-12.42,5.5}, + {-1782.86,5342.13,-12.42,5.5}, + {-1780.88,5339.83,-12.42,5.5}, + {-1779.02,5337.96,-12.42,5.5}, + }, +}; + +static const Position recruitExitPositions[4][4] = +{ + { + {-1792.35,5337.14,-12.42,5.5}, + {-1790.15,5335.14,-12.42,5.5}, + {-1787.79,5333.10,-12.42,5.5}, + {-1785.90,5331.25,-12.42,5.5}, + }, + { + {-1789.79,5339.68,-12.42,5.5}, + {-1787.73,5337.60,-12.42,5.5}, + {-1785.66,5335.26,-12.42,5.5}, + {-1783.63,5333.44,-12.42,5.5}, + }, + { + {-1787.64,5341.81,-12.42,5.5}, + {-1785.46,5339.81,-12.42,5.5}, + {-1783.16,5337.67,-12.42,5.5}, + {-1781.29,5335.79,-12.42,5.5}, + }, + { + {-1785.31,5344.09,-12.42,5.5}, + {-1782.86,5342.13,-12.42,5.5}, + {-1780.88,5339.83,-12.42,5.5}, + {-1779.02,5337.96,-12.42,5.5}, + }, +}; + +static const Position veteranEntryPosition = {-1799.42,5319.73,-12.42,1.62}; +static const Position veteranEventPosition = {-1780.71,5332.77,-12.42,2.129}; +static const Position veteranExitPosition = {-1799.42,5319.73,-12.42,1.62}; + struct npc_commander_steeleAI: public ScriptedAI { npc_commander_steeleAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } @@ -843,7 +906,7 @@ struct npc_commander_steeleAI: public ScriptedAI case 3: summoned->ForcedDespawn(); break;// dynamic_cast(summoned)->UnSummon(); } } -} +}; enum { From c71278bf995095234ced144d1808bcc41e24752b Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 19 Feb 2022 19:09:31 +0100 Subject: [PATCH 04/13] working trainee event --- .../scripts/outland/shattrath_city.cpp | 193 +++++++++++------- 1 file changed, 122 insertions(+), 71 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 22fadac0895..f878044baa7 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -704,6 +704,17 @@ bool QuestRewarded_npc_adal(Player* player, Creature* creature, Quest const* que return false; // unhandled } +enum recruitEventIds +{ + NPC_GRAND_ANCHORITE_ALMONEN = 19216, + NPC_COMMANDER_STEELE = 25141, + NPC_F_DRAENEI_TRAINEE = 25137, + NPC_M_DRAENEI_TRAINEE = 25136, + NPC_F_BLOODELF_TRAINEE = 25135, + NPC_M_BLOODELF_TRAINEE = 25134, + NPC_BLOODELF_VETERAN = 25143, +}; + struct npc_shattered_sun_traineeAI : public ScriptedAI { npc_shattered_sun_traineeAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } @@ -713,9 +724,9 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI void ReceiveAIEvent(AIEventType type, Unit* sender, Unit* invoker, uint32 miscValue) override { - if (!sender || (sender->GetEntry() != 25141 && sender->GetEntry() != 19216)) + if (!sender || (sender->GetEntry() != NPC_COMMANDER_STEELE && sender->GetEntry() != NPC_GRAND_ANCHORITE_ALMONEN)) return; - //sLog.outError("type: %d, miscV: %d", type, miscValue); + switch (type) { case AI_EVENT_CUSTOM_EVENTAI_A: @@ -723,12 +734,15 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI m_creature->SetStandState(UNIT_STAND_STATE_STAND); else if (miscValue == 68) m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); + else if (miscValue == 253) + m_creature->HandleEmote(urand(0,2) ? 253 : 4); else m_creature->HandleEmote(miscValue); break; case AI_EVENT_CUSTOM_EVENTAI_B: { + SetRootSelf(true); switch (miscValue) { case 0: @@ -748,10 +762,7 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } break; case AI_EVENT_CUSTOM_EVENTAI_C: - //0: Trainees Outside - //10: Summon Soldiers Inside - //11: Dismiss Soldiers inside - //Placeholder: Send trainee away + // Unused break; default: break; @@ -759,73 +770,116 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } }; -static const ObjectGuid recruitMatrix[4][4]; -static const ObjectGuid veteran; - static const Position recruitEntryPositions[4][4] = { { - {-1792.35,5337.14,-12.42,5.5}, - {-1790.15,5335.14,-12.42,5.5}, - {-1787.79,5333.10,-12.42,5.5}, - {-1785.90,5331.25,-12.42,5.5}, + {-1810.735, 5292.215, -12.3448, 5.5}, + {-1797.464, 5308.929, -14.69543, 5.5}, + {-1764.172974, 5386.48584, -5.273263, 5.5}, + {-1816.387, 5357.304, -12.43532, 5.5}, }, { - {-1789.79,5339.68,-12.42,5.5}, - {-1787.73,5337.60,-12.42,5.5}, - {-1785.66,5335.26,-12.42,5.5}, - {-1783.63,5333.44,-12.42,5.5}, + {-1823.218, 5329.122, -12.3977, 5.5}, + {-1841.915, 5347.13, -12.34478, 5.5}, + {-1824.706, 5307.167, -12.3448, 5.5}, + {-1790.77, 5300.418, -20.52535, 5.5}, }, { - {-1787.64,5341.81,-12.42,5.5}, - {-1785.46,5339.81,-12.42,5.5}, - {-1783.16,5337.67,-12.42,5.5}, - {-1781.29,5335.79,-12.42,5.5}, + {-1795.66, 5306.961, -16.11753, 5.5}, + {-1835.797, 5375.394, -12.3448, 5.5}, + {-1823.988, 5360.059, -12.43532, 5.5}, + {-1809.875, 5325.414, -12.40578, 5.5}, }, { - {-1785.31,5344.09,-12.42,5.5}, - {-1782.86,5342.13,-12.42,5.5}, - {-1780.88,5339.83,-12.42,5.5}, - {-1779.02,5337.96,-12.42,5.5}, + {-1811.616, 5333.609, -12.43531, 5.5}, + {-1818.436, 5351.488, -12.43532, 5.5}, + {-1828.191, 5364.457, -12.34482, 5.5}, + {-1818.281, 5301.583, -12.3448, 5.5}, + }, +}; + +static const Position recruitEventPositions[4][4] = +{ + { + {-1783.63, 5333.444, -12.43531, 5.497787}, + {-1779.016, 5337.96, -12.43531, 5.497787}, + {-1783.164, 5337.674, -12.43531, 5.497787}, + {-1787.639, 5341.807, -12.43532, 5.497787}, + }, + { + {-1787.731, 5337.603, -12.43532, 5.497787}, + {-1792.356, 5337.139, -12.43532, 5.497787}, + {-1785.664, 5335.256, -12.43532, 5.497787}, + {-1780.876, 5339.828, -12.43531, 5.497787}, + }, + { + {-1781.292, 5335.792, -12.43531, 5.497787}, + {-1782.86, 5342.133, -12.43531, 5.497787}, + {-1789.791, 5339.68, -12.43532, 5.497787}, + {-1785.902, 5331.252, -12.43613, 5.497787}, + }, + { + {-1787.792, 5333.102, -12.43613, 5.497787}, + {-1785.457, 5339.807, -12.43532, 5.497787}, + {-1785.311, 5344.088, -12.43532, 5.497787}, + {-1790.151, 5335.142, -12.43532, 5.497787}, }, }; static const Position recruitExitPositions[4][4] = { { - {-1792.35,5337.14,-12.42,5.5}, - {-1790.15,5335.14,-12.42,5.5}, - {-1787.79,5333.10,-12.42,5.5}, - {-1785.90,5331.25,-12.42,5.5}, + {-1796.377, 5299.302, -19.65246, 100}, + {-1744.358, 5380.27, -12.43531, 100}, + {-1796.183, 5304.772, -17.0572, 100}, + {-1798.558, 5309.034, -14.36996, 100}, }, { - {-1789.79,5339.68,-12.42,5.5}, - {-1787.73,5337.60,-12.42,5.5}, - {-1785.66,5335.26,-12.42,5.5}, - {-1783.63,5333.44,-12.42,5.5}, + {-1796.379, 5299.602, -19.50641, 100}, + {-1796.706, 5308.721, -15.00909, 100}, + {-1799.474, 5307.094, -15.06679, 100}, + {-1730.106, 5363.373, -9.859305, 100}, }, { - {-1787.64,5341.81,-12.42,5.5}, - {-1785.46,5339.81,-12.42,5.5}, - {-1783.16,5337.67,-12.42,5.5}, - {-1781.29,5335.79,-12.42,5.5}, + {-1728.108, 5366.323, -9.279177, 100}, + {-1764.693, 5385.993, -5.32568, 100}, + {-1798.901, 5305.465, -16.00611, 100}, + {-1794.535, 5303.782, -17.97032, 100}, }, { - {-1785.31,5344.09,-12.42,5.5}, - {-1782.86,5342.13,-12.42,5.5}, - {-1780.88,5339.83,-12.42,5.5}, - {-1779.02,5337.96,-12.42,5.5}, + {-1794.568, 5309.374, -15.2566, 100}, + {-1763.738, 5383.413, -7.619812, 100}, + {-1741.796, 5385.382, -12.43531, 100}, + {-1792.979, 5307.494, -16.58447, 100}, }, }; -static const Position veteranEntryPosition = {-1799.42,5319.73,-12.42,1.62}; -static const Position veteranEventPosition = {-1780.71,5332.77,-12.42,2.129}; -static const Position veteranExitPosition = {-1799.42,5319.73,-12.42,1.62}; +static const Position veteranEntryPosition = {-1803.735, 5294.502, -12.38359, 1.62}; +static const Position veteranEventPosition = {-1780.713, 5332.765, -12.43613, 5.497787}; +static const Position veteranExitPosition = {-1798.737, 5308.549, -14.55699, 1.62}; struct npc_commander_steeleAI: public ScriptedAI { npc_commander_steeleAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } + ObjectGuid recruitMatrix[4][4]; + ObjectGuid veteran; + + void ReceiveAIEvent(AIEventType type, Unit* sender, Unit* invoker, uint32 miscValue) override + { + if (type == AI_EVENT_CUSTOM_EVENTAI_D) + { + if (miscValue == 0) + { + HandleRecruitSpawn(true); + } + else if (miscValue == 1) + { + HandleRecruitSpawn(false); + } + } + } + void HandleRecruitSpawn(bool despawn) { if (despawn) @@ -836,41 +890,40 @@ struct npc_commander_steeleAI: public ScriptedAI { if (recruitMatrix[x][y]){ Unit* crRecruit = m_creature->GetMap()->GetUnit(recruitMatrix[x][y]); - if (crRecruit && crRecruit->IsAlive()) + if (crRecruit && crRecruit->IsAlive() && crRecruit->AI()) { - crRecruit->GetMotionMaster()->MovePoint(3, recruitExitPositions[x][y]); + crRecruit->AI()->SetRootSelf(false); + crRecruit->GetMotionMaster()->MovePoint(3, recruitExitPositions[x][y], FORCED_MOVEMENT_RUN); } } } } Unit* crVeteran = m_creature->GetMap()->GetUnit(veteran); - if (crVeteran && crVeteran->IsAlive()) - crVeteran->GetMotionMaster()->MovePoint(3, veteranExitPosition); - //crVeteran->GetMotionMaster()->UnpauseWaypoints(); + if (crVeteran && crVeteran->IsAlive() && crVeteran->AI()) + { + crVeteran->AI()->SetRootSelf(false); + crVeteran->GetMotionMaster()->MovePoint(3, veteranExitPosition, FORCED_MOVEMENT_RUN); + } } else { - uint32 pathIdCounter = 0; for (int x=0; x<4; x++) { for (int y=0; y<4; y++) { - std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; + static const std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; TempSpawnSettings spawnSettings; spawnSettings.x = recruitEntryPositions[x][y].x; spawnSettings.y = recruitEntryPositions[x][y].y; spawnSettings.z = recruitEntryPositions[x][y].z; spawnSettings.ori = recruitEntryPositions[x][y].o; - spawnSettings.spawnType = TEMPSPAWN_MANUAL_DESPAWN; - spawnSettings.setRun = true; + spawnSettings.spawnType = TEMPSPAWN_CORPSE_DESPAWN; spawnSettings.entry = entries[urand(0,3)]; spawnSettings.activeObject = true; spawnSettings.spawner = m_creature; - //spawnSettings.ownerGuid = m_creature->GetObjectGuid(); - //spawnSettings.pathId = pathIdCounter; Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); recruitMatrix[x][y] = summoned->GetObjectGuid(); - //summoned->GetMotionMaster()->MovePath(pathIdCounter++, PATH_FROM_ENTRY, FORCED_MOVEMENT_RUN); + summoned->GetMotionMaster()->MovePoint(2, recruitEventPositions[x][y], FORCED_MOVEMENT_RUN); } } TempSpawnSettings spawnSettings; @@ -878,32 +931,26 @@ struct npc_commander_steeleAI: public ScriptedAI spawnSettings.y = veteranEntryPosition.y; spawnSettings.z = veteranEntryPosition.z; spawnSettings.ori = veteranEntryPosition.o; - spawnSettings.spawnType = TEMPSPAWN_MANUAL_DESPAWN; - spawnSettings.setRun = true; + spawnSettings.spawnType = TEMPSPAWN_CORPSE_DESPAWN; spawnSettings.entry = NPC_BLOODELF_VETERAN; spawnSettings.activeObject = true; spawnSettings.spawner = m_creature; - //spawnSettings.ownerGuid = m_creature->GetObjectGuid(); Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); veteran = summoned->GetObjectGuid(); - //Testing - //summoned->GetMotionMaster()->MovePath(0, PATH_FROM_ENTRY, FORCED_MOVEMENT_RUN); - summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition); - //Testing - //Spawn recruits, make them run to their positions, start the emote event. synchronize first shout to the saluting + summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition, FORCED_MOVEMENT_RUN); } } void SummonedMovementInform(Creature* summoned, uint32 motionType, uint32 uiPointId) override { - sLog.outError("SummonedMovementInform called"); - if (summoned->GetEntry() == NPC_BLOODELF_VETERAN) + static const std::unordered_set entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE, NPC_BLOODELF_VETERAN}; + static const float forward = 5.497790; + if (entries.find(summoned->GetEntry()) != entries.end()) { - sLog.outError("Veteran Point ID: %u", uiPointId); - } - switch (uiPointId) { - case 2: summoned->GetMotionMaster()->Clear(); summoned->GetMotionMaster()->MoveIdle(); summoned->SetFacingTo(5.5); break;//summoned->SendHeartBeat(); break; //Get real Facing value - case 3: summoned->ForcedDespawn(); break;// dynamic_cast(summoned)->UnSummon(); + switch (uiPointId) { + case 2: summoned->GetMotionMaster()->Clear(); summoned->GetMotionMaster()->MoveIdle(); summoned->SetFacingTo(forward); break; + case 3: summoned->ForcedDespawn(); + } } } }; @@ -961,6 +1008,10 @@ void AddSC_shattrath_city() pNewScript->GetAI = &GetNewAIInstance; pNewScript->RegisterSelf(); + pNewScript = new Script; + pNewScript->Name = "npc_commander_steele"; + pNewScript->GetAI = &GetNewAIInstance; + pNewScript->RegisterSelf(); pNewScript = new Script; pNewScript->Name = "npc_adal"; From d0f002b0652cb2cd83a833e93705092e928b620e Mon Sep 17 00:00:00 2001 From: insunaa Date: Sat, 19 Feb 2022 19:23:49 +0100 Subject: [PATCH 05/13] bracket prettification --- src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index f878044baa7..560ef57cf9a 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -870,13 +870,9 @@ struct npc_commander_steeleAI: public ScriptedAI if (type == AI_EVENT_CUSTOM_EVENTAI_D) { if (miscValue == 0) - { HandleRecruitSpawn(true); - } else if (miscValue == 1) - { HandleRecruitSpawn(false); - } } } @@ -947,7 +943,8 @@ struct npc_commander_steeleAI: public ScriptedAI static const float forward = 5.497790; if (entries.find(summoned->GetEntry()) != entries.end()) { - switch (uiPointId) { + switch (uiPointId) + { case 2: summoned->GetMotionMaster()->Clear(); summoned->GetMotionMaster()->MoveIdle(); summoned->SetFacingTo(forward); break; case 3: summoned->ForcedDespawn(); } From 1914387be9fc4d4a48257a6cb0a1dae16c095db3 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sun, 20 Feb 2022 12:10:59 +0100 Subject: [PATCH 06/13] minor bracket fix and set steele to active while recruits exist --- .../AI/ScriptDevAI/scripts/outland/shattrath_city.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 560ef57cf9a..53d11c97db2 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -869,10 +869,8 @@ struct npc_commander_steeleAI: public ScriptedAI { if (type == AI_EVENT_CUSTOM_EVENTAI_D) { - if (miscValue == 0) - HandleRecruitSpawn(true); - else if (miscValue == 1) - HandleRecruitSpawn(false); + HandleRecruitSpawn(!miscValue); + m_creature->SetActiveObjectState(miscValue); } } @@ -884,7 +882,8 @@ struct npc_commander_steeleAI: public ScriptedAI { for (int y=0; y<4; y++) { - if (recruitMatrix[x][y]){ + if (recruitMatrix[x][y]) + { Unit* crRecruit = m_creature->GetMap()->GetUnit(recruitMatrix[x][y]); if (crRecruit && crRecruit->IsAlive() && crRecruit->AI()) { From b6ef7d742e7bb6819f7425bdf1d728881b3e650d Mon Sep 17 00:00:00 2001 From: insunaa Date: Sun, 20 Feb 2022 18:40:38 +0100 Subject: [PATCH 07/13] move trainee movementinform from steele to trainee ai --- .../scripts/outland/shattrath_city.cpp | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 53d11c97db2..53b72787254 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -768,6 +768,16 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI break; } } + + void MovementInform(uint32 motionType, uint32 uiPointId) override + { + static const float forward = 5.497790; + switch (uiPointId) + { + case 2: m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveIdle(); m_creature->SetFacingTo(forward); break; + case 3: m_creature->ForcedDespawn(); + } + } }; static const Position recruitEntryPositions[4][4] = @@ -935,20 +945,6 @@ struct npc_commander_steeleAI: public ScriptedAI summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition, FORCED_MOVEMENT_RUN); } } - - void SummonedMovementInform(Creature* summoned, uint32 motionType, uint32 uiPointId) override - { - static const std::unordered_set entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE, NPC_BLOODELF_VETERAN}; - static const float forward = 5.497790; - if (entries.find(summoned->GetEntry()) != entries.end()) - { - switch (uiPointId) - { - case 2: summoned->GetMotionMaster()->Clear(); summoned->GetMotionMaster()->MoveIdle(); summoned->SetFacingTo(forward); break; - case 3: summoned->ForcedDespawn(); - } - } - } }; enum From 28e0ed08b643ffd523ca4070df838636a958f2f1 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sun, 20 Feb 2022 18:45:52 +0100 Subject: [PATCH 08/13] simplify code --- .../scripts/outland/shattrath_city.cpp | 180 +++++++++--------- 1 file changed, 88 insertions(+), 92 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 53b72787254..4b2e2c0a35c 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -771,7 +771,6 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI void MovementInform(uint32 motionType, uint32 uiPointId) override { - static const float forward = 5.497790; switch (uiPointId) { case 2: m_creature->GetMotionMaster()->Clear(); m_creature->GetMotionMaster()->MoveIdle(); m_creature->SetFacingTo(forward); break; @@ -780,100 +779,98 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } }; -static const Position recruitEntryPositions[4][4] = -{ - { - {-1810.735, 5292.215, -12.3448, 5.5}, - {-1797.464, 5308.929, -14.69543, 5.5}, - {-1764.172974, 5386.48584, -5.273263, 5.5}, - {-1816.387, 5357.304, -12.43532, 5.5}, - }, - { - {-1823.218, 5329.122, -12.3977, 5.5}, - {-1841.915, 5347.13, -12.34478, 5.5}, - {-1824.706, 5307.167, -12.3448, 5.5}, - {-1790.77, 5300.418, -20.52535, 5.5}, - }, - { - {-1795.66, 5306.961, -16.11753, 5.5}, - {-1835.797, 5375.394, -12.3448, 5.5}, - {-1823.988, 5360.059, -12.43532, 5.5}, - {-1809.875, 5325.414, -12.40578, 5.5}, - }, - { - {-1811.616, 5333.609, -12.43531, 5.5}, - {-1818.436, 5351.488, -12.43532, 5.5}, - {-1828.191, 5364.457, -12.34482, 5.5}, - {-1818.281, 5301.583, -12.3448, 5.5}, - }, -}; - -static const Position recruitEventPositions[4][4] = -{ - { - {-1783.63, 5333.444, -12.43531, 5.497787}, - {-1779.016, 5337.96, -12.43531, 5.497787}, - {-1783.164, 5337.674, -12.43531, 5.497787}, - {-1787.639, 5341.807, -12.43532, 5.497787}, - }, - { - {-1787.731, 5337.603, -12.43532, 5.497787}, - {-1792.356, 5337.139, -12.43532, 5.497787}, - {-1785.664, 5335.256, -12.43532, 5.497787}, - {-1780.876, 5339.828, -12.43531, 5.497787}, - }, - { - {-1781.292, 5335.792, -12.43531, 5.497787}, - {-1782.86, 5342.133, -12.43531, 5.497787}, - {-1789.791, 5339.68, -12.43532, 5.497787}, - {-1785.902, 5331.252, -12.43613, 5.497787}, - }, - { - {-1787.792, 5333.102, -12.43613, 5.497787}, - {-1785.457, 5339.807, -12.43532, 5.497787}, - {-1785.311, 5344.088, -12.43532, 5.497787}, - {-1790.151, 5335.142, -12.43532, 5.497787}, - }, -}; - -static const Position recruitExitPositions[4][4] = -{ - { - {-1796.377, 5299.302, -19.65246, 100}, - {-1744.358, 5380.27, -12.43531, 100}, - {-1796.183, 5304.772, -17.0572, 100}, - {-1798.558, 5309.034, -14.36996, 100}, - }, - { - {-1796.379, 5299.602, -19.50641, 100}, - {-1796.706, 5308.721, -15.00909, 100}, - {-1799.474, 5307.094, -15.06679, 100}, - {-1730.106, 5363.373, -9.859305, 100}, - }, - { - {-1728.108, 5366.323, -9.279177, 100}, - {-1764.693, 5385.993, -5.32568, 100}, - {-1798.901, 5305.465, -16.00611, 100}, - {-1794.535, 5303.782, -17.97032, 100}, - }, - { - {-1794.568, 5309.374, -15.2566, 100}, - {-1763.738, 5383.413, -7.619812, 100}, - {-1741.796, 5385.382, -12.43531, 100}, - {-1792.979, 5307.494, -16.58447, 100}, - }, -}; - -static const Position veteranEntryPosition = {-1803.735, 5294.502, -12.38359, 1.62}; -static const Position veteranEventPosition = {-1780.713, 5332.765, -12.43613, 5.497787}; -static const Position veteranExitPosition = {-1798.737, 5308.549, -14.55699, 1.62}; - struct npc_commander_steeleAI: public ScriptedAI { npc_commander_steeleAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } ObjectGuid recruitMatrix[4][4]; ObjectGuid veteran; + const Position veteranEntryPosition = {-1803.735, 5294.502, -12.38359, 1.62}; + const Position veteranEventPosition = {-1780.713, 5332.765, -12.43613, 5.497787}; + const Position veteranExitPosition = {-1798.737, 5308.549, -14.55699, 1.62}; + const Position recruitEntryPositions[4][4] = + { + { + {-1810.735, 5292.215, -12.3448, 5.5}, + {-1797.464, 5308.929, -14.69543, 5.5}, + {-1764.172974, 5386.48584, -5.273263, 5.5}, + {-1816.387, 5357.304, -12.43532, 5.5}, + }, + { + {-1823.218, 5329.122, -12.3977, 5.5}, + {-1841.915, 5347.13, -12.34478, 5.5}, + {-1824.706, 5307.167, -12.3448, 5.5}, + {-1790.77, 5300.418, -20.52535, 5.5}, + }, + { + {-1795.66, 5306.961, -16.11753, 5.5}, + {-1835.797, 5375.394, -12.3448, 5.5}, + {-1823.988, 5360.059, -12.43532, 5.5}, + {-1809.875, 5325.414, -12.40578, 5.5}, + }, + { + {-1811.616, 5333.609, -12.43531, 5.5}, + {-1818.436, 5351.488, -12.43532, 5.5}, + {-1828.191, 5364.457, -12.34482, 5.5}, + {-1818.281, 5301.583, -12.3448, 5.5}, + }, + }; + + const Position recruitEventPositions[4][4] = + { + { + {-1783.63, 5333.444, -12.43531, 5.497787}, + {-1779.016, 5337.96, -12.43531, 5.497787}, + {-1783.164, 5337.674, -12.43531, 5.497787}, + {-1787.639, 5341.807, -12.43532, 5.497787}, + }, + { + {-1787.731, 5337.603, -12.43532, 5.497787}, + {-1792.356, 5337.139, -12.43532, 5.497787}, + {-1785.664, 5335.256, -12.43532, 5.497787}, + {-1780.876, 5339.828, -12.43531, 5.497787}, + }, + { + {-1781.292, 5335.792, -12.43531, 5.497787}, + {-1782.86, 5342.133, -12.43531, 5.497787}, + {-1789.791, 5339.68, -12.43532, 5.497787}, + {-1785.902, 5331.252, -12.43613, 5.497787}, + }, + { + {-1787.792, 5333.102, -12.43613, 5.497787}, + {-1785.457, 5339.807, -12.43532, 5.497787}, + {-1785.311, 5344.088, -12.43532, 5.497787}, + {-1790.151, 5335.142, -12.43532, 5.497787}, + }, + }; + + const Position recruitExitPositions[4][4] = + { + { + {-1796.377, 5299.302, -19.65246, 100}, + {-1744.358, 5380.27, -12.43531, 100}, + {-1796.183, 5304.772, -17.0572, 100}, + {-1798.558, 5309.034, -14.36996, 100}, + }, + { + {-1796.379, 5299.602, -19.50641, 100}, + {-1796.706, 5308.721, -15.00909, 100}, + {-1799.474, 5307.094, -15.06679, 100}, + {-1730.106, 5363.373, -9.859305, 100}, + }, + { + {-1728.108, 5366.323, -9.279177, 100}, + {-1764.693, 5385.993, -5.32568, 100}, + {-1798.901, 5305.465, -16.00611, 100}, + {-1794.535, 5303.782, -17.97032, 100}, + }, + { + {-1794.568, 5309.374, -15.2566, 100}, + {-1763.738, 5383.413, -7.619812, 100}, + {-1741.796, 5385.382, -12.43531, 100}, + {-1792.979, 5307.494, -16.58447, 100}, + }, + }; void ReceiveAIEvent(AIEventType type, Unit* sender, Unit* invoker, uint32 miscValue) override { @@ -912,12 +909,12 @@ struct npc_commander_steeleAI: public ScriptedAI } else { + static const std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; + TempSpawnSettings spawnSettings; for (int x=0; x<4; x++) { for (int y=0; y<4; y++) { - static const std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; - TempSpawnSettings spawnSettings; spawnSettings.x = recruitEntryPositions[x][y].x; spawnSettings.y = recruitEntryPositions[x][y].y; spawnSettings.z = recruitEntryPositions[x][y].z; @@ -931,7 +928,6 @@ struct npc_commander_steeleAI: public ScriptedAI summoned->GetMotionMaster()->MovePoint(2, recruitEventPositions[x][y], FORCED_MOVEMENT_RUN); } } - TempSpawnSettings spawnSettings; spawnSettings.x = veteranEntryPosition.x; spawnSettings.y = veteranEntryPosition.y; spawnSettings.z = veteranEntryPosition.z; From fdad60f4e751facb2dab1746056a3e55e7446d63 Mon Sep 17 00:00:00 2001 From: insunaa Date: Mon, 21 Feb 2022 12:27:57 +0100 Subject: [PATCH 09/13] nullptr guard --- .../scripts/outland/shattrath_city.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 4b2e2c0a35c..eea2eafee7d 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -923,9 +923,11 @@ struct npc_commander_steeleAI: public ScriptedAI spawnSettings.entry = entries[urand(0,3)]; spawnSettings.activeObject = true; spawnSettings.spawner = m_creature; - Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); - recruitMatrix[x][y] = summoned->GetObjectGuid(); - summoned->GetMotionMaster()->MovePoint(2, recruitEventPositions[x][y], FORCED_MOVEMENT_RUN); + if (Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap())) + { + recruitMatrix[x][y] = summoned->GetObjectGuid(); + summoned->GetMotionMaster()->MovePoint(2, recruitEventPositions[x][y], FORCED_MOVEMENT_RUN); + } } } spawnSettings.x = veteranEntryPosition.x; @@ -936,9 +938,11 @@ struct npc_commander_steeleAI: public ScriptedAI spawnSettings.entry = NPC_BLOODELF_VETERAN; spawnSettings.activeObject = true; spawnSettings.spawner = m_creature; - Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap()); - veteran = summoned->GetObjectGuid(); - summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition, FORCED_MOVEMENT_RUN); + if (Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap())) + { + veteran = summoned->GetObjectGuid(); + summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition, FORCED_MOVEMENT_RUN); + } } } }; From 04d442609a409f830c3571dfb866fffbbcbb9cd8 Mon Sep 17 00:00:00 2001 From: insunaa Date: Mon, 21 Feb 2022 12:50:48 +0100 Subject: [PATCH 10/13] made applause section more accurate --- .../ScriptDevAI/scripts/outland/shattrath_city.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index eea2eafee7d..8200d1f6a01 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -717,7 +717,14 @@ enum recruitEventIds struct npc_shattered_sun_traineeAI : public ScriptedAI { - npc_shattered_sun_traineeAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } + npc_shattered_sun_traineeAI(Creature* pCreature) : ScriptedAI(pCreature) { + AddCustomAction(0, true, [&]() + { + m_creature->HandleEmote(urand(0,4) ? 21 : 4); + ResetTimer(0, 1500u); + }); + Reset(); + } const float radian = M_PI_F/2; const float forward = 5.497790; @@ -735,7 +742,7 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI else if (miscValue == 68) m_creature->SetStandState(UNIT_STAND_STATE_KNEEL); else if (miscValue == 253) - m_creature->HandleEmote(urand(0,2) ? 253 : 4); + ResetTimer(0, 2000u); else m_creature->HandleEmote(miscValue); @@ -762,7 +769,7 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } break; case AI_EVENT_CUSTOM_EVENTAI_C: - // Unused + DisableTimer(0); break; default: break; @@ -895,6 +902,7 @@ struct npc_commander_steeleAI: public ScriptedAI if (crRecruit && crRecruit->IsAlive() && crRecruit->AI()) { crRecruit->AI()->SetRootSelf(false); + crRecruit->AI()->ReceiveAIEvent(AI_EVENT_CUSTOM_EVENTAI_C, m_creature, m_creature, 0); crRecruit->GetMotionMaster()->MovePoint(3, recruitExitPositions[x][y], FORCED_MOVEMENT_RUN); } } From a78bdecd4aed52c10f5c2fc9fbc97766026658c4 Mon Sep 17 00:00:00 2001 From: insunaa Date: Mon, 21 Feb 2022 16:17:42 +0100 Subject: [PATCH 11/13] fix spawn coord and script declaration --- sql/scriptdev2/scriptdev2.sql | 2 ++ src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/scriptdev2/scriptdev2.sql b/sql/scriptdev2/scriptdev2.sql index f924aac68fc..5a597914e2e 100644 --- a/sql/scriptdev2/scriptdev2.sql +++ b/sql/scriptdev2/scriptdev2.sql @@ -1116,6 +1116,8 @@ UPDATE creature_template SET ScriptName='npc_dirty_larry' WHERE entry=19720; UPDATE creature_template SET ScriptName='npc_khadgars_servant' WHERE entry=19685; UPDATE creature_template SET ScriptName='npc_salsalabim' WHERE entry=18584; UPDATE creature_template SET ScriptName='npc_adal' WHERE entry IN(18481); +UPDATE `creature_template` SET `ScriptName`="npc_shattered_sun_trainee" WHERE `entry` IN (25134, 25135, 25136, 25137, 25143); +UPDATE `creature_template` SET `ScriptName`="npc_commander_steele" WHERE `entry`=25141; /* SILITHUS */ UPDATE creature_template SET ScriptName='npc_anachronos_the_ancient' WHERE entry=15381; diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index 8200d1f6a01..c1d4ff78fb5 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -34,6 +34,7 @@ EndContentData */ #include "AI/ScriptDevAI/base/escort_ai.h" #include "AI/ScriptDevAI/include/sc_creature.h" #include "Entities/Creature.h" +#include "Entities/Object.h" #include "Entities/Unit.h" #include "World/WorldState.h" #include "AI/ScriptDevAI/base/TimerAI.h" @@ -800,7 +801,7 @@ struct npc_commander_steeleAI: public ScriptedAI { {-1810.735, 5292.215, -12.3448, 5.5}, {-1797.464, 5308.929, -14.69543, 5.5}, - {-1764.172974, 5386.48584, -5.273263, 5.5}, + {-1801.254, 5313.176, -12.43915, 5.5}, {-1816.387, 5357.304, -12.43532, 5.5}, }, { @@ -879,7 +880,7 @@ struct npc_commander_steeleAI: public ScriptedAI }, }; - void ReceiveAIEvent(AIEventType type, Unit* sender, Unit* invoker, uint32 miscValue) override + void ReceiveAIEvent(AIEventType type, Unit*, Unit*, uint32 miscValue) override { if (type == AI_EVENT_CUSTOM_EVENTAI_D) { From c3d20bb353ca23a03b4c0d6181c123601e713d0c Mon Sep 17 00:00:00 2001 From: insunaa Date: Thu, 24 Mar 2022 09:43:36 +0100 Subject: [PATCH 12/13] deduplicate spawning --- .../scripts/outland/shattrath_city.cpp | 68 ++++++++----------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index c1d4ff78fb5..f7884cf9fec 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -787,15 +787,15 @@ struct npc_shattered_sun_traineeAI : public ScriptedAI } }; -struct npc_commander_steeleAI: public ScriptedAI +struct npc_commander_steeleAI : public ScriptedAI { npc_commander_steeleAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } ObjectGuid recruitMatrix[4][4]; ObjectGuid veteran; - const Position veteranEntryPosition = {-1803.735, 5294.502, -12.38359, 1.62}; - const Position veteranEventPosition = {-1780.713, 5332.765, -12.43613, 5.497787}; - const Position veteranExitPosition = {-1798.737, 5308.549, -14.55699, 1.62}; + const Position veteranEntryPosition = {-1803.735, 5294.502, -12.38359, 1.62}; + const Position veteranEventPosition = {-1780.713, 5332.765, -12.43613, 5.497787}; + const Position veteranExitPosition = {-1798.737, 5308.549, -14.55699, 1.62}; const Position recruitEntryPositions[4][4] = { { @@ -893,9 +893,9 @@ struct npc_commander_steeleAI: public ScriptedAI { if (despawn) { - for (int x=0; x<4; x++) + for (int x = 0; x < 4; ++x) { - for (int y=0; y<4; y++) + for (int y = 0; y < 4; ++y) { if (recruitMatrix[x][y]) { @@ -919,39 +919,29 @@ struct npc_commander_steeleAI: public ScriptedAI else { static const std::vector entries = {NPC_F_BLOODELF_TRAINEE, NPC_F_DRAENEI_TRAINEE, NPC_M_BLOODELF_TRAINEE, NPC_M_DRAENEI_TRAINEE}; - TempSpawnSettings spawnSettings; - for (int x=0; x<4; x++) - { - for (int y=0; y<4; y++) - { - spawnSettings.x = recruitEntryPositions[x][y].x; - spawnSettings.y = recruitEntryPositions[x][y].y; - spawnSettings.z = recruitEntryPositions[x][y].z; - spawnSettings.ori = recruitEntryPositions[x][y].o; - spawnSettings.spawnType = TEMPSPAWN_CORPSE_DESPAWN; - spawnSettings.entry = entries[urand(0,3)]; - spawnSettings.activeObject = true; - spawnSettings.spawner = m_creature; - if (Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap())) - { - recruitMatrix[x][y] = summoned->GetObjectGuid(); - summoned->GetMotionMaster()->MovePoint(2, recruitEventPositions[x][y], FORCED_MOVEMENT_RUN); - } - } - } - spawnSettings.x = veteranEntryPosition.x; - spawnSettings.y = veteranEntryPosition.y; - spawnSettings.z = veteranEntryPosition.z; - spawnSettings.ori = veteranEntryPosition.o; - spawnSettings.spawnType = TEMPSPAWN_CORPSE_DESPAWN; - spawnSettings.entry = NPC_BLOODELF_VETERAN; - spawnSettings.activeObject = true; - spawnSettings.spawner = m_creature; - if (Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap())) - { - veteran = summoned->GetObjectGuid(); - summoned->GetMotionMaster()->MovePoint(2, veteranEventPosition, FORCED_MOVEMENT_RUN); - } + for (int x = 0; x < 4; ++x) + for (int y = 0; y < 4; ++y) + summonTrainee(recruitEntryPositions[x][y].x, recruitEntryPositions[x][y].y, recruitEntryPositions[x][y].z, recruitEntryPositions[x][y].o, entries[urand(0, 3)], + recruitMatrix[x][y], recruitExitPositions[x][y]); + summonTrainee(veteranEntryPosition.x, veteranEntryPosition.y, veteranEntryPosition.z, veteranEntryPosition.o, NPC_BLOODELF_VETERAN, veteran, veteranEntryPosition); + } + } + + void summonTrainee(float x, float y, float z, float o, uint32 entry, ObjectGuid& positioning, Position gridPos) + { + TempSpawnSettings spawnSettings; + spawnSettings.x = x; + spawnSettings.y = y; + spawnSettings.z = z; + spawnSettings.ori = o; + spawnSettings.spawnType = TEMPSPAWN_CORPSE_DESPAWN; + spawnSettings.entry = entry; + spawnSettings.activeObject = true; + spawnSettings.spawner = m_creature; + if (Creature* summoned = m_creature->SummonCreature(spawnSettings, m_creature->GetMap())) + { + positioning = summoned->GetObjectGuid(); + summoned->GetMotionMaster()->MovePoint(2, gridPos, FORCED_MOVEMENT_RUN); } } }; From 66d709533ed8ce8d9902ccffb11e224c848700cd Mon Sep 17 00:00:00 2001 From: insunaa Date: Thu, 24 Mar 2022 09:48:42 +0100 Subject: [PATCH 13/13] fix alignment --- .../scripts/outland/shattrath_city.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp index f7884cf9fec..768647b1780 100644 --- a/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp +++ b/src/game/AI/ScriptDevAI/scripts/outland/shattrath_city.cpp @@ -799,20 +799,20 @@ struct npc_commander_steeleAI : public ScriptedAI const Position recruitEntryPositions[4][4] = { { - {-1810.735, 5292.215, -12.3448, 5.5}, + {-1810.735, 5292.215, -12.3448, 5.5}, {-1797.464, 5308.929, -14.69543, 5.5}, {-1801.254, 5313.176, -12.43915, 5.5}, {-1816.387, 5357.304, -12.43532, 5.5}, }, { - {-1823.218, 5329.122, -12.3977, 5.5}, - {-1841.915, 5347.13, -12.34478, 5.5}, - {-1824.706, 5307.167, -12.3448, 5.5}, - {-1790.77, 5300.418, -20.52535, 5.5}, + {-1823.218, 5329.122, -12.3977, 5.5}, + {-1841.915, 5347.13, -12.34478, 5.5}, + {-1824.706, 5307.167, -12.3448, 5.5}, + {-1790.77, 5300.418, -20.52535, 5.5}, }, { - {-1795.66, 5306.961, -16.11753, 5.5}, - {-1835.797, 5375.394, -12.3448, 5.5}, + {-1795.66, 5306.961, -16.11753, 5.5}, + {-1835.797, 5375.394, -12.3448, 5.5}, {-1823.988, 5360.059, -12.43532, 5.5}, {-1809.875, 5325.414, -12.40578, 5.5}, }, @@ -820,15 +820,15 @@ struct npc_commander_steeleAI : public ScriptedAI {-1811.616, 5333.609, -12.43531, 5.5}, {-1818.436, 5351.488, -12.43532, 5.5}, {-1828.191, 5364.457, -12.34482, 5.5}, - {-1818.281, 5301.583, -12.3448, 5.5}, + {-1818.281, 5301.583, -12.3448, 5.5}, }, }; const Position recruitEventPositions[4][4] = { { - {-1783.63, 5333.444, -12.43531, 5.497787}, - {-1779.016, 5337.96, -12.43531, 5.497787}, + {-1783.63, 5333.444, -12.43531, 5.497787}, + {-1779.016, 5337.96, -12.43531, 5.497787}, {-1783.164, 5337.674, -12.43531, 5.497787}, {-1787.639, 5341.807, -12.43532, 5.497787}, }, @@ -840,8 +840,8 @@ struct npc_commander_steeleAI : public ScriptedAI }, { {-1781.292, 5335.792, -12.43531, 5.497787}, - {-1782.86, 5342.133, -12.43531, 5.497787}, - {-1789.791, 5339.68, -12.43532, 5.497787}, + {-1782.86, 5342.133, -12.43531, 5.497787}, + {-1789.791, 5339.68, -12.43532, 5.497787}, {-1785.902, 5331.252, -12.43613, 5.497787}, }, { @@ -856,8 +856,8 @@ struct npc_commander_steeleAI : public ScriptedAI { { {-1796.377, 5299.302, -19.65246, 100}, - {-1744.358, 5380.27, -12.43531, 100}, - {-1796.183, 5304.772, -17.0572, 100}, + {-1744.358, 5380.27, -12.43531, 100}, + {-1796.183, 5304.772, -17.0572, 100}, {-1798.558, 5309.034, -14.36996, 100}, }, { @@ -868,12 +868,12 @@ struct npc_commander_steeleAI : public ScriptedAI }, { {-1728.108, 5366.323, -9.279177, 100}, - {-1764.693, 5385.993, -5.32568, 100}, + {-1764.693, 5385.993, -5.32568, 100}, {-1798.901, 5305.465, -16.00611, 100}, {-1794.535, 5303.782, -17.97032, 100}, }, { - {-1794.568, 5309.374, -15.2566, 100}, + {-1794.568, 5309.374, -15.2566, 100}, {-1763.738, 5383.413, -7.619812, 100}, {-1741.796, 5385.382, -12.43531, 100}, {-1792.979, 5307.494, -16.58447, 100},