TrinityCore
cs_gobject.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
19Name: gobject_commandscript
20%Complete: 100
21Comment: All gobject related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "Chat.h"
27#include "ChatCommand.h"
28#include "DatabaseEnv.h"
29#include "DB2Stores.h"
30#include "GameEventMgr.h"
31#include "GameObject.h"
32#include "GameObjectAI.h"
33#include "GameTime.h"
34#include "Language.h"
35#include "Log.h"
36#include "Map.h"
37#include "MapManager.h"
38#include "ObjectAccessor.h"
39#include "ObjectMgr.h"
40#include "PhasingHandler.h"
41#include "Player.h"
42#include "PoolMgr.h"
43#include "RBAC.h"
44#include "WorldSession.h"
45#include <sstream>
46
47using namespace Trinity::ChatCommands;
48
51
52// definitions are over in cs_npc.cpp
53bool HandleNpcSpawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")>> const& opts);
54bool HandleNpcDespawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("removerespawntime")>> const& opts);
55
57{
58public:
59 gobject_commandscript() : CommandScript("gobject_commandscript") { }
60
62 {
63 static ChatCommandTable gobjectCommandTable =
64 {
78 };
79 static ChatCommandTable commandTable =
80 {
81 { "gobject", gobjectCommandTable },
82 };
83 return commandTable;
84 }
85
87 {
88 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
89 if (!object)
90 {
91 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*guidLow).c_str());
92 handler->SetSentErrorMessage(true);
93 return false;
94 }
95
96 uint32_t const autoCloseTime = object->GetGOInfo()->GetAutoCloseTime() ? 10000u : 0u;
97
98 // Activate
99 object->SetLootState(GO_READY);
100 object->UseDoorOrButton(autoCloseTime, false, handler->GetSession()->GetPlayer());
101
102 handler->PSendSysMessage("Object activated!");
103
104 return true;
105 }
106
107 //spawn go
108 static bool HandleGameObjectAddCommand(ChatHandler* handler, GameObjectEntry objectId, Optional<int32> spawnTimeSecs)
109 {
110 if (!objectId)
111 return false;
112
113 GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId);
114 if (!objectInfo)
115 {
116 handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
117 handler->SetSentErrorMessage(true);
118 return false;
119 }
120
121 if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
122 {
123 // report to DB errors log as in loading case
124 TC_LOG_ERROR("sql.sql", "Gameobject (Entry {} GoType: {}) have invalid displayId ({}), not spawned.", *objectId, objectInfo->type, objectInfo->displayId);
126 handler->SetSentErrorMessage(true);
127 return false;
128 }
129
130 Player* player = handler->GetSession()->GetPlayer();
131 Map* map = player->GetMap();
132
133 GameObject* object = GameObject::CreateGameObject(objectInfo->entry, map, *player, QuaternionData::fromEulerAnglesZYX(player->GetOrientation(), 0.0f, 0.0f), 255, GO_STATE_READY);
134 if (!object)
135 return false;
136
137 PhasingHandler::InheritPhaseShift(object, player);
138
139 if (spawnTimeSecs)
140 object->SetRespawnTime(*spawnTimeSecs);
141
142 // fill the gameobject data and save to the db
143 object->SaveToDB(map->GetId(), { map->GetDifficultyID() });
144 ObjectGuid::LowType spawnId = object->GetSpawnId();
145
146 // delete the old object and do a clean load from DB with a fresh new GameObject instance.
147 // this is required to avoid weird behavior and memory leaks
148 delete object;
149
150 // this will generate a new guid if the object is in an instance
151 object = GameObject::CreateGameObjectFromDB(spawnId, map);
152 if (!object)
153 return false;
154
156 sObjectMgr->AddGameobjectToGrid(ASSERT_NOTNULL(sObjectMgr->GetGameObjectData(spawnId)));
157
158 handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), std::to_string(spawnId).c_str(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
159 return true;
160 }
161
162 // add go, temp only
164 {
165 Player* player = handler->GetSession()->GetPlayer();
166 Seconds spawntm(spawntime.value_or(300));
167
168 if (!sObjectMgr->GetGameObjectTemplate(objectId))
169 {
170 handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, objectId);
171 handler->SetSentErrorMessage(true);
172 return false;
173 }
174
175 player->SummonGameObject(objectId, *player, QuaternionData::fromEulerAnglesZYX(player->GetOrientation(), 0.0f, 0.0f), spawntm);
176
177 return true;
178 }
179
181 {
182 Player* player = handler->GetSession()->GetPlayer();
183 QueryResult result;
184 GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
185
186 if (objectId)
187 {
188 if (objectId->holds_alternative<GameObjectEntry>())
189 {
190 result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE map = '{}' AND id = '{}' ORDER BY order_ ASC LIMIT 1",
191 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), static_cast<uint32>(objectId->get<GameObjectEntry>()));
192 }
193 else
194 {
195 std::string name = std::string(objectId->get<std::string_view>());
196 WorldDatabase.EscapeString(name);
197 result = WorldDatabase.PQuery(
198 "SELECT guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, (POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ "
199 "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {} AND name LIKE '%{}%' ORDER BY order_ ASC LIMIT 1",
200 player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name);
201 }
202 }
203 else
204 {
205 std::ostringstream eventFilter;
206 eventFilter << " AND (eventEntry IS NULL ";
207 bool initString = true;
208
209 for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
210 {
211 if (initString)
212 {
213 eventFilter << "OR eventEntry IN (" << *itr;
214 initString = false;
215 }
216 else
217 eventFilter << ',' << *itr;
218 }
219
220 if (!initString)
221 eventFilter << "))";
222 else
223 eventFilter << ')';
224
225 result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, PhaseId, PhaseGroup, "
226 "(POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ FROM gameobject "
227 "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{}' {} ORDER BY order_ ASC LIMIT 10",
228 handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(),
229 handler->GetSession()->GetPlayer()->GetMapId(), eventFilter.str());
230 }
231
232 if (!result)
233 {
235 return true;
236 }
237
238 bool found = false;
239 float x, y, z, o;
240 ObjectGuid::LowType guidLow;
241 uint32 id, phaseId, phaseGroup;
242 uint16 mapId;
243 uint32 poolId;
244
245 do
246 {
247 Field* fields = result->Fetch();
248 guidLow = fields[0].GetUInt64();
249 id = fields[1].GetUInt32();
250 x = fields[2].GetFloat();
251 y = fields[3].GetFloat();
252 z = fields[4].GetFloat();
253 o = fields[5].GetFloat();
254 mapId = fields[6].GetUInt16();
255 phaseId = fields[7].GetUInt32();
256 phaseGroup = fields[8].GetUInt32();
257 poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow);
258 if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(player->GetMap()->GetPoolData(), guidLow))
259 found = true;
260 } while (result->NextRow() && !found);
261
262 if (!found)
263 {
265 return false;
266 }
267
268 GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id);
269
270 if (!objectInfo)
271 {
273 return false;
274 }
275
276 GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
277
278 handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, std::to_string(guidLow).c_str(), objectInfo->name.c_str(), std::to_string(guidLow).c_str(), id, x, y, z, mapId, o, phaseId, phaseGroup);
279
280 if (target)
281 {
282 int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - GameTime::GetGameTime());
283 if (curRespawnDelay < 0)
284 curRespawnDelay = 0;
285
286 std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, TimeFormat::ShortText);
287 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), TimeFormat::ShortText);
288
289 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
290 }
291 return true;
292 }
293
294 //delete object by selection or guid
296 {
297 if (GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(spawnId))
298 {
299 Player const* const player = handler->GetSession()->GetPlayer();
300 ObjectGuid ownerGuid = object->GetOwnerGUID();
301 if (!ownerGuid.IsEmpty())
302 {
303 Unit* owner = ObjectAccessor::GetUnit(*player, ownerGuid);
304 if (!owner || !ownerGuid.IsPlayer())
305 {
306 handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), spawnId);
307 handler->SetSentErrorMessage(true);
308 return false;
309 }
310 owner->RemoveGameObject(object, false);
311 }
312 }
313
314 if (GameObject::DeleteFromDB(spawnId))
315 {
316 handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, std::to_string(*spawnId).c_str());
317 return true;
318 }
319 else
320 {
321 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*spawnId).c_str());
322 handler->SetSentErrorMessage(true);
323 return false;
324 }
325 }
326
327 //turn selected object
329 {
330 if (!guidLow)
331 return false;
332
333 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
334 if (!object)
335 {
336 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*guidLow).c_str());
337 handler->SetSentErrorMessage(true);
338 return false;
339 }
340
341 if (!oz)
342 oz = handler->GetSession()->GetPlayer()->GetOrientation();
343
344 Map* map = object->GetMap();
345 object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), *oz);
346 object->SetLocalRotationAngles(*oz, oy.value_or(0.0f), ox.value_or(0.0f));
347 object->SaveToDB();
348
349 // Generate a completely new spawn with new guid
350 // 3.3.5a client caches recently deleted objects and brings them back to life
351 // when CreateObject block for this guid is received again
352 // however it entirely skips parsing that block and only uses already known location
353 object->Delete();
354
355 object = GameObject::CreateGameObjectFromDB(guidLow, map);
356 if (!object)
357 return false;
358
359 handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, std::to_string(object->GetSpawnId()).c_str(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str(), object->GetOrientation());
360 return true;
361 }
362
363 //move selected object
364 static bool HandleGameObjectMoveCommand(ChatHandler* handler, GameObjectSpawnId guidLow, Optional<std::array<float,3>> xyz)
365 {
366 if (!guidLow)
367 return false;
368
369 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
370 if (!object)
371 {
372 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*guidLow).c_str());
373 handler->SetSentErrorMessage(true);
374 return false;
375 }
376
377 Position pos;
378 if (xyz)
379 {
380 pos = { (*xyz)[0], (*xyz)[1], (*xyz)[2] };
381 if (!MapManager::IsValidMapCoord(object->GetMapId(), pos))
382 {
384 handler->SetSentErrorMessage(true);
385 return false;
386 }
387 }
388 else
389 {
390 pos = handler->GetSession()->GetPlayer()->GetPosition();
391 }
392
393 Map* map = object->GetMap();
394
395 pos.SetOrientation(object->GetOrientation());
396 object->Relocate(pos);
397
398 // update which cell has this gameobject registered for loading
399 sObjectMgr->RemoveGameobjectFromGrid(object->GetGameObjectData());
400 object->SaveToDB();
401 sObjectMgr->AddGameobjectToGrid(object->GetGameObjectData());
402
403 // Generate a completely new spawn with new guid
404 // 3.3.5a client caches recently deleted objects and brings them back to life
405 // when CreateObject block for this guid is received again
406 // however it entirely skips parsing that block and only uses already known location
407 object->Delete();
408
409 object = GameObject::CreateGameObjectFromDB(guidLow, map);
410 if (!object)
411 return false;
412
413 handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, std::to_string(object->GetSpawnId()).c_str(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str());
414 return true;
415 }
416
417 //set phasemask for selected object
419 {
420 if (!guidLow)
421 return false;
422
423 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
424 if (!object)
425 {
426 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*guidLow).c_str());
427 handler->SetSentErrorMessage(true);
428 return false;
429 }
430
431 if (!phaseId)
432 {
434 handler->SetSentErrorMessage(true);
435 return false;
436 }
437
438 PhasingHandler::AddPhase(object, phaseId, true);
439 object->SaveToDB();
440 return true;
441 }
442
444 {
445 float distance = dist.value_or(10.0f);
446 uint32 count = 0;
447
448 Player* player = handler->GetSession()->GetPlayer();
449
451 stmt->setFloat(0, player->GetPositionX());
452 stmt->setFloat(1, player->GetPositionY());
453 stmt->setFloat(2, player->GetPositionZ());
454 stmt->setUInt32(3, player->GetMapId());
455 stmt->setFloat(4, player->GetPositionX());
456 stmt->setFloat(5, player->GetPositionY());
457 stmt->setFloat(6, player->GetPositionZ());
458 stmt->setFloat(7, distance * distance);
459 PreparedQueryResult result = WorldDatabase.Query(stmt);
460
461 if (result)
462 {
463 do
464 {
465 Field* fields = result->Fetch();
466 ObjectGuid::LowType guid = fields[0].GetUInt64();
467 uint32 entry = fields[1].GetUInt32();
468 float x = fields[2].GetFloat();
469 float y = fields[3].GetFloat();
470 float z = fields[4].GetFloat();
471 uint16 mapId = fields[5].GetUInt16();
472
473 GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
474
475 if (!gameObjectInfo)
476 continue;
477
478 handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gameObjectInfo->name.c_str(), x, y, z, mapId, "", "");
479
480 ++count;
481 } while (result->NextRow());
482 }
483
484 handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE, distance, count);
485 return true;
486 }
487
488 //show info of gameobject
490 {
491 uint32 entry = 0;
492 uint32 type = 0;
493 uint32 displayId = 0;
494 std::string name;
495 uint32 lootId = 0;
496
497 GameObject* thisGO = nullptr;
498 GameObjectData const* spawnData = nullptr;
499
500 ObjectGuid::LowType spawnId = 0;
501 if (isGuid || data.holds_alternative<Hyperlink<gameobject>>())
502 {
503 spawnId = *data;
504 spawnData = sObjectMgr->GetGameObjectData(spawnId);
505 if (!spawnData)
506 {
507 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, spawnId);
508 handler->SetSentErrorMessage(true);
509 return false;
510 }
511 entry = spawnData->id;
512 thisGO = handler->GetObjectFromPlayerMapByDbGuid(spawnId);
513 }
514 else
515 {
516 entry = *data;
517 }
518
519 GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
520 if (!gameObjectInfo)
521 {
523 handler->SetSentErrorMessage(true);
524 return false;
525 }
526
527 type = gameObjectInfo->type;
528 displayId = gameObjectInfo->displayId;
529 name = gameObjectInfo->name;
530 lootId = gameObjectInfo->GetLootId();
531 if (type == GAMEOBJECT_TYPE_CHEST && !lootId)
532 lootId = gameObjectInfo->chest.chestPersonalLoot;
533
534 // If we have a real object, send some info about it
535 if (thisGO)
536 {
537 handler->PSendSysMessage(LANG_SPAWNINFO_GUIDINFO, thisGO->GetGUID().ToString().c_str());
539
540 if (thisGO->GetGameObjectData() && thisGO->GetGameObjectData()->spawnGroupData->groupId)
541 {
542 SpawnGroupTemplateData const* groupData = thisGO->GetGameObjectData()->spawnGroupData;
543 handler->PSendSysMessage(LANG_SPAWNINFO_GROUP_ID, groupData->name.c_str(), groupData->groupId, groupData->flags, thisGO->GetMap()->IsSpawnGroupActive(groupData->groupId));
544 }
545
546 GameObjectOverride const* goOverride = sObjectMgr->GetGameObjectOverride(spawnId);
547 if (!goOverride)
548 goOverride = sObjectMgr->GetGameObjectTemplateAddon(entry);
549 if (goOverride)
550 handler->PSendSysMessage(LANG_GOINFO_ADDON, goOverride->Faction, goOverride->Flags);
551 }
552
553 if (spawnData)
554 {
555 float yaw, pitch, roll;
556 spawnData->rotation.toEulerAnglesZYX(yaw, pitch, roll);
557 handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, std::to_string(spawnData->spawnId).c_str(), spawnData->spawnPoint.GetPositionX(), spawnData->spawnPoint.GetPositionY(), spawnData->spawnPoint.GetPositionZ());
558 handler->PSendSysMessage(LANG_SPAWNINFO_ROTATION, yaw, pitch, roll);
559 }
560
561 handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
562 handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
563 handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
564 handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
565 handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());
566 handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size);
567 handler->PSendSysMessage(LANG_OBJECTINFO_AIINFO, gameObjectInfo->AIName.c_str(), sObjectMgr->GetScriptName(gameObjectInfo->ScriptId).c_str());
568 if (GameObjectAI const* ai = thisGO ? thisGO->AI() : nullptr)
570
571 if (GameObjectDisplayInfoEntry const* modelInfo = sGameObjectDisplayInfoStore.LookupEntry(displayId))
572 handler->PSendSysMessage(LANG_GOINFO_MODEL, modelInfo->GeoBoxMax.X, modelInfo->GeoBoxMax.Y, modelInfo->GeoBoxMax.Z, modelInfo->GeoBoxMin.X, modelInfo->GeoBoxMin.Y, modelInfo->GeoBoxMin.Z);
573
574 return true;
575 }
576
577 static bool HandleGameObjectSetStateCommand(ChatHandler* handler, GameObjectSpawnId guidLow, int32 objectType, Optional<uint32> objectState)
578 {
579 if (!guidLow)
580 return false;
581
582 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
583 if (!object)
584 {
585 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(*guidLow).c_str());
586 handler->SetSentErrorMessage(true);
587 return false;
588 }
589
590 if (objectType < 0)
591 {
592 if (objectType == -1)
593 object->SendGameObjectDespawn();
594 else if (objectType == -2)
595 return false;
596 return true;
597 }
598
599 if (!objectState)
600 return false;
601
602 switch (objectType)
603 {
604 case 0:
605 object->SetGoState(GOState(*objectState));
606 break;
607 case 1:
608 object->SetGoType(GameobjectTypes(*objectState));
609 break;
610 case 2:
611 object->SetGoArtKit(*objectState);
612 break;
613 case 3:
614 object->SetGoAnimProgress(*objectState);
615 break;
616 case 4:
617 object->SendCustomAnim(*objectState);
618 break;
619 case 5:
620 if (*objectState > GO_DESTRUCTIBLE_REBUILDING)
621 return false;
622
623 object->SetDestructibleState(GameObjectDestructibleState(*objectState));
624 break;
625 default:
626 break;
627 }
628 handler->PSendSysMessage("Set gobject type %d state %u", objectType, *objectState);
629 return true;
630 }
631};
632
634{
636}
#define EXACT_SEQUENCE(str)
DB2Storage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore("GameObjectDisplayInfo.db2", &GameobjectDisplayInfoLoadInfo::Instance)
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
int32_t int32
Definition: Define.h:138
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
#define ASSERT_NOTNULL(pointer)
Definition: Errors.h:84
#define sGameEventMgr
Definition: GameEventMgr.h:177
@ GO_READY
Definition: GameObject.h:157
@ LANG_OBJECTINFO_AIINFO
Definition: Language.h:1087
@ LANG_GAMEOBJECT_DETAIL
Definition: Language.h:597
@ LANG_COMMAND_DELOBJMESSAGE
Definition: Language.h:327
@ LANG_COMMAND_TURNOBJMESSAGE
Definition: Language.h:328
@ LANG_COMMAND_OBJNOTFOUND
Definition: Language.h:325
@ LANG_GOINFO_NAME
Definition: Language.h:1083
@ LANG_GAMEOBJECT_HAVE_INVALID_DATA
Definition: Language.h:404
@ LANG_OBJECTINFO_AITYPE
Definition: Language.h:1147
@ LANG_COMMAND_MOVEOBJMESSAGE
Definition: Language.h:329
@ LANG_GAMEOBJECT_NOT_EXIST
Definition: Language.h:594
@ LANG_GOINFO_MODEL
Definition: Language.h:118
@ LANG_COMMAND_TARGETOBJNOTFOUND
Definition: Language.h:318
@ LANG_GO_LIST_CHAT
Definition: Language.h:588
@ LANG_GAMEOBJECT_ADD
Definition: Language.h:598
@ LANG_COMMAND_NEAROBJMESSAGE
Definition: Language.h:665
@ LANG_SPAWNINFO_SPAWNID_LOCATION
Definition: Language.h:1137
@ LANG_GOINFO_DISPLAYID
Definition: Language.h:1082
@ LANG_GOINFO_SIZE
Definition: Language.h:116
@ LANG_GOINFO_ADDON
Definition: Language.h:117
@ LANG_INVALID_TARGET_COORD
Definition: Language.h:315
@ LANG_GOINFO_ENTRY
Definition: Language.h:1080
@ LANG_GOINFO_LOOTID
Definition: Language.h:1084
@ LANG_SPAWNINFO_GROUP_ID
Definition: Language.h:1134
@ LANG_BAD_VALUE
Definition: Language.h:149
@ LANG_SPAWNINFO_ROTATION
Definition: Language.h:1138
@ LANG_GOINFO_TYPE
Definition: Language.h:1081
@ LANG_SPAWNINFO_COMPATIBILITY_MODE
Definition: Language.h:1135
@ LANG_SPAWNINFO_GUIDINFO
Definition: Language.h:1136
@ LANG_COMMAND_RAWPAWNTIMES
Definition: Language.h:666
@ LANG_COMMAND_DELOBJREFERCREATURE
Definition: Language.h:326
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
#define sObjectMgr
Definition: ObjectMgr.h:1946
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
#define sPoolMgr
Definition: PoolMgr.h:179
Role Based Access Control related classes definition.
GameobjectTypes
@ GAMEOBJECT_TYPE_CHEST
GameObjectDestructibleState
@ GO_DESTRUCTIBLE_REBUILDING
GOState
@ GO_STATE_READY
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
Definition: Util.cpp:115
@ WORLD_SEL_GAMEOBJECT_NEAREST
Definition: WorldDatabase.h:72
WorldSession * GetSession()
Definition: Chat.h:42
void PSendSysMessage(const char *fmt, Args &&... args)
Definition: Chat.h:57
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition: Chat.cpp:387
void SetSentErrorMessage(bool val)
Definition: Chat.h:114
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:113
Class used to access individual fields of database query result.
Definition: Field.h:90
uint64 GetUInt64() const
Definition: Field.cpp:78
uint16 GetUInt16() const
Definition: Field.cpp:46
float GetFloat() const
Definition: Field.cpp:94
uint32 GetUInt32() const
Definition: Field.cpp:62
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:102
uint32 GetRespawnDelay() const
Definition: GameObject.h:264
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:202
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
static GameObject * CreateGameObjectFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
GameObjectAI * AI() const
Definition: GameObject.h:378
GameObjectData const * GetGameObjectData() const
Definition: GameObject.h:205
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:212
time_t GetRespawnTimeEx() const
bool GetRespawnCompatibilityMode()
Definition: GameObject.h:374
static bool DeleteFromDB(ObjectGuid::LowType spawnId)
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:82
Definition: Map.h:189
bool IsSpawnGroupActive(uint32 groupId) const
Definition: Map.cpp:2474
uint32 GetId() const
Definition: Map.cpp:3228
SpawnedPoolData & GetPoolData()
Definition: Map.h:715
LowType GetCounter() const
Definition: ObjectGuid.h:293
bool IsEmpty() const
Definition: ObjectGuid.h:319
bool IsPlayer() const
Definition: ObjectGuid.h:326
std::string ToString() const
Definition: ObjectGuid.cpp:554
uint64 LowType
Definition: ObjectGuid.h:278
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
void setFloat(const uint8 index, const float value)
void setUInt32(const uint8 index, const uint32 value)
Definition: Unit.h:627
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:5238
constexpr uint32 GetMapId() const
Definition: Position.h:201
Map * GetMap() const
Definition: Object.h:624
GameObject * SummonGameObject(uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
Definition: Object.cpp:2065
Player * GetPlayer() const
static bool HandleGameObjectDeleteCommand(ChatHandler *handler, GameObjectSpawnId spawnId)
Definition: cs_gobject.cpp:295
static bool HandleGameObjectTargetCommand(ChatHandler *handler, Optional< Variant< GameObjectEntry, std::string_view > > objectId)
Definition: cs_gobject.cpp:180
static bool HandleGameObjectNearCommand(ChatHandler *handler, Optional< float > dist)
Definition: cs_gobject.cpp:443
static bool HandleGameObjectInfoCommand(ChatHandler *handler, Optional< EXACT_SEQUENCE("guid")> isGuid, Variant< Hyperlink< gameobject_entry >, Hyperlink< gameobject >, uint32 > data)
Definition: cs_gobject.cpp:489
static bool HandleGameObjectSetPhaseCommand(ChatHandler *handler, GameObjectSpawnId guidLow, uint32 phaseId)
Definition: cs_gobject.cpp:418
static bool HandleGameObjectAddCommand(ChatHandler *handler, GameObjectEntry objectId, Optional< int32 > spawnTimeSecs)
Definition: cs_gobject.cpp:108
static bool HandleGameObjectActivateCommand(ChatHandler *handler, GameObjectSpawnId guidLow)
Definition: cs_gobject.cpp:86
static bool HandleGameObjectAddTempCommand(ChatHandler *handler, GameObjectEntry objectId, Optional< uint64 > spawntime)
Definition: cs_gobject.cpp:163
static bool HandleGameObjectMoveCommand(ChatHandler *handler, GameObjectSpawnId guidLow, Optional< std::array< float, 3 > > xyz)
Definition: cs_gobject.cpp:364
ChatCommandTable GetCommands() const override
Definition: cs_gobject.cpp:61
static bool HandleGameObjectTurnCommand(ChatHandler *handler, GameObjectSpawnId guidLow, Optional< float > oz, Optional< float > oy, Optional< float > ox)
Definition: cs_gobject.cpp:328
static bool HandleGameObjectSetStateCommand(ChatHandler *handler, GameObjectSpawnId guidLow, int32 objectType, Optional< uint32 > objectState)
Definition: cs_gobject.cpp:577
void AddSC_gobject_commandscript()
Definition: cs_gobject.cpp:633
bool HandleNpcSpawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")> > const &opts)
Definition: cs_npc.cpp:1368
bool HandleNpcDespawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("removerespawntime")> > const &opts)
Definition: cs_npc.cpp:1409
time_t GetGameTime()
Definition: GameTime.cpp:44
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
std::string GetTypeName()
Definition: Util.h:514
@ RBAC_PERM_COMMAND_GOBJECT_ADD
Definition: RBAC.h:261
@ RBAC_PERM_COMMAND_GOBJECT_SET_PHASE
Definition: RBAC.h:268
@ RBAC_PERM_COMMAND_GOBJECT_SET_STATE
Definition: RBAC.h:269
@ RBAC_PERM_COMMAND_GOBJECT_DESPAWNGROUP
Definition: RBAC.h:729
@ RBAC_PERM_COMMAND_GOBJECT_DELETE
Definition: RBAC.h:263
@ RBAC_PERM_COMMAND_GOBJECT_INFO
Definition: RBAC.h:264
@ RBAC_PERM_COMMAND_GOBJECT_ACTIVATE
Definition: RBAC.h:260
@ RBAC_PERM_COMMAND_GOBJECT_TARGET
Definition: RBAC.h:270
@ RBAC_PERM_COMMAND_GOBJECT_NEAR
Definition: RBAC.h:266
@ RBAC_PERM_COMMAND_GOBJECT_MOVE
Definition: RBAC.h:265
@ RBAC_PERM_COMMAND_GOBJECT_TURN
Definition: RBAC.h:271
@ RBAC_PERM_COMMAND_GOBJECT_SPAWNGROUP
Definition: RBAC.h:728
@ RBAC_PERM_COMMAND_GOBJECT_ADD_TEMP
Definition: RBAC.h:262
QuaternionData rotation
struct GameObjectTemplate::@213::@218 chest
uint32 GetLootId() const
constexpr void SetOrientation(float orientation)
Definition: Position.h:71
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
void toEulerAnglesZYX(float &Z, float &Y, float &X) const
Definition: GameObject.cpp:113
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
uint32 id
Definition: SpawnData.h:104
Position spawnPoint
Definition: SpawnData.h:105
std::string name
Definition: SpawnData.h:68
SpawnGroupFlags flags
Definition: SpawnData.h:70
SpawnGroupTemplateData const * spawnGroupData
Definition: SpawnData.h:96
uint64 spawnId
Definition: SpawnData.h:93