TrinityCore
naxxramas.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "MotionMaster.h"
20#include "MoveSpline.h"
21#include "MoveSplineInit.h"
22#include "ScriptedCreature.h"
23#include "PassiveAI.h"
24#include "TemporarySummon.h"
25#include "naxxramas.h"
26
27/*
28 According to sniffs there are multiple spawn groups (5 to be precise) since Living Poisons with the same initial spline
29 destination are only getting spawned in 31 seconds intervals. For the sake of readability we will stick
30 with one and increase the interval.
31
32 Here are some values:
33 - The "Frogger" spawner spawns the same group in 31 second intervals. Since we are lazy and wanna keep the values readable
34 we stick with one timer set at 6s.
35 - The slime moves with a spline velocity of 2.5f which equals the walk speed of it.
36 - If a slime explodes it will despawn 8.5s after its death.
37 - If a slime reaches its final spline destination it will despawn after 500 milliseconds -+ 100 depending on Blizzard's packet interval
38*/
39
41{
43};
44
46{
51};
52
53std::array<LivingPoisonData, 3> const LivingPoisons = {
54 {
55 {
56 { 3175.399f, -3134.5156f, 293.37762f, 4.4535513f },
57 { 3167.0532f, -3150.3875f, 294.0628f },
58 { 3158.178f, -3163.7876f, 293.3122f },
59 5s + 500ms
60 },
61 {
62 { 3154.5203f, -3125.6458f, 293.44492f, 4.6543846f },
63 { 3149.712f, -3142.9995f, 294.0628f },
64 { 3145.9402f, -3158.5762f, 293.32156f },
65 6s
66 },
67 {
68 { 3128.609f, -3119.2295f, 293.42194f, 4.7248187f },
69 { 3128.868f, -3140.0342f, 294.0628f },
70 { 3129.5356f, -3156.7466f, 293.32394f },
71 7s
72 }
73 }
74};
75
77{
79
80 void Reset() override
81 {
83 }
84
85 void UpdateAI(uint32 diff) override
86 {
87 _events.Update(diff);
88
89 while (uint32 eventId = _events.ExecuteEvent())
90 {
91 switch (eventId)
92 {
94 for (LivingPoisonData const& poisonData : LivingPoisons)
95 {
96 if (Creature* slime = DoSummon(NPC_LIVING_POISON, poisonData.SpawnPos, 8s + 500ms, TEMPSUMMON_CORPSE_TIMED_DESPAWN))
97 {
98 LaunchSpline(slime, poisonData.FirstSplineDest);
99 slime->m_Events.AddEventAtOffset([poisonData, slime]()
100 {
101 if (slime->isDead())
102 return;
103
104 LaunchSpline(slime, poisonData.SecondSplineDest);
105 if (!slime->movespline->Finalized())
106 slime->DespawnOrUnsummon(Milliseconds(slime->movespline->Duration()) + 500ms);
107 }, poisonData.NextSplineTimer);
108 }
109 }
110 _events.Repeat(6s);
111 break;
112 default:
113 break;
114 }
115 }
116 }
117
118private:
120
121 static void LaunchSpline(Creature* slime, Position const& dest)
122 {
123 std::function<void(Movement::MoveSplineInit&)> initializer = [dest = dest](Movement::MoveSplineInit& init)
124 {
125 init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
126 init.SetWalk(true);
127 };
128 slime->GetMotionMaster()->LaunchMoveSpline(std::move(initializer));
129 }
130};
131
133{
135}
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
Definition: ObjectDefines.h:68
if(posix_memalign(&__mallocedMemory, __align, __size)) return NULL
Creature * DoSummon(uint32 entry, Position const &pos, Milliseconds despawnTime=30s, TempSummonType summonType=TEMPSUMMON_CORPSE_TIMED_DESPAWN)
Definition: CreatureAI.cpp:464
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void LaunchMoveSpline(std::function< void(Movement::MoveSplineInit &init)> &&initializer, uint32 id=0, MovementGeneratorPriority priority=MOTION_PRIORITY_NORMAL, MovementGeneratorType type=EFFECT_MOTION_TYPE)
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
std::array< LivingPoisonData, 3 > const LivingPoisons
Definition: naxxramas.cpp:53
void AddSC_naxxramas()
Definition: naxxramas.cpp:132
NaxxEvents
Definition: naxxramas.cpp:41
@ EVENT_SUMMON_LIVING_POISON
Definition: naxxramas.cpp:42
@ NPC_LIVING_POISON
Definition: naxxramas.h:111
#define RegisterNaxxramasCreatureAI(ai_name)
Definition: naxxramas.h:221
Milliseconds NextSplineTimer
Definition: naxxramas.cpp:50
Position SecondSplineDest
Definition: naxxramas.cpp:49
Position FirstSplineDest
Definition: naxxramas.cpp:48
Position SpawnPos
Definition: naxxramas.cpp:47
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetPositionZ() const
Definition: Position.h:78
npc_frogger_trigger_naxx(Creature *creature)
Definition: naxxramas.cpp:78
void UpdateAI(uint32 diff) override
Definition: naxxramas.cpp:85
void Reset() override
Definition: naxxramas.cpp:80
static void LaunchSpline(Creature *slime, Position const &dest)
Definition: naxxramas.cpp:121