TrinityCore
Loading...
Searching...
No Matches
Transport.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 "Transport.h"
19#include "Cell.h"
20#include "CellImpl.h"
21#include "Common.h"
22#include "DBCStores.h"
23#include "GameObjectAI.h"
24#include "Log.h"
25#include "MapManager.h"
26#include "ObjectMgr.h"
27#include "ScriptMgr.h"
28#include "Spline.h"
29#include "Player.h"
30#include "Totem.h"
31#include "UpdateData.h"
32#include "Vehicle.h"
33#include <G3D/Vector3.h>
34
36 _transportInfo(nullptr), _isMoving(true), _pendingStop(false),
37 _triggeredArrivalEvent(false), _triggeredDepartureEvent(false),
38 _passengerTeleportItr(_passengers.begin()), _delayedAddModel(false), _delayedTeleport(false)
39{
41}
42
48
49bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
50{
51 Relocate(x, y, z, ang);
52
53 if (!IsPositionValid())
54 {
55 TC_LOG_ERROR("entities.transport", "Transport (GUID: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})",
56 guidlow, x, y);
57 return false;
58 }
59
60 Object::_Create(ObjectGuid::Create<HighGuid::Mo_Transport>(guidlow));
61
62 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
63 if (!goinfo)
64 {
65 TC_LOG_ERROR("sql.sql", "Transport not created: entry in `gameobject_template` not found, guidlow: {} map: {} (X: {} Y: {} Z: {}) ang: {}", guidlow, mapid, x, y, z, ang);
66 return false;
67 }
68
69 m_goInfo = goinfo;
70 m_goTemplateAddon = sObjectMgr->GetGameObjectTemplateAddon(entry);
71
72 TransportTemplate const* tInfo = sTransportMgr->GetTransportTemplate(entry);
73 if (!tInfo)
74 {
75 TC_LOG_ERROR("sql.sql", "Transport {} (name: {}) will not be created, missing `transport_template` entry.", entry, goinfo->name);
76 return false;
77 }
78
79 _transportInfo = tInfo;
80
81 // initialize waypoints
82 _nextFrame = tInfo->keyFrames.begin();
86
87 if (GameObjectOverride const* goOverride = GetGameObjectOverride())
88 {
89 SetFaction(goOverride->Faction);
90 ReplaceAllFlags(GameObjectFlags(goOverride->Flags));
91 }
92
94 SetObjectScale(goinfo->size);
95 SetPeriod(tInfo->pathTime);
96 SetEntry(goinfo->entry);
97 SetDisplayId(goinfo->displayId);
100 SetGoAnimProgress(animprogress);
101 SetName(goinfo->name);
102 SetLocalRotation(0.0f, 0.0f, 0.0f, 1.0f);
104
105 CreateModel();
106 return true;
107}
108
109void Transport::CleanupsBeforeDelete(bool finalCleanup /*= true*/)
110{
112 while (!_passengers.empty())
113 {
114 WorldObject* obj = *_passengers.begin();
115 RemovePassenger(obj);
116 }
117
119}
120
122{
123 uint32 const positionUpdateDelay = 200;
124
125 if (AI())
126 AI()->UpdateAI(diff);
127 else if (!AIM_Initialize())
128 TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");
129
130 if (GetKeyFrames().size() <= 1)
131 return;
132
133 if (IsMoving() || !_pendingStop)
135
137 bool justStopped = false;
138
139 // Set current waypoint
140 // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
141 // ... arrive | ... delay ... | departure
142 // event / event /
143 for (;;)
144 {
145 if (timer >= _currentFrame->ArriveTime)
146 {
148 {
151 }
152
153 if (timer < _currentFrame->DepartureTime)
154 {
155 justStopped = IsMoving();
156 SetMoving(false);
158 {
163 }
164 break; // its a stop frame and we are waiting
165 }
166 }
167
168 if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
169 {
170 DoEventIfAny(*_currentFrame, true); // departure event
172 }
173
174 // not waiting anymore
175 SetMoving(true);
176
177 // Enable movement
178 if (GetGOInfo()->moTransport.canBeStopped)
180
181 if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
182 break; // found current waypoint
183
185
186 sScriptMgr->OnRelocate(this, _currentFrame->Node->NodeIndex, _currentFrame->Node->ContinentID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);
187
188 TC_LOG_DEBUG("entities.transport", "Transport {} ({}) moved to node {} {} {} {} {}", GetEntry(), GetName(), _currentFrame->Node->NodeIndex, _currentFrame->Node->ContinentID, _currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z);
189
190 // Departure event
191 if (_currentFrame->IsTeleportFrame())
192 if (TeleportTransport(_nextFrame->Node->ContinentID, _nextFrame->Node->Loc.X, _nextFrame->Node->Loc.Y, _nextFrame->Node->Loc.Z, _nextFrame->InitialOrientation))
193 return; // Update more in new map thread
194 }
195
196 // Add model to map after we are fully done with moving maps
198 {
199 _delayedAddModel = false;
200 if (m_model)
202 }
203
204 // Set position
207 {
208 _positionChangeTimer.Reset(positionUpdateDelay);
209 if (IsMoving())
210 {
211 float t = !justStopped ? CalculateSegmentPos(float(timer) * 0.001f) : 1.0f;
212 G3D::Vector3 pos, dir;
213 _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
214 _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
215 UpdatePosition(pos.x, pos.y, pos.z, std::atan2(dir.y, dir.x) + float(M_PI));
216 }
217 else if (justStopped)
218 UpdatePosition(_currentFrame->Node->Loc.X, _currentFrame->Node->Loc.Y, _currentFrame->Node->Loc.Z, _currentFrame->InitialOrientation);
219 else
220 {
221 /* There are four possible scenarios that trigger loading/unloading passengers:
222 1. transport moves from inactive to active grid
223 2. the grid that transport is currently in becomes active
224 3. transport moves from active to inactive grid
225 4. the grid that transport is currently in unloads
226 */
227 bool gridActive = GetMap()->IsGridLoaded(GetPositionX(), GetPositionY());
228
229 if (_staticPassengers.empty() && gridActive) // 2.
231 else if (!_staticPassengers.empty() && !gridActive)
232 // 4. - if transports stopped on grid edge, some passengers can remain in active grids
233 // unload all static passengers otherwise passengers won't load correctly when the grid that transport is currently in becomes active
235 }
236 }
237
238 sScriptMgr->OnTransportUpdate(this, diff);
239}
240
242{
243 if (GetKeyFrames().size() <= 1)
244 return;
245
247}
248
250{
251 if (!IsInWorld())
252 return;
253
254 if (_passengers.insert(passenger).second)
255 {
256 passenger->SetTransport(this);
258 passenger->m_movementInfo.transport.guid = GetGUID();
259 TC_LOG_DEBUG("entities.transport", "Object {} boarded transport {}.", passenger->GetName(), GetName());
260
261 if (Player* plr = passenger->ToPlayer())
262 sScriptMgr->OnAddPassenger(this, plr);
263 }
264}
265
267{
268 bool erased = false;
270 {
271 PassengerSet::iterator itr = _passengers.find(passenger);
272 if (itr != _passengers.end())
273 {
274 if (itr == _passengerTeleportItr)
276
277 _passengers.erase(itr);
278 erased = true;
279 }
280 }
281 else
282 erased = _passengers.erase(passenger) > 0;
283
284 if (erased || _staticPassengers.erase(passenger)) // static passenger can remove itself in case of grid unload
285 {
286 passenger->SetTransport(nullptr);
288 passenger->m_movementInfo.transport.Reset();
289 TC_LOG_DEBUG("entities.transport", "Object {} removed from transport {}.", passenger->GetName(), GetName());
290
291 if (Player* plr = passenger->ToPlayer())
292 {
293 sScriptMgr->OnRemovePassenger(this, plr);
294 plr->SetFallInformation(0, plr->GetPositionZ());
295 }
296 }
297}
298
300{
301 Map* map = GetMap();
302 if (map->GetCreatureRespawnTime(guid))
303 return nullptr;
304
305 Creature* creature = new Creature();
306
307 if (!creature->LoadFromDB(guid, map, false, false))
308 {
309 delete creature;
310 return nullptr;
311 }
312
313 float x, y, z, o;
314 data->spawnPoint.GetPosition(x, y, z, o);
315
316 creature->SetTransport(this);
318 creature->m_movementInfo.transport.guid = GetGUID();
319 creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
320 CalculatePassengerPosition(x, y, z, &o);
321 creature->Relocate(x, y, z, o);
322 creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
324
328
329 if (!creature->IsPositionValid())
330 {
331 TC_LOG_ERROR("entities.transport", "Passenger {} not created. Suggested coordinates aren't valid (X: {} Y: {})", creature->GetGUID().ToString(), creature->GetPositionX(), creature->GetPositionY());
332 delete creature;
333 return nullptr;
334 }
335
336 if (!map->AddToMap(creature))
337 {
338 delete creature;
339 return nullptr;
340 }
341
342 _staticPassengers.insert(creature);
343 sScriptMgr->OnAddCreaturePassenger(this, creature);
344 return creature;
345}
346
348{
349 Map* map = GetMap();
350 if (map->GetGORespawnTime(guid))
351 return nullptr;
352
353 GameObject* go = new GameObject();
354
355 if (!go->LoadFromDB(guid, map, false))
356 {
357 delete go;
358 return nullptr;
359 }
360
361 ASSERT(data);
362
363 float x, y, z, o;
364 data->spawnPoint.GetPosition(x, y, z, o);
365
366 go->SetTransport(this);
368 go->m_movementInfo.transport.pos.Relocate(x, y, z, o);
369 CalculatePassengerPosition(x, y, z, &o);
370 go->Relocate(x, y, z, o);
371 go->RelocateStationaryPosition(x, y, z, o);
372
373 if (!go->IsPositionValid())
374 {
375 TC_LOG_ERROR("entities.transport", "Passenger {} not created. Suggested coordinates aren't valid (X: {} Y: {})", go->GetGUID().ToString(), go->GetPositionX(), go->GetPositionY());
376 delete go;
377 return nullptr;
378 }
379
380 if (!map->AddToMap(go))
381 {
382 delete go;
383 return nullptr;
384 }
385
386 _staticPassengers.insert(go);
387 return go;
388}
389
390TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/)
391{
392 Map* map = FindMap();
393 if (!map)
394 return nullptr;
395
397 if (properties)
398 {
399 switch (properties->Control)
400 {
402 mask = UNIT_MASK_GUARDIAN;
403 break;
405 mask = UNIT_MASK_PUPPET;
406 break;
408 mask = UNIT_MASK_MINION;
409 break;
413 {
414 switch (properties->Title)
415 {
419 mask = UNIT_MASK_GUARDIAN;
420 break;
423 mask = UNIT_MASK_TOTEM;
424 break;
427 mask = UNIT_MASK_SUMMON;
428 break;
430 mask = UNIT_MASK_MINION;
431 break;
432 default:
433 if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
434 mask = UNIT_MASK_GUARDIAN;
435 break;
436 }
437 break;
438 }
439 default:
440 return nullptr;
441 }
442 }
443
444 uint32 phase = PHASEMASK_NORMAL;
445 if (summoner)
446 phase = summoner->GetPhaseMask();
447
448 TempSummon* summon = nullptr;
449 switch (mask)
450 {
451 case UNIT_MASK_SUMMON:
452 summon = new TempSummon(properties, summoner, false);
453 break;
455 summon = new Guardian(properties, summoner, false);
456 break;
457 case UNIT_MASK_PUPPET:
458 summon = new Puppet(properties, summoner);
459 break;
460 case UNIT_MASK_TOTEM:
461 summon = new Totem(properties, summoner);
462 break;
463 case UNIT_MASK_MINION:
464 summon = new Minion(properties, summoner, false);
465 break;
466 }
467
468 float x, y, z, o;
469 pos.GetPosition(x, y, z, o);
470 CalculatePassengerPosition(x, y, z, &o);
471
472 if (!summon->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, phase, entry, { x, y, z, o }, nullptr, vehId))
473 {
474 delete summon;
475 return nullptr;
476 }
477
478 summon->SetCreatedBySpell(spellId);
479
480 summon->SetTransport(this);
484 summon->Relocate(x, y, z, o);
485 summon->SetHomePosition(x, y, z, o);
486 summon->SetTransportHomePosition(pos);
487
491
492 summon->InitStats(duration);
493
494 if (!map->AddToMap<Creature>(summon))
495 {
496 delete summon;
497 return nullptr;
498 }
499
500 _staticPassengers.insert(summon);
501
502 summon->InitSummon();
503 summon->SetTempSummonType(summonType);
504
505 return summon;
506}
507
508void Transport::UpdatePosition(float x, float y, float z, float o)
509{
510 bool newActive = GetMap()->IsGridLoaded(x, y);
511 Cell oldCell(GetPositionX(), GetPositionY());
512
513 Relocate(x, y, z, o);
515
517
518 /* There are four possible scenarios that trigger loading/unloading passengers:
519 1. transport moves from inactive to active grid
520 2. the grid that transport is currently in becomes active
521 3. transport moves from active to inactive grid
522 4. the grid that transport is currently in unloads
523 */
524 if (_staticPassengers.empty() && newActive) // 1.
526 else if (!_staticPassengers.empty() && !newActive && oldCell.DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
528 else
530 // 4. is handed by grid unload
531}
532
534{
536 if (!mapId)
537 return;
538
539 CellObjectGuidsMap const* cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetSpawnMode());
540 if (!cells)
541 return;
542
543 for (auto const& [cellId, guids] : *cells)
544 {
545 // GameObjects on transport
546 for (ObjectGuid::LowType spawnId : guids.gameobjects)
547 CreateGOPassenger(spawnId, sObjectMgr->GetGameObjectData(spawnId));
548
549 // Creatures on transport
550 for (ObjectGuid::LowType spawnId : guids.creatures)
551 CreateNPCPassenger(spawnId, sObjectMgr->GetCreatureData(spawnId));
552 }
553}
554
556{
557 while (!_staticPassengers.empty())
558 {
559 WorldObject* obj = *_staticPassengers.begin();
560 obj->AddObjectToRemoveList(); // also removes from _staticPassengers
561 }
562}
563
565{
566 if (!GetGOInfo()->moTransport.canBeStopped)
567 return;
568
569 _pendingStop = !enabled;
570}
571
573{
574 // Clear events flagging
577
578 // Set frames
580 if (_nextFrame == GetKeyFrames().end())
581 _nextFrame = GetKeyFrames().begin();
582}
583
585{
586 KeyFrame const& frame = *_currentFrame;
587 const float speed = float(m_goInfo->moTransport.moveSpeed);
588 const float accel = float(m_goInfo->moTransport.accelRate);
589 float timeSinceStop = frame.TimeFrom + (now - (1.0f / float(IN_MILLISECONDS)) * frame.DepartureTime);
590 float timeUntilStop = frame.TimeTo - (now - (1.0f / float(IN_MILLISECONDS)) * frame.DepartureTime);
591 float segmentPos, dist;
592 float accelTime = _transportInfo->accelTime;
593 float accelDist = _transportInfo->accelDist;
594 // calculate from nearest stop, less confusing calculation...
595 if (timeSinceStop < timeUntilStop)
596 {
597 if (timeSinceStop < accelTime)
598 dist = 0.5f * accel * timeSinceStop * timeSinceStop;
599 else
600 dist = accelDist + (timeSinceStop - accelTime) * speed;
601 segmentPos = dist - frame.DistSinceStop;
602 }
603 else
604 {
605 if (timeUntilStop < _transportInfo->accelTime)
606 dist = 0.5f * accel * timeUntilStop * timeUntilStop;
607 else
608 dist = accelDist + (timeUntilStop - accelTime) * speed;
609 segmentPos = frame.DistUntilStop - dist;
610 }
611
612 return segmentPos / frame.NextDistFromPrev;
613}
614
615bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
616{
617 Map const* oldMap = GetMap();
618
619 if (oldMap->GetId() != newMapid)
620 {
621 _delayedTeleport = true;
623 return true;
624 }
625 else
626 {
627 // Teleport players, they need to know it
628 for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
629 {
630 if ((*itr)->GetTypeId() == TYPEID_PLAYER)
631 {
632 // will be relocated in UpdatePosition of the vehicle
633 if (Unit* veh = (*itr)->ToUnit()->GetVehicleBase())
634 if (veh->GetTransport() == this)
635 continue;
636
637 float destX, destY, destZ, destO;
638 (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
639 TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
640
641 (*itr)->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO,
643 }
644 }
645
646 UpdatePosition(x, y, z, o);
647 return false;
648 }
649}
650
652{
653 if (!_delayedTeleport)
654 return;
655
656 _delayedTeleport = false;
657 Map* newMap = sMapMgr->CreateBaseMap(_nextFrame->Node->ContinentID);
658 GetMap()->RemoveFromMap<Transport>(this, false);
659 SetMap(newMap);
660
661 float x = _nextFrame->Node->Loc.X,
662 y = _nextFrame->Node->Loc.Y,
663 z = _nextFrame->Node->Loc.Z,
664 o =_nextFrame->InitialOrientation;
665
667 {
669
670 float destX, destY, destZ, destO;
671 obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
672 TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
673
674 switch (obj->GetTypeId())
675 {
676 case TYPEID_PLAYER:
677 if (!obj->ToPlayer()->TeleportTo(_nextFrame->Node->ContinentID, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
678 RemovePassenger(obj);
679 break;
682 break;
683 default:
684 RemovePassenger(obj);
685 break;
686 }
687 }
688
689 Relocate(x, y, z, o);
690 GetMap()->AddToMap<Transport>(this);
691}
692
694{
695 for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
696 {
697 WorldObject* passenger = *itr;
698 // transport teleported but passenger not yet (can happen for players)
699 if (passenger->GetMap() != GetMap())
700 continue;
701
702 // if passenger is on vehicle we have to assume the vehicle is also on transport
703 // and its the vehicle that will be updating its passengers
704 if (Unit* unit = passenger->ToUnit())
705 if (unit->GetVehicle())
706 continue;
707
708 // Do not use Unit::UpdatePosition here, we don't want to remove auras
709 // as if regular movement occurred
710 float x, y, z, o;
711 passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o);
712 CalculatePassengerPosition(x, y, z, &o);
713 switch (passenger->GetTypeId())
714 {
715 case TYPEID_UNIT:
716 {
717 Creature* creature = passenger->ToCreature();
718 GetMap()->CreatureRelocation(creature, x, y, z, o, false);
719 creature->GetTransportHomePosition(x, y, z, o);
720 CalculatePassengerPosition(x, y, z, &o);
721 creature->SetHomePosition(x, y, z, o);
722 break;
723 }
724 case TYPEID_PLAYER:
725 //relocate only passengers in world and skip any player that might be still logging in/teleporting
726 if (passenger->IsInWorld() && !passenger->ToPlayer()->IsBeingTeleported())
727 {
728 GetMap()->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
729 passenger->ToPlayer()->SetFallInformation(0, passenger->GetPositionZ());
730 }
731 break;
733 GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o, false);
734 passenger->ToGameObject()->RelocateStationaryPosition(x, y, z, o);
735 break;
737 GetMap()->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
738 break;
739 default:
740 break;
741 }
742
743 if (Unit* unit = passenger->ToUnit())
744 if (Vehicle* vehicle = unit->GetVehicleKit())
745 vehicle->RelocatePassengers();
746 }
747}
748
749void Transport::DoEventIfAny(KeyFrame const& node, bool departure)
750{
751 if (uint32 eventid = departure ? node.Node->DepartureEventID : node.Node->ArrivalEventID)
752 {
753 TC_LOG_DEBUG("maps.script", "Taxi {} event {} of node {} of {} path", departure ? "departure" : "arrival", eventid, node.Node->NodeIndex, GetName());
754 GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
755 EventInform(eventid);
756 }
757}
758
760{
761 Map::PlayerList const& players = GetMap()->GetPlayers();
762 if (players.isEmpty())
763 return;
764
765 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
766 BuildFieldsUpdate(itr->GetSource(), data_map);
767
768 ClearUpdateMask(true);
769}
770
771std::string Transport::GetDebugInfo() const
772{
773 std::stringstream sstr;
774 sstr << GameObject::GetDebugInfo();
775 return sstr.str();
776}
@ IN_MILLISECONDS
Definition Common.h:35
#define M_PI
Definition Common.h:72
uint32_t uint32
Definition Define.h:133
#define ASSERT
Definition Errors.h:68
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition Log.h:165
#define sMapMgr
Definition MapManager.h:211
@ PHASEMASK_NORMAL
TempSummonType
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:41
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:40
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:60
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
Definition ObjectMgr.h:521
#define sObjectMgr
Definition ObjectMgr.h:1721
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition Object.h:63
@ TELE_TO_TRANSPORT_TELEPORT
Definition Player.h:684
@ TELE_TO_NOT_LEAVE_COMBAT
Definition Player.h:681
@ TELE_TO_NOT_UNSUMMON_PET
Definition Player.h:682
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:680
#define sScriptMgr
Definition ScriptMgr.h:1168
@ GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT
@ SUMMON_TYPE_VEHICLE2
@ SUMMON_TYPE_LIGHTWELL
@ SUMMON_TYPE_MINION
@ SUMMON_TYPE_GUARDIAN
@ SUMMON_TYPE_TOTEM
@ SUMMON_TYPE_VEHICLE
@ SUMMON_TYPE_MINIPET
@ SUMMON_TYPE_GUARDIAN2
GameObjectFlags
@ GO_STATE_READY
@ GO_STATE_ACTIVE
@ SUMMON_CATEGORY_PET
@ SUMMON_CATEGORY_VEHICLE
@ SUMMON_CATEGORY_ALLY
@ SUMMON_CATEGORY_PUPPET
@ SUMMON_CATEGORY_WILD
@ SUMMON_CATEGORY_UNK
#define sTransportMgr
@ MOVEMENTFLAG_ONTRANSPORT
@ UNIT_MASK_PUPPET
Definition Unit.h:370
@ UNIT_MASK_TOTEM
Definition Unit.h:367
@ UNIT_MASK_SUMMON
Definition Unit.h:364
@ UNIT_MASK_GUARDIAN
Definition Unit.h:366
@ UNIT_MASK_MINION
Definition Unit.h:365
@ UNIT_STATE_IGNORE_PATHFINDING
Definition Unit.h:248
@ UPDATEFLAG_ROTATION
Definition UpdateData.h:50
@ UPDATEFLAG_LOWGUID
Definition UpdateData.h:45
@ UPDATEFLAG_TRANSPORT
Definition UpdateData.h:42
@ UPDATEFLAG_STATIONARY_POSITION
Definition UpdateData.h:47
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:293
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:300
void SetTransportHomePosition(float x, float y, float z, float o)
Definition Creature.h:298
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, Position const &pos, CreatureData const *data=nullptr, uint32 vehId=0, bool dynamic=false)
virtual void UpdateAI(uint32)
void SetGoState(GOState state)
GameObjectValue m_goValue
Definition GameObject.h:346
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:102
void CreateModel()
GOState GetGoState() const
Definition GameObject.h:178
std::string GetDebugInfo() const override
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool=true)
void ReplaceAllFlags(GameObjectFlags flags)
Definition GameObject.h:173
void SetGoAnimProgress(uint8 animprogress)
Definition GameObject.h:184
GameObjectAI * AI() const
Definition GameObject.h:275
void SetGoType(GameobjectTypes type)
Definition GameObject.h:177
void SetLocalRotation(float qx, float qy, float qz, float qw)
GameObjectTemplateAddon const * m_goTemplateAddon
Definition GameObject.h:344
bool AIM_Initialize()
GameObjectModel * m_model
Definition GameObject.h:288
void UpdateModelPosition()
void RelocateStationaryPosition(float x, float y, float z, float o)
Definition GameObject.h:298
void SetDisplayId(uint32 displayid)
GameObjectTemplate const * m_goInfo
Definition GameObject.h:343
void CleanupsBeforeDelete(bool finalCleanup=true) override
GameObjectOverride const * GetGameObjectOverride() const
void SetParentRotation(QuaternionData const &rotation)
void EventInform(uint32 eventId, WorldObject *invoker=nullptr)
void SetFaction(uint32 faction) override
Definition GameObject.h:286
bool isEmpty() const
Definition LinkedList.h:108
iterator end()
iterator begin()
Definition Map.h:281
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float orientation)
Definition Map.cpp:1174
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
Definition Map.cpp:1140
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
Definition Map.cpp:1108
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
bool AddToMap(T *)
Definition Map.cpp:630
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:587
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:555
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:554
void InsertGameObjectModel(GameObjectModel const &model)
Definition Map.h:536
uint32 GetId() const
Definition Map.cpp:4216
bool IsGridLoaded(uint32 gridId) const
Definition Map.h:330
void RemoveFromMap(T *, bool)
Definition Map.cpp:1027
PlayerList const & GetPlayers() const
Definition Map.h:448
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
Definition Map.cpp:1081
std::string ToString() const
uint32 LowType
Definition ObjectGuid.h:142
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
Definition Object.cpp:492
static Creature * ToCreature(Object *o)
Definition Object.h:186
static Unit * ToUnit(Object *o)
Definition Object.h:192
static GameObject * ToGameObject(Object *o)
Definition Object.h:198
bool IsInWorld() const
Definition Object.h:73
TypeID GetTypeId() const
Definition Object.h:93
void ClearUpdateMask(bool remove)
Definition Object.cpp:479
uint32 GetEntry() const
Definition Object.h:81
void _Create(ObjectGuid const &guid)
Definition Object.cpp:109
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void SetEntry(uint32 entry)
Definition Object.h:82
virtual void SetObjectScale(float scale)
Definition Object.h:85
uint16 m_updateFlag
Definition Object.h:235
ObjectGuid GetGUID() const
Definition Object.h:79
static DynamicObject * ToDynObject(Object *o)
Definition Object.h:210
static Player * ToPlayer(Object *o)
Definition Object.h:180
void SetFallInformation(uint32 time, float z)
Definition Player.cpp:24853
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
Definition Player.cpp:1524
bool IsBeingTeleported() const
Definition Player.h:1820
virtual void InitSummon()
void SetTempSummonType(TempSummonType type)
virtual void InitStats(uint32 lifetime)
Definition Totem.h:39
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
void UpdatePosition(float x, float y, float z, float o)
void SetPeriod(uint32 period)
Definition Transport.h:83
void UpdatePassengerPositions(PassengerSet &passengers)
void LoadStaticPassengers()
Needed when transport moves from inactive to active grid.
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition Transport.h:125
uint32 GetTransportPeriod() const override
Definition Transport.h:82
KeyFrameVec::const_iterator _currentFrame
Definition Transport.h:118
void Update(uint32 diff) override
void BuildUpdate(UpdateDataMapType &data_map) override
void DoEventIfAny(KeyFrame const &node, bool departure)
void EnableMovement(bool enabled)
TempSummon * SummonPassenger(uint32 entry, Position const &pos, TempSummonType summonType, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, Unit *summoner=nullptr, uint32 spellId=0, uint32 vehId=0)
Temporarily summons a creature as passenger on this transport.
float CalculateSegmentPos(float perc)
void RemovePassenger(WorldObject *passenger)
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
std::string GetDebugInfo() const override
PassengerSet _staticPassengers
Definition Transport.h:130
bool _delayedAddModel
Definition Transport.h:132
KeyFrameVec const & GetKeyFrames() const
Definition Transport.h:86
bool _pendingStop
Definition Transport.h:122
void DelayedTeleportTransport()
TimeTracker _positionChangeTimer
Definition Transport.h:120
bool _triggeredDepartureEvent
Definition Transport.h:126
Creature * CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const *data)
PassengerSet::iterator _passengerTeleportItr
Definition Transport.h:129
GameObject * CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const *data)
std::set< WorldObject * > PassengerSet
Definition Transport.h:33
bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
Definition Transport.cpp:49
KeyFrameVec::const_iterator _nextFrame
Definition Transport.h:119
TransportTemplate const * _transportInfo
Definition Transport.h:116
bool _delayedTeleport
Definition Transport.h:133
void MoveToNextWaypoint()
void AddPassenger(WorldObject *passenger)
void DelayedUpdate(uint32 diff)
bool IsMoving() const
Helpers to know if stop frame was reached.
Definition Transport.h:113
PassengerSet _passengers
Definition Transport.h:128
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
Definition Transport.h:71
bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
void CleanupsBeforeDelete(bool finalCleanup=true) override
void SetMoving(bool val)
Definition Transport.h:114
Definition Unit.h:769
Unit * GetVehicleBase() const
Definition Unit.cpp:11826
void SetCreatedBySpell(int32 spellId)
Definition Unit.h:964
void AddUnitState(uint32 f)
Definition Unit.h:875
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:1676
uint32 GetPhaseMask() const
Definition Object.h:368
Map * GetMap() const
Definition Object.h:449
Map * FindMap() const
Definition Object.h:450
void SetTransport(Transport *t)
Definition Object.h:573
std::string const & GetName() const
Definition Object.h:382
virtual void SetMap(Map *map)
Definition Object.cpp:1808
void AddObjectToRemoveList()
Definition Object.cpp:1838
void SetName(std::string newname)
Definition Object.h:383
MovementInfo m_movementInfo
Definition Object.h:575
Definition Cell.h:47
bool DiffGrid(Cell const &cell) const
Definition Cell.h:64
struct GameObjectTemplate::@191::@206 moTransport
float DistUntilStop
float NextDistFromPrev
float DistSinceStop
uint32 DepartureTime
TaxiPathNodeEntry const * Node
float TimeFrom
float TimeTo
void RemoveMovementFlag(uint32 flag)
struct MovementInfo::TransportInfo transport
void AddMovementFlag(uint32 flag)
float GetPositionZ() const
Definition Position.h:81
float GetOrientation() const
Definition Position.h:82
bool IsPositionValid() const
Definition Position.cpp:44
float GetPositionX() const
Definition Position.h:79
void GetPosition(float &x, float &y) const
Definition Position.h:84
float GetPositionY() const
Definition Position.h:80
void Relocate(float x, float y)
Definition Position.h:66
Position spawnPoint
Definition SpawnData.h:97
void Update(int32 diff)
Definition Timer.h:121
bool Passed() const
Definition Timer.h:131
void Reset(int32 expiry)
Definition Timer.h:136
KeyFrameVec keyFrames
struct GameObjectValue::@187 Transport
uint32 PathProgress
Definition GameObject.h:48