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