TrinityCore
zone_stormwind_city.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "Containers.h"
21#include "Conversation.h"
22#include "CreatureAIImpl.h"
23#include "MotionMaster.h"
24#include "ObjectAccessor.h"
25#include "PhasingHandler.h"
26#include "Player.h"
27#include "ScriptMgr.h"
28#include "ScriptedCreature.h"
29#include "ScriptedGossip.h"
30#include "SpellScript.h"
31#include "TemporarySummon.h"
32
34{
36
38
40
44
47
49
52};
53
55{
60
62
66
68
70
72
75};
76
77// 55 - Stormwind Keep - Tides of War
79{
81
82 void OnUnitEnter(Unit* unit) override
83 {
84 Player* player = unit->ToPlayer();
86 return;
87
88 // @TODO: cooldown after generic impl
89
91 }
92};
93
94Position const VisionOfSailorsMemoryPosition = { -8384.131f, 324.383f, 148.443f, 1.559973f };
95
96// 4857 - Conversation
98{
99public:
100 conversation_start_council_tides_of_war() : ConversationScript("conversation_start_council_tides_of_war") { }
101
103 {
106 };
107
109 {
111
114 };
115
116 void OnConversationCreate(Conversation* conversation, Unit* creator) override
117 {
118 Creature* jainaObject = GetClosestCreatureWithOptions(creator, 30.0f, { .CreatureId = NPC_JAINA_TIDES_OF_WAR, .IgnorePhases = true });
119 if (!jainaObject)
120 return;
121
122 TempSummon* jainaClone = jainaObject->SummonPersonalClone(jainaObject->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, creator->ToPlayer());
123 if (!jainaClone)
124 return;
125
126 conversation->AddActor(CONVO_ACTOR_JAINA, 3, jainaClone->GetGUID());
127 conversation->Start();
128 }
129
130 void OnConversationStart(Conversation* conversation) override
131 {
132 LocaleConstant privateOwnerLocale = conversation->GetPrivateObjectOwnerLocale();
133
134 if (Milliseconds const* jainaWalkStartTime = conversation->GetLineStartTime(privateOwnerLocale, CONVO_LINE_JAINA_WALK))
135 _events.ScheduleEvent(EVENT_JAINA_WALK, *jainaWalkStartTime);
136
138 }
139
140 void OnConversationUpdate(Conversation* conversation, uint32 diff) override
141 {
142 _events.Update(diff);
143
144 switch (_events.ExecuteEvent())
145 {
146 case EVENT_JAINA_WALK:
147 {
148 Creature* jainaClone = conversation->GetActorCreature(3);
149 if (!jainaClone)
150 break;
151
152 jainaClone->GetMotionMaster()->MovePath(PATH_JAINA_VISION_START, false);
153 break;
154 }
156 {
157 Unit* privateObjectOwner = ObjectAccessor::GetUnit(*conversation, conversation->GetPrivateObjectOwner());
158 if (!privateObjectOwner)
159 break;
160
161 Player* player = privateObjectOwner->ToPlayer();
162 if (!player)
163 break;
164
167 break;
168 }
169 default:
170 break;
171 }
172 }
173
174private:
176};
177
178// 120590 - Jaina Proudmoore
180{
182
183 bool OnGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override
184 {
185 if (menuId == GOSSIP_MENU_NATION_OF_KULTIRAS)
186 {
187 if (gossipListId == GOSSIP_OPTION_START_KULTIRAS_INTRO)
188 {
189 CloseGossipMenuFor(player);
190 // @TODO: script start of TolDagor intro
191 }
192 else if (gossipListId == GOSSIP_OPTION_SKIP_KULTIRAS_INTRO)
193 {
194 CloseGossipMenuFor(player);
195 player->CastSpell(nullptr, SPELL_SKIP_KULTIRAS_INTRO, false);
196 }
197 }
198 return true;
199 }
200
201 void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
202 {
203 if (pathId == PATH_JAINA_VISION_START)
204 {
205 me->SetFacingTo(5.1164f);
207
208 _scheduler.Schedule(14s, [this](TaskContext /*context*/)
209 {
211 me->GetMotionMaster()->MovePath(PATH_JAINA_VISION_FINISH, false);
212 });
213 }
214 else if (pathId == PATH_JAINA_VISION_FINISH)
216 }
217
218 void DoAction(int32 action) override
219 {
220 if (action == ACTION_JAINA_LEAVE_COUNCIL)
221 {
222 _scheduler.Schedule(1s, [this](TaskContext task)
223 {
225 task.Schedule(4s, [this](TaskContext task)
226 {
228 task.Schedule(2s, [this](TaskContext /*task*/)
229 {
230 Unit* privateObjectOwner = ObjectAccessor::GetUnit(*me, me->GetPrivateObjectOwner());
231 if (!privateObjectOwner)
232 return;
233
234 Conversation::CreateConversation(CONVERSATION_JAINA_LEAVE_COUNCIL, privateObjectOwner, *privateObjectOwner, privateObjectOwner->GetGUID(), nullptr, true);
236 });
237 });
238 });
239 }
240 }
241
242 void UpdateAI(uint32 diff) override
243 {
244 _scheduler.Update(diff);
245 }
246
247private:
249};
250
251// 858 - Movie
253{
254public:
255 player_conv_after_movie_tides_of_war() : PlayerScript("player_conv_after_movie_tides_of_war") { }
256
257 void OnMovieComplete(Player* player, uint32 movieId) override
258 {
259 if (movieId == MOVIE_POST_TIDES_OF_WAR)
260 {
261 Creature* jainaClone = GetClosestCreatureWithOptions(player, 30.0f, { .CreatureId = NPC_JAINA_TIDES_OF_WAR, .IgnorePhases = true, .PrivateObjectOwnerGuid = player->GetGUID() });
262 if (!jainaClone)
263 return;
264
265 jainaClone->DespawnOrUnsummon();
266 player->CastSpell(player, SPELL_CONVO_POST_MOVIE_TIDES_OF_WAR, true);
267 }
268 }
269};
270
271// 284807 - Despawn
273{
275 {
276 if (Creature* creature = GetHitUnit()->ToCreature())
277 creature->DespawnOrUnsummon();
278 }
279
280 void Register() override
281 {
283 }
284};
285
286// 120756 - Anduin Wrynn
288{
290
291 void OnQuestAccept(Player* player, Quest const* quest) override
292 {
293 if (quest->GetQuestId() == QUEST_NATION_OF_KULTIRAS)
294 {
296
297 Creature* jainaObject = GetClosestCreatureWithOptions(player, 15.0f, { .CreatureId = NPC_JAINA_TIDES_OF_WAR, .IgnorePhases = true });
298 if (!jainaObject)
299 return;
300
301 TempSummon* jainaClone = jainaObject->SummonPersonalClone(jainaObject->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player->ToPlayer());
302 if (!jainaClone)
303 return;
304
305 jainaClone->AI()->DoAction(ACTION_JAINA_LEAVE_COUNCIL);
306 }
307 }
308};
309
310// 279998 - Kul Tiras: Skip Intro
312{
314 {
315 if (Player* player = GetCaster()->ToPlayer())
316 {
317 player->CastSpell(nullptr, SPELL_SKIP_TOLDAGOR_TELEPORT, false);
319 }
320 }
321
322 void Register() override
323 {
325 }
326};
327
329{
330 // Creature
333
334 // Conversation
336
337 // PlayerScript
339
340 // AreaTrigger
342
343 // Spells
346}
LocaleConstant
Definition: Common.h:48
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ TEMPSUMMON_MANUAL_DESPAWN
Definition: ObjectDefines.h:70
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:145
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
#define RegisterAreaTriggerAI(ai_name)
Definition: ScriptMgr.h:1416
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
Creature * GetClosestCreatureWithOptions(WorldObject *source, float maxSearchRange, FindCreatureOptions const &options)
void CloseGossipMenuFor(Player *player)
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:591
Milliseconds GetLineEndTime(LocaleConstant locale, int32 lineId) const
void AddActor(int32 actorId, uint32 actorIdx, ObjectGuid const &actorGuid)
LocaleConstant GetPrivateObjectOwnerLocale() const
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
Milliseconds const * GetLineStartTime(LocaleConstant locale, int32 lineId) const
Creature * GetActorCreature(uint32 actorIdx) const
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, bool generatePath=true)
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition: Player.cpp:16680
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:16050
uint32 GetQuestId() const
Definition: QuestDef.h:587
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
TaskContext & Schedule(std::chrono::duration< Rep, Period > time, TaskScheduler::task_handler_t task)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
virtual void DoAction(int32)
Definition: UnitAI.h:72
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:3017
TempSummon * SummonPersonalClone(Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, Player *privateObjectOwner=nullptr)
Definition: Object.cpp:2048
ObjectGuid GetPrivateObjectOwner() const
Definition: Object.h:785
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
void OnConversationStart(Conversation *conversation) override
void OnConversationCreate(Conversation *conversation, Unit *creator) override
void OnConversationUpdate(Conversation *conversation, uint32 diff) override
void OnMovieComplete(Player *player, uint32 movieId) override
void HandleHitTarget(SpellEffIndex)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
at_stormwind_keep_tides_of_war(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
void OnQuestAccept(Player *player, Quest const *quest) override
npc_anduin_wrynn_nation_of_kultiras(Creature *creature)
bool OnGossipSelect(Player *player, uint32 menuId, uint32 gossipListId) override
npc_jaina_proudmoore_tides_of_war(Creature *creature)
void DoAction(int32 action) override
void WaypointPathEnded(uint32, uint32 pathId) override
void UpdateAI(uint32 diff) override
NationOfKulTirasData
@ SPELL_SKIP_TOLDAGOR_TELEPORT
@ GOSSIP_OPTION_START_KULTIRAS_INTRO
@ GOSSIP_MENU_NATION_OF_KULTIRAS
@ CONVERSATION_JAINA_LEAVE_COUNCIL
@ QUEST_OUT_LIKE_FLYNN
@ GOSSIP_OPTION_SKIP_KULTIRAS_INTRO
@ SPELL_SKIP_KULTIRAS_INTRO
@ SAY_JAINA_LEAVE_COUNCIL
@ QUEST_NATION_OF_KULTIRAS
@ QUEST_DAUGHTER_OF_THE_SEA
@ QUEST_NATION_OF_KULTIRAS_NPE
@ ACTION_JAINA_LEAVE_COUNCIL
@ SPELL_JAINA_TELEPORT
Position const VisionOfSailorsMemoryPosition
void AddSC_stormwind_city()
@ SPELL_JAINA_ARCANE_CHANNEL
@ SPELL_CONVO_POST_MOVIE_TIDES_OF_WAR
@ NPC_JAINA_TIDES_OF_WAR
@ NPC_ANDUIN_TIDES_OF_WAR
@ MOVIE_POST_TIDES_OF_WAR
@ CONVERSATION_START_COUNCIL_TIDES_OF_WAR
@ PATH_JAINA_VISION_FINISH
@ QUEST_OBJECTIVE_ATTEND_COUNCIL
@ NPC_VISION_OF_SAILORS_MEMORY
@ PATH_JAINA_VISION_START
@ QUEST_TIDES_OF_WAR