TrinityCore
zone_tanaris.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/* ScriptData
19SDName: Tanaris
20SD%Complete: 80
21SDComment: Quest support:
22SDCategory: Tanaris
23EndScriptData */
24
25/* ContentData
26EndContentData */
27
28#include "ScriptMgr.h"
29#include "MotionMaster.h"
30#include "ObjectAccessor.h"
31#include "Player.h"
32#include "ScriptedFollowerAI.h"
33
34/*####
35# npc_tooga
36####*/
37
39{
47
49 NPC_TORTA = 6015,
50
52};
53
54Position const ToWaterLoc = {-7032.664551f, -4906.199219f, -1.606446f, 0.0f};
55
57{
58public:
59 npc_tooga() : CreatureScript("npc_tooga") { }
60
61 struct npc_toogaAI : public FollowerAI
62 {
63 npc_toogaAI(Creature* creature) : FollowerAI(creature)
64 {
65 Initialize();
66 }
67
69 {
70 CheckSpeechTimer = 2500;
71 PostEventTimer = 1000;
73
75 }
76
80
82
83 void Reset() override
84 {
85 Initialize();
86 }
87
88 void MoveInLineOfSight(Unit* who) override
89 {
91
93 {
95 {
96 Player* player = GetLeaderForFollower();
97 if (player)
99
100 TortaGUID = who->GetGUID();
101 SetFollowComplete(true);
102 }
103 }
104 }
105
106 void MovementInform(uint32 MotionType, uint32 PointId) override
107 {
108 FollowerAI::MovementInform(MotionType, PointId);
109
110 if ((MotionType == POINT_MOTION_TYPE) && (PointId == POINT_ID_TO_WATER))
112 }
113
114 void UpdateFollowerAI(uint32 Diff) override
115 {
116 if (!UpdateVictim())
117 {
118 //we are doing the post-event, or...
120 {
121 if (PostEventTimer <= Diff)
122 {
123 PostEventTimer = 5000;
124
126 if (!torta || !torta->IsAlive())
127 {
128 //something happened, so just complete
130 return;
131 }
132
133 switch (PhasePostEvent)
134 {
135 case 1:
137 break;
138 case 2:
139 torta->AI()->Talk(SAY_TORT_POST_2);
140 break;
141 case 3:
143 break;
144 case 4:
145 torta->AI()->Talk(SAY_TORT_POST_4);
146 break;
147 case 5:
149 break;
150 case 6:
151 torta->AI()->Talk(SAY_TORT_POST_6);
153 break;
154 }
155
157 }
158 else
159 PostEventTimer -= Diff;
160 }
161 //...we are doing regular speech check
163 {
164 if (CheckSpeechTimer <= Diff)
165 {
166 CheckSpeechTimer = 5000;
167
168 if (urand(0, 9) > 8)
170 }
171 else
172 CheckSpeechTimer -= Diff;
173 }
174
175 return;
176 }
177 }
178
179 void OnQuestAccept(Player* player, Quest const* quest) override
180 {
181 if (quest->GetQuestId() == QUEST_TOOGA)
183 }
184 };
185
186 CreatureAI* GetAI(Creature* creature) const override
187 {
188 return new npc_toogaAI(creature);
189 }
190};
191
193{
194}
uint32_t uint32
Definition: Define.h:142
@ POINT_MOTION_TYPE
#define INTERACTION_DISTANCE
Definition: ObjectDefines.h:24
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
@ STATE_FOLLOW_COMPLETE
@ STATE_FOLLOW_POSTEVENT
@ STATE_FOLLOW_INPROGRESS
@ FACTION_ESCORTEE_N_NEUTRAL_PASSIVE
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
virtual void MovementInform(uint32, uint32)
Definition: CreatureAI.h:154
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
CreatureAI * AI() const
Definition: Creature.h:214
void StartFollow(Player *player, uint32 factionForFollower=0, uint32 quest=0)
void MoveInLineOfSight(Unit *) override
Player * GetLeaderForFollower()
void SetFollowComplete(bool withEndEvent=false)
bool HasFollowState(uint32 uiFollowState) const
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void Clear()
Definition: ObjectGuid.h:286
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition: Player.cpp:16598
uint32 GetQuestId() const
Definition: QuestDef.h:587
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
bool IsAlive() const
Definition: Unit.h:1164
Unit * GetVictim() const
Definition: Unit.h:715
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
npc_toogaAI(Creature *creature)
void UpdateFollowerAI(uint32 Diff) override
void MovementInform(uint32 MotionType, uint32 PointId) override
void OnQuestAccept(Player *player, Quest const *quest) override
void Reset() override
void MoveInLineOfSight(Unit *who) override
Position const ToWaterLoc
void AddSC_tanaris()
Tooga
@ NPC_TORTA
@ SAY_TOOG_POST_1
@ SAY_TORT_POST_2
@ SAY_TORT_POST_6
@ SAY_TORT_POST_4
@ SAY_TOOG_WORRIED
@ QUEST_TOOGA
@ SAY_TOOG_POST_3
@ SAY_TOOG_POST_5
@ POINT_ID_TO_WATER