TrinityCore
Loading...
Searching...
No Matches
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 {
88 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *guidLow);
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 ObjectGuid ownerGuid = object->GetOwnerGUID();
306 if (!ownerGuid.IsEmpty())
307 {
308 Unit* owner = ObjectAccessor::GetUnit(*player, ownerGuid);
309 if (!owner || !ownerGuid.IsPlayer())
310 {
311 handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, *spawnId, ownerGuid.ToString().c_str());
312 handler->SetSentErrorMessage(true);
313 return false;
314 }
315 owner->RemoveGameObject(object, false);
316 }
317 }
318
319 if (GameObject::DeleteFromDB(spawnId))
320 {
322 return true;
323 }
324 else
325 {
326 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *spawnId);
327 handler->SetSentErrorMessage(true);
328 return false;
329 }
330 }
331
332 //turn selected object
334 {
335 if (!guidLow)
336 return false;
337
338 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
339 if (!object)
340 {
341 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *guidLow);
342 handler->SetSentErrorMessage(true);
343 return false;
344 }
345
346 if (!oz)
347 oz = handler->GetSession()->GetPlayer()->GetOrientation();
348
349 Map* map = object->GetMap();
350 object->Relocate(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), *oz);
351 object->SetLocalRotationAngles(*oz, oy.value_or(0.0f), ox.value_or(0.0f));
352 object->SaveToDB();
353
354 // Generate a completely new spawn with new guid
355 // 3.3.5a client caches recently deleted objects and brings them back to life
356 // when CreateObject block for this guid is received again
357 // however it entirely skips parsing that block and only uses already known location
358 object->Delete();
359
360 object = new GameObject();
361 if (!object->LoadFromDB(guidLow, map, true))
362 {
363 delete object;
364 return false;
365 }
366
367 handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId());
368 return true;
369 }
370
371 //move selected object
372 static bool HandleGameObjectMoveCommand(ChatHandler* handler, GameObjectSpawnId guidLow, Optional<std::array<float,3>> xyz)
373 {
374 if (!guidLow)
375 return false;
376
377 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
378 if (!object)
379 {
380 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *guidLow);
381 handler->SetSentErrorMessage(true);
382 return false;
383 }
384
385 Position pos;
386 if (xyz)
387 {
388 pos = { (*xyz)[0], (*xyz)[1], (*xyz)[2] };
389 if (!MapManager::IsValidMapCoord(object->GetMapId(), pos))
390 {
392 handler->SetSentErrorMessage(true);
393 return false;
394 }
395 }
396 else
397 {
398 pos = handler->GetSession()->GetPlayer()->GetPosition();
399 }
400
401 Map* map = object->GetMap();
402
403 pos.SetOrientation(object->GetOrientation());
404 object->Relocate(pos);
405
406 // update which cell has this gameobject registered for loading
407 sObjectMgr->RemoveGameobjectFromGrid(guidLow, object->GetGameObjectData());
408 object->SaveToDB();
409 sObjectMgr->AddGameobjectToGrid(guidLow, object->GetGameObjectData());
410
411 // Generate a completely new spawn with new guid
412 // 3.3.5a client caches recently deleted objects and brings them back to life
413 // when CreateObject block for this guid is received again
414 // however it entirely skips parsing that block and only uses already known location
415 object->Delete();
416
417 object = new GameObject();
418 if (!object->LoadFromDB(guidLow, map, true))
419 {
420 delete object;
421 return false;
422 }
423
424 handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId());
425 return true;
426 }
427
428 //set phasemask for selected object
429 static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, GameObjectSpawnId guidLow, uint32 phaseMask)
430 {
431 if (!guidLow)
432 return false;
433
434 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
435 if (!object)
436 {
437 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *guidLow);
438 handler->SetSentErrorMessage(true);
439 return false;
440 }
441
442 if (!phaseMask)
443 {
445 handler->SetSentErrorMessage(true);
446 return false;
447 }
448
449 object->SetPhaseMask(phaseMask, true);
450 object->SaveToDB();
451 return true;
452 }
453
455 {
456 float distance = dist.value_or(10.0f);
457 uint32 count = 0;
458
459 Player* player = handler->GetSession()->GetPlayer();
460
462 stmt->setFloat(0, player->GetPositionX());
463 stmt->setFloat(1, player->GetPositionY());
464 stmt->setFloat(2, player->GetPositionZ());
465 stmt->setUInt32(3, player->GetMapId());
466 stmt->setFloat(4, player->GetPositionX());
467 stmt->setFloat(5, player->GetPositionY());
468 stmt->setFloat(6, player->GetPositionZ());
469 stmt->setFloat(7, distance * distance);
470 PreparedQueryResult result = WorldDatabase.Query(stmt);
471
472 if (result)
473 {
474 do
475 {
476 Field* fields = result->Fetch();
477 ObjectGuid::LowType guid = fields[0].GetUInt32();
478 uint32 entry = fields[1].GetUInt32();
479 float x = fields[2].GetFloat();
480 float y = fields[3].GetFloat();
481 float z = fields[4].GetFloat();
482 uint16 mapId = fields[5].GetUInt16();
483
484 GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
485
486 if (!gameObjectInfo)
487 continue;
488
489 handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId, "", "");
490
491 ++count;
492 } while (result->NextRow());
493 }
494
495 handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE, distance, count);
496 return true;
497 }
498
499 //show info of gameobject
501 {
502 uint32 entry = 0;
503 uint32 type = 0;
504 uint32 displayId = 0;
505 std::string name;
506 uint32 lootId = 0;
507
508 GameObject* thisGO = nullptr;
509 GameObjectData const* spawnData = nullptr;
510
511 ObjectGuid::LowType spawnId = 0;
512 if (isGuid || data.holds_alternative<Hyperlink<gameobject>>())
513 {
514 spawnId = *data;
515 spawnData = sObjectMgr->GetGameObjectData(spawnId);
516 if (!spawnData)
517 {
518 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, spawnId);
519 handler->SetSentErrorMessage(true);
520 return false;
521 }
522 entry = spawnData->id;
523 thisGO = handler->GetObjectFromPlayerMapByDbGuid(spawnId);
524 }
525 else
526 {
527 entry = *data;
528 }
529
530 GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
531 if (!gameObjectInfo)
532 {
534 handler->SetSentErrorMessage(true);
535 return false;
536 }
537
538 type = gameObjectInfo->type;
539 displayId = gameObjectInfo->displayId;
540 name = gameObjectInfo->name;
541 lootId = gameObjectInfo->GetLootId();
542
543 // If we have a real object, send some info about it
544 if (thisGO)
545 {
546 handler->PSendSysMessage(LANG_SPAWNINFO_GUIDINFO, thisGO->GetGUID().ToString().c_str());
548
549 if (thisGO->GetGameObjectData() && thisGO->GetGameObjectData()->spawnGroupData->groupId)
550 {
551 SpawnGroupTemplateData const* groupData = thisGO->GetGameObjectData()->spawnGroupData;
552 handler->PSendSysMessage(LANG_SPAWNINFO_GROUP_ID, groupData->name.c_str(), groupData->groupId, groupData->flags, thisGO->GetMap()->IsSpawnGroupActive(groupData->groupId));
553 }
554
555 GameObjectOverride const* goOverride = sObjectMgr->GetGameObjectOverride(spawnId);
556 if (!goOverride)
557 goOverride = sObjectMgr->GetGameObjectTemplateAddon(entry);
558 if (goOverride)
559 handler->PSendSysMessage(LANG_GOINFO_ADDON, goOverride->Faction, goOverride->Flags);
560 }
561
562 if (spawnData)
563 {
564 float yaw, pitch, roll;
565 spawnData->rotation.toEulerAnglesZYX(yaw, pitch, roll);
567 handler->PSendSysMessage(LANG_SPAWNINFO_ROTATION, yaw, pitch, roll);
568 }
569
570 handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
571 handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
572 handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
573 handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId);
574 handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());
575 handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size);
576 handler->PSendSysMessage(LANG_OBJECTINFO_AIINFO, gameObjectInfo->AIName.c_str(), sObjectMgr->GetScriptName(gameObjectInfo->ScriptId).c_str());
577 if (GameObjectAI const* ai = thisGO ? thisGO->AI() : nullptr)
579
580 if (GameObjectDisplayInfoEntry const* modelInfo = sGameObjectDisplayInfoStore.LookupEntry(displayId))
581 handler->PSendSysMessage(LANG_GOINFO_MODEL, modelInfo->GeoBoxMax.X, modelInfo->GeoBoxMax.Y, modelInfo->GeoBoxMax.Z, modelInfo->GeoBoxMin.X, modelInfo->GeoBoxMin.Y, modelInfo->GeoBoxMin.Z);
582
583 return true;
584 }
585
586 static bool HandleGameObjectSetStateCommand(ChatHandler* handler, GameObjectSpawnId guidLow, int32 objectType, Optional<uint32> objectState)
587 {
588 if (!guidLow)
589 return false;
590
591 GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
592 if (!object)
593 {
594 handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, *guidLow);
595 handler->SetSentErrorMessage(true);
596 return false;
597 }
598
599 if (objectType < 0)
600 {
601 if (objectType == -1)
602 object->SendObjectDeSpawnAnim(object->GetGUID());
603 else if (objectType == -2)
604 return false;
605 return true;
606 }
607
608 if (!objectState)
609 return false;
610
611 switch (objectType)
612 {
613 case 0:
614 object->SetGoState(GOState(*objectState));
615 break;
616 case 1:
617 object->SetGoType(GameobjectTypes(*objectState));
618 break;
619 case 2:
620 object->SetGoArtKit(*objectState);
621 break;
622 case 3:
623 object->SetGoAnimProgress(*objectState);
624 break;
625 case 4:
626 object->SendCustomAnim(*objectState);
627 break;
628 case 5:
629 if (*objectState > GO_DESTRUCTIBLE_REBUILDING)
630 return false;
631
632 object->SetDestructibleState(GameObjectDestructibleState(*objectState));
633 break;
634 default:
635 break;
636 }
637 handler->PSendSysMessage("Set gobject type %d state %u", objectType, *objectState);
638 return true;
639 }
640};
641
#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.
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
@ 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:1721
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
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
WorldSession * GetSession()
Definition Chat.h:46
GameObject * GetObjectFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:489
void SetSentErrorMessage(bool val)
Definition Chat.h:134
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:69
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
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)
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:3495
uint32 GetId() const
Definition Map.cpp:4216
bool IsEmpty() const
Definition ObjectGuid.h:172
bool IsPlayer() const
Definition ObjectGuid.h:179
std::string ToString() const
uint32 LowType
Definition ObjectGuid.h:142
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetPhaseMaskForSpawn() const
Definition Player.cpp:24769
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:5111
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
static bool HandleGameObjectDeleteCommand(ChatHandler *handler, GameObjectSpawnId spawnId)
static bool HandleGameObjectTargetCommand(ChatHandler *handler, Optional< Variant< GameObjectEntry, std::string_view > > objectId)
static bool HandleGameObjectNearCommand(ChatHandler *handler, Optional< float > dist)
static bool HandleGameObjectInfoCommand(ChatHandler *handler, Optional< EXACT_SEQUENCE("guid")> isGuid, Variant< Hyperlink< gameobject_entry >, Hyperlink< gameobject >, uint32 > data)
static bool HandleGameObjectAddCommand(ChatHandler *handler, GameObjectEntry objectId, Optional< int32 > spawnTimeSecs)
static bool HandleGameObjectActivateCommand(ChatHandler *handler, GameObjectSpawnId guidLow)
static bool HandleGameObjectAddTempCommand(ChatHandler *handler, GameObjectEntry objectId, Optional< uint64 > spawntime)
static bool HandleGameObjectMoveCommand(ChatHandler *handler, GameObjectSpawnId guidLow, Optional< std::array< float, 3 > > xyz)
ChatCommandTable GetCommands() const override
static bool HandleGameObjectTurnCommand(ChatHandler *handler, GameObjectSpawnId guidLow, Optional< float > oz, Optional< float > oy, Optional< float > ox)
static bool HandleGameObjectSetStateCommand(ChatHandler *handler, GameObjectSpawnId guidLow, int32 objectType, Optional< uint32 > objectState)
static bool HandleGameObjectSetPhaseCommand(ChatHandler *handler, GameObjectSpawnId guidLow, uint32 phaseMask)
void AddSC_gobject_commandscript()
bool HandleNpcSpawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")> > const &opts)
Definition cs_npc.cpp:1322
bool HandleNpcDespawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("removerespawntime")> > const &opts)
Definition cs_npc.cpp:1363
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
uint32 GetLootId() const
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
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
uint32 id
Definition SpawnData.h:96
Position spawnPoint
Definition SpawnData.h:97
SpawnGroupFlags flags
Definition SpawnData.h:63
uint32 spawnId
Definition SpawnData.h:85
SpawnGroupTemplateData const * spawnGroupData
Definition SpawnData.h:88