TrinityCore
Loading...
Searching...
No Matches
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: 1560
22SDCategory: Tanaris
23EndScriptData */
24
25/* ContentData
26npc_tooga
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "MotionMaster.h"
31#include "ObjectAccessor.h"
32#include "Player.h"
33#include "ScriptedEscortAI.h"
34#include "ScriptedFollowerAI.h"
35#include "ScriptedGossip.h"
36#include "WorldSession.h"
37
38/*####
39# npc_tooga
40####*/
41
57
58Position const ToWaterLoc = {-7032.664551f, -4906.199219f, -1.606446f, 0.0f};
59
61{
62public:
63 npc_tooga() : CreatureScript("npc_tooga") { }
64
65 struct npc_toogaAI : public FollowerAI
66 {
67 npc_toogaAI(Creature* creature) : FollowerAI(creature)
68 {
69 Initialize();
70 }
71
73 {
74 CheckSpeechTimer = 2500;
75 PostEventTimer = 1000;
77
79 }
80
84
86
87 void Reset() override
88 {
89 Initialize();
90 }
91
92 void MoveInLineOfSight(Unit* who) override
93
94 {
96
98 {
100 {
101 Player* player = GetLeaderForFollower();
102 if (player)
104
105 TortaGUID = who->GetGUID();
106 SetFollowComplete(true);
107 }
108 }
109 }
110
111 void MovementInform(uint32 MotionType, uint32 PointId) override
112 {
113 FollowerAI::MovementInform(MotionType, PointId);
114
115 if ((MotionType == POINT_MOTION_TYPE) && (PointId == POINT_ID_TO_WATER))
117 }
118
119 void UpdateFollowerAI(uint32 Diff) override
120 {
121 if (!UpdateVictim())
122 {
123 //we are doing the post-event, or...
125 {
126 if (PostEventTimer <= Diff)
127 {
128 PostEventTimer = 5000;
129
131 if (!torta || !torta->IsAlive())
132 {
133 //something happened, so just complete
135 return;
136 }
137
138 switch (PhasePostEvent)
139 {
140 case 1:
142 break;
143 case 2:
144 torta->AI()->Talk(SAY_TORT_POST_2);
145 break;
146 case 3:
148 break;
149 case 4:
150 torta->AI()->Talk(SAY_TORT_POST_4);
151 break;
152 case 5:
154 break;
155 case 6:
156 torta->AI()->Talk(SAY_TORT_POST_6);
158 break;
159 }
160
162 }
163 else
164 PostEventTimer -= Diff;
165 }
166 //...we are doing regular speech check
168 {
169 if (CheckSpeechTimer <= Diff)
170 {
171 CheckSpeechTimer = 5000;
172
173 if (urand(0, 9) > 8)
175 }
176 else
177 CheckSpeechTimer -= Diff;
178 }
179
180 return;
181 }
182
184 }
185
186 void OnQuestAccept(Player* player, Quest const* quest) override
187 {
188 if (quest->GetQuestId() == QUEST_TOOGA)
190 }
191 };
192
193 CreatureAI* GetAI(Creature* creature) const override
194 {
195 return new npc_toogaAI(creature);
196 }
197};
198
200{
201 new npc_tooga();
202}
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
#define INTERACTION_DISTANCE
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)
virtual void MovementInform(uint32, uint32)
Definition CreatureAI.h:173
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
CreatureAI * AI() const
Definition Creature.h:154
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={})
void Clear()
Definition ObjectGuid.h:150
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition Player.cpp:16032
uint32 GetQuestId() const
Definition QuestDef.h:229
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Definition Unit.h:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool IsAlive() const
Definition Unit.h:1234
Unit * GetVictim() const
Definition Unit.h:859
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
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