TrinityCore
Loading...
Searching...
No Matches
cs_npc.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: npc_commandscript
20%Complete: 100
21Comment: All npc related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "CharacterCache.h"
27#include "Chat.h"
28#include "ChatCommand.h"
29#include "CreatureAI.h"
30#include "CreatureGroups.h"
31#include "DB2Stores.h"
32#include "DatabaseEnv.h"
34#include "GameTime.h"
35#include "Language.h"
36#include "Loot.h"
37#include "Map.h"
38#include "MapUtils.h"
39#include "MotionMaster.h"
40#include "MovementDefines.h"
41#include "ObjectAccessor.h"
42#include "ObjectMgr.h"
43#include "Pet.h"
44#include "PhasingHandler.h"
45#include "Player.h"
46#include "RBAC.h"
47#include "SmartEnum.h"
48#include "SpellMgr.h"
49#include "Transport.h"
50#include "World.h"
51#include "WorldSession.h"
52
53using namespace Trinity::ChatCommands;
54
57
58// shared with cs_gobject.cpp, definitions are at the bottom of this file
59bool HandleNpcSpawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")>> const& opts);
60bool HandleNpcDespawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("removerespawntime")>> const& opts);
61
63{
64public:
65 npc_commandscript() : CommandScript("npc_commandscript") { }
66
67 std::span<ChatCommandBuilder const> GetCommands() const override
68 {
69 static ChatCommandTable npcAddCommandTable =
70 {
75// { "weapon", HandleNpcAddWeaponCommand, rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, Console::No },
77 };
78 static ChatCommandTable npcSetCommandTable =
79 {
92 };
93 static ChatCommandTable npcCommandTable =
94 {
95 { "add", npcAddCommandTable },
96 { "set", npcSetCommandTable },
106 { "spawngroup", HandleNpcSpawnGroup, rbac::RBAC_PERM_COMMAND_NPC_SPAWNGROUP, Console::No },
107 { "despawngroup", HandleNpcDespawnGroup, rbac::RBAC_PERM_COMMAND_NPC_DESPAWNGROUP, Console::No },
111 { "follow stop", HandleNpcUnFollowCommand, rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, Console::No },
114 };
115 static ChatCommandTable commandTable =
116 {
117 { "npc", npcCommandTable },
118 };
119 return commandTable;
120 }
121
122 //add spawn of creature
124 {
125 if (!sObjectMgr->GetCreatureTemplate(id))
126 return false;
127
128 Player* chr = handler->GetSession()->GetPlayer();
129 Map* map = chr->GetMap();
130
131 if (Transport* trans = dynamic_cast<Transport*>(chr->GetTransport()))
132 {
133 ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
134 CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
135 data.spawnId = guid;
136 data.spawnGroupData = sObjectMgr->GetDefaultSpawnGroup();
137 data.id = id;
139 if (Creature* creature = trans->CreateNPCPassenger(guid, &data))
140 {
141 creature->SaveToDB(trans->GetGOInfo()->moTransport.SpawnMap, { map->GetDifficultyID() });
142 sObjectMgr->AddCreatureToGrid(&data);
143 }
144 return true;
145 }
146
147 Creature* creature = Creature::CreateCreature(id, map, chr->GetPosition());
148 if (!creature)
149 return false;
150
152 creature->SaveToDB(map->GetId(), { map->GetDifficultyID() });
153
154 ObjectGuid::LowType db_guid = creature->GetSpawnId();
155
156 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
157 // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
158 creature->CleanupsBeforeDelete();
159 delete creature;
160
161 creature = Creature::CreateCreatureFromDB(db_guid, map, true, true);
162 if (!creature)
163 return false;
164
165 sObjectMgr->AddCreatureToGrid(sObjectMgr->GetCreatureData(db_guid));
166 return true;
167 }
168
169 //add item in vendorlist
171 {
172 if (!item)
173 {
175 handler->SetSentErrorMessage(true);
176 return false;
177 }
178
179 Creature* vendor = handler->getSelectedCreature();
180 if (!vendor)
181 {
183 handler->SetSentErrorMessage(true);
184 return false;
185 }
186
187 uint32 itemId = item->GetId();
188 uint32 maxcount = mc.value_or(0);
189 uint32 incrtime = it.value_or(0);
190 uint32 extendedcost = ec.value_or(0);
191 uint32 vendor_entry = vendor->GetEntry();
192
193 VendorItem vItem;
194 vItem.item = itemId;
195 vItem.maxcount = maxcount;
196 vItem.incrtime = incrtime;
197 vItem.ExtendedCost = extendedcost;
199
200 if (bonusListIDs)
201 for (std::string_view token : Trinity::Tokenize(*bonusListIDs, ';', false))
202 if (Optional<int32> bonusListID = Trinity::StringTo<int32>(token))
203 vItem.BonusListIDs.push_back(*bonusListID);
204
205 if (!sObjectMgr->IsVendorItemValid(vendor_entry, vItem, handler->GetSession()->GetPlayer()))
206 {
207 handler->SetSentErrorMessage(true);
208 return false;
209 }
210
211 sObjectMgr->AddVendorItem(vendor_entry, vItem);
212
213 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->GetDefaultLocaleName(), maxcount, incrtime, extendedcost);
214 return true;
215 }
216
217 //add move for creature
219 {
220 // attempt check creature existence by DB data
221 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
222 if (!data)
223 {
224 handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(*lowGuid).c_str());
225 handler->SetSentErrorMessage(true);
226 return false;
227 }
228
229 // Update movement type
231
233 stmt->setUInt64(1, lowGuid);
234
235 WorldDatabase.Execute(stmt);
236
238
239 return true;
240 }
241
243 {
244 if (sWorld->getAllowMovement())
245 {
246 sWorld->SetAllowMovement(false);
248 }
249 else
250 {
251 sWorld->SetAllowMovement(true);
253 }
254 return true;
255 }
256
257 static bool HandleNpcSetEntryCommand(ChatHandler* handler, CreatureEntry newEntryNum)
258 {
259 if (!newEntryNum)
260 return false;
261
262 Unit* unit = handler->getSelectedUnit();
263 if (!unit || unit->GetTypeId() != TYPEID_UNIT)
264 {
266 handler->SetSentErrorMessage(true);
267 return false;
268 }
269 Creature* creature = unit->ToCreature();
270 if (creature->UpdateEntry(newEntryNum))
271 handler->SendSysMessage(LANG_DONE);
272 else
273 handler->SendSysMessage(LANG_ERROR);
274 return true;
275 }
276
277 //change level of creature or pet
278 static bool HandleNpcSetLevelCommand(ChatHandler* handler, uint8 lvl)
279 {
280 if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
281 {
283 handler->SetSentErrorMessage(true);
284 return false;
285 }
286
287 Creature* creature = handler->getSelectedCreature();
288 if (!creature || creature->IsPet())
289 {
291 handler->SetSentErrorMessage(true);
292 return false;
293 }
294
295 creature->SetLevel(lvl);
296 creature->UpdateLevelDependantStats();
297 creature->SaveToDB();
298
299 return true;
300 }
301
303 {
304 ObjectGuid::LowType spawnId;
305 if (spawnIdArg)
306 spawnId = *spawnIdArg;
307 else
308 {
309 Creature* creature = handler->getSelectedCreature();
310 if (!creature || creature->IsPet() || creature->IsTotem())
311 {
313 handler->SetSentErrorMessage(true);
314 return false;
315 }
316 if (TempSummon* summon = creature->ToTempSummon())
317 {
318 summon->UnSummon();
320 return true;
321 }
322 spawnId = creature->GetSpawnId();
323 }
324
325 if (Creature::DeleteFromDB(spawnId))
326 {
328 return true;
329 }
330 else
331 {
332 handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(spawnId).c_str());
333 handler->SetSentErrorMessage(true);
334 return false;
335 }
336 }
337
338 //del item from vendor list
340 {
341 Creature* vendor = handler->getSelectedCreature();
342 if (!vendor || !vendor->IsVendor())
343 {
345 handler->SetSentErrorMessage(true);
346 return false;
347 }
348
349 if (!item)
350 {
352 handler->SetSentErrorMessage(true);
353 return false;
354 }
355
356 uint32 itemId = item->GetId();
357 if (!sObjectMgr->RemoveVendorItem(vendor->GetEntry(), ITEM_VENDOR_TYPE_ITEM, itemId))
358 {
359 handler->PSendSysMessage(LANG_ITEM_NOT_IN_LIST, itemId);
360 handler->SetSentErrorMessage(true);
361 return false;
362 }
363
365 return true;
366 }
367
368 //set faction of creature
369 static bool HandleNpcSetFactionIdCommand(ChatHandler* handler, uint32 factionId)
370 {
371 if (!sFactionTemplateStore.LookupEntry(factionId))
372 {
373 handler->PSendSysMessage(LANG_WRONG_FACTION, factionId);
374 handler->SetSentErrorMessage(true);
375 return false;
376 }
377
378 Creature* creature = handler->getSelectedCreature();
379
380 if (!creature)
381 {
383 handler->SetSentErrorMessage(true);
384 return false;
385 }
386
387 creature->SetFaction(factionId);
388
389 // Faction is set in creature_template - not inside creature
390
391 // Update in memory..
392 if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
393 const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
394
395 // ..and DB
397
398 stmt->setUInt16(0, uint16(factionId));
399 stmt->setUInt32(1, creature->GetEntry());
400
401 WorldDatabase.Execute(stmt);
402
403 return true;
404 }
405
406 //set npcflag of creature
407 static bool HandleNpcSetFlagCommand(ChatHandler* handler, NPCFlags npcFlags, NPCFlags2 npcFlags2)
408 {
409 Creature* creature = handler->getSelectedCreature();
410
411 if (!creature)
412 {
414 handler->SetSentErrorMessage(true);
415 return false;
416 }
417
418 creature->ReplaceAllNpcFlags(npcFlags);
419 creature->ReplaceAllNpcFlags2(npcFlags2);
420
422
423 stmt->setUInt64(0, uint64(npcFlags) | (uint64(npcFlags2) << 32));
424 stmt->setUInt32(1, creature->GetEntry());
425
426 WorldDatabase.Execute(stmt);
427
429
430 return true;
431 }
432
433 //set data of creature for testing scripting
434 static bool HandleNpcSetDataCommand(ChatHandler* handler, uint32 data_1, uint32 data_2)
435 {
436 Creature* creature = handler->getSelectedCreature();
437
438 if (!creature)
439 {
441 handler->SetSentErrorMessage(true);
442 return false;
443 }
444
445 creature->AI()->SetData(data_1, data_2);
446 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
447 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().ToString().c_str(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str());
448 return true;
449 }
450
451 //npc follow handling
453 {
454 Player* player = handler->GetSession()->GetPlayer();
455 Creature* creature = handler->getSelectedCreature();
456
457 if (!creature)
458 {
460 handler->SetSentErrorMessage(true);
461 return false;
462 }
463
464 // Follow player - Using pet's default dist and angle
465 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
466
467 handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str());
468 return true;
469 }
470
471 static bool HandleNpcInfoCommand(ChatHandler* handler)
472 {
473 Creature* target = handler->getSelectedCreature();
474
475 if (!target)
476 {
478 handler->SetSentErrorMessage(true);
479 return false;
480 }
481
482 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
483
484 uint32 faction = target->GetFaction();
485 uint64 npcflags = (uint64(target->GetNpcFlags2()) << 32) | target->GetNpcFlags();
486 uint64 mechanicImmuneMask = 0;
488 mechanicImmuneMask = immunities->Mechanic.to_ullong();
489 uint32 displayid = target->GetDisplayId();
490 uint32 nativeid = target->GetNativeDisplayId();
491 uint32 entry = target->GetEntry();
492
494
495 if (curRespawnDelay < 0)
496 curRespawnDelay = 0;
497 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), TimeFormat::ShortText);
498 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), TimeFormat::ShortText);
499
500 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetName().c_str(), std::to_string(target->GetSpawnId()).c_str(), target->GetGUID().ToString().c_str(), entry, faction, std::to_string(npcflags).c_str(), displayid, nativeid);
501 if (target->GetCreatureData() && target->GetCreatureData()->spawnGroupData->groupId)
502 {
503 SpawnGroupTemplateData const* const groupData = target->GetCreatureData()->spawnGroupData;
504 handler->PSendSysMessage(LANG_SPAWNINFO_GROUP_ID, groupData->name.c_str(), groupData->groupId, groupData->flags, target->GetMap()->IsSpawnGroupActive(groupData->groupId));
505 }
507 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
509 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), std::to_string(target->GetMaxHealth()).c_str(), std::to_string(target->GetHealth()).c_str());
511
513 for (UnitFlags flag : EnumUtils::Iterate<UnitFlags>())
514 if (target->HasUnitFlag(flag))
515 handler->PSendSysMessage("%s (0x%X)", EnumUtils::ToTitle(flag), flag);
516
518 for (UnitFlags2 flag : EnumUtils::Iterate<UnitFlags2>())
519 if (target->HasUnitFlag2(flag))
520 handler->PSendSysMessage("%s (0x%X)", EnumUtils::ToTitle(flag), flag);
521
523 for (UnitFlags3 flag : EnumUtils::Iterate<UnitFlags3>())
524 if (target->HasUnitFlag3(flag))
525 handler->PSendSysMessage("%s (0x%X)", EnumUtils::ToTitle(flag), flag);
526
528 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
529
530 CreatureDifficulty const* creatureDifficulty = target->GetCreatureDifficulty();
531 handler->PSendSysMessage(LANG_NPCINFO_LOOT, creatureDifficulty->LootID, creatureDifficulty->PickPocketLootID, creatureDifficulty->SkinLootID);
532
534
535 if (CreatureData const* data = sObjectMgr->GetCreatureData(target->GetSpawnId()))
536 {
537 handler->PSendSysMessage(LANG_NPCINFO_PHASES, data->phaseId, data->phaseGroup);
538 PhasingHandler::PrintToChat(handler, target);
539 }
540
541 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
542 handler->PSendSysMessage(LANG_NPCINFO_POSITION, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
543 handler->PSendSysMessage(LANG_OBJECTINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());
547 if (CreatureAI const* ai = target->AI())
550 for (CreatureFlagsExtra flag : EnumUtils::Iterate<CreatureFlagsExtra>())
551 if (cInfo->flags_extra & flag)
552 handler->PSendSysMessage("%s (0x%X)", EnumUtils::ToTitle(flag), flag);
553
555 for (NPCFlags flag : EnumUtils::Iterate<NPCFlags>())
556 if (target->HasNpcFlag(flag))
557 handler->PSendSysMessage("* %s (0x%X)", EnumUtils::ToTitle(flag), flag);
558
559 for (NPCFlags2 flag : EnumUtils::Iterate<NPCFlags2>())
560 if (target->HasNpcFlag2(flag))
561 handler->PSendSysMessage("* %s (0x%X)", EnumUtils::ToTitle(flag), flag);
562
563 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, Trinity::StringFormat("0x{:X}", mechanicImmuneMask).c_str());
564 for (Mechanics m : EnumUtils::Iterate<Mechanics>())
565 if (m && (mechanicImmuneMask & (UI64LIT(1) << m)))
566 handler->PSendSysMessage("%s (0x%X)", EnumUtils::ToTitle(m), m);
567
568 return true;
569 }
570
572 {
573 float distance = dist.value_or(10.0f);
574 uint32 count = 0;
575
576 Player* player = handler->GetSession()->GetPlayer();
577
579 stmt->setFloat(0, player->GetPositionX());
580 stmt->setFloat(1, player->GetPositionY());
581 stmt->setFloat(2, player->GetPositionZ());
582 stmt->setUInt32(3, player->GetMapId());
583 stmt->setFloat(4, player->GetPositionX());
584 stmt->setFloat(5, player->GetPositionY());
585 stmt->setFloat(6, player->GetPositionZ());
586 stmt->setFloat(7, distance * distance);
587 PreparedQueryResult result = WorldDatabase.Query(stmt);
588
589 if (result)
590 {
591 do
592 {
593 Field* fields = result->Fetch();
594 ObjectGuid::LowType guid = fields[0].GetUInt64();
595 uint32 entry = fields[1].GetUInt32();
596 float x = fields[2].GetFloat();
597 float y = fields[3].GetFloat();
598 float z = fields[4].GetFloat();
599 uint16 mapId = fields[5].GetUInt16();
600
601 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
602 if (!creatureTemplate)
603 continue;
604
605 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), creatureTemplate->Name.c_str(), x, y, z, mapId, "", "");
606
607 ++count;
608 }
609 while (result->NextRow());
610 }
611
612 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
613
614 return true;
615 }
616
617 //move selected creature
619 {
620 Creature* creature = handler->getSelectedCreature();
621 Player const* player = handler->GetSession()->GetPlayer();
622 if (!player)
623 return false;
624
625 if (!spawnid && !creature)
626 return false;
627
628 ObjectGuid::LowType lowguid = spawnid ? *spawnid : creature->GetSpawnId();
629 // Attempting creature load from DB data
630 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
631 if (!data)
632 {
633 handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(lowguid).c_str());
634 handler->SetSentErrorMessage(true);
635 return false;
636 }
637
638 if (player->GetMapId() != data->mapId)
639 {
640 handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, std::to_string(lowguid).c_str());
641 handler->SetSentErrorMessage(true);
642 return false;
643 }
644
645 // update position in memory
646 sObjectMgr->RemoveCreatureFromGrid(data);
647 const_cast<CreatureData*>(data)->spawnPoint.Relocate(*player);
648 sObjectMgr->AddCreatureToGrid(data);
649
650 // update position in DB
652 stmt->setFloat(0, player->GetPositionX());
653 stmt->setFloat(1, player->GetPositionY());
654 stmt->setFloat(2, player->GetPositionZ());
655 stmt->setFloat(3, player->GetOrientation());
656 stmt->setUInt64(4, lowguid);
657 WorldDatabase.Execute(stmt);
658
659 // respawn selected creature at the new location
660 if (creature)
661 creature->DespawnOrUnsummon(0s, 1s);
662
664 return true;
665 }
666
667 //play npc emote
668 static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, uint32 emote)
669 {
670 Creature* target = handler->getSelectedCreature();
671 if (!target)
672 {
674 handler->SetSentErrorMessage(true);
675 return false;
676 }
677
678 target->SetEmoteState(Emote(emote));
679
680 return true;
681 }
682
683 //set model of creature
684 static bool HandleNpcSetModelCommand(ChatHandler* handler, uint32 displayId)
685 {
686 Creature* creature = handler->getSelectedCreature();
687
688 if (!creature || creature->IsPet())
689 {
691 handler->SetSentErrorMessage(true);
692 return false;
693 }
694
695 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
696 {
698 handler->SetSentErrorMessage(true);
699 return false;
700 }
701
702 creature->SetDisplayId(displayId, true);
703
704 creature->SaveToDB();
705
706 return true;
707 }
708
722 {
723 // 3 arguments:
724 // GUID (optional - you can also select the creature)
725 // stay|random|way (determines the kind of movement)
726 // NODEL (optional - tells the system NOT to delete any waypoints)
727 // this is very handy if you want to do waypoints, that are
728 // later switched on/off according to special events (like escort
729 // quests, etc)
730
731 bool doNotDelete = nodel.has_value();
732
733 ObjectGuid::LowType lowguid = UI64LIT(0);
734 Creature* creature = nullptr;
735
736 if (!lowGuid) // case .setmovetype $move_type (with selected creature)
737 {
738 creature = handler->getSelectedCreature();
739 if (!creature || creature->IsPet())
740 return false;
741 lowguid = creature->GetSpawnId();
742 }
743 else // case .setmovetype #creature_guid $move_type (with selected creature)
744 {
745 lowguid = *lowGuid;
746
747 if (lowguid)
748 creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
749
750 // attempt check creature existence by DB data
751 if (!creature)
752 {
753 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
754 if (!data)
755 {
756 handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(lowguid).c_str());
757 handler->SetSentErrorMessage(true);
758 return false;
759 }
760 }
761 else
762 {
763 lowguid = creature->GetSpawnId();
764 }
765 }
766
767 // now lowguid is low guid really existed creature
768 // and creature point (maybe) to this creature or nullptr
769
770 MovementGeneratorType move_type;
771 switch (type.index())
772 {
773 case 0:
774 move_type = IDLE_MOTION_TYPE;
775 break;
776 case 1:
777 move_type = RANDOM_MOTION_TYPE;
778 break;
779 case 2:
780 move_type = WAYPOINT_MOTION_TYPE;
781 break;
782 default:
783 return false;
784 }
785
786 // update movement type
787 //if (doNotDelete == false)
788 // WaypointMgr.DeletePath(lowguid);
789
790 if (creature)
791 {
792 // update movement type
793 if (doNotDelete == false)
794 creature->LoadPath(0);
795
796 creature->SetDefaultMovementType(move_type);
797 creature->GetMotionMaster()->Initialize();
798 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
799 {
800 creature->setDeathState(JUST_DIED);
801 creature->Respawn();
802 }
803 creature->SaveToDB();
804 }
805 if (doNotDelete == false)
806 {
808 }
809 else
810 {
812 }
813
814 return true;
815 }
816
817 //npc phase handling
818 //change phase of creature
819 static bool HandleNpcSetPhaseGroup(ChatHandler* handler, char const* args)
820 {
821 if (!*args)
822 return false;
823
824 int32 phaseGroupId = atoi(args);
825
826 Creature* creature = handler->getSelectedCreature();
827 if (!creature || creature->IsPet())
828 {
830 handler->SetSentErrorMessage(true);
831 return false;
832 }
833
835 PhasingHandler::AddPhaseGroup(creature, phaseGroupId, true);
836 creature->SetDBPhase(-phaseGroupId);
837
838 creature->SaveToDB();
839
840 return true;
841 }
842
843 //npc phase handling
844 //change phase of creature
845 static bool HandleNpcSetPhaseCommand(ChatHandler* handler, uint32 phaseID)
846 {
847 if (phaseID == 0)
848 {
850 handler->SetSentErrorMessage(true);
851 return false;
852 }
853
854 Creature* creature = handler->getSelectedCreature();
855 if (!creature || creature->IsPet())
856 {
858 handler->SetSentErrorMessage(true);
859 return false;
860 }
861
863 PhasingHandler::AddPhase(creature, phaseID, true);
864 creature->SetDBPhase(phaseID);
865
866 creature->SaveToDB();
867
868 return true;
869 }
870
871 //set spawn dist of creature
872 static bool HandleNpcSetWanderDistanceCommand(ChatHandler* handler, float option)
873 {
874 if (option < 0.0f)
875 {
877 return false;
878 }
879
881 if (option > 0.0f)
882 mtype = RANDOM_MOTION_TYPE;
883
884 Creature* creature = handler->getSelectedCreature();
885 ObjectGuid::LowType guidLow = UI64LIT(0);
886
887 if (creature)
888 guidLow = creature->GetSpawnId();
889 else
890 return false;
891
892 creature->SetWanderDistance((float)option);
893 creature->SetDefaultMovementType(mtype);
894 creature->GetMotionMaster()->Initialize();
895 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
896 {
897 creature->setDeathState(JUST_DIED);
898 creature->Respawn();
899 }
900
902
903 stmt->setFloat(0, option);
904 stmt->setUInt8(1, uint8(mtype));
905 stmt->setUInt64(2, guidLow);
906
907 WorldDatabase.Execute(stmt);
908
910 return true;
911 }
912
913 //spawn time handling
914 static bool HandleNpcSetSpawnTimeCommand(ChatHandler* handler, uint32 spawnTime)
915 {
916 Creature* creature = handler->getSelectedCreature();
917 if (!creature)
918 return false;
919
921 stmt->setUInt32(0, spawnTime);
922 stmt->setUInt64(1, creature->GetSpawnId());
923 WorldDatabase.Execute(stmt);
924
925 creature->SetRespawnDelay(spawnTime);
926 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime);
927
928 return true;
929 }
930
931 static bool HandleNpcSayCommand(ChatHandler* handler, Tail text)
932 {
933 if (text.empty())
934 return false;
935
936 Creature* creature = handler->getSelectedCreature();
937 if (!creature)
938 {
940 handler->SetSentErrorMessage(true);
941 return false;
942 }
943
944 creature->Say(text, LANG_UNIVERSAL);
945
946 // make some emotes
947 switch (text.back())
948 {
949 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
950 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
951 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
952 }
953
954 return true;
955 }
956
957 //show text emote by creature in chat
958 static bool HandleNpcTextEmoteCommand(ChatHandler* handler, Tail text)
959 {
960 if (text.empty())
961 return false;
962
963 Creature* creature = handler->getSelectedCreature();
964
965 if (!creature)
966 {
968 handler->SetSentErrorMessage(true);
969 return false;
970 }
971
972 creature->TextEmote(text);
973
974 return true;
975 }
976
977 // npc unfollow handling
979 {
980 Player* player = handler->GetSession()->GetPlayer();
981 Creature* creature = handler->getSelectedCreature();
982
983 if (!creature)
984 {
986 handler->SetSentErrorMessage(true);
987 return false;
988 }
989
990 MovementGenerator* movement = creature->GetMotionMaster()->GetMovementGenerator([player](MovementGenerator const* a) -> bool
991 {
993 {
994 FollowMovementGenerator const* followMovement = dynamic_cast<FollowMovementGenerator const*>(a);
995 return followMovement && followMovement->GetTarget() == player;
996 }
997 return false;
998 });
999
1000 if (!movement)
1001 {
1002 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1003 handler->SetSentErrorMessage(true);
1004 return false;
1005 }
1006
1007 creature->GetMotionMaster()->Remove(movement);
1008 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
1009 return true;
1010 }
1011
1012 // make npc whisper to player
1013 static bool HandleNpcWhisperCommand(ChatHandler* handler, Variant<Hyperlink<player>, std::string_view> recv, Tail text)
1014 {
1015 if (text.empty())
1016 return false;
1017
1018 Creature* creature = handler->getSelectedCreature();
1019 if (!creature)
1020 {
1022 handler->SetSentErrorMessage(true);
1023 return false;
1024 }
1025
1026 // check online security
1027 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1028 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1029 return false;
1030
1031 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1032 return true;
1033 }
1034
1035 static bool HandleNpcYellCommand(ChatHandler* handler, Tail text)
1036 {
1037 if (text.empty())
1038 return false;
1039
1040 Creature* creature = handler->getSelectedCreature();
1041 if (!creature)
1042 {
1044 handler->SetSentErrorMessage(true);
1045 return false;
1046 }
1047
1048 creature->Yell(text, LANG_UNIVERSAL);
1049
1050 // make an emote
1052
1053 return true;
1054 }
1055
1056 // add creature, temp only
1058 {
1059 bool loot = false;
1060 if (lootStr)
1061 {
1062 if (StringEqualI(*lootStr, "loot"))
1063 loot = true;
1064 else if (StringEqualI(*lootStr, "noloot"))
1065 loot = false;
1066 else
1067 return false;
1068 }
1069
1070 Player* chr = handler->GetSession()->GetPlayer();
1071 if (!sObjectMgr->GetCreatureTemplate(id))
1072 return false;
1073
1075
1076 return true;
1077 }
1078
1079 //npc tame handling
1080 static bool HandleNpcTameCommand(ChatHandler* handler)
1081 {
1082 Creature* creatureTarget = handler->getSelectedCreature();
1083 if (!creatureTarget || creatureTarget->IsPet())
1084 {
1086 handler->SetSentErrorMessage (true);
1087 return false;
1088 }
1089
1090 Player* player = handler->GetSession()->GetPlayer();
1091
1092 if (!player->GetPetGUID().IsEmpty())
1093 {
1095 handler->SetSentErrorMessage (true);
1096 return false;
1097 }
1098
1099 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1100
1101 if (!cInfo->IsTameable (player->CanTameExoticPets(), creatureTarget->GetCreatureDifficulty()))
1102 {
1104 handler->SetSentErrorMessage (true);
1105 return false;
1106 }
1107
1108 // Everything looks OK, create new pet
1109 Pet* pet = player->CreateTamedPetFrom(creatureTarget);
1110 if (!pet)
1111 {
1113 handler->SetSentErrorMessage (true);
1114 return false;
1115 }
1116
1117 // place pet before player
1118 float x, y, z;
1119 player->GetClosePoint (x, y, z, creatureTarget->GetCombatReach(), CONTACT_DISTANCE);
1120 pet->Relocate(x, y, z, float(M_PI) - player->GetOrientation());
1121
1122 // set pet to defensive mode by default (some classes can't control controlled pets in fact).
1124
1125 // calculate proper level
1126 uint8 level = std::max<uint8>(player->GetLevel()-5, creatureTarget->GetLevel());
1127
1128 // prepare visual effect for levelup
1129 pet->SetLevel(level - 1);
1130
1131 // add to world
1132 pet->GetMap()->AddToMap(pet->ToCreature());
1133
1134 // visual effect for levelup
1135 pet->SetLevel(level);
1136
1137 // caster have pet now
1138 player->SetMinion(pet, true);
1139
1141 player->PetSpellInitialize();
1142
1143 return true;
1144 }
1145
1147 {
1148 Creature* creatureTarget = handler->getSelectedCreature();
1149 if (!creatureTarget || creatureTarget->IsPet())
1150 {
1152 handler->SetSentErrorMessage(true);
1153 return false;
1154 }
1155
1156 if (!creatureTarget->IsAIEnabled())
1157 {
1159 handler->SetSentErrorMessage(true);
1160 return false;
1161 }
1162
1163 if (force)
1164 creatureTarget->ClearUnitState(UNIT_STATE_EVADE);
1165 creatureTarget->AI()->EnterEvadeMode(why.value_or(EvadeReason::Other));
1166
1167 return true;
1168 }
1169
1170 static void _ShowLootEntry(ChatHandler* handler, uint32 itemId, uint32 itemCount, bool alternateString = false)
1171 {
1172 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
1173 char const* name = nullptr;
1174 if (itemTemplate)
1175 name = itemTemplate->GetName(handler->GetSessionDbcLocale());
1176 if (!name)
1177 name = "Unknown item";
1178 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_ENTRY, alternateString ? 6 : 3 /*number of bytes from following string*/, "\xE2\x94\x80\xE2\x94\x80",
1179 itemCount, ItemQualityColors[itemTemplate ? static_cast<ItemQualities>(itemTemplate->GetQuality()) : ITEM_QUALITY_POOR], itemId, name, itemId);
1180 }
1181
1182 static void _ShowLootCurrencyEntry(ChatHandler* handler, uint32 currencyId, uint32 count, bool alternateString = false)
1183 {
1184 CurrencyTypesEntry const* currency = sCurrencyTypesStore.LookupEntry(currencyId);
1185 char const* name = nullptr;
1186 if (currency)
1187 name = currency->Name[handler->GetSessionDbcLocale()];
1188 if (!name)
1189 name = "Unknown currency";
1190 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_CURRENCY, alternateString ? 6 : 3 /*number of bytes from following string*/, "\xE2\x94\x80\xE2\x94\x80",
1191 count, ItemQualityColors[currency ? static_cast<ItemQualities>(currency->Quality) : ITEM_QUALITY_POOR], currencyId, count, name, currencyId);
1192 }
1193
1194 static void _ShowLootTrackingQuestCurrencyEntry(ChatHandler* handler, uint32 questId, bool alternateString = false)
1195 {
1196 Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
1197 std::string_view name;
1198 if (quest)
1199 {
1200 name = quest->GetLogTitle();
1201 if (handler->GetSessionDbLocaleIndex() != LOCALE_enUS)
1202 if (QuestTemplateLocale const* localeData = sObjectMgr->GetQuestLocale(questId))
1203 ObjectMgr::GetLocaleString(localeData->LogTitle, handler->GetSessionDbLocaleIndex(), name);
1204 }
1205 if (name.empty())
1206 name = "Unknown quest";
1207 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_TRACKING_QUEST, alternateString ? 6 : 3 /*number of bytes from following string*/, "\xE2\x94\x80\xE2\x94\x80",
1208 questId, STRING_VIEW_FMT_ARG(name), questId);
1209 }
1210
1211 static void _IterateNotNormalLootMap(ChatHandler* handler, NotNormalLootItemMap const& map, std::vector<LootItem> const& items)
1212 {
1213 for (NotNormalLootItemMap::value_type const& pair : map)
1214 {
1215 if (!pair.second)
1216 continue;
1217 Player const* player = ObjectAccessor::FindConnectedPlayer(pair.first);
1218 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL, player ? player->GetName() : Trinity::StringFormat("Offline player (GUID {})", pair.first.ToString()), pair.second->size());
1219
1220 for (auto it = pair.second->cbegin(); it != pair.second->cend(); ++it)
1221 {
1222 LootItem const& item = items[it->LootListId];
1223 if (!it->is_looted && !item.is_looted)
1224 {
1225 switch (item.type)
1226 {
1227 case LootItemType::Item:
1228 _ShowLootEntry(handler, item.itemid, item.count, true);
1229 break;
1231 _ShowLootCurrencyEntry(handler, item.itemid, item.count, true);
1232 break;
1234 _ShowLootTrackingQuestCurrencyEntry(handler, item.itemid, true);
1235 break;
1236 }
1237 }
1238 }
1239 }
1240 }
1241
1242 static void _ShowLootContents(ChatHandler* handler, bool all, Loot const* loot)
1243 {
1244 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_MONEY, loot->gold / GOLD, (loot->gold % GOLD) / SILVER, loot->gold % SILVER);
1245
1246 if (!all)
1247 {
1248 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_LABEL, "Standard items", loot->items.size());
1249 for (LootItem const& item : loot->items)
1250 {
1251 if (!item.is_looted)
1252 {
1253 switch (item.type)
1254 {
1255 case LootItemType::Item:
1256 _ShowLootEntry(handler, item.itemid, item.count);
1257 break;
1259 _ShowLootCurrencyEntry(handler, item.itemid, item.count);
1260 break;
1262 _ShowLootTrackingQuestCurrencyEntry(handler, item.itemid);
1263 break;
1264 }
1265 }
1266 }
1267 }
1268 else
1269 {
1270 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_LABEL, "Standard items", loot->items.size());
1271 for (LootItem const& item : loot->items)
1272 {
1273 if (!item.is_looted && !item.freeforall && item.conditions.IsEmpty())
1274 {
1275 switch (item.type)
1276 {
1277 case LootItemType::Item:
1278 _ShowLootEntry(handler, item.itemid, item.count);
1279 break;
1281 _ShowLootCurrencyEntry(handler, item.itemid, item.count);
1282 break;
1284 _ShowLootTrackingQuestCurrencyEntry(handler, item.itemid);
1285 break;
1286 }
1287 }
1288 }
1289
1290 if (!loot->GetPlayerFFAItems().empty())
1291 {
1292 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_LABEL_2, "FFA items per allowed player");
1293 _IterateNotNormalLootMap(handler, loot->GetPlayerFFAItems(), loot->items);
1294 }
1295 }
1296 }
1297
1299 {
1300 Creature* creatureTarget = handler->getSelectedCreature();
1301 if (!creatureTarget || creatureTarget->IsPet())
1302 {
1304 handler->SetSentErrorMessage(true);
1305 return false;
1306 }
1307
1308 if (!creatureTarget->isDead())
1309 {
1310 handler->PSendSysMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName().c_str());
1311 handler->SetSentErrorMessage(true);
1312 return false;
1313 }
1314
1315 Loot const* loot = creatureTarget->m_loot.get();
1316 if ((!loot || loot->isLooted())
1317 && !std::ranges::count_if(creatureTarget->m_personalLoot, std::not_fn(&Loot::isLooted), Trinity::Containers::MapValue))
1318 {
1319 handler->PSendSysMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName().c_str());
1320 handler->SetSentErrorMessage(true);
1321 return false;
1322 }
1323
1324 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_HEADER, creatureTarget->GetName().c_str(), creatureTarget->GetEntry());
1325
1326 if (loot)
1327 _ShowLootContents(handler, all.has_value(), loot);
1328 else
1329 {
1330 for (auto const& [lootOwner, personalLoot] : creatureTarget->m_personalLoot)
1331 {
1332 CharacterCacheEntry const* character = sCharacterCache->GetCharacterCacheByGuid(lootOwner);
1333 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_LABEL_2, Trinity::StringFormat("Personal loot for {}", character ? character->Name : ""sv));
1334 _ShowLootContents(handler, all.has_value(), personalLoot.get());
1335 }
1336 }
1337
1338 return true;
1339 }
1340
1341 static bool HandleNpcAddFormationCommand(ChatHandler* handler, ObjectGuid::LowType leaderGUID, Optional<bool> linkedAggro, Optional<bool> formationMovement)
1342 {
1343 Creature* creature = handler->getSelectedCreature();
1344
1345 if (!creature || !creature->GetSpawnId())
1346 {
1348 handler->SetSentErrorMessage(true);
1349 return false;
1350 }
1351
1352 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1353 if (creature->GetFormation())
1354 {
1355 handler->PSendSysMessage("Selected creature is already member of group " UI64FMTD, creature->GetFormation()->GetLeaderSpawnId());
1356 return false;
1357 }
1358
1359 if (!lowguid)
1360 return false;
1361
1362 Player* chr = handler->GetSession()->GetPlayer();
1363
1364 float followAngle = creature->GetRelativeAngle(chr) * 180.0f / float(M_PI);
1365 float followDist = chr->GetExactDist2d(creature);
1366 uint32 groupAI = 0;
1367 if (linkedAggro == true)
1368 groupAI |= FLAG_MEMBERS_ASSIST_MEMBER;
1369 if (formationMovement == true)
1370 groupAI |= FLAG_IDLE_IN_FORMATION;
1371
1372 sFormationMgr->AddFormationMember(lowguid, followAngle, followDist, leaderGUID, groupAI);
1373 creature->SearchFormation();
1374
1376 stmt->setUInt64(0, leaderGUID);
1377 stmt->setUInt64(1, lowguid);
1378 stmt->setFloat (2, followDist);
1379 stmt->setFloat (3, followAngle);
1380 stmt->setUInt32(4, groupAI);
1381
1382 WorldDatabase.Execute(stmt);
1383
1384 handler->PSendSysMessage("Creature " UI64FMTD " added to formation with leader " UI64FMTD, lowguid, leaderGUID);
1385
1386 return true;
1387 }
1388
1390 {
1391 Creature* creature = handler->getSelectedCreature();
1392
1393 if (!creature)
1394 {
1396 handler->SetSentErrorMessage(true);
1397 return false;
1398 }
1399
1400 if (!creature->GetSpawnId())
1401 {
1402 handler->PSendSysMessage("Selected %s isn't in creature table", creature->GetGUID().ToString().c_str());
1403 handler->SetSentErrorMessage(true);
1404 return false;
1405 }
1406
1407 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1408 {
1409 handler->PSendSysMessage("Selected creature can't link with guid '" UI64FMTD "'", linkguid);
1410 handler->SetSentErrorMessage(true);
1411 return false;
1412 }
1413
1414 handler->PSendSysMessage("LinkGUID '" UI64FMTD "' added to creature with DBTableGUID: '" UI64FMTD "'", linkguid, creature->GetSpawnId());
1415 return true;
1416 }
1417
1419 static bool HandleNpcAddWeaponCommand([[maybe_unused]] ChatHandler* handler, [[maybe_unused]] uint32 SlotID, [[maybe_unused]] ItemTemplate const* tmpItem)
1420 {
1421 /*
1422 if (!tmpItem)
1423 return;
1424
1425 uint64 guid = handler->GetSession()->GetPlayer()->GetSelection();
1426 if (guid == 0)
1427 {
1428 handler->SendSysMessage(LANG_NO_SELECTION);
1429 handler->SetSentErrorMessage(true);
1430 return false;
1431 }
1432
1433 Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid);
1434
1435 if (!creature)
1436 {
1437 handler->SendSysMessage(LANG_SELECT_CREATURE);
1438 handler->SetSentErrorMessage(true);
1439 return false;
1440 }
1441
1442 switch (SlotID)
1443 {
1444 case 1:
1445 creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, tmpItem->ItemId);
1446 break;
1447 case 2:
1448 creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, tmpItem->ItemId);
1449 break;
1450 case 3:
1451 creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, tmpItem->ItemId);
1452 break;
1453 default:
1454 handler->PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST, SlotID);
1455 handler->SetSentErrorMessage(true);
1456 return false;
1457 }
1458
1459 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT, tmpItem->ItemID, tmpItem->Name1, SlotID);
1460 */
1461 return true;
1462 }
1463};
1464
1466{
1467 new npc_commandscript();
1468}
1469
1470bool HandleNpcSpawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")>> const& opts)
1471{
1472 if (opts.empty())
1473 return false;
1474
1475 bool ignoreRespawn = false;
1476 bool force = false;
1477 uint32 groupId = 0;
1478
1479 // Decode arguments
1480 for (auto const& variant : opts)
1481 {
1482 switch (variant.index())
1483 {
1484 case 0:
1485 groupId = variant.get<uint32>();
1486 break;
1487 case 1:
1488 force = true;
1489 break;
1490 case 2:
1491 ignoreRespawn = true;
1492 break;
1493 }
1494 }
1495
1496 Player* player = handler->GetSession()->GetPlayer();
1497
1498 std::vector <WorldObject*> creatureList;
1499 if (!player->GetMap()->SpawnGroupSpawn(groupId, ignoreRespawn, force, &creatureList))
1500 {
1501 handler->PSendSysMessage(LANG_SPAWNGROUP_BADGROUP, groupId);
1502 handler->SetSentErrorMessage(true);
1503 return false;
1504 }
1505
1506 handler->PSendSysMessage(LANG_SPAWNGROUP_SPAWNCOUNT, creatureList.size());
1507
1508 return true;
1509}
1510
1511bool HandleNpcDespawnGroup(ChatHandler* handler, std::vector<Variant<uint32, EXACT_SEQUENCE("removerespawntime")>> const& opts)
1512{
1513 if (opts.empty())
1514 return false;
1515
1516 bool deleteRespawnTimes = false;
1517 uint32 groupId = 0;
1518
1519 // Decode arguments
1520 for (auto const& variant : opts)
1521 {
1522 if (variant.holds_alternative<uint32>())
1523 groupId = variant.get<uint32>();
1524 else
1525 deleteRespawnTimes = true;
1526 }
1527
1528 Player* player = handler->GetSession()->GetPlayer();
1529
1530 size_t n = 0;
1531 if (!player->GetMap()->SpawnGroupDespawn(groupId, deleteRespawnTimes, &n))
1532 {
1533 handler->PSendSysMessage(LANG_SPAWNGROUP_BADGROUP, groupId);
1534 handler->SetSentErrorMessage(true);
1535 return false;
1536 }
1537 handler->PSendSysMessage("Despawned a total of %zu objects.", n);
1538
1539 return true;
1540}
#define sCharacterCache
#define EXACT_SEQUENCE(str)
@ LOCALE_enUS
Definition Common.h:52
#define M_PI
Definition Common.h:118
CreatureFlagsExtra
@ FLAG_MEMBERS_ASSIST_MEMBER
@ FLAG_IDLE_IN_FORMATION
#define sFormationMgr
DB2Storage< CurrencyTypesEntry > sCurrencyTypesStore("CurrencyTypes.db2", &CurrencyTypesLoadInfo::Instance)
DB2Storage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore("CreatureDisplayInfo.db2", &CreatureDisplayInfoLoadInfo::Instance)
DB2Storage< FactionTemplateEntry > sFactionTemplateStore("FactionTemplate.db2", &FactionTemplateLoadInfo::Instance)
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define UI64FMTD
Definition Define.h:138
uint8_t uint8
Definition Define.h:156
#define STRING_VIEW_FMT_ARG(str)
Definition Define.h:147
int64_t int64
Definition Define.h:149
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
#define UI64LIT(N)
Definition Define.h:139
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
@ ITEM_VENDOR_TYPE_ITEM
@ LANG_NPCINFO_EQUIPMENT
Definition Language.h:1101
@ LANG_NPC_SETDATA
Definition Language.h:636
@ LANG_OBJECTINFO_STRINGIDS
Definition Language.h:1162
@ LANG_COMMAND_NPC_SHOWLOOT_ENTRY
Definition Language.h:342
@ LANG_OBJECTINFO_AIINFO
Definition Language.h:1096
@ LANG_SELECT_CREATURE
Definition Language.h:32
@ LANG_SPAWNGROUP_SPAWNCOUNT
Definition Language.h:1149
@ LANG_CREATURE_NON_TAMEABLE
Definition Language.h:398
@ LANG_CREATURE_NOT_FOLLOW_YOU
Definition Language.h:396
@ LANG_ERROR
Definition Language.h:78
@ LANG_CREATURE_FOLLOW_YOU_NOW
Definition Language.h:395
@ LANG_YOU_ALREADY_HAVE_PET
Definition Language.h:399
@ LANG_WAYPOINT_ADDED
Definition Language.h:281
@ LANG_NPCINFO_LOOT
Definition Language.h:621
@ LANG_OBJECTINFO_AITYPE
Definition Language.h:1156
@ LANG_CREATURE_NOT_AI_ENABLED
Definition Language.h:1250
@ LANG_CREATURE_MOVE_ENABLED
Definition Language.h:462
@ LANG_NPCINFO_DYNAMIC_FLAGS
Definition Language.h:620
@ LANG_COMMAND_NOT_DEAD_OR_NO_LOOT
Definition Language.h:339
@ LANG_NPCINFO_POSITION
Definition Language.h:622
@ LANG_NPCINFO_UNIT_FIELD_FLAGS
Definition Language.h:1103
@ LANG_VALUE_SAVED_REJOIN
Definition Language.h:311
@ LANG_COMMAND_CREATUREMOVED
Definition Language.h:322
@ LANG_MOVE_TYPE_SET
Definition Language.h:307
@ LANG_NPCINFO_REACTSTATE
Definition Language.h:1083
@ LANG_COMMAND_NPC_SHOWLOOT_CURRENCY
Definition Language.h:347
@ LANG_COMMAND_DELCREATMESSAGE
Definition Language.h:321
@ LANG_CREATURE_NOT_FOLLOW_YOU_NOW
Definition Language.h:397
@ LANG_WRONG_FACTION
Definition Language.h:165
@ LANG_COMMAND_CREATUREATSAMEMAP
Definition Language.h:323
@ LANG_COMMAND_NEAR_NPC_MESSAGE
Old ones now free:
Definition Language.h:639
@ LANG_COMMAND_NEEDITEMSEND
Definition Language.h:330
@ LANG_NPCINFO_UNIT_FIELD_FLAGS_2
Definition Language.h:1157
@ LANG_NPCINFO_HEALTH
Definition Language.h:619
@ LANG_COMMAND_VENDORSELECTION
Definition Language.h:329
@ LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL
Definition Language.h:345
@ LANG_NPCINFO_PHASES
Definition Language.h:1085
@ LANG_CREATURE_MOVE_DISABLED
Definition Language.h:461
@ LANG_NPCINFO_NPC_FLAGS
Definition Language.h:1159
@ LANG_ITEM_ADDED_TO_LIST
Definition Language.h:250
@ LANG_NPCINFO_MOVEMENT_DATA
Definition Language.h:1242
@ LANG_COMMAND_SPAWNTIME
Definition Language.h:351
@ LANG_NPCINFO_CHAR
Definition Language.h:617
@ LANG_ITEM_DELETED_FROM_LIST
Definition Language.h:252
@ LANG_MOVE_TYPE_SET_NODEL
Definition Language.h:308
@ LANG_COMMAND_NPC_SHOWLOOT_TRACKING_QUEST
Definition Language.h:346
@ LANG_COMMAND_INVALID_PARAM
Definition Language.h:364
@ LANG_SPAWNINFO_GROUP_ID
Definition Language.h:1143
@ LANG_COMMAND_WANDER_DISTANCE
Definition Language.h:350
@ LANG_COMMAND_CREATGUIDNOTFOUND
Definition Language.h:338
@ LANG_BAD_VALUE
Definition Language.h:149
@ LANG_NPCINFO_UNIT_FIELD_FLAGS_3
Definition Language.h:1158
@ LANG_NPCINFO_LEVEL
Definition Language.h:618
@ LANG_ITEM_NOT_IN_LIST
Definition Language.h:253
@ LANG_NPCINFO_FLAGS_EXTRA
Definition Language.h:1243
@ LANG_DONE
Definition Language.h:75
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:589
@ LANG_SPAWNINFO_COMPATIBILITY_MODE
Definition Language.h:1144
@ LANG_COMMAND_RAWPAWNTIMES
Definition Language.h:669
@ LANG_COMMAND_NPC_SHOWLOOT_LABEL
Definition Language.h:341
@ LANG_NPCINFO_ARMOR
Definition Language.h:1086
@ LANG_SPAWNGROUP_BADGROUP
Definition Language.h:1148
@ LANG_COMMAND_NPC_SHOWLOOT_LABEL_2
Definition Language.h:344
@ LANG_COMMAND_NPC_SHOWLOOT_HEADER
Definition Language.h:340
@ LANG_NPCINFO_DUNGEON_ID
Definition Language.h:625
@ LANG_NPCINFO_MECHANIC_IMMUNE
Definition Language.h:1102
@ LANG_COMMAND_NPC_SHOWLOOT_MONEY
Definition Language.h:343
@ LANG_PHASE_NOTFOUND
Definition Language.h:1071
std::unordered_map< ObjectGuid, std::unique_ptr< NotNormalLootItemList > > NotNormalLootItemMap
Definition Loot.h:236
MovementGeneratorType
@ IDLE_MOTION_TYPE
@ WAYPOINT_MOTION_TYPE
@ FOLLOW_MOTION_TYPE
@ RANDOM_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
#define CONTACT_DISTANCE
@ TYPEID_UNIT
Definition ObjectGuid.h:43
#define sObjectMgr
Definition ObjectMgr.h:1885
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
#define PET_FOLLOW_DIST
Definition PetDefines.h:98
@ PET_SAVE_AS_CURRENT
Definition PetDefines.h:43
Role Based Access Control related classes definition.
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ LANG_UNIVERSAL
ItemQualities
@ ITEM_QUALITY_POOR
@ EMOTE_ONESHOT_EXCLAMATION
@ EMOTE_ONESHOT_QUESTION
@ EMOTE_ONESHOT_SHOUT
@ EMOTE_ONESHOT_TALK
Mechanics
@ SILVER
@ GOLD
TC_COMMON_API bool StringEqualI(std::string_view str1, std::string_view str2)
Definition Util.cpp:849
UnitFlags2
@ REACT_DEFENSIVE
NPCFlags
Non Player Character flags.
UnitFlags3
NPCFlags2
char const * DescribeReactState(ReactStates state)
UnitFlags
@ JUST_DIED
Definition Unit.h:253
@ UNIT_STATE_EVADE
Definition Unit.h:283
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
Definition Util.cpp:116
@ WORLD_UPD_CREATURE_POSITION
@ WORLD_UPD_CREATURE_NPCFLAG
@ WORLD_SEL_CREATURE_NEAREST
@ WORLD_INS_CREATURE_FORMATION
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
@ WORLD_UPD_CREATURE_FACTION
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
Unit * getSelectedUnit()
Definition Chat.cpp:216
virtual LocaleConstant GetSessionDbLocaleIndex() const
Definition Chat.cpp:598
WorldSession * GetSession()
Definition Chat.h:42
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:593
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:401
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition Chat.cpp:61
Creature * getSelectedCreature()
Definition Chat.cpp:240
void SetSentErrorMessage(bool val)
Definition Chat.h:127
void PSendSysMessage(char const *fmt, Args &&... args)
Definition Chat.h:62
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:111
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
ObjectGuid::LowType GetLeaderSpawnId() const
int8 GetOriginalEquipmentId() const
Definition Creature.h:254
void Respawn(bool force=false)
void UpdateLevelDependantStats()
void setDeathState(DeathState s) override
static Creature * CreateCreatureFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true, bool allowDuplicate=false)
bool GetRespawnCompatibilityMode() const
Definition Creature.h:423
std::unique_ptr< Loot > m_loot
Definition Creature.h:299
CreatureDifficulty const * GetCreatureDifficulty() const
Definition Creature.h:268
std::unordered_map< ObjectGuid, std::unique_ptr< Loot > > m_personalLoot
Definition Creature.h:300
static Creature * CreateCreature(uint32 entry, Map *map, Position const &pos, uint32 vehId=0)
void SetReactState(ReactStates st)
Definition Creature.h:174
void SetRespawnDelay(uint32 delay)
Definition Creature.h:360
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool updateLevel=true)
Definition Creature.cpp:593
CreatureData const * GetCreatureData() const
Definition Creature.h:267
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:110
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:266
uint32 GetRespawnDelay() const
Definition Creature.h:359
static bool DeleteFromDB(ObjectGuid::LowType spawnId)
CreatureGroup * GetFormation()
Definition Creature.h:406
std::string_view GetStringId(StringIdType type) const
Definition Creature.h:277
void SearchFormation()
Definition Creature.cpp:393
void SetDisplayId(uint32 displayId, bool setNative=false) override
ReactStates GetReactState() const
Definition Creature.h:175
void SetWanderDistance(float dist)
Definition Creature.h:363
std::string GetScriptName() const
uint8 GetCurrentEquipmentId() const
Definition Creature.h:255
void SaveToDB()
CreatureMovementData const & GetMovementTemplate() const
time_t GetRespawnTimeEx() const
std::string const & GetAIName() const
CreatureAI * AI() const
Definition Creature.h:228
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition Creature.h:164
void LoadPath(uint32 pathid)
Definition Creature.h:397
static char const * ToTitle(Enum value)
Definition SmartEnum.h:124
Class used to access individual fields of database query result.
Definition Field.h:94
float GetFloat() const noexcept
Definition Field.cpp:85
uint64 GetUInt64() const noexcept
Definition Field.cpp:71
uint32 GetUInt32() const noexcept
Definition Field.cpp:57
uint16 GetUInt16() const noexcept
Definition Field.cpp:43
Definition Map.h:225
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2350
bool AddToMap(T *)
Definition Map.cpp:517
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:524
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2476
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
Definition Map.cpp:2439
uint32 GetId() const
Definition Map.cpp:3257
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
MovementGenerator * GetMovementGenerator(std::function< bool(MovementGenerator const *)> const &filter, MovementSlot slot=MOTION_SLOT_ACTIVE) const
void Remove(MovementGenerator *movement, MovementSlot slot=MOTION_SLOT_ACTIVE)
virtual MovementGeneratorType GetMovementGeneratorType() const =0
static ObjectGuid const Empty
Definition ObjectGuid.h:314
bool IsEmpty() const
Definition ObjectGuid.h:362
std::string ToString() const
uint64 LowType
Definition ObjectGuid.h:321
static std::string_view GetLocaleString(std::vector< std::string > const &data, LocaleConstant locale)
Definition ObjectMgr.h:1611
uint32 GetEntry() const
Definition Object.h:89
uint32 GetDynamicFlags() const
Definition Object.h:95
Creature * ToCreature()
Definition Object.h:121
Definition Pet.h:40
void SavePetToDB(PetSaveMode mode)
Definition Pet.cpp:451
static void PrintToChat(ChatHandler *chat, WorldObject const *target)
static void AddPhase(WorldObject *object, uint32 phaseId, bool updateVisibility)
static void AddPhaseGroup(WorldObject *object, uint32 phaseGroupId, bool updateVisibility)
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
static void ResetPhaseShift(WorldObject *object)
bool CanTameExoticPets() const
Definition Player.h:2496
void PetSpellInitialize()
Definition Player.cpp:22471
void setUInt16(uint8 index, uint16 value)
void setUInt32(uint8 index, uint32 value)
void setFloat(uint8 index, float value)
void setUInt64(uint8 index, uint64 value)
void setUInt8(uint8 index, uint8 value)
std::string const & GetLogTitle() const
Definition QuestDef.h:666
static CreatureImmunities const * GetCreatureImmunities(int32 creatureImmunitiesId)
Definition SpellMgr.cpp:687
virtual void SetData(uint32 id, uint32 value)
Definition UnitAI.h:75
Definition Unit.h:635
void ClearUnitState(uint32 f)
Definition Unit.h:744
void SetMinion(Minion *minion, bool apply)
Definition Unit.cpp:6247
bool HasUnitFlag3(UnitFlags3 flags) const
Definition Unit.h:855
void ReplaceAllNpcFlags2(NPCFlags2 flags)
Definition Unit.h:1005
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:14332
NPCFlags GetNpcFlags() const
Definition Unit.h:995
void SetFaction(uint32 faction) override
Definition Unit.h:872
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:14337
Pet * CreateTamedPetFrom(Creature *creatureTarget, uint32 spell_id=0)
Definition Unit.cpp:11072
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsPet() const
Definition Unit.h:751
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:845
NPCFlags2 GetNpcFlags2() const
Definition Unit.h:1001
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:10328
bool HasUnitFlag2(UnitFlags2 flags) const
Definition Unit.h:850
bool IsAlive() const
Definition Unit.h:1185
float GetCombatReach() const override
Definition Unit.h:705
TempSummon * ToTempSummon()
Definition Unit.h:1828
bool HasNpcFlag2(NPCFlags2 flags) const
Definition Unit.h:1002
void SetEmoteState(Emote emote)
Definition Unit.h:865
uint32 GetDisplayId() const
Definition Unit.h:1610
bool IsAIEnabled() const
Definition Unit.h:666
uint32 GetNativeDisplayId() const
Definition Unit.h:1613
uint64 GetMaxHealth() const
Definition Unit.h:789
uint64 GetHealth() const
Definition Unit.h:788
uint32 GetFaction() const override
Definition Unit.h:871
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:14342
uint32 GetCreateHealth() const
Definition Unit.h:1415
bool HasNpcFlag(NPCFlags flags) const
Definition Unit.h:996
uint32 GetArmor() const
Definition Unit.h:774
virtual float GetFollowAngle() const
Definition Unit.h:1816
UF::UpdateField< UF::UnitData, int32(WowCS::EntityFragment::CGObject), TYPEID_UNIT > m_unitData
Definition Unit.h:1881
void SetLevel(uint8 lvl, bool sendUpdate=true)
Definition Unit.cpp:9956
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1657
bool IsVendor() const
Definition Unit.h:1007
bool IsTotem() const
Definition Unit.h:753
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:999
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:14347
uint8 GetLevel() const
Definition Unit.h:757
ObjectGuid GetPetGUID() const
Definition Unit.h:1197
bool isDead() const
Definition Unit.h:1187
constexpr uint32 GetMapId() const
Definition Position.h:216
Map * GetMap() const
Definition Object.h:411
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition Object.cpp:2749
float GetTransOffsetX() const
Definition Object.h:538
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
TransportBase * GetTransport() const
Definition Object.h:537
uint32 GetInstanceId() const
Definition Object.h:308
float GetTransOffsetY() const
Definition Object.h:539
std::string const & GetName() const
Definition Object.h:342
float GetTransOffsetZ() const
Definition Object.h:540
float GetTransOffsetO() const
Definition Object.h:541
void SetDBPhase(int32 p)
Definition Object.h:330
Player * GetPlayer() const
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition cs_npc.cpp:872
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:123
static bool HandleNpcTameCommand(ChatHandler *handler)
Definition cs_npc.cpp:1080
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:958
static void _IterateNotNormalLootMap(ChatHandler *handler, NotNormalLootItemMap const &map, std::vector< LootItem > const &items)
Definition cs_npc.cpp:1211
static bool HandleNpcDeleteCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnIdArg)
Definition cs_npc.cpp:302
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition cs_npc.cpp:684
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1035
static bool HandleNpcSetFlagCommand(ChatHandler *handler, NPCFlags npcFlags, NPCFlags2 npcFlags2)
Definition cs_npc.cpp:407
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:452
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, uint32 spawnTime)
Definition cs_npc.cpp:914
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< std::string_view > bonusListIDs)
Definition cs_npc.cpp:170
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition cs_npc.cpp:668
static bool HandleNpcSetMoveTypeCommand(ChatHandler *handler, Optional< CreatureSpawnId > lowGuid, Variant< EXACT_SEQUENCE("stay"), EXACT_SEQUENCE("random"), EXACT_SEQUENCE("way")> type, Optional< EXACT_SEQUENCE("nodel")> nodel)
Definition cs_npc.cpp:721
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:978
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
Definition cs_npc.cpp:278
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition cs_npc.cpp:242
static bool HandleNpcShowLootCommand(ChatHandler *handler, Optional< EXACT_SEQUENCE("all")> all)
Definition cs_npc.cpp:1298
static void _ShowLootContents(ChatHandler *handler, bool all, Loot const *loot)
Definition cs_npc.cpp:1242
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phaseID)
Definition cs_npc.cpp:845
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID, Optional< bool > linkedAggro, Optional< bool > formationMovement)
Definition cs_npc.cpp:1341
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:931
static bool HandleNpcInfoCommand(ChatHandler *handler)
Definition cs_npc.cpp:471
static bool HandleNpcAddWeaponCommand(ChatHandler *handler, uint32 SlotID, ItemTemplate const *tmpItem)
Definition cs_npc.cpp:1419
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
Definition cs_npc.cpp:571
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item)
Definition cs_npc.cpp:339
static bool HandleNpcEvadeCommand(ChatHandler *handler, Optional< EvadeReason > why, Optional< EXACT_SEQUENCE("force")> force)
Definition cs_npc.cpp:1146
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
Definition cs_npc.cpp:434
static void _ShowLootCurrencyEntry(ChatHandler *handler, uint32 currencyId, uint32 count, bool alternateString=false)
Definition cs_npc.cpp:1182
static void _ShowLootTrackingQuestCurrencyEntry(ChatHandler *handler, uint32 questId, bool alternateString=false)
Definition cs_npc.cpp:1194
static bool HandleNpcSetPhaseGroup(ChatHandler *handler, char const *args)
Definition cs_npc.cpp:819
static void _ShowLootEntry(ChatHandler *handler, uint32 itemId, uint32 itemCount, bool alternateString=false)
Definition cs_npc.cpp:1170
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition cs_npc.cpp:1389
std::span< ChatCommandBuilder const > GetCommands() const override
Definition cs_npc.cpp:67
static bool HandleNpcWhisperCommand(ChatHandler *handler, Variant< Hyperlink< player >, std::string_view > recv, Tail text)
Definition cs_npc.cpp:1013
static bool HandleNpcMoveCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnid)
Definition cs_npc.cpp:618
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition cs_npc.cpp:369
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition cs_npc.cpp:257
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition cs_npc.cpp:218
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, Optional< std::string_view > lootStr, CreatureEntry id)
Definition cs_npc.cpp:1057
bool HandleNpcSpawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")> > const &opts)
Definition cs_npc.cpp:1470
void AddSC_npc_commandscript()
Definition cs_npc.cpp:1465
bool HandleNpcDespawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("removerespawntime")> > const &opts)
Definition cs_npc.cpp:1511
#define sWorld
Definition World.h:916
@ CONFIG_MAX_PLAYER_LEVEL
Definition World.h:262
time_t GetGameTime()
Definition GameTime.cpp:52
TC_GAME_API Player * FindPlayerByName(std::string_view name)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
ChatCommandBuilder const [] ChatCommandTable
Definition ChatCommand.h:49
constexpr auto MapValue
Definition MapUtils.h:77
std::string ToString(Type &&val, Params &&... params)
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Util.cpp:57
std::string GetTypeName()
Definition Util.h:588
std::string StringFormat(FormatString< Args... > fmt, Args &&... args) noexcept
Default TC string format function.
@ RBAC_PERM_COMMAND_NPC_SET_LEVEL
Definition RBAC.h:457
@ RBAC_PERM_COMMAND_NPC_PLAYEMOTE
Definition RBAC.h:468
@ RBAC_PERM_COMMAND_NPC_FOLLOW
Definition RBAC.h:450
@ RBAC_PERM_COMMAND_NPC_EVADE
Definition RBAC.h:708
@ RBAC_PERM_COMMAND_NPC_INFO
Definition RBAC.h:465
@ RBAC_PERM_COMMAND_NPC_TEXTEMOTE
Definition RBAC.h:470
@ RBAC_PERM_COMMAND_NPC_ADD_FORMATION
Definition RBAC.h:444
@ RBAC_PERM_COMMAND_NPC_ADD
Definition RBAC.h:443
@ RBAC_PERM_COMMAND_NPC_NEAR
Definition RBAC.h:466
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST
Definition RBAC.h:462
@ RBAC_PERM_COMMAND_NPC_SET_PHASE
Definition RBAC.h:461
@ RBAC_PERM_COMMAND_NPC_DELETE
Definition RBAC.h:448
@ RBAC_PERM_COMMAND_NPC_SET_ENTRY
Definition RBAC.h:454
@ RBAC_PERM_COMMAND_NPC_DESPAWNGROUP
Definition RBAC.h:727
@ RBAC_PERM_COMMAND_NPC_TAME
Definition RBAC.h:473
@ RBAC_PERM_COMMAND_NPC_MOVE
Definition RBAC.h:467
@ RBAC_PERM_COMMAND_NPC_ADD_ITEM
Definition RBAC.h:445
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME
Definition RBAC.h:463
@ RBAC_PERM_COMMAND_NPC_SET_FACTIONID
Definition RBAC.h:455
@ RBAC_PERM_COMMAND_NPC_SET_MOVETYPE
Definition RBAC.h:460
@ RBAC_PERM_COMMAND_NPC_SPAWNGROUP
Definition RBAC.h:726
@ RBAC_PERM_COMMAND_NPC_SET_DATA
Definition RBAC.h:464
@ RBAC_PERM_COMMAND_NPC_SHOWLOOT
Definition RBAC.h:735
@ RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE
Definition RBAC.h:453
@ RBAC_PERM_COMMAND_NPC_SET_MODEL
Definition RBAC.h:459
@ RBAC_PERM_COMMAND_NPC_ADD_MOVE
Definition RBAC.h:446
@ RBAC_PERM_COMMAND_NPC_SET_LINK
Definition RBAC.h:458
@ RBAC_PERM_COMMAND_NPC_WHISPER
Definition RBAC.h:471
@ RBAC_PERM_COMMAND_NPC_SET_FLAG
Definition RBAC.h:456
@ RBAC_PERM_COMMAND_NPC_YELL
Definition RBAC.h:472
@ RBAC_PERM_COMMAND_NPC_SAY
Definition RBAC.h:469
@ RBAC_PERM_COMMAND_NPC_ADD_TEMP
Definition RBAC.h:447
@ RBAC_PERM_COMMAND_NPC_DELETE_ITEM
Definition RBAC.h:449
std::string ToString() const
Definition Creature.cpp:62
std::string Name
bool IsTameable(bool canTameExotic, CreatureDifficulty const *creatureDifficulty) const
LocalizedString Name
uint32 GetQuality() const
uint32 GetId() const
char const * GetName(LocaleConstant locale) const
char const * GetDefaultLocaleName() const
uint32 itemid
Definition Loot.h:178
uint32 count
Definition Loot.h:186
bool is_looted
Definition Loot.h:188
LootItemType type
Definition Loot.h:187
Definition Loot.h:286
bool isLooted() const
Definition Loot.h:312
uint32 gold
Definition Loot.h:290
std::vector< LootItem > items
Definition Loot.h:289
NotNormalLootItemMap const & GetPlayerFFAItems() const
Definition Loot.h:287
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
float GetExactDist2d(const float x, const float y) const
Definition Position.h:117
float GetRelativeAngle(float x, float y) const
Definition Position.h:147
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr void Relocate(float x, float y)
Definition Position.h:74
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
uint32 id
Definition SpawnData.h:135
Position spawnPoint
Definition SpawnData.h:136
SpawnGroupFlags flags
Definition SpawnData.h:72
SpawnGroupTemplateData const * spawnGroupData
Definition SpawnData.h:124
uint64 spawnId
Definition SpawnData.h:121
uint32 ExtendedCost
uint32 maxcount
std::vector< int32 > BonusListIDs
uint32 incrtime