TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
InstanceScript.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 "InstanceScript.h"
19#include "AreaBoundary.h"
20#include "Creature.h"
21#include "CreatureAI.h"
22#include "CreatureAIImpl.h"
23#include "DatabaseEnv.h"
24#include "DBCStructure.h"
25#include "GameObject.h"
26#include "Group.h"
27#include "LFGMgr.h"
28#include "Log.h"
29#include "Map.h"
30#include "ObjectMgr.h"
31#include "Opcodes.h"
32#include "Pet.h"
33#include "Player.h"
34#include "RBAC.h"
35#include "ScriptMgr.h"
36#include "ScriptReloadMgr.h"
37#include "World.h"
38#include "WorldSession.h"
39#include <cstdarg>
40#include <sstream>
41
43{
44 for (const_iterator it = begin(); it != end(); ++it)
45 delete it->Boundary;
46}
47
48InstanceScript::InstanceScript(InstanceMap* map) : instance(map), completedEncounters(0), _instanceSpawnGroups(sObjectMgr->GetSpawnGroupsForInstance(map->GetId()))
49{
50#ifdef TRINITY_API_USE_DYNAMIC_LINKING
51 uint32 scriptId = sObjectMgr->GetInstanceTemplate(map->GetId())->ScriptId;
52 auto const scriptname = sObjectMgr->GetScriptName(scriptId);
53 ASSERT(!scriptname.empty());
54 // Acquire a strong reference from the script module
55 // to keep it loaded until this object is destroyed.
56 module_reference = sScriptMgr->AcquireModuleReferenceOfScriptName(scriptname);
57#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
58}
59
61{
62 std::string data = GetSaveData();
63 if (data.empty())
64 return;
65
68 stmt->setString(1, data);
69 stmt->setUInt32(2, instance->GetInstanceId());
70 CharacterDatabase.Execute(stmt);
71}
72
74{
75 for (std::vector<BossInfo>::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr)
76 if (itr->state == IN_PROGRESS)
77 return true;
78
79 return false;
80}
81
83{
84 AddObject(creature, true);
85 AddMinion(creature, true);
86}
87
89{
90 AddObject(creature, false);
91 AddMinion(creature, false);
92}
93
95{
96 AddObject(go, true);
97 AddDoor(go, true);
98}
99
101{
102 AddObject(go, false);
103 AddDoor(go, false);
104}
105
107{
108 ObjectGuidMap::const_iterator i = _objectGuids.find(type);
109 if (i != _objectGuids.end())
110 return i->second;
111 return ObjectGuid::Empty;
112}
113
115{
116 return GetObjectGuid(type);
117}
118
120{
121 return instance->GetCreature(GetObjectGuid(type));
122}
123
125{
126 return instance->GetGameObject(GetObjectGuid(type));
127}
128
129void InstanceScript::SetHeaders(std::string const& dataHeaders)
130{
131 for (char header : dataHeaders)
132 if (isalpha(header))
133 headers.push_back(header);
134}
135
137{
138 for (BossBoundaryEntry const& entry : data)
139 if (entry.BossId < bosses.size())
140 bosses[entry.BossId].boundary.push_back(entry.Boundary);
141}
142
144{
145 while (data->entry)
146 {
147 if (data->bossId < bosses.size())
148 minions.insert(std::make_pair(data->entry, MinionInfo(&bosses[data->bossId])));
149
150 ++data;
151 }
152 TC_LOG_DEBUG("scripts", "InstanceScript::LoadMinionData: {} minions loaded.", uint64(minions.size()));
153}
154
156{
157 while (data->entry)
158 {
159 if (data->bossId < bosses.size())
160 doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type)));
161
162 ++data;
163 }
164 TC_LOG_DEBUG("scripts", "InstanceScript::LoadDoorData: {} doors loaded.", uint64(doors.size()));
165}
166
168{
169 if (creatureData)
171
172 if (gameObjectData)
174
175 TC_LOG_DEBUG("scripts", "InstanceScript::LoadObjectData: {} objects loaded.", _creatureInfo.size() + _gameObjectInfo.size());
176}
177
179{
180 while (data->entry)
181 {
182 ASSERT(objectInfo.find(data->entry) == objectInfo.end());
183 objectInfo[data->entry] = data->type;
184 ++data;
185 }
186}
187
189{
190 DoorInfoMapBounds range = doors.equal_range(door->GetEntry());
191 if (range.first == range.second)
192 return;
193
194 bool open = true;
195 for (; range.first != range.second && open; ++range.first)
196 {
197 DoorInfo const& info = range.first->second;
198 switch (info.type)
199 {
200 case DOOR_TYPE_ROOM:
201 open = (info.bossInfo->state != IN_PROGRESS);
202 break;
204 open = (info.bossInfo->state == DONE);
205 break;
207 open = (info.bossInfo->state == IN_PROGRESS);
208 break;
209 default:
210 break;
211 }
212 }
213
215}
216
218{
219 switch (state)
220 {
221 case NOT_STARTED:
222 if (!minion->IsAlive())
223 minion->Respawn();
224 else if (minion->IsInCombat())
225 minion->AI()->EnterEvadeMode();
226 break;
227 case IN_PROGRESS:
228 if (!minion->IsAlive())
229 minion->Respawn();
230 else if (!minion->GetVictim())
231 minion->AI()->DoZoneInCombat();
232 break;
233 default:
234 break;
235 }
236}
237
239{
241 return;
242 enum states { BLOCK, SPAWN, FORCEBLOCK };
243 std::unordered_map<uint32, states> newStates;
244 for (auto it = _instanceSpawnGroups->begin(), end = _instanceSpawnGroups->end(); it != end; ++it)
245 {
246 InstanceSpawnGroupInfo const& info = *it;
247 states& curValue = newStates[info.SpawnGroupId]; // makes sure there's a BLOCK value in the map
248 if (curValue == FORCEBLOCK) // nothing will change this
249 continue;
250 if (!((1 << GetBossState(info.BossStateId)) & info.BossStates))
251 continue;
254 continue;
256 curValue = FORCEBLOCK;
258 curValue = SPAWN;
259 }
260 for (auto const& pair : newStates)
261 {
262 uint32 const groupId = pair.first;
263 bool const doSpawn = (pair.second == SPAWN);
264 if (instance->IsSpawnGroupActive(groupId) == doSpawn)
265 continue; // nothing to do here
266 // if we should spawn group, then spawn it...
267 if (doSpawn)
268 instance->SpawnGroupSpawn(groupId);
269 else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
271 }
272}
273
275{
276 ASSERT(id < bosses.size());
277 return &bosses[id];
278}
279
281{
282 ObjectInfoMap::const_iterator j = _creatureInfo.find(obj->GetEntry());
283 if (j != _creatureInfo.end())
284 AddObject(obj, j->second, add);
285}
286
288{
289 ObjectInfoMap::const_iterator j = _gameObjectInfo.find(obj->GetEntry());
290 if (j != _gameObjectInfo.end())
291 AddObject(obj, j->second, add);
292}
293
295{
296 if (add)
297 _objectGuids[type] = obj->GetGUID();
298 else
299 {
300 ObjectGuidMap::iterator i = _objectGuids.find(type);
301 if (i != _objectGuids.end() && i->second == obj->GetGUID())
302 _objectGuids.erase(i);
303 }
304}
305
307{
308 DoorInfoMapBounds range = doors.equal_range(door->GetEntry());
309 if (range.first == range.second)
310 return;
311
312 for (; range.first != range.second; ++range.first)
313 {
314 DoorInfo const& data = range.first->second;
315
316 if (add)
317 {
318 data.bossInfo->door[data.type].insert(door->GetGUID());
319 }
320 else
321 data.bossInfo->door[data.type].erase(door->GetGUID());
322 }
323
324 if (add)
325 UpdateDoorState(door);
326}
327
328void InstanceScript::AddMinion(Creature* minion, bool add)
329{
330 MinionInfoMap::iterator itr = minions.find(minion->GetEntry());
331 if (itr == minions.end())
332 return;
333
334 if (add)
335 itr->second.bossInfo->minion.insert(minion->GetGUID());
336 else
337 itr->second.bossInfo->minion.erase(minion->GetGUID());
338}
339
341{
342 if (id < bosses.size())
343 {
344 BossInfo* bossInfo = &bosses[id];
345 if (bossInfo->state == TO_BE_DECIDED) // loading
346 {
347 bossInfo->state = state;
348 TC_LOG_DEBUG("scripts", "InstanceScript: Initialize boss {} state as {} (map {}, {}).", id, GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
349 return false;
350 }
351 else
352 {
353 if (bossInfo->state == state)
354 return false;
355
356 if (bossInfo->state == DONE)
357 {
358 TC_LOG_ERROR("map", "InstanceScript: Tried to set instance boss {} state from {} back to {} for map {}, instance id {}. Blocked!", id, GetBossStateName(bossInfo->state), GetBossStateName(state), instance->GetId(), instance->GetInstanceId());
359 return false;
360 }
361
362 if (state == DONE)
363 for (GuidSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
364 if (Creature* minion = instance->GetCreature(*i))
365 if (minion->isWorldBoss() && minion->IsAlive())
366 return false;
367
368 bossInfo->state = state;
369 SaveToDB();
370 }
371
372 for (uint32 type = 0; type < MAX_DOOR_TYPES; ++type)
373 for (GuidSet::iterator i = bossInfo->door[type].begin(); i != bossInfo->door[type].end(); ++i)
374 if (GameObject* door = instance->GetGameObject(*i))
375 UpdateDoorState(door);
376
377 GuidSet minions = bossInfo->minion; // Copy to prevent iterator invalidation (minion might be unsummoned in UpdateMinionState)
378 for (GuidSet::iterator i = minions.begin(); i != minions.end(); ++i)
379 if (Creature* minion = instance->GetCreature(*i))
380 UpdateMinionState(minion, state);
381
383 return true;
384 }
385 return false;
386}
387
388bool InstanceScript::_SkipCheckRequiredBosses(Player const* player /*= nullptr*/) const
389{
391}
392
394{
395 for (size_t i = 0; i < bosses.size(); ++i)
398}
399
400void InstanceScript::Load(char const* data)
401{
402 if (!data)
403 {
405 return;
406 }
407
408 OUT_LOAD_INST_DATA(data);
409
410 std::istringstream loadStream(data);
411
412 if (ReadSaveDataHeaders(loadStream))
413 {
414 ReadSaveDataBossStates(loadStream);
415 ReadSaveDataMore(loadStream);
416 }
417 else
419
421}
422
423bool InstanceScript::ReadSaveDataHeaders(std::istringstream& data)
424{
425 for (char header : headers)
426 {
427 char buff;
428 data >> buff;
429
430 if (header != buff)
431 return false;
432 }
433
434 return true;
435}
436
437void InstanceScript::ReadSaveDataBossStates(std::istringstream& data)
438{
439 uint32 bossId = 0;
440 for (std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i, ++bossId)
441 {
442 uint32 buff;
443 data >> buff;
444 if (buff == IN_PROGRESS || buff == FAIL || buff == SPECIAL)
445 buff = NOT_STARTED;
446
447 if (buff < TO_BE_DECIDED)
448 SetBossState(bossId, EncounterState(buff));
449 }
451}
452
454{
456
457 std::ostringstream saveStream;
458
459 WriteSaveDataHeaders(saveStream);
460 WriteSaveDataBossStates(saveStream);
461 WriteSaveDataMore(saveStream);
462
464
465 return saveStream.str();
466}
467
468void InstanceScript::WriteSaveDataHeaders(std::ostringstream& data)
469{
470 for (char header : headers)
471 data << header << ' ';
472}
473
474void InstanceScript::WriteSaveDataBossStates(std::ostringstream& data)
475{
476 for (BossInfo const& bossInfo : bosses)
477 data << uint32(bossInfo.state) << ' ';
478}
479
480void InstanceScript::HandleGameObject(ObjectGuid guid, bool open, GameObject* go /*= nullptr*/)
481{
482 if (!go)
483 go = instance->GetGameObject(guid);
484 if (go)
486 else
487 TC_LOG_DEBUG("scripts", "InstanceScript: HandleGameObject failed");
488}
489
490void InstanceScript::DoUseDoorOrButton(ObjectGuid guid, uint32 withRestoreTime /*= 0*/, bool useAlternativeState /*= false*/)
491{
492 if (!guid)
493 return;
494
495 if (GameObject* go = instance->GetGameObject(guid))
496 {
497 if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR || go->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
498 {
499 if (go->getLootState() == GO_READY)
500 go->UseDoorOrButton(withRestoreTime, useAlternativeState);
501 else if (go->getLootState() == GO_ACTIVATED)
502 go->ResetDoorOrButton();
503 }
504 else
505 TC_LOG_ERROR("scripts", "InstanceScript: DoUseDoorOrButton can't use gameobject entry {}, because type is {}.", go->GetEntry(), go->GetGoType());
506 }
507 else
508 TC_LOG_DEBUG("scripts", "InstanceScript: DoUseDoorOrButton failed");
509}
510
512{
513 if (!guid)
514 return;
515
516 if (GameObject* go = instance->GetGameObject(guid))
517 {
518 if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR || go->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
519 {
520 if (go->getLootState() == GO_ACTIVATED)
521 go->ResetDoorOrButton();
522 }
523 else
524 TC_LOG_ERROR("scripts", "InstanceScript: DoCloseDoorOrButton can't use gameobject entry {}, because type is {}.", go->GetEntry(), go->GetGoType());
525 }
526 else
527 TC_LOG_DEBUG("scripts", "InstanceScript: DoCloseDoorOrButton failed");
528}
529
530void InstanceScript::DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn /*= 1min */)
531{
532 if (GameObject* go = instance->GetGameObject(guid))
533 {
534 switch (go->GetGoType())
535 {
540 // not expect any of these should ever be handled
541 TC_LOG_ERROR("scripts", "InstanceScript: DoRespawnGameObject can't respawn gameobject entry {}, because type is {}.", go->GetEntry(), go->GetGoType());
542 return;
543 default:
544 break;
545 }
546
547 if (go->isSpawned())
548 return;
549
550 go->SetRespawnTime(timeToDespawn.count());
551 }
552 else
553 TC_LOG_DEBUG("scripts", "InstanceScript: DoRespawnGameObject failed");
554}
555
557{
558 Map::PlayerList const& lPlayers = instance->GetPlayers();
559
560 if (!lPlayers.isEmpty())
561 {
562 for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
563 if (Player* player = itr->GetSource())
564 player->SendUpdateWorldState(uiStateId, uiStateData);
565 }
566 else
567 TC_LOG_DEBUG("scripts", "DoUpdateWorldState attempt send data but no players in map.");
568}
569
570// Send Notify to all players in instance
571void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
572{
573 InstanceMap::PlayerList const& players = instance->GetPlayers();
574
575 if (!players.isEmpty())
576 {
577 va_list ap;
578 va_start(ap, format);
579 char buff[1024];
580 vsnprintf(buff, 1024, format, ap);
581 va_end(ap);
582 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
583 if (Player* player = i->GetSource())
584 if (WorldSession* session = player->GetSession())
585 session->SendNotification("%s", buff);
586 }
587}
588
589// Update Achievement Criteria for all players in instance
590void InstanceScript::DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= nullptr*/)
591{
592 Map::PlayerList const& PlayerList = instance->GetPlayers();
593
594 if (!PlayerList.isEmpty())
595 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
596 if (Player* player = i->GetSource())
597 player->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit);
598}
599
600// Start timed achievement for all players in instance
602{
603 Map::PlayerList const& PlayerList = instance->GetPlayers();
604
605 if (!PlayerList.isEmpty())
606 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
607 if (Player* player = i->GetSource())
608 player->StartTimedAchievement(type, entry);
609}
610
611// Stop timed achievement for all players in instance
613{
614 Map::PlayerList const& PlayerList = instance->GetPlayers();
615
616 if (!PlayerList.isEmpty())
617 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
618 if (Player* player = i->GetSource())
619 player->RemoveTimedAchievement(type, entry);
620}
621
622void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
623{
624 Map::PlayerList const& playerList = instance->GetPlayers();
625 for (auto itr = playerList.begin(); itr != playerList.end(); ++itr)
626 DoRemoveAurasDueToSpellOnPlayer(itr->GetSource(), spell, includePets, includeControlled);
627}
628
629void InstanceScript::DoRemoveAurasDueToSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
630{
631 if (!player)
632 return;
633
634 player->RemoveAurasDueToSpell(spell);
635
636 if (!includePets)
637 return;
638
639 for (uint8 itr2 = 0; itr2 < MAX_SUMMON_SLOT; ++itr2)
640 {
641 if (ObjectGuid summonGUID = player->m_SummonSlot[itr2])
642 if (Creature* summon = instance->GetCreature(summonGUID))
643 summon->RemoveAurasDueToSpell(spell);
644 }
645
646 if (!includeControlled)
647 return;
648
649 for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
650 {
651 if (Unit* controlled = *itr2)
652 if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT)
653 controlled->RemoveAurasDueToSpell(spell);
654 }
655}
656
657void InstanceScript::DoCastSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
658{
659 Map::PlayerList const& playerList = instance->GetPlayers();
660 for (auto itr = playerList.begin(); itr != playerList.end(); ++itr)
661 DoCastSpellOnPlayer(itr->GetSource(), spell, includePets, includeControlled);
662}
663
664void InstanceScript::DoCastSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
665{
666 if (!player)
667 return;
668
669 player->CastSpell(player, spell, true);
670
671 if (!includePets)
672 return;
673
674 for (uint8 itr2 = 0; itr2 < MAX_SUMMON_SLOT; ++itr2)
675 {
676 if (ObjectGuid summonGUID = player->m_SummonSlot[itr2])
677 if (Creature* summon = instance->GetCreature(summonGUID))
678 summon->CastSpell(player, spell, true);
679 }
680
681 if (!includeControlled)
682 return;
683
684 for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
685 {
686 if (Unit* controlled = *itr2)
687 if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT)
688 controlled->CastSpell(player, spell, true);
689 }
690}
691
693{
694 return sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP);
695}
696
697bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= nullptr*/, uint32 /*miscvalue1*/ /*= 0*/)
698{
699 TC_LOG_ERROR("misc", "Achievement system call InstanceScript::CheckAchievementCriteriaMeet but instance script for map {} not have implementation for achievement criteria {}",
700 instance->GetId(), criteria_id);
701 return false;
702}
703
704void InstanceScript::SendEncounterUnit(EncounterFrameType type, Unit const* unit /*= nullptr*/, uint8 param1 /*= 0*/, uint8 param2 /*= 0*/)
705{
706 // size of this packet is at most 15 (usually less)
708 data << uint32(type);
709
710 switch (type)
711 {
715 if (!unit)
716 return;
717 data << unit->GetPackGUID();
718 data << uint8(param1);
719 break;
723 data << uint8(param1);
724 break;
726 data << uint8(param1);
727 data << uint8(param2);
728 break;
730 default:
731 break;
732 }
733
734 instance->SendToPlayers(&data);
735}
736
738{
739 DungeonEncounterList const* encounters = sObjectMgr->GetDungeonEncounterList(instance->GetId(), instance->GetDifficulty());
740 if (!encounters)
741 return;
742
743 uint32 dungeonId = 0;
744
745 for (auto const& encounter : *encounters)
746 {
747 if (encounter->creditType == type && encounter->creditEntry == creditEntry)
748 {
749 completedEncounters |= 1 << encounter->dbcEntry->Bit;
750 if (encounter->lastEncounterDungeon)
751 {
752 dungeonId = encounter->lastEncounterDungeon;
753 TC_LOG_DEBUG("lfg", "UpdateEncounterState: Instance {} (instanceId {}) completed encounter {}. Credit Dungeon: {}", instance->GetMapName(), instance->GetInstanceId(), encounter->dbcEntry->Name[0], dungeonId);
754 break;
755 }
756 }
757 }
758
759 if (dungeonId)
760 {
761 Map::PlayerList const& players = instance->GetPlayers();
762 for (auto const& ref : players)
763 {
764 if (Player* player = ref.GetSource())
765 {
766 if (Group* grp = player->GetGroup())
767 {
768 if (grp->isLFGGroup())
769 {
770 sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, instance);
771 return;
772 }
773 }
774 }
775 }
776 }
777}
778
780{
782}
783
785{
787}
788
789/*static*/ char const* InstanceScript::GetBossStateName(uint8 state)
790{
791 // See enum EncounterState in InstanceScript.h
792 switch (state)
793 {
794 case NOT_STARTED:
795 return "NOT_STARTED";
796 case IN_PROGRESS:
797 return "IN_PROGRESS";
798 case FAIL:
799 return "FAIL";
800 case DONE:
801 return "DONE";
802 case SPECIAL:
803 return "SPECIAL";
804 case TO_BE_DECIDED:
805 return "TO_BE_DECIDED";
806 default:
807 return "INVALID";
808 }
809}
810
811bool InstanceHasScript(WorldObject const* obj, char const* scriptName)
812{
813 if (InstanceMap* instance = obj->GetMap()->ToInstanceMap())
814 return instance->GetScriptName() == scriptName;
815
816 return false;
817}
@ CHAR_UPD_INSTANCE_DATA
AchievementCriteriaTimedTypes
Definition: DBCEnums.h:121
AchievementCriteriaTypes
Definition: DBCEnums.h:133
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint8_t uint8
Definition: Define.h:135
uint64_t uint64
Definition: Define.h:132
uint32_t uint32
Definition: Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:27
#define ASSERT
Definition: Errors.h:68
@ GO_ACTIVATED
Definition: GameObject.h:78
@ GO_READY
Definition: GameObject.h:77
bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
#define OUT_LOAD_INST_DATA_FAIL
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ SPECIAL
@ NOT_STARTED
@ TO_BE_DECIDED
EncounterFrameType
@ ENCOUNTER_FRAME_ENABLE_OBJECTIVE
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_UPDATE_PRIORITY
@ ENCOUNTER_FRAME_DISABLE_OBJECTIVE
@ ENCOUNTER_FRAME_UPDATE_OBJECTIVE
@ ENCOUNTER_FRAME_ADD_TIMER
@ ENCOUNTER_FRAME_PHASE_SHIFT_CHANGED
@ ENCOUNTER_FRAME_ENGAGE
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
std::map< uint32, uint32 > ObjectInfoMap
@ DOOR_TYPE_SPAWN_HOLE
@ DOOR_TYPE_ROOM
@ DOOR_TYPE_PASSAGE
@ MAX_DOOR_TYPES
std::pair< DoorInfoMap::const_iterator, DoorInfoMap::const_iterator > DoorInfoMapBounds
#define sLFGMgr
Definition: LFGMgr.h:483
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
@ TYPEID_UNIT
Definition: ObjectGuid.h:38
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:261
#define sObjectMgr
Definition: ObjectMgr.h:1723
EncounterCreditType
Definition: ObjectMgr.h:897
@ ENCOUNTER_CREDIT_KILL_CREATURE
Definition: ObjectMgr.h:898
@ ENCOUNTER_CREDIT_CAST_SPELL
Definition: ObjectMgr.h:899
std::vector< std::unique_ptr< DungeonEncounter const > > DungeonEncounterList
Definition: ObjectMgr.h:913
Role Based Access Control related classes definition.
#define sScriptMgr
Definition: ScriptMgr.h:1169
@ GAMEOBJECT_TYPE_BUTTON
@ GAMEOBJECT_TYPE_TRAP
@ GAMEOBJECT_TYPE_FISHINGNODE
@ GAMEOBJECT_TYPE_DOOR
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ MAX_SUMMON_SLOT
@ GO_STATE_READY
@ GO_STATE_ACTIVE
void DoZoneInCombat(Creature *creature=nullptr)
Definition: CreatureAI.cpp:73
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
Definition: CreatureAI.cpp:214
void Respawn(bool force=false)
Definition: Creature.cpp:2057
CreatureAI * AI() const
Definition: Creature.h:154
void SetGoState(GOState state)
Definition: Group.h:165
TeamId GetTeamIdInInstance() const
Definition: Map.h:900
virtual std::string GetSaveData()
void UpdateMinionState(Creature *minion, EncounterState state)
uint32 GetCompletedEncounterMask() const
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
void DoCloseDoorOrButton(ObjectGuid guid)
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
void DoCastSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
std::vector< char > headers
Creature * GetCreature(uint32 type)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
MinionInfoMap minions
void DoCastSpellOnPlayer(Player *player, uint32 spell, bool includePets=false, bool includeControlled=false)
virtual bool CheckAchievementCriteriaMeet(uint32, Player const *, Unit const *=nullptr, uint32=0)
InstanceScript(InstanceMap *map)
virtual void ReadSaveDataMore(std::istringstream &)
void DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
uint32 completedEncounters
virtual void Load(char const *data)
virtual void OnCreatureRemove(Creature *creature) override
static bool ServerAllowsTwoSideGroups()
virtual ObjectGuid GetGuidData(uint32 type) const override
void DoUseDoorOrButton(ObjectGuid guid, uint32 withRestoreTime=0, bool useAlternativeState=false)
void UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit *source)
virtual void OnGameObjectRemove(GameObject *go) override
BossInfo * GetBossInfo(uint32 id)
static char const * GetBossStateName(uint8 state)
void WriteSaveDataBossStates(std::ostringstream &data)
InstanceMap * instance
ObjectGuidMap _objectGuids
void UpdateEncounterStateForKilledCreature(uint32 creatureId, Unit *source)
DoorInfoMap doors
void AddMinion(Creature *minion, bool add)
ObjectInfoMap _gameObjectInfo
EncounterState GetBossState(uint32 id) const
void AddObject(Creature *obj, bool add)
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
virtual bool IsEncounterInProgress() const
ObjectInfoMap _creatureInfo
virtual void AddDoor(GameObject *door, bool add)
bool ReadSaveDataHeaders(std::istringstream &data)
void WriteSaveDataHeaders(std::ostringstream &data)
void LoadMinionData(MinionData const *data)
void LoadDoorData(DoorData const *data)
virtual void Create()
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
std::vector< BossInfo > bosses
void DoRemoveAurasDueToSpellOnPlayer(Player *player, uint32 spell, bool includePets=false, bool includeControlled=false)
void ReadSaveDataBossStates(std::istringstream &data)
GameObject * GetGameObject(uint32 type)
void LoadBossBoundaries(BossBoundaryData const &data)
virtual void UpdateDoorState(GameObject *door)
bool _SkipCheckRequiredBosses(Player const *player=nullptr) const
void DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
void SetHeaders(std::string const &dataHeaders)
std::vector< InstanceSpawnGroupInfo > const *const _instanceSpawnGroups
void SendEncounterUnit(EncounterFrameType type, Unit const *unit=nullptr, uint8 param1=0, uint8 param2=0)
ObjectGuid GetObjectGuid(uint32 type) const
virtual void WriteSaveDataMore(std::ostringstream &)
void UpdateEncounterStateForSpellCast(uint32 spellId, Unit *source)
void DoSendNotifyToInstance(char const *format,...)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
bool isEmpty() const
Definition: LinkedList.h:108
iterator end()
Definition: MapRefManager.h:35
iterator begin()
Definition: MapRefManager.h:34
void SetSpawnGroupInactive(uint32 groupId)
Definition: Map.h:779
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition: Map.cpp:3380
void SendToPlayers(WorldPacket const *data) const
Definition: Map.cpp:3666
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:4428
bool IsSpawnGroupActive(uint32 groupId) const
Definition: Map.cpp:3493
uint32 GetId() const
Definition: Map.cpp:4214
char const * GetMapName() const
Definition: Map.cpp:2924
InstanceMap * ToInstanceMap()
Definition: Map.h:520
Difficulty GetDifficulty() const
Definition: Map.h:412
uint32 GetInstanceId() const
Definition: Map.h:387
PlayerList const & GetPlayers() const
Definition: Map.h:448
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:4395
static ObjectGuid const Empty
Definition: ObjectGuid.h:132
PackedGuid const & GetPackGUID() const
Definition: Object.h:79
uint32 GetEntry() const
Definition: Object.h:80
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:77
Definition: Player.h:915
WorldSession * GetSession() const
Definition: Player.h:1712
void setUInt32(uint8 index, uint32 value)
void setString(uint8 index, std::string const &value)
Definition: Unit.h:769
bool IsAlive() const
Definition: Unit.h:1234
ControlList m_Controlled
Definition: Unit.h:1276
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3780
Unit * GetVictim() const
Definition: Unit.h:857
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT]
Definition: Unit.h:1487
bool IsInCombat() const
Definition: Unit.h:1142
Map * GetMap() const
Definition: Object.h:449
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2831
Player session in the World.
Definition: WorldSession.h:456
bool HasPermission(uint32 permissionId)
@ SMSG_UPDATE_INSTANCE_ENCOUNTER_UNIT
Definition: Opcodes.h:561
#define sWorld
Definition: World.h:893
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
Definition: World.h:98
ObjectData const gameObjectData[]
ObjectData const creatureData[]
@ RBAC_PERM_SKIP_CHECK_INSTANCE_REQUIRED_BOSSES
Definition: RBAC.h:66
const_iterator begin() const
const_iterator end() const
StorageType::const_iterator const_iterator
EncounterState state
GuidSet door[MAX_DOOR_TYPES]
GuidSet minion
uint32 entry
DoorType type
uint32 bossId
BossInfo * bossInfo
DoorType type