AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
npc_commandscript Class Reference
Inheritance diagram for npc_commandscript:
CommandScript ScriptObject

Public Member Functions

 npc_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
std::string const & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleNpcAddCommand (ChatHandler *handler, CreatureEntry id)
 
static bool HandleNpcLoadCommand (ChatHandler *handler, CreatureSpawnId spawnId)
 
static bool HandleNpcAddVendorItemCommand (ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< bool > addMulti)
 
static bool HandleNpcAddMoveCommand (ChatHandler *handler, CreatureSpawnId lowGuid)
 
static bool HandleNpcSetAllowMovementCommand (ChatHandler *handler)
 
static bool HandleNpcSetEntryCommand (ChatHandler *handler, CreatureEntry newEntryNum)
 
static bool HandleNpcSetLevelCommand (ChatHandler *handler, uint8 lvl)
 
static bool HandleNpcDeleteCommand (ChatHandler *handler, Optional< ObjectGuid::LowType > lowGuid)
 
static bool HandleNpcDeleteVendorItemCommand (ChatHandler *handler, ItemTemplate const *item, Optional< bool > addMulti)
 
static bool HandleNpcSetFactionIdCommand (ChatHandler *handler, uint32 factionId)
 
static bool HandleNpcSetFactionTempIdCommand (ChatHandler *handler, uint32 tempfaction)
 
static bool HandleNpcSetOriginalFaction (ChatHandler *handler)
 
static bool HandleNpcSetFlagCommand (ChatHandler *handler, uint32 npcFlags)
 
static bool HandleNpcSetDataCommand (ChatHandler *handler, uint32 data_1, uint32 data_2)
 
static bool HandleNpcFollowCommand (ChatHandler *handler)
 
static bool HandleNpcInfoCommand (ChatHandler *handler, Optional< CreatureSpawnId > spawnIdArg)
 
static bool HandleNpcInfoCommandShowCreature (ChatHandler *handler, Creature *target)
 
static bool HandleNpcInfoCommandShowFromDB (ChatHandler *handler, ObjectGuid::LowType lowGuid, CreatureData const *cData)
 
static bool HandleNpcGuidCommand (ChatHandler *handler)
 
static bool HandleNpcNearCommand (ChatHandler *handler, Optional< float > dist)
 
static bool HandleNpcMoveCommand (ChatHandler *handler, Optional< ObjectGuid::LowType > guid)
 
static bool HandleNpcPlayEmoteCommand (ChatHandler *handler, uint32 emote)
 
static bool HandleNpcSetModelCommand (ChatHandler *handler, uint32 displayId)
 
static bool HandleNpcSetMoveTypeCommand (ChatHandler *handler, Optional< CreatureSpawnId > lowGuid, Variant< EXACT_SEQUENCE("stay"), EXACT_SEQUENCE("random"), EXACT_SEQUENCE("way")> type, Optional< EXACT_SEQUENCE("nodel")> nodel)
 
static bool HandleNpcSetPhaseCommand (ChatHandler *handler, uint32 phasemask)
 
static bool HandleNpcSetWanderDistanceCommand (ChatHandler *handler, float option)
 
static bool HandleNpcSetSpawnTimeCommand (ChatHandler *handler, std::string spawnTimeStr)
 
static bool HandleNpcSayCommand (ChatHandler *handler, Tail text)
 
static bool HandleNpcTextEmoteCommand (ChatHandler *handler, Tail text)
 
static bool HandleNpcUnFollowCommand (ChatHandler *handler)
 
static bool HandleNpcWhisperCommand (ChatHandler *handler, std::string const &recv, Tail text)
 
static bool HandleNpcYellCommand (ChatHandler *handler, Tail text)
 
static bool HandleNpcAddTempSpawnCommand (ChatHandler *handler, CreatureEntry id)
 
static bool HandleNpcTameCommand (ChatHandler *handler)
 
static bool HandleNpcDoActionCommand (ChatHandler *handler, uint32 actionId)
 
static bool HandleNpcAddFormationCommand (ChatHandler *handler, ObjectGuid::LowType leaderGUID)
 
static bool HandleNpcSetLinkCommand (ChatHandler *handler, ObjectGuid::LowType linkguid)
 
static bool HandleNpcSpawnGroupCommand (ChatHandler *handler, uint32 groupId)
 
static bool HandleNpcDespawnGroupCommand (ChatHandler *handler, uint32 groupId)
 
static void ShowLootEntry (ChatHandler *handler, LootItem const &item)
 
static bool HandleNpcShowLootCommand (ChatHandler *handler)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (char const *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (char const *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_commandscript()

npc_commandscript::npc_commandscript ( )
inline
142: CommandScript("npc_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable npc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

145 {
146 static ChatCommandTable npcAddCommandTable =
147 {
153 };
154 static ChatCommandTable npcDeleteCommandTable =
155 {
158 };
159 static ChatCommandTable npcFollowCommandTable =
160 {
163 };
164
165 static ChatCommandTable npcFactionCommandTable =
166 {
170 };
171
172 static ChatCommandTable npcSetCommandTable =
173 {
176 { "faction", npcFactionCommandTable},
186 };
187 static ChatCommandTable npcCommandTable =
188 {
200 { "add", npcAddCommandTable },
201 { "delete", npcDeleteCommandTable },
202 { "follow", npcFollowCommandTable },
204 { "set", npcSetCommandTable },
208 };
209 static ChatCommandTable commandTable =
210 {
211 { "npc", npcCommandTable }
212 };
213 return commandTable;
214 }
static bool HandleNpcWhisperCommand(ChatHandler *handler, std::string const &recv, Tail text)
Definition cs_npc.cpp:1267
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
Definition cs_npc.cpp:1372
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:1309
static bool HandleNpcSetFactionTempIdCommand(ChatHandler *handler, uint32 tempfaction)
Definition cs_npc.cpp:528
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition cs_npc.cpp:1104
static bool HandleNpcShowLootCommand(ChatHandler *handler)
Definition cs_npc.cpp:1508
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:217
static bool HandleNpcSetOriginalFaction(ChatHandler *handler)
Definition cs_npc.cpp:547
static bool HandleNpcTameCommand(ChatHandler *handler)
Definition cs_npc.cpp:1322
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1214
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition cs_npc.cpp:945
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1288
static bool HandleNpcGuidCommand(ChatHandler *handler)
Definition cs_npc.cpp:748
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition cs_npc.cpp:1080
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:610
static bool HandleNpcInfoCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnIdArg)
Definition cs_npc.cpp:628
static bool HandleNpcSpawnGroupCommand(ChatHandler *handler, uint32 groupId)
Definition cs_npc.cpp:1442
static bool HandleNpcMoveCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > guid)
Definition cs_npc.cpp:861
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition cs_npc.cpp:930
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:980
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:1233
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
Definition cs_npc.cpp:417
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition cs_npc.cpp:382
static bool HandleNpcDeleteCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > lowGuid)
Definition cs_npc.cpp:440
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1188
static bool HandleNpcDespawnGroupCommand(ChatHandler *handler, uint32 groupId)
Definition cs_npc.cpp:1469
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
Definition cs_npc.cpp:778
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, std::string spawnTimeStr)
Definition cs_npc.cpp:1148
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
Definition cs_npc.cpp:593
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< bool > addMulti)
Definition cs_npc.cpp:327
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< bool > addMulti)
Definition cs_npc.cpp:465
static bool HandleNpcSetFlagCommand(ChatHandler *handler, uint32 npcFlags)
Definition cs_npc.cpp:568
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition cs_npc.cpp:1416
static bool HandleNpcLoadCommand(ChatHandler *handler, CreatureSpawnId spawnId)
Definition cs_npc.cpp:275
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition cs_npc.cpp:492
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition cs_npc.cpp:397
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition cs_npc.cpp:361
static bool HandleNpcDoActionCommand(ChatHandler *handler, uint32 actionId)
Definition cs_npc.cpp:1358
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_NPC_SET_LEVEL
Definition RBAC.h:415
@ RBAC_PERM_COMMAND_NPC_PLAYEMOTE
Definition RBAC.h:426
@ RBAC_PERM_COMMAND_NPC_FOLLOW
Definition RBAC.h:408
@ RBAC_PERM_COMMAND_NPC_EVADE
Definition RBAC.h:621
@ RBAC_PERM_COMMAND_NPC_INFO
Definition RBAC.h:423
@ RBAC_PERM_COMMAND_NPC_TEXTEMOTE
Definition RBAC.h:428
@ RBAC_PERM_COMMAND_NPC_ADD_FORMATION
Definition RBAC.h:402
@ RBAC_PERM_COMMAND_NPC_ADD
Definition RBAC.h:401
@ RBAC_PERM_COMMAND_NPC_NEAR
Definition RBAC.h:424
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST
Definition RBAC.h:420
@ RBAC_PERM_COMMAND_NPC_SET_PHASE
Definition RBAC.h:419
@ RBAC_PERM_COMMAND_NPC_DELETE
Definition RBAC.h:406
@ RBAC_PERM_COMMAND_NPC_SET_ENTRY
Definition RBAC.h:412
@ RBAC_PERM_COMMAND_NPC_DESPAWNGROUP
Definition RBAC.h:628
@ RBAC_PERM_COMMAND_NPC_TAME
Definition RBAC.h:431
@ RBAC_PERM_COMMAND_NPC_MOVE
Definition RBAC.h:425
@ RBAC_PERM_COMMAND_NPC_ADD_ITEM
Definition RBAC.h:403
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME
Definition RBAC.h:421
@ RBAC_PERM_COMMAND_NPC_SET_FACTIONID
Definition RBAC.h:413
@ RBAC_PERM_COMMAND_NPC_SET_MOVETYPE
Definition RBAC.h:418
@ RBAC_PERM_COMMAND_NPC_SPAWNGROUP
Definition RBAC.h:627
@ RBAC_PERM_COMMAND_NPC_SET_DATA
Definition RBAC.h:422
@ RBAC_PERM_COMMAND_NPC_LOAD
Definition RBAC.h:696
@ RBAC_PERM_COMMAND_NPC_SHOWLOOT
Definition RBAC.h:637
@ RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE
Definition RBAC.h:411
@ RBAC_PERM_COMMAND_NPC_SET_MODEL
Definition RBAC.h:417
@ RBAC_PERM_COMMAND_NPC_ADD_MOVE
Definition RBAC.h:404
@ RBAC_PERM_COMMAND_NPC_SET_LINK
Definition RBAC.h:416
@ RBAC_PERM_COMMAND_NPC_FOLLOW_STOP
Definition RBAC.h:409
@ RBAC_PERM_COMMAND_NPC_WHISPER
Definition RBAC.h:429
@ RBAC_PERM_COMMAND_NPC_SET_FLAG
Definition RBAC.h:414
@ RBAC_PERM_COMMAND_NPC_YELL
Definition RBAC.h:430
@ RBAC_PERM_COMMAND_NPC_SAY
Definition RBAC.h:427
@ RBAC_PERM_COMMAND_NPC_ADD_TEMP
Definition RBAC.h:405
@ RBAC_PERM_COMMAND_NPC_DELETE_ITEM
Definition RBAC.h:407

References HandleNpcAddCommand(), HandleNpcAddFormationCommand(), HandleNpcAddMoveCommand(), HandleNpcAddTempSpawnCommand(), HandleNpcAddVendorItemCommand(), HandleNpcDeleteCommand(), HandleNpcDeleteVendorItemCommand(), HandleNpcDespawnGroupCommand(), HandleNpcDoActionCommand(), HandleNpcFollowCommand(), HandleNpcGuidCommand(), HandleNpcInfoCommand(), HandleNpcLoadCommand(), HandleNpcMoveCommand(), HandleNpcNearCommand(), HandleNpcPlayEmoteCommand(), HandleNpcSayCommand(), HandleNpcSetAllowMovementCommand(), HandleNpcSetDataCommand(), HandleNpcSetEntryCommand(), HandleNpcSetFactionIdCommand(), HandleNpcSetFactionTempIdCommand(), HandleNpcSetFlagCommand(), HandleNpcSetLevelCommand(), HandleNpcSetLinkCommand(), HandleNpcSetModelCommand(), HandleNpcSetMoveTypeCommand(), HandleNpcSetOriginalFaction(), HandleNpcSetPhaseCommand(), HandleNpcSetSpawnTimeCommand(), HandleNpcSetWanderDistanceCommand(), HandleNpcShowLootCommand(), HandleNpcSpawnGroupCommand(), HandleNpcTameCommand(), HandleNpcTextEmoteCommand(), HandleNpcUnFollowCommand(), HandleNpcWhisperCommand(), HandleNpcYellCommand(), rbac::RBAC_PERM_COMMAND_NPC_ADD, rbac::RBAC_PERM_COMMAND_NPC_ADD_FORMATION, rbac::RBAC_PERM_COMMAND_NPC_ADD_ITEM, rbac::RBAC_PERM_COMMAND_NPC_ADD_MOVE, rbac::RBAC_PERM_COMMAND_NPC_ADD_TEMP, rbac::RBAC_PERM_COMMAND_NPC_DELETE, rbac::RBAC_PERM_COMMAND_NPC_DELETE_ITEM, rbac::RBAC_PERM_COMMAND_NPC_DESPAWNGROUP, rbac::RBAC_PERM_COMMAND_NPC_EVADE, rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, rbac::RBAC_PERM_COMMAND_NPC_FOLLOW_STOP, rbac::RBAC_PERM_COMMAND_NPC_INFO, rbac::RBAC_PERM_COMMAND_NPC_LOAD, rbac::RBAC_PERM_COMMAND_NPC_MOVE, rbac::RBAC_PERM_COMMAND_NPC_NEAR, rbac::RBAC_PERM_COMMAND_NPC_PLAYEMOTE, rbac::RBAC_PERM_COMMAND_NPC_SAY, rbac::RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE, rbac::RBAC_PERM_COMMAND_NPC_SET_DATA, rbac::RBAC_PERM_COMMAND_NPC_SET_ENTRY, rbac::RBAC_PERM_COMMAND_NPC_SET_FACTIONID, rbac::RBAC_PERM_COMMAND_NPC_SET_FLAG, rbac::RBAC_PERM_COMMAND_NPC_SET_LEVEL, rbac::RBAC_PERM_COMMAND_NPC_SET_LINK, rbac::RBAC_PERM_COMMAND_NPC_SET_MODEL, rbac::RBAC_PERM_COMMAND_NPC_SET_MOVETYPE, rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST, rbac::RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME, rbac::RBAC_PERM_COMMAND_NPC_SHOWLOOT, rbac::RBAC_PERM_COMMAND_NPC_SPAWNGROUP, rbac::RBAC_PERM_COMMAND_NPC_TAME, rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, rbac::RBAC_PERM_COMMAND_NPC_WHISPER, and rbac::RBAC_PERM_COMMAND_NPC_YELL.

◆ HandleNpcAddCommand()

static bool npc_commandscript::HandleNpcAddCommand ( ChatHandler handler,
CreatureEntry  id 
)
inlinestatic
218 {
219 if (!sObjectMgr->GetCreatureTemplate(id))
220 return false;
221
222 Player* chr = handler->GetSession()->GetPlayer();
223 float x = chr->GetPositionX();
224 float y = chr->GetPositionY();
225 float z = chr->GetPositionZ();
226 float o = chr->GetOrientation();
227 Map* map = chr->GetMap();
228
229 if (Transport* tt = chr->GetTransport())
230 if (MotionTransport* trans = tt->ToMotionTransport())
231 {
232 ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
233 CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
234 data.id = id;
235 data.phaseMask = chr->GetPhaseMaskForSpawn();
236 data.posX = chr->GetTransOffsetX();
237 data.posY = chr->GetTransOffsetY();
238 data.posZ = chr->GetTransOffsetZ();
239 data.orientation = chr->GetTransOffsetO();
240
241 if (Creature* creature = trans->CreateNPCPassenger(guid, &data))
242 {
243 creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMaskForSpawn());
244 sObjectMgr->AddCreatureToGrid(guid, &data);
245 }
246 return true;
247 }
248
249 Creature* creature = new Creature();
250 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
251 {
252 delete creature;
253 return false;
254 }
255
256 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
257
258 ObjectGuid::LowType spawnId = creature->GetSpawnId();
259
260 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
261 // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
262 creature->CleanupsBeforeDelete();
263 delete creature;
264 creature = new Creature();
265 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
266 {
267 delete creature;
268 return false;
269 }
270
271 sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId));
272 return true;
273 }
#define sObjectMgr
Definition ObjectMgr.h:1730
WorldSession * GetSession()
Definition Chat.h:242
Definition Creature.h:47
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1677
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, CreatureData const *data=nullptr)
Definition Creature.cpp:1151
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
void SaveToDB()
Definition Creature.cpp:1380
MotionTransport * ToMotionTransport()
Definition GameObject.h:328
Definition Map.h:168
uint8 GetSpawnMode() const
Definition Map.h:271
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:528
uint32 GetId() const
Definition Map.h:234
Definition Transport.h:51
uint32 LowType
Definition ObjectGuid.h:125
Definition Player.h:1086
uint32 GetPhaseMaskForSpawn() const
Definition Player.cpp:14083
Definition Transport.h:30
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:12631
Map * GetMap() const
Definition Object.h:631
float GetTransOffsetX() const
Definition Object.h:695
float GetTransOffsetY() const
Definition Object.h:696
float GetTransOffsetZ() const
Definition Object.h:697
Transport * GetTransport() const
Definition Object.h:694
float GetTransOffsetO() const
Definition Object.h:698
Player * GetPlayer() const
Definition WorldSession.h:480
Definition CreatureData.h:370
uint32 id
Definition CreatureData.h:372
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122
float posX
Definition SpawnData.h:71
float posY
Definition SpawnData.h:72
uint32 phaseMask
Definition SpawnData.h:70
float orientation
Definition SpawnData.h:74
float posZ
Definition SpawnData.h:73

References Unit::CleanupsBeforeDelete(), Creature::Create(), Map::GenerateLowGuid(), Map::GetId(), WorldObject::GetMap(), Position::GetOrientation(), Player::GetPhaseMaskForSpawn(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), Creature::GetSpawnId(), Map::GetSpawnMode(), WorldObject::GetTransOffsetO(), WorldObject::GetTransOffsetX(), WorldObject::GetTransOffsetY(), WorldObject::GetTransOffsetZ(), WorldObject::GetTransport(), CreatureData::id, Creature::LoadCreatureFromDB(), SpawnData::orientation, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, Creature::SaveToDB(), sObjectMgr, GameObject::ToMotionTransport(), and Unit.

Referenced by GetCommands().

◆ HandleNpcAddFormationCommand()

static bool npc_commandscript::HandleNpcAddFormationCommand ( ChatHandler handler,
ObjectGuid::LowType  leaderGUID 
)
inlinestatic
1373 {
1374 Creature* creature = handler->getSelectedCreature();
1375
1376 if (!creature || !creature->GetSpawnId())
1377 {
1379 return false;
1380 }
1381
1382 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1383 if (creature->GetFormation())
1384 {
1385 handler->PSendSysMessage("Selected creature is already member of group {}", creature->GetFormation()->GetId());
1386 return false;
1387 }
1388
1389 if (!lowguid)
1390 return false;
1391
1392 Player* chr = handler->GetSession()->GetPlayer();
1393 FormationInfo group_member;
1394 group_member.follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
1395 group_member.follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2)) + pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
1396 group_member.leaderGUID = leaderGUID;
1397 group_member.groupAI = 0;
1398
1399 sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1400 creature->SearchFormation();
1401
1403 stmt->SetData(0, leaderGUID);
1404 stmt->SetData(1, lowguid);
1405 stmt->SetData(2, group_member.follow_dist);
1406 stmt->SetData(3, group_member.follow_angle);
1407 stmt->SetData(4, uint32(group_member.groupAI));
1408
1409 WorldDatabase.Execute(stmt);
1410
1411 handler->PSendSysMessage("Creature {} added to formation with leader {}", lowguid, leaderGUID);
1412
1413 return true;
1414 }
#define sFormationMgr
Definition CreatureGroups.h:130
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint32_t uint32
Definition Define.h:107
@ LANG_SELECT_CREATURE
Definition Language.h:32
@ WORLD_INS_CREATURE_FORMATION
Definition WorldDatabase.h:53
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
Creature * getSelectedCreature() const
Definition Chat.cpp:418
uint32 GetId() const
Definition CreatureGroups.h:100
CreatureGroup const * GetFormation() const
Definition Creature.h:372
void SearchFormation()
Definition Creature.cpp:371
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
Definition CreatureGroups.h:52
float follow_dist
Definition CreatureGroups.h:64
float follow_angle
Definition CreatureGroups.h:65
ObjectGuid::LowType leaderGUID
Definition CreatureGroups.h:63
uint16 groupAI
Definition CreatureGroups.h:66
float GetAngle(Position const *pos) const
Definition Position.cpp:85

References FormationInfo::follow_angle, FormationInfo::follow_dist, Position::GetAngle(), Creature::GetFormation(), CreatureGroup::GetId(), Position::GetOrientation(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetSpawnId(), FormationInfo::groupAI, LANG_SELECT_CREATURE, FormationInfo::leaderGUID, ChatHandler::PSendSysMessage(), Creature::SearchFormation(), ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), sFormationMgr, WORLD_INS_CREATURE_FORMATION, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcAddMoveCommand()

static bool npc_commandscript::HandleNpcAddMoveCommand ( ChatHandler handler,
CreatureSpawnId  lowGuid 
)
inlinestatic
362 {
363 // attempt check creature existence by DB data
364 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
365 if (!data)
366 {
368 return false;
369 }
370
371 // Update movement type
374 stmt->SetData(1, uint32(lowGuid));
375 WorldDatabase.Execute(stmt);
376
378
379 return true;
380 }
std::uint8_t uint8
Definition Define.h:109
@ LANG_WAYPOINT_ADDED
Definition Language.h:283
@ LANG_COMMAND_CREATGUIDNOTFOUND
Definition Language.h:340
@ WAYPOINT_MOTION_TYPE
Definition MotionMaster.h:41
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
Definition WorldDatabase.h:47
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168

References LANG_COMMAND_CREATGUIDNOTFOUND, LANG_WAYPOINT_ADDED, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), sObjectMgr, WAYPOINT_MOTION_TYPE, WORLD_UPD_CREATURE_MOVEMENT_TYPE, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcAddTempSpawnCommand()

static bool npc_commandscript::HandleNpcAddTempSpawnCommand ( ChatHandler handler,
CreatureEntry  id 
)
inlinestatic
1310 {
1311 Player* chr = handler->GetSession()->GetPlayer();
1312
1313 if (!id)
1314 return false;
1315
1316 chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1317
1318 return true;
1319 }
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:53
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2448

References WorldSession::GetPlayer(), ChatHandler::GetSession(), WorldObject::SummonCreature(), and TEMPSUMMON_CORPSE_DESPAWN.

Referenced by GetCommands().

◆ HandleNpcAddVendorItemCommand()

static bool npc_commandscript::HandleNpcAddVendorItemCommand ( ChatHandler handler,
ItemTemplate const *  item,
Optional< uint32 mc,
Optional< uint32 it,
Optional< uint32 ec,
Optional< bool >  addMulti 
)
inlinestatic
328 {
329 if (!item)
330 {
332 return false;
333 }
334
335 Creature* vendor = handler->getSelectedCreature();
336 if (!vendor)
337 {
339 return false;
340 }
341
342 uint32 itemId = item->ItemId;
343 uint32 maxcount = mc.value_or(0);
344 uint32 incrtime = it.value_or(0);
345 uint32 extendedcost = ec.value_or(0);
346 uint32 vendor_entry = addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry();
347
348 if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, handler->GetSession()->GetPlayer()))
349 {
350 handler->SetSentErrorMessage(true);
351 return false;
352 }
353
354 sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost);
355
356 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1, maxcount, incrtime, extendedcost);
357 return true;
358 }
@ LANG_COMMAND_NEEDITEMSEND
Definition Language.h:332
@ LANG_ITEM_ADDED_TO_LIST
Definition Language.h:252
void SetSentErrorMessage(bool val)
Definition Chat.h:238
uint32 GetEntry() const
Definition Object.h:117
uint32 GetCurrentVendor() const
Definition WorldSession.h:484

References WorldSession::GetCurrentVendor(), Object::GetEntry(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), ItemTemplate::ItemId, LANG_COMMAND_NEEDITEMSEND, LANG_ITEM_ADDED_TO_LIST, LANG_SELECT_CREATURE, ItemTemplate::Name1, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcDeleteCommand()

static bool npc_commandscript::HandleNpcDeleteCommand ( ChatHandler handler,
Optional< ObjectGuid::LowType lowGuid 
)
inlinestatic
441 {
442 Creature* creature;
443 if (lowGuid.has_value())
444 creature = handler->GetCreatureFromPlayerMapByDbGuid(*lowGuid);
445 else
446 creature = handler->getSelectedCreature();
447
448 if (!creature || creature->IsPet() || creature->IsTotem())
449 {
451 return false;
452 }
453
454 // Delete the creature
455 creature->CombatStop();
456 creature->DeleteFromDB();
457 creature->AddObjectToRemoveList();
458
460
461 return true;
462 }
@ LANG_COMMAND_DELCREATMESSAGE
Definition Language.h:323
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:586
virtual void DeleteFromDB()
Definition Creature.cpp:1835
bool IsPet() const
Definition Unit.h:798
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7532
bool IsTotem() const
Definition Unit.h:800
void AddObjectToRemoveList()
Definition Object.cpp:2227

References WorldObject::AddObjectToRemoveList(), Unit::CombatStop(), Creature::DeleteFromDB(), ChatHandler::GetCreatureFromPlayerMapByDbGuid(), ChatHandler::getSelectedCreature(), Unit::IsPet(), Unit::IsTotem(), LANG_COMMAND_DELCREATMESSAGE, LANG_SELECT_CREATURE, ChatHandler::SendErrorMessage(), and ChatHandler::SendSysMessage().

Referenced by GetCommands().

◆ HandleNpcDeleteVendorItemCommand()

static bool npc_commandscript::HandleNpcDeleteVendorItemCommand ( ChatHandler handler,
ItemTemplate const *  item,
Optional< bool >  addMulti 
)
inlinestatic
466 {
467 Creature* vendor = handler->getSelectedCreature();
468 if (!vendor || !vendor->IsVendor())
469 {
471 return false;
472 }
473
474 if (!item)
475 {
477 return false;
478 }
479
480 uint32 itemId = item->ItemId;
481 if (!sObjectMgr->RemoveVendorItem(addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry(), itemId))
482 {
483 handler->SendErrorMessage(LANG_ITEM_NOT_IN_LIST, itemId);
484 return false;
485 }
486
487 handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1);
488 return true;
489 }
@ LANG_COMMAND_VENDORSELECTION
Definition Language.h:331
@ LANG_ITEM_DELETED_FROM_LIST
Definition Language.h:254
@ LANG_ITEM_NOT_IN_LIST
Definition Language.h:255
bool IsVendor() const
Definition Unit.h:804

References WorldSession::GetCurrentVendor(), Object::GetEntry(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Unit::IsVendor(), ItemTemplate::ItemId, LANG_COMMAND_NEEDITEMSEND, LANG_COMMAND_VENDORSELECTION, LANG_ITEM_DELETED_FROM_LIST, LANG_ITEM_NOT_IN_LIST, ItemTemplate::Name1, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcDespawnGroupCommand()

static bool npc_commandscript::HandleNpcDespawnGroupCommand ( ChatHandler handler,
uint32  groupId 
)
inlinestatic
1470 {
1471 Player* player = handler->GetSession()->GetPlayer();
1472 if (!player)
1473 return false;
1474
1475 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
1476 if (!groupData)
1477 {
1479 return false;
1480 }
1481
1482 if (groupData->flags & SPAWNGROUP_FLAG_SYSTEM)
1483 {
1484 handler->SendErrorMessage(LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR, groupId, groupData->name);
1485 return false;
1486 }
1487
1488 if (player->GetMap()->SpawnGroupDespawn(groupId, true))
1489 handler->PSendSysMessage(LANG_SPAWNGROUP_DESPAWN_SUCCESS, groupId, groupData->name);
1490 else
1491 handler->SendErrorMessage(LANG_SPAWNGROUP_DESPAWN_FAILED, groupId, groupData->name);
1492
1493 return true;
1494 }
@ LANG_SPAWNGROUP_DESPAWN_FAILED
Definition Language.h:1472
@ LANG_SPAWNGROUP_DESPAWN_SUCCESS
Definition Language.h:1471
@ LANG_SPAWNGROUP_NOT_FOUND
Definition Language.h:1478
@ LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR
Definition Language.h:1470
@ SPAWNGROUP_FLAG_SYSTEM
Definition SpawnData.h:44
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false)
Definition Map.cpp:2698
Definition SpawnData.h:58
std::string name
Definition SpawnData.h:60
SpawnGroupFlags flags
Definition SpawnData.h:62

References SpawnGroupTemplateData::flags, WorldObject::GetMap(), WorldSession::GetPlayer(), ChatHandler::GetSession(), LANG_SPAWNGROUP_DESPAWN_FAILED, LANG_SPAWNGROUP_DESPAWN_SUCCESS, LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR, LANG_SPAWNGROUP_NOT_FOUND, SpawnGroupTemplateData::name, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sObjectMgr, SPAWNGROUP_FLAG_SYSTEM, and Map::SpawnGroupDespawn().

Referenced by GetCommands().

◆ HandleNpcDoActionCommand()

static bool npc_commandscript::HandleNpcDoActionCommand ( ChatHandler handler,
uint32  actionId 
)
inlinestatic
1359 {
1360 Creature* creature = handler->getSelectedCreature();
1361 if (!creature)
1362 {
1364 return false;
1365 }
1366
1367 creature->AI()->DoAction(actionId);
1368 handler->PSendSysMessage(LANG_NPC_DO_ACTION, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), actionId);
1369 return true;
1370 }
@ LANG_NPC_DO_ACTION
Definition Language.h:677
CreatureAI * AI() const
Definition Creature.h:144
std::string ToString() const
Definition ObjectGuid.cpp:48
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
virtual void DoAction(int32)
Definition UnitAI.h:217
std::string const & GetName() const
Definition Object.h:529

References Creature::AI(), UnitAI::DoAction(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetName(), ChatHandler::getSelectedCreature(), LANG_NPC_DO_ACTION, LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleNpcFollowCommand()

static bool npc_commandscript::HandleNpcFollowCommand ( ChatHandler handler)
inlinestatic
611 {
612 Player* player = handler->GetSession()->GetPlayer();
613 Creature* creature = handler->getSelectedCreature();
614
615 if (!creature)
616 {
618 return false;
619 }
620
621 // Follow player - Using pet's default dist and angle
622 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
623
625 return true;
626 }
@ LANG_CREATURE_FOLLOW_YOU_NOW
Definition Language.h:390
constexpr float PET_FOLLOW_DIST
Definition PetDefines.h:206
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE, bool inheritWalkState=true, bool inheritSpeed=true)
The unit will follow this target. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:448
MotionMaster * GetMotionMaster()
Definition Unit.h:1758
virtual float GetFollowAngle() const
Definition Unit.h:1895

References Unit::GetFollowAngle(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), LANG_CREATURE_FOLLOW_YOU_NOW, LANG_SELECT_CREATURE, MotionMaster::MoveFollow(), PET_FOLLOW_DIST, ChatHandler::PSendSysMessage(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleNpcGuidCommand()

static bool npc_commandscript::HandleNpcGuidCommand ( ChatHandler handler)
inlinestatic
749 {
750 Creature* target = handler->getSelectedCreature();
751
752 if (!target)
753 {
755 return false;
756 }
757
758 uint32 faction = target->GetFaction();
759 uint32 npcflags = target->GetNpcFlags();
760 uint32 displayid = target->GetDisplayId();
761 uint32 nativeid = target->GetNativeDisplayId();
762 uint32 entry = target->GetEntry();
763 uint32 id1 = 0;
764 uint32 id2 = 0;
765 uint32 id3 = 0;
766 if (CreatureData const* cData = target->GetCreatureData())
767 {
768 id1 = cData->id;
769 id2 = cData->id2;
770 id3 = cData->id3;
771 }
772
773 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
774
775 return true;
776 }
@ LANG_NPCINFO_CHAR
Definition Language.h:595
CreatureData const * GetCreatureData() const
Definition Creature.h:208
NPCFlags GetNpcFlags() const
Clears emote state (looping emote)
Definition Unit.h:763
uint32 GetFaction() const
Definition Unit.h:852
uint32 GetDisplayId() const
Definition Unit.h:1974
uint32 GetNativeDisplayId() const
Definition Unit.h:1976

References Creature::GetCreatureData(), Unit::GetDisplayId(), Object::GetEntry(), Unit::GetFaction(), Object::GetGUID(), Unit::GetNativeDisplayId(), Unit::GetNpcFlags(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), LANG_NPCINFO_CHAR, LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleNpcInfoCommand()

static bool npc_commandscript::HandleNpcInfoCommand ( ChatHandler handler,
Optional< CreatureSpawnId spawnIdArg 
)
inlinestatic
629 {
630 Creature* target = handler->getSelectedCreature();
631 ObjectGuid::LowType lowGuid = 0;
632
633 if (spawnIdArg)
634 lowGuid = *spawnIdArg;
635
636 if (!target && lowGuid)
637 target = handler->GetCreatureFromPlayerMapByDbGuid(lowGuid);
638
639 if (target)
640 return HandleNpcInfoCommandShowCreature(handler, target);
641
642 if (!lowGuid)
643 {
645 return false;
646 }
647
648 CreatureData const* cData = sObjectMgr->GetCreatureData(lowGuid);
649 if (!cData)
650 cData = sObjectMgr->LoadCreatureDataFromDB(lowGuid);
651 if (cData)
652 return HandleNpcInfoCommandShowFromDB(handler, lowGuid, cData);
653
655 return false;
656 }
static bool HandleNpcInfoCommandShowFromDB(ChatHandler *handler, ObjectGuid::LowType lowGuid, CreatureData const *cData)
Definition cs_npc.cpp:724
static bool HandleNpcInfoCommandShowCreature(ChatHandler *handler, Creature *target)
Definition cs_npc.cpp:658

References ChatHandler::GetCreatureFromPlayerMapByDbGuid(), ChatHandler::getSelectedCreature(), HandleNpcInfoCommandShowCreature(), HandleNpcInfoCommandShowFromDB(), LANG_COMMAND_CREATGUIDNOTFOUND, LANG_SELECT_CREATURE, ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcInfoCommandShowCreature()

static bool npc_commandscript::HandleNpcInfoCommandShowCreature ( ChatHandler handler,
Creature target 
)
inlinestatic
659 {
660 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
661 uint32 faction = target->GetFaction();
662 uint32 npcflags = target->GetNpcFlags();
663 uint64 mechanicImmuneMask = 0;
664 uint32 spellSchoolImmuneMask = 0;
665
666 if (CreatureImmunities const* immunities = sSpellMgr->GetCreatureImmunities(cInfo->CreatureImmunitiesId))
667 {
668 mechanicImmuneMask = immunities->Mechanic.to_ullong();
669 for (std::size_t j = 0; j < immunities->School.size(); ++j)
670 if (immunities->School[j])
671 spellSchoolImmuneMask |= (1u << j);
672 }
673
674 uint32 displayid = target->GetDisplayId();
675 uint32 nativeid = target->GetNativeDisplayId();
676 uint32 entry = target->GetEntry();
677 uint32 id1 = 0;
678 uint32 id2 = 0;
679 uint32 id3 = 0;
680 if (CreatureData const* cData = target->GetCreatureData())
681 {
682 id1 = cData->id;
683 id2 = cData->id2;
684 id3 = cData->id3;
685 }
686
687 int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
688 if (curRespawnDelay < 0)
689 curRespawnDelay = 0;
690
691 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
692 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
693
694 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
695 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
697 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
698 handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
699 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr, curRespawnDelayStr);
700 handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
703 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
704 handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
705 handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName(), target->GetScriptName());
706
707 for (auto npcFlagText : npcFlagTexts)
708 if (npcflags & npcFlagText.flag)
709 handler->PSendSysMessage(npcFlagText.text, npcFlagText.flag);
710
711 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, Acore::StringFormat("0x{:X}", mechanicImmuneMask).c_str());
712 for (uint8 i = 1; i < MAX_MECHANIC; ++i)
713 if (mechanicImmuneMask & (1ULL << i))
714 handler->PSendSysMessage(mechanicImmunes[i].text, mechanicImmunes[i].flag);
715
716 handler->PSendSysMessage(LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, spellSchoolImmuneMask);
717 for (auto spellSchoolImmune : spellSchoolImmunes)
718 if (spellSchoolImmuneMask & (1 << spellSchoolImmune.flag))
719 handler->PSendSysMessage(spellSchoolImmune.text, spellSchoolImmune.flag);
720
721 return true;
722 }
std::uint64_t uint64
Definition Define.h:106
std::int64_t int64
Definition Define.h:102
@ LANG_NPCINFO_EQUIPMENT
Definition Language.h:1098
@ LANG_NPCINFO_LOOT
Definition Language.h:599
@ LANG_NPCINFO_POSITION
Definition Language.h:600
@ LANG_NPCINFO_FLAGS
Definition Language.h:598
@ LANG_NPCINFO_AIINFO
Definition Language.h:1093
@ LANG_NPCINFO_SPELL_SCHOOL_IMMUNE
Definition Language.h:1129
@ LANG_NPCINFO_HEALTH
Definition Language.h:597
@ LANG_NPCINFO_PHASEMASK
Definition Language.h:1082
@ LANG_NPCINFO_LEVEL
Definition Language.h:596
@ LANG_COMMAND_RAWPAWNTIMES
Definition Language.h:650
@ LANG_NPCINFO_ARMOR
Definition Language.h:1083
@ LANG_NPCINFO_DUNGEON_ID
Definition Language.h:603
@ LANG_NPCINFO_MECHANIC_IMMUNE
Definition Language.h:1099
@ MAX_MECHANIC
Definition SharedDefines.h:1350
#define sSpellMgr
Definition SpellMgr.h:847
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
int8 GetOriginalEquipmentId() const
Definition Creature.h:197
uint8 GetCurrentEquipmentId()
Definition Creature.h:198
CreatureTemplate const * GetCreatureTemplate() const
Definition Creature.h:207
uint32 GetRespawnDelay() const
Definition Creature.h:296
std::string GetScriptName() const
Definition Creature.cpp:3182
time_t GetRespawnTimeEx() const
Definition Creature.cpp:3059
std::string const & GetAIName() const
Definition Creature.cpp:3177
uint32 GetMaxHealth() const
Definition Unit.h:1110
UnitFlags GetUnitFlags() const
Definition Unit.h:747
uint32 GetHealth() const
Definition Unit.h:1109
uint32 GetCreateHealth() const
Definition Unit.h:1113
uint32 GetArmor() const
Definition Unit.h:1158
uint8 GetLevel() const
Definition Unit.h:1104
UnitFlags2 GetUnitFlags2() const
Remove all UnitFlags and set new ones. UnitFlags available in UnitDefines.h.
Definition Unit.h:753
uint32 GetDynamicFlags() const override
Definition Unit.h:769
uint32 GetPhaseMask() const
Definition Object.h:517
uint32 GetInstanceId() const
Definition Object.h:514
NpcFlagText const npcFlagTexts[NPCFLAG_COUNT]
Definition cs_npc.cpp:52
SpellSchoolImmune const spellSchoolImmunes[MAX_SPELL_SCHOOL]
Definition cs_npc.cpp:128
MechanicImmune const mechanicImmunes[MAX_MECHANIC]
Definition cs_npc.cpp:86
std::string StringFormat(FormatStringView fmt, Args &&... args)
Default AC string format function.
Definition StringFormat.h:44
Seconds GetGameTime()
Definition GameTime.cpp:38
Definition SpellMgr.h:571
Definition CreatureData.h:187
int32 CreatureImmunitiesId
Definition CreatureData.h:240
uint32 SkinLootId
Definition CreatureData.h:222
uint32 pickpocketLootId
Definition CreatureData.h:221
uint32 lootid
Definition CreatureData.h:220

References CreatureTemplate::CreatureImmunitiesId, MechanicImmune::flag, Creature::GetAIName(), Unit::GetArmor(), Unit::GetCreateHealth(), Creature::GetCreatureData(), Creature::GetCreatureTemplate(), Creature::GetCurrentEquipmentId(), Unit::GetDisplayId(), Unit::GetDynamicFlags(), Object::GetEntry(), Unit::GetFaction(), GameTime::GetGameTime(), Object::GetGUID(), Unit::GetHealth(), WorldObject::GetInstanceId(), Unit::GetLevel(), Unit::GetMaxHealth(), Unit::GetNativeDisplayId(), Unit::GetNpcFlags(), Creature::GetOriginalEquipmentId(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Creature::GetRespawnDelay(), Creature::GetRespawnTimeEx(), Creature::GetScriptName(), Creature::GetSpawnId(), Unit::GetUnitFlags(), Unit::GetUnitFlags2(), LANG_COMMAND_RAWPAWNTIMES, LANG_NPCINFO_AIINFO, LANG_NPCINFO_ARMOR, LANG_NPCINFO_CHAR, LANG_NPCINFO_DUNGEON_ID, LANG_NPCINFO_EQUIPMENT, LANG_NPCINFO_FLAGS, LANG_NPCINFO_HEALTH, LANG_NPCINFO_LEVEL, LANG_NPCINFO_LOOT, LANG_NPCINFO_MECHANIC_IMMUNE, LANG_NPCINFO_PHASEMASK, LANG_NPCINFO_POSITION, LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, CreatureTemplate::lootid, MAX_MECHANIC, mechanicImmunes, npcFlagTexts, CreatureTemplate::pickpocketLootId, ChatHandler::PSendSysMessage(), secsToTimeString(), CreatureTemplate::SkinLootId, spellSchoolImmunes, sSpellMgr, Acore::StringFormat(), MechanicImmune::text, and ObjectGuid::ToString().

Referenced by HandleNpcInfoCommand().

◆ HandleNpcInfoCommandShowFromDB()

static bool npc_commandscript::HandleNpcInfoCommandShowFromDB ( ChatHandler handler,
ObjectGuid::LowType  lowGuid,
CreatureData const *  cData 
)
inlinestatic
725 {
726 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id);
727 if (!cInfo)
728 {
730 return false;
731 }
732
733 handler->PSendSysMessage("(Not in world - showing DB data)");
734 uint32 scriptId = cData->ScriptId ? cData->ScriptId : cInfo->ScriptID;
735 handler->PSendSysMessage(LANG_NPCINFO_CHAR, lowGuid, ObjectGuid::Create<HighGuid::Unit>(cData->id, lowGuid).ToString(), cData->id,
736 cData->id, cData->id2, cData->id3, cData->displayid, cData->displayid, cInfo->faction,
737 cData->npcflag);
738 handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, cData->phaseMask);
739 handler->PSendSysMessage(LANG_NPCINFO_POSITION, cData->posX, cData->posY, cData->posZ);
740 handler->PSendSysMessage("Map: {} Spawn time: {}s", cData->mapid,
741 cData->spawntimesecs);
742 handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, cData->equipmentId, cData->equipmentId);
744 sObjectMgr->GetScriptName(scriptId));
745 return true;
746 }
uint32 ScriptID
Definition CreatureData.h:242
uint32 faction
Definition CreatureData.h:199
std::string AIName
Definition CreatureData.h:229

References CreatureTemplate::AIName, CreatureData::displayid, CreatureData::equipmentId, CreatureTemplate::faction, CreatureData::id, CreatureData::id2, CreatureData::id3, LANG_COMMAND_CREATGUIDNOTFOUND, LANG_NPCINFO_AIINFO, LANG_NPCINFO_CHAR, LANG_NPCINFO_EQUIPMENT, LANG_NPCINFO_PHASEMASK, LANG_NPCINFO_POSITION, SpawnData::mapid, CreatureData::npcflag, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, ChatHandler::PSendSysMessage(), CreatureTemplate::ScriptID, SpawnData::ScriptId, ChatHandler::SendErrorMessage(), sObjectMgr, and CreatureData::spawntimesecs.

Referenced by HandleNpcInfoCommand().

◆ HandleNpcLoadCommand()

static bool npc_commandscript::HandleNpcLoadCommand ( ChatHandler handler,
CreatureSpawnId  spawnId 
)
inlinestatic
276 {
277 if (!spawnId)
278 return false;
279
280 if (sObjectMgr->GetCreatureData(spawnId))
281 {
282 handler->SendErrorMessage("Creature spawn {} is already loaded.", uint32(spawnId));
283 return false;
284 }
285
286 CreatureData const* data = sObjectMgr->LoadCreatureDataFromDB(spawnId);
287 if (!data)
288 {
289 handler->SendErrorMessage("Creature spawn {} not found in the database.", uint32(spawnId));
290 return false;
291 }
292
293 if (sPoolMgr->IsPartOfAPool<Creature>(spawnId))
294 {
295 handler->SendErrorMessage("Creature spawn {} is part of a pool and cannot be manually loaded.", uint32(spawnId));
296 return false;
297 }
298
299 QueryResult eventResult = WorldDatabase.Query("SELECT guid FROM game_event_creature WHERE guid = {}", uint32(spawnId));
300 if (eventResult)
301 {
302 handler->SendErrorMessage("Creature spawn {} is managed by the game event system and cannot be manually loaded.", uint32(spawnId));
303 return false;
304 }
305
306 Map* map = sMapMgr->FindBaseNonInstanceMap(data->mapid);
307 if (!map)
308 {
309 handler->SendErrorMessage("Creature spawn {} is on a non-continent map (ID: {}). Only continent maps are supported.", uint32(spawnId), data->mapid);
310 return false;
311 }
312
313 Creature* creature = new Creature();
314 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
315 {
316 delete creature;
317 handler->SendErrorMessage("Failed to load creature spawn {}.", uint32(spawnId));
318 return false;
319 }
320
321 sObjectMgr->AddCreatureToGrid(spawnId, data);
322 handler->PSendSysMessage("Creature spawn {} loaded successfully.", uint32(spawnId));
323 return true;
324 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
#define sMapMgr
Definition MapMgr.h:220
#define sPoolMgr
Definition PoolMgr.h:216
uint16 mapid
Definition SpawnData.h:69

References Creature::LoadCreatureFromDB(), SpawnData::mapid, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sMapMgr, sObjectMgr, sPoolMgr, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcMoveCommand()

static bool npc_commandscript::HandleNpcMoveCommand ( ChatHandler handler,
Optional< ObjectGuid::LowType guid 
)
inlinestatic
862 {
863 Creature* creature;
864 if (guid.has_value())
865 creature = handler->GetCreatureFromPlayerMapByDbGuid(*guid);
866 else
867 creature = handler->getSelectedCreature();
868
869 if (!creature)
870 return false;
871
872 ObjectGuid::LowType lowGuid;
873 if (guid.has_value())
874 lowGuid = *guid;
875 else
876 lowGuid = creature->GetSpawnId();
877
878 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
879 if (!data)
880 {
882 return false;
883 }
884
885 if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
886 {
888 return false;
889 }
890
891 float x = handler->GetSession()->GetPlayer()->GetPositionX();
892 float y = handler->GetSession()->GetPlayer()->GetPositionY();
893 float z = handler->GetSession()->GetPlayer()->GetPositionZ();
894 float o = handler->GetSession()->GetPlayer()->GetOrientation();
895
896 if (creature)
897 {
898 if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
899 {
900 const_cast<CreatureData*>(data)->posX = x;
901 const_cast<CreatureData*>(data)->posY = y;
902 const_cast<CreatureData*>(data)->posZ = z;
903 const_cast<CreatureData*>(data)->orientation = o;
904 }
905
906 creature->SetPosition(x, y, z, o);
907 creature->GetMotionMaster()->Initialize();
908
909 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
910 {
912 creature->Respawn();
913 }
914 }
915
917 stmt->SetData(0, x);
918 stmt->SetData(1, y);
919 stmt->SetData(2, z);
920 stmt->SetData(3, o);
921 stmt->SetData(4, lowGuid);
922
923 WorldDatabase.Execute(stmt);
924
926 return true;
927 }
@ LANG_COMMAND_CREATUREMOVED
Definition Language.h:324
@ LANG_COMMAND_CREATUREATSAMEMAP
Definition Language.h:325
@ WORLD_UPD_CREATURE_POSITION
Definition WorldDatabase.h:50
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition Creature.cpp:1956
void Respawn(bool force=false)
Definition Creature.cpp:2027
void SetPosition(float x, float y, float z, float o)
Definition Creature.cpp:3293
void Initialize()
Definition MotionMaster.cpp:76
bool IsAlive() const
Definition Unit.h:1793
uint32 GetMapId() const
Definition Position.h:281

References ChatHandler::GetCreatureFromPlayerMapByDbGuid(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetSpawnId(), MotionMaster::Initialize(), Unit::IsAlive(), JustDied, LANG_COMMAND_CREATGUIDNOTFOUND, LANG_COMMAND_CREATUREATSAMEMAP, LANG_COMMAND_CREATUREMOVED, SpawnData::mapid, ChatHandler::PSendSysMessage(), Creature::Respawn(), ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), Creature::setDeathState(), Creature::SetPosition(), sObjectMgr, WORLD_UPD_CREATURE_POSITION, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcNearCommand()

static bool npc_commandscript::HandleNpcNearCommand ( ChatHandler handler,
Optional< float >  dist 
)
inlinestatic
779 {
780 float distance = dist.value_or(10.0f);
781 uint32 count = 0;
782
783 Player* player = handler->GetSession()->GetPlayer();
784
785 // Grid search - finds all creatures including temporary spawns
786 std::list<Creature*> creatures;
787 Acore::AllWorldObjectsInRange check(player, distance);
789 Cell::VisitObjects(player, searcher, distance);
790
791 std::unordered_set<ObjectGuid::LowType> gridSpawnIds;
792
793 for (Creature* creature : creatures)
794 {
795 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(creature->GetEntry());
796 if (!creatureTemplate)
797 continue;
798
799 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, creature->GetSpawnId(), creature->GetEntry(),
800 creature->GetSpawnId(), creatureTemplate->Name,
801 creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(),
802 creature->GetMapId(), "", "");
803
804 if (creature->GetSpawnId())
805 gridSpawnIds.insert(creature->GetSpawnId());
806 ++count;
807 }
808
809 if (count > 0 && distance <= SIZE_OF_GRIDS)
810 {
811 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
812 return true;
813 }
814
815 // Fallback to DB query
817 stmt->SetData(0, player->GetPositionX());
818 stmt->SetData(1, player->GetPositionY());
819 stmt->SetData(2, player->GetPositionZ());
820 stmt->SetData(3, player->GetMapId());
821 stmt->SetData(4, player->GetPositionX());
822 stmt->SetData(5, player->GetPositionY());
823 stmt->SetData(6, player->GetPositionZ());
824 stmt->SetData(7, distance * distance);
825 stmt->SetData(8, player->GetPhaseMask());
826 PreparedQueryResult result = WorldDatabase.Query(stmt);
827
828 if (result)
829 {
830 do
831 {
832 Field* fields = result->Fetch();
833 ObjectGuid::LowType guid = fields[0].Get<uint32>();
834
835 // Skip entries already emitted via grid search
836 if (gridSpawnIds.count(guid))
837 continue;
838
839 uint32 entry = fields[1].Get<uint32>();
840 float x = fields[2].Get<float>();
841 float y = fields[3].Get<float>();
842 float z = fields[4].Get<float>();
843 uint16 mapId = fields[5].Get<uint16>();
844
845 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
846 if (!creatureTemplate)
847 continue;
848
849 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, entry, guid, creatureTemplate->Name, x, y, z, mapId, "", "");
850
851 ++count;
852 } while (result->NextRow());
853 }
854
855 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
856
857 return true;
858 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
std::uint16_t uint16
Definition Define.h:108
@ LANG_COMMAND_NEAR_NPC_MESSAGE
Old ones now free:
Definition Language.h:620
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:567
#define SIZE_OF_GRIDS
Definition MapDefines.h:26
@ WORLD_SEL_CREATURE_NEAREST
Definition WorldDatabase.h:92
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:1648
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Definition GridNotifiers.h:496
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
std::string Name
Definition CreatureData.h:192

References Field::Get(), WorldLocation::GetMapId(), WorldObject::GetPhaseMask(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), LANG_COMMAND_NEAR_NPC_MESSAGE, LANG_CREATURE_LIST_CHAT, CreatureTemplate::Name, ChatHandler::PSendSysMessage(), PreparedStatementBase::SetData(), SIZE_OF_GRIDS, sObjectMgr, Cell::VisitObjects(), WORLD_SEL_CREATURE_NEAREST, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcPlayEmoteCommand()

static bool npc_commandscript::HandleNpcPlayEmoteCommand ( ChatHandler handler,
uint32  emote 
)
inlinestatic
931 {
932 Creature* target = handler->getSelectedCreature();
933 if (!target)
934 {
936 return false;
937 }
938
939 target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
940
941 return true;
942 }
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17367

References ChatHandler::getSelectedCreature(), LANG_SELECT_CREATURE, ChatHandler::SendErrorMessage(), Unit::SetUInt32Value(), and UNIT_NPC_EMOTESTATE.

Referenced by GetCommands().

◆ HandleNpcSayCommand()

static bool npc_commandscript::HandleNpcSayCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1189 {
1190 if (text.empty())
1191 return false;
1192
1193 Creature* creature = handler->getSelectedCreature();
1194 if (!creature)
1195 {
1197 return false;
1198 }
1199
1200 creature->Say(text, LANG_UNIVERSAL);
1201
1202 // make some emotes
1203 switch (text.back())
1204 {
1205 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1206 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1207 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1208 }
1209
1210 return true;
1211 }
@ EMOTE_ONESHOT_EXCLAMATION
Definition SharedDefines.h:1903
@ EMOTE_ONESHOT_QUESTION
Definition SharedDefines.h:1904
@ EMOTE_ONESHOT_TALK
Definition SharedDefines.h:1899
@ LANG_UNIVERSAL
Definition SharedDefines.h:723
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:17184
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2187

References EMOTE_ONESHOT_EXCLAMATION, EMOTE_ONESHOT_QUESTION, EMOTE_ONESHOT_TALK, ChatHandler::getSelectedCreature(), Unit::HandleEmoteCommand(), LANG_SELECT_CREATURE, LANG_UNIVERSAL, Unit::Say(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleNpcSetAllowMovementCommand()

static bool npc_commandscript::HandleNpcSetAllowMovementCommand ( ChatHandler handler)
inlinestatic
383 {
384 if (sWorld->getAllowMovement())
385 {
386 sWorld->SetAllowMovement(false);
388 }
389 else
390 {
391 sWorld->SetAllowMovement(true);
393 }
394 return true;
395 }
@ LANG_CREATURE_MOVE_ENABLED
Definition Language.h:440
@ LANG_CREATURE_MOVE_DISABLED
Definition Language.h:439
#define sWorld
Definition World.h:318

References LANG_CREATURE_MOVE_DISABLED, LANG_CREATURE_MOVE_ENABLED, ChatHandler::SendSysMessage(), and sWorld.

Referenced by GetCommands().

◆ HandleNpcSetDataCommand()

static bool npc_commandscript::HandleNpcSetDataCommand ( ChatHandler handler,
uint32  data_1,
uint32  data_2 
)
inlinestatic
594 {
595 Creature* creature = handler->getSelectedCreature();
596
597 if (!creature)
598 {
600 return false;
601 }
602
603 creature->AI()->SetData(data_1, data_2);
604 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
605 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript);
606 return true;
607 }
@ LANG_NPC_SETDATA
Definition Language.h:617
virtual void SetData(uint32, uint32)
Definition UnitAI.h:219

References Creature::AI(), Creature::GetAIName(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetName(), Creature::GetScriptName(), ChatHandler::getSelectedCreature(), LANG_NPC_SETDATA, LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), UnitAI::SetData(), and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleNpcSetEntryCommand()

static bool npc_commandscript::HandleNpcSetEntryCommand ( ChatHandler handler,
CreatureEntry  newEntryNum 
)
inlinestatic
398 {
399 if (!newEntryNum)
400 return false;
401
402 Unit* unit = handler->getSelectedUnit();
403 if (!unit || !unit->IsCreature())
404 {
406 return false;
407 }
408 Creature* creature = unit->ToCreature();
409 if (creature->UpdateEntry(newEntryNum))
410 handler->SendSysMessage(LANG_DONE);
411 else
412 handler->SendSysMessage(LANG_ERROR);
413 return true;
414 }
@ LANG_ERROR
Definition Language.h:78
@ LANG_DONE
Definition Language.h:75
Unit * getSelectedUnit() const
Definition Chat.cpp:394
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool changelevel=true, bool updateAI=false)
Definition Creature.cpp:581
bool IsCreature() const
Definition Object.h:205
Creature * ToCreature()
Definition Object.h:206
Definition Unit.h:665

References ChatHandler::getSelectedUnit(), Object::IsCreature(), LANG_DONE, LANG_ERROR, LANG_SELECT_CREATURE, ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), Object::ToCreature(), and Creature::UpdateEntry().

Referenced by GetCommands().

◆ HandleNpcSetFactionIdCommand()

static bool npc_commandscript::HandleNpcSetFactionIdCommand ( ChatHandler handler,
uint32  factionId 
)
inlinestatic
493 {
494 if (!sFactionTemplateStore.LookupEntry(factionId))
495 {
496 handler->SendErrorMessage(LANG_WRONG_FACTION, factionId);
497 return false;
498 }
499
500 Creature* creature = handler->getSelectedCreature();
501
502 if (!creature)
503 {
505 return false;
506 }
507
508 creature->SetFaction(factionId);
509
510 // Faction is set in creature_template - not inside creature
511
512 // Update in memory..
513 if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
514 const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
515
516 // ..and DB
518
519 stmt->SetData(0, uint16(factionId));
520 stmt->SetData(1, creature->GetEntry());
521
522 WorldDatabase.Execute(stmt);
523
524 return true;
525 }
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
@ LANG_WRONG_FACTION
Definition Language.h:167
@ WORLD_UPD_CREATURE_FACTION
Definition WorldDatabase.h:48
void SetFaction(uint32 faction)
Definition Unit.cpp:7117

References Creature::GetCreatureTemplate(), Object::GetEntry(), ChatHandler::getSelectedCreature(), LANG_SELECT_CREATURE, LANG_WRONG_FACTION, ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), Unit::SetFaction(), sFactionTemplateStore, WORLD_UPD_CREATURE_FACTION, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcSetFactionTempIdCommand()

static bool npc_commandscript::HandleNpcSetFactionTempIdCommand ( ChatHandler handler,
uint32  tempfaction 
)
inlinestatic
529 {
530 Player* player = handler->GetSession()->GetPlayer();
531 Unit* unit = player->GetSelectedUnit();
532
533 if (!unit)
534 return false;
535
536 Creature* creature = unit->ToCreature();
537
538 if (!creature)
539 return false;
540
541 creature->SetFaction(tempfaction);
542
543 return true;
544 }
Unit * GetSelectedUnit() const
Definition Player.cpp:11715

References WorldSession::GetPlayer(), Player::GetSelectedUnit(), ChatHandler::GetSession(), Unit::SetFaction(), and Object::ToCreature().

Referenced by GetCommands().

◆ HandleNpcSetFlagCommand()

static bool npc_commandscript::HandleNpcSetFlagCommand ( ChatHandler handler,
uint32  npcFlags 
)
inlinestatic
569 {
570 Creature* creature = handler->getSelectedCreature();
571
572 if (!creature)
573 {
575 return false;
576 }
577
578 creature->ReplaceAllNpcFlags(NPCFlags(npcFlags));
579
581
582 stmt->SetData(0, NPCFlags(npcFlags));
583 stmt->SetData(1, creature->GetEntry());
584
585 WorldDatabase.Execute(stmt);
586
588
589 return true;
590 }
@ LANG_VALUE_SAVED_REJOIN
Definition Language.h:313
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:320
@ WORLD_UPD_CREATURE_NPCFLAG
Definition WorldDatabase.h:49
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:767

References Object::GetEntry(), ChatHandler::getSelectedCreature(), LANG_SELECT_CREATURE, LANG_VALUE_SAVED_REJOIN, Unit::ReplaceAllNpcFlags(), ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), WORLD_UPD_CREATURE_NPCFLAG, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcSetLevelCommand()

static bool npc_commandscript::HandleNpcSetLevelCommand ( ChatHandler handler,
uint8  lvl 
)
inlinestatic
418 {
419 if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
420 {
422 return false;
423 }
424
425 Creature* creature = handler->getSelectedCreature();
426 if (!creature || creature->IsPet())
427 {
429 return false;
430 }
431
432 creature->SetMaxHealth(100 + 30*lvl);
433 creature->SetHealth(100 + 30*lvl);
434 creature->SetLevel(lvl);
435 creature->SaveToDB();
436
437 return true;
438 }
@ LANG_BAD_VALUE
Definition Language.h:151
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:195
void SetHealth(uint32 val)
Definition Unit.cpp:12352
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:12334
void SetMaxHealth(uint32 val)
Definition Unit.cpp:12402

References CONFIG_MAX_PLAYER_LEVEL, ChatHandler::getSelectedCreature(), Unit::IsPet(), LANG_BAD_VALUE, LANG_SELECT_CREATURE, Creature::SaveToDB(), ChatHandler::SendErrorMessage(), Unit::SetHealth(), Unit::SetLevel(), Unit::SetMaxHealth(), and sWorld.

Referenced by GetCommands().

◆ HandleNpcSetLinkCommand()

static bool npc_commandscript::HandleNpcSetLinkCommand ( ChatHandler handler,
ObjectGuid::LowType  linkguid 
)
inlinestatic
1417 {
1418 Creature* creature = handler->getSelectedCreature();
1419
1420 if (!creature)
1421 {
1423 return false;
1424 }
1425
1426 if (!creature->GetSpawnId())
1427 {
1428 handler->SendErrorMessage("Selected creature {} isn't in creature table", creature->GetGUID().ToString());
1429 return false;
1430 }
1431
1432 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1433 {
1434 handler->SendErrorMessage("Selected creature can't link with guid '{}'", linkguid);
1435 return false;
1436 }
1437
1438 handler->PSendSysMessage("LinkGUID '{}' added to creature with DBTableGUID: '{}'", linkguid, creature->GetSpawnId());
1439 return true;
1440 }

References Object::GetGUID(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sObjectMgr, and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleNpcSetModelCommand()

static bool npc_commandscript::HandleNpcSetModelCommand ( ChatHandler handler,
uint32  displayId 
)
inlinestatic
946 {
947 Creature* creature = handler->getSelectedCreature();
948
949 if (!creature || creature->IsPet())
950 {
952 return false;
953 }
954
955 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
956 {
958 return false;
959 }
960
961 creature->SetDisplayId(displayId);
962 creature->SetNativeDisplayId(displayId);
963 creature->SaveToDB();
964
965 return true;
966 }
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ LANG_COMMAND_FACTION_INVPARAM
Definition Language.h:359
void SetDisplayId(uint32 displayId, float displayScale=1.f) override
Definition Creature.cpp:3533
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:1978
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250

References ChatHandler::getSelectedCreature(), Unit::IsPet(), LANG_COMMAND_FACTION_INVPARAM, LANG_SELECT_CREATURE, Creature::SaveToDB(), sCreatureDisplayInfoStore, ChatHandler::SendErrorMessage(), Creature::SetDisplayId(), Unit::SetNativeDisplayId(), and Acore::ToString().

Referenced by GetCommands().

◆ HandleNpcSetMoveTypeCommand()

static bool npc_commandscript::HandleNpcSetMoveTypeCommand ( ChatHandler handler,
Optional< CreatureSpawnId lowGuid,
Variant< EXACT_SEQUENCE("stay"), EXACT_SEQUENCE("random"), EXACT_SEQUENCE("way")>  type,
Optional< EXACT_SEQUENCE("nodel")>  nodel 
)
inlinestatic

HandleNpcSetMoveTypeCommand Set the movement type for an NPC.

Valid movement types are:

  • stay - NPC wont move
  • random - NPC will move randomly according to the wander_distance
  • way - NPC will move with given waypoints set

additional parameter: NODEL - so no waypoints are deleted, if you change the movement type

981 {
982 // 3 arguments:
983 // GUID (optional - you can also select the creature)
984 // stay|random|way (determines the kind of movement)
985 // NODEL (optional - tells the system NOT to delete any waypoints)
986 // this is very handy if you want to do waypoints, that are
987 // later switched on/off according to special events (like escort
988 // quests, etc)
989
990 bool doNotDelete = nodel.has_value();
991
992 ObjectGuid::LowType lowguid = 0;
993 Creature* creature = nullptr;
994
995 if (!lowGuid) // case .setmovetype $move_type (with selected creature)
996 {
997 creature = handler->getSelectedCreature();
998 if (!creature || creature->IsPet())
999 return false;
1000 lowguid = creature->GetSpawnId();
1001 }
1002 else // case .setmovetype #creature_guid $move_type (with selected creature)
1003 {
1004 lowguid = *lowGuid;
1005
1006 if (lowguid)
1007 creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
1008
1009 // attempt check creature existence by DB data
1010 if (!creature)
1011 {
1012 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
1013 if (!data)
1014 {
1016 return false;
1017 }
1018 }
1019 else
1020 {
1021 lowguid = creature->GetSpawnId();
1022 }
1023 }
1024
1025 // now lowguid is low guid really existed creature
1026 // and creature point (maybe) to this creature or nullptr
1027
1028 MovementGeneratorType move_type;
1029 switch (type.index())
1030 {
1031 case 0:
1032 move_type = IDLE_MOTION_TYPE;
1033 break;
1034 case 1:
1035 move_type = RANDOM_MOTION_TYPE;
1036 break;
1037 case 2:
1038 move_type = WAYPOINT_MOTION_TYPE;
1039 break;
1040 default:
1041 return false;
1042 }
1043
1044 // update movement type
1045 //if (doNotDelete == false)
1046 // WaypointMgr.DeletePath(lowguid);
1047
1048 if (creature)
1049 {
1050 // update movement type
1051 if (!doNotDelete)
1052 creature->LoadPath(0);
1053
1054 creature->SetDefaultMovementType(move_type);
1055 creature->GetMotionMaster()->Initialize();
1056
1057 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1058 {
1060 creature->Respawn();
1061 }
1062
1063 creature->SaveToDB();
1064 }
1065
1066 if (!doNotDelete)
1067 {
1068 handler->PSendSysMessage(LANG_MOVE_TYPE_SET, move_type);
1069 }
1070 else
1071 {
1072 handler->PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, move_type);
1073 }
1074
1075 return true;
1076 }
@ LANG_MOVE_TYPE_SET
Definition Language.h:309
@ LANG_MOVE_TYPE_SET_NODEL
Definition Language.h:310
MovementGeneratorType
Definition MotionMaster.h:38
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
@ RANDOM_MOTION_TYPE
Definition MotionMaster.h:40
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition Creature.h:92
void LoadPath(uint32 pathid)
Definition Creature.h:358

References ChatHandler::GetCreatureFromPlayerMapByDbGuid(), Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), Unit::IsAlive(), Unit::IsPet(), JustDied, LANG_COMMAND_CREATGUIDNOTFOUND, LANG_MOVE_TYPE_SET, LANG_MOVE_TYPE_SET_NODEL, Creature::LoadPath(), ChatHandler::PSendSysMessage(), RANDOM_MOTION_TYPE, Creature::Respawn(), Creature::SaveToDB(), ChatHandler::SendErrorMessage(), Creature::setDeathState(), Creature::SetDefaultMovementType(), sObjectMgr, and WAYPOINT_MOTION_TYPE.

Referenced by GetCommands().

◆ HandleNpcSetOriginalFaction()

static bool npc_commandscript::HandleNpcSetOriginalFaction ( ChatHandler handler)
inlinestatic
548 {
549 Player* player = handler->GetSession()->GetPlayer();
550
551 if (!player)
552 return false;
553
554 if (!player->GetSelectedUnit())
555 return false;
556
557 Creature* creature = player->GetSelectedUnit()->ToCreature();
558
559 if (!creature)
560 return false;
561
562 creature->RestoreFaction();
563
564 return true;
565 }
void RestoreFaction()
Definition Unit.cpp:14969

References WorldSession::GetPlayer(), Player::GetSelectedUnit(), ChatHandler::GetSession(), Unit::RestoreFaction(), and Object::ToCreature().

Referenced by GetCommands().

◆ HandleNpcSetPhaseCommand()

static bool npc_commandscript::HandleNpcSetPhaseCommand ( ChatHandler handler,
uint32  phasemask 
)
inlinestatic
1081 {
1082 if (phasemask == 0)
1083 {
1085 return false;
1086 }
1087
1088 Creature* creature = handler->getSelectedCreature();
1089 if (!creature)
1090 {
1092 return false;
1093 }
1094
1095 creature->SetPhaseMask(phasemask, true);
1096
1097 if (!creature->IsPet())
1098 creature->SaveToDB();
1099
1100 return true;
1101 }
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition Unit.cpp:15323

References ChatHandler::getSelectedCreature(), Unit::IsPet(), LANG_BAD_VALUE, LANG_SELECT_CREATURE, Creature::SaveToDB(), ChatHandler::SendErrorMessage(), and Unit::SetPhaseMask().

Referenced by GetCommands().

◆ HandleNpcSetSpawnTimeCommand()

static bool npc_commandscript::HandleNpcSetSpawnTimeCommand ( ChatHandler handler,
std::string  spawnTimeStr 
)
inlinestatic
1149 {
1150 if (spawnTimeStr.empty())
1151 {
1152 return false;
1153 }
1154
1155 if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
1156 {
1158 return false;
1159 }
1160
1161 Creature* creature = handler->getSelectedCreature();
1162 if (!creature)
1163 return false;
1164
1165 int32 spawnTime = TimeStringToSecs(spawnTimeStr);
1166 if (spawnTime <= 0)
1167 {
1168 spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
1169 }
1170
1171 if (spawnTime <= 0)
1172 {
1174 return false;
1175 }
1176
1178 stmt->SetData(0, spawnTime);
1179 stmt->SetData(1, creature->GetSpawnId());
1180 WorldDatabase.Execute(stmt);
1181
1182 creature->SetRespawnDelay(spawnTime);
1183 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true));
1184
1185 return true;
1186 }
std::int32_t int32
Definition Define.h:103
@ LANG_COMMAND_SPAWNTIME
Definition Language.h:346
uint32 TimeStringToSecs(std::string const &timestring)
Definition Util.cpp:163
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
Definition WorldDatabase.h:52
void SetRespawnDelay(uint32 delay)
Definition Creature.h:297

References ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), LANG_BAD_VALUE, LANG_COMMAND_SPAWNTIME, ChatHandler::PSendSysMessage(), secsToTimeString(), ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), Creature::SetRespawnDelay(), TimeStringToSecs(), WORLD_UPD_CREATURE_SPAWN_TIME_SECS, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcSetWanderDistanceCommand()

static bool npc_commandscript::HandleNpcSetWanderDistanceCommand ( ChatHandler handler,
float  option 
)
inlinestatic
1105 {
1106 if (option < 0.0f)
1107 {
1109 return false;
1110 }
1111
1113
1114 if (option > 0.0f)
1115 mtype = RANDOM_MOTION_TYPE;
1116
1117 Creature* creature = handler->getSelectedCreature();
1118 ObjectGuid::LowType guidLow = 0;
1119
1120 if (creature)
1121 guidLow = creature->GetSpawnId();
1122 else
1123 return false;
1124
1125 creature->SetWanderDistance((float)option);
1126 creature->SetDefaultMovementType(mtype);
1127 creature->GetMotionMaster()->Initialize();
1128
1129 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1130 {
1132 creature->Respawn();
1133 }
1134
1136
1137 stmt->SetData(0, option);
1138 stmt->SetData(1, uint8(mtype));
1139 stmt->SetData(2, guidLow);
1140
1141 WorldDatabase.Execute(stmt);
1142
1144 return true;
1145 }
@ LANG_COMMAND_WANDER_DISTANCE
Definition Language.h:345
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
Definition WorldDatabase.h:51
void SetWanderDistance(float dist)
Definition Creature.h:308

References Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), Unit::IsAlive(), JustDied, LANG_BAD_VALUE, LANG_COMMAND_WANDER_DISTANCE, ChatHandler::PSendSysMessage(), RANDOM_MOTION_TYPE, Creature::Respawn(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), Creature::setDeathState(), Creature::SetDefaultMovementType(), Creature::SetWanderDistance(), WORLD_UPD_CREATURE_WANDER_DISTANCE, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcShowLootCommand()

static bool npc_commandscript::HandleNpcShowLootCommand ( ChatHandler handler)
inlinestatic
1509 {
1510 Creature* creatureTarget = handler->getSelectedCreature();
1511 if (!creatureTarget || creatureTarget->IsPet())
1512 {
1514 return false;
1515 }
1516
1517 Loot const& loot = creatureTarget->loot;
1518 if (!creatureTarget->isDead() || (loot.empty() && loot.quest_items.empty()))
1519 {
1520 handler->SendErrorMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName());
1521 return false;
1522 }
1523
1524 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_HEADER, creatureTarget->GetName(), creatureTarget->GetEntry());
1525 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_MONEY, loot.gold / GOLD, (loot.gold % GOLD) / SILVER, loot.gold % SILVER);
1526
1528 for (LootItem const& item : loot.items)
1529 if (!item.is_looted)
1530 ShowLootEntry(handler, item);
1531
1533 for (LootItem const& item : loot.quest_items)
1534 if (!item.is_looted)
1535 ShowLootEntry(handler, item);
1536
1537 return true;
1538 }
@ LANG_COMMAND_NOT_DEAD_OR_NO_LOOT
Definition Language.h:1530
@ LANG_COMMAND_NPC_SHOWLOOT_QUEST
Definition Language.h:1535
@ LANG_COMMAND_NPC_SHOWLOOT_ITEMS
Definition Language.h:1533
@ LANG_COMMAND_NPC_SHOWLOOT_HEADER
Definition Language.h:1531
@ LANG_COMMAND_NPC_SHOWLOOT_MONEY
Definition Language.h:1532
@ SILVER
Definition SharedDefines.h:240
@ GOLD
Definition SharedDefines.h:241
Loot loot
Definition Creature.h:231
bool isDead() const
Definition Unit.h:1795
static void ShowLootEntry(ChatHandler *handler, LootItem const &item)
Definition cs_npc.cpp:1496
Definition LootMgr.h:154
Definition LootMgr.h:313
bool empty() const
Definition LootMgr.h:367
uint32 gold
Definition LootMgr.h:322
std::vector< LootItem > items
Definition LootMgr.h:320
std::vector< LootItem > quest_items
Definition LootMgr.h:321

References Loot::empty(), Object::GetEntry(), WorldObject::GetName(), ChatHandler::getSelectedCreature(), Loot::gold, GOLD, Unit::isDead(), Unit::IsPet(), Loot::items, LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, LANG_COMMAND_NPC_SHOWLOOT_HEADER, LANG_COMMAND_NPC_SHOWLOOT_ITEMS, LANG_COMMAND_NPC_SHOWLOOT_MONEY, LANG_COMMAND_NPC_SHOWLOOT_QUEST, LANG_SELECT_CREATURE, Creature::loot, ChatHandler::PSendSysMessage(), Loot::quest_items, ChatHandler::SendErrorMessage(), ShowLootEntry(), and SILVER.

Referenced by GetCommands().

◆ HandleNpcSpawnGroupCommand()

static bool npc_commandscript::HandleNpcSpawnGroupCommand ( ChatHandler handler,
uint32  groupId 
)
inlinestatic
1443 {
1444 Player* player = handler->GetSession()->GetPlayer();
1445 if (!player)
1446 return false;
1447
1448 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
1449 if (!groupData)
1450 {
1452 return false;
1453 }
1454
1455 if (groupData->flags & SPAWNGROUP_FLAG_SYSTEM)
1456 {
1457 handler->SendErrorMessage(LANG_SPAWNGROUP_SPAWN_SYSTEM_ERROR, groupId, groupData->name);
1458 return false;
1459 }
1460
1461 if (player->GetMap()->SpawnGroupSpawn(groupId, true, true))
1462 handler->PSendSysMessage(LANG_SPAWNGROUP_SPAWN_SUCCESS, groupId, groupData->name);
1463 else
1464 handler->SendErrorMessage(LANG_SPAWNGROUP_SPAWN_FAILED, groupId, groupData->name);
1465
1466 return true;
1467 }
@ LANG_SPAWNGROUP_SPAWN_SYSTEM_ERROR
Definition Language.h:1467
@ LANG_SPAWNGROUP_SPAWN_FAILED
Definition Language.h:1469
@ LANG_SPAWNGROUP_SPAWN_SUCCESS
Definition Language.h:1468
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false)
Definition Map.cpp:2614

References SpawnGroupTemplateData::flags, WorldObject::GetMap(), WorldSession::GetPlayer(), ChatHandler::GetSession(), LANG_SPAWNGROUP_NOT_FOUND, LANG_SPAWNGROUP_SPAWN_FAILED, LANG_SPAWNGROUP_SPAWN_SUCCESS, LANG_SPAWNGROUP_SPAWN_SYSTEM_ERROR, SpawnGroupTemplateData::name, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), sObjectMgr, SPAWNGROUP_FLAG_SYSTEM, and Map::SpawnGroupSpawn().

Referenced by GetCommands().

◆ HandleNpcTameCommand()

static bool npc_commandscript::HandleNpcTameCommand ( ChatHandler handler)
inlinestatic
1323 {
1324 Creature* creatureTarget = handler->getSelectedCreature();
1325 if (!creatureTarget || creatureTarget->IsPet())
1326 {
1328 handler->SetSentErrorMessage(true);
1329 return false;
1330 }
1331
1332 Player* player = handler->GetSession()->GetPlayer();
1333
1334 if (player->IsExistPet())
1335 {
1337 return false;
1338 }
1339
1340 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1341
1342 if (!cInfo->IsTameable(player->CanTameExoticPets()))
1343 {
1345 handler->SetSentErrorMessage (true);
1346 return false;
1347 }
1348
1349 if (!player->CreatePet(creatureTarget))
1350 {
1352 return false;
1353 }
1354
1355 return true;
1356 }
@ LANG_CREATURE_NON_TAMEABLE
Definition Language.h:393
@ LANG_YOU_ALREADY_HAVE_PET
Definition Language.h:394
bool IsExistPet()
Definition Player.cpp:9413
bool CanTameExoticPets() const
Definition Player.h:2219
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition Player.cpp:9419
uint32 Entry
Definition CreatureData.h:188
bool IsTameable(bool exotic) const
Definition CreatureData.h:269

References Player::CanTameExoticPets(), Player::CreatePet(), CreatureTemplate::Entry, Creature::GetCreatureTemplate(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Player::IsExistPet(), Unit::IsPet(), CreatureTemplate::IsTameable(), LANG_CREATURE_NON_TAMEABLE, LANG_SELECT_CREATURE, LANG_YOU_ALREADY_HAVE_PET, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleNpcTextEmoteCommand()

static bool npc_commandscript::HandleNpcTextEmoteCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1215 {
1216 if (text.empty())
1217 return false;
1218
1219 Creature* creature = handler->getSelectedCreature();
1220
1221 if (!creature)
1222 {
1224 return false;
1225 }
1226
1227 creature->TextEmote(text);
1228
1229 return true;
1230 }
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:17194

References ChatHandler::getSelectedCreature(), LANG_SELECT_CREATURE, ChatHandler::SendErrorMessage(), and Unit::TextEmote().

Referenced by GetCommands().

◆ HandleNpcUnFollowCommand()

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler)
inlinestatic
1234 {
1235 Player* player = handler->GetSession()->GetPlayer();
1236 Creature* creature = handler->getSelectedCreature();
1237
1238 if (!creature)
1239 {
1241 return false;
1242 }
1243
1244 if (/*creature->GetMotionMaster()->empty() ||*/
1246 {
1247 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1248 return false;
1249 }
1250
1251 FollowMovementGenerator<Creature> const* mgen = static_cast<FollowMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top()));
1252
1253 if (mgen->GetTarget() != player)
1254 {
1255 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1256 return false;
1257 }
1258
1259 // reset movement
1260 creature->GetMotionMaster()->MovementExpired(true);
1261
1263 return true;
1264 }
@ LANG_CREATURE_NOT_FOLLOW_YOU
Definition Language.h:391
@ LANG_CREATURE_NOT_FOLLOW_YOU_NOW
Definition Language.h:392
@ FOLLOW_MOTION_TYPE
Definition MotionMaster.h:54
Definition TargetedMovementGenerator.h:82
Unit * GetTarget() const
Definition TargetedMovementGenerator.h:96
_Ty top() const
Definition MotionMaster.h:176
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition MotionMaster.cpp:981
void MovementExpired(bool reset=true)
Definition MotionMaster.h:206

References FOLLOW_MOTION_TYPE, MotionMaster::GetCurrentMovementGeneratorType(), Unit::GetMotionMaster(), WorldObject::GetName(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), FollowMovementGenerator< T >::GetTarget(), LANG_CREATURE_NOT_FOLLOW_YOU, LANG_CREATURE_NOT_FOLLOW_YOU_NOW, LANG_SELECT_CREATURE, MotionMaster::MovementExpired(), ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and MotionMaster::top().

Referenced by GetCommands().

◆ HandleNpcWhisperCommand()

static bool npc_commandscript::HandleNpcWhisperCommand ( ChatHandler handler,
std::string const &  recv,
Tail  text 
)
inlinestatic
1268 {
1269 if (text.empty())
1270 return false;
1271
1272 Creature* creature = handler->getSelectedCreature();
1273 if (!creature)
1274 {
1276 return false;
1277 }
1278
1279 // check online security
1280 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1281 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1282 return false;
1283
1284 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1285 return true;
1286 }
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:65
static ObjectGuid const Empty
Definition ObjectGuid.h:123
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:17199
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition ObjectAccessor.cpp:295

References ObjectGuid::Empty, ObjectAccessor::FindPlayerByName(), ChatHandler::getSelectedCreature(), ChatHandler::HasLowerSecurity(), LANG_SELECT_CREATURE, LANG_UNIVERSAL, ChatHandler::SendErrorMessage(), and Unit::Whisper().

Referenced by GetCommands().

◆ HandleNpcYellCommand()

static bool npc_commandscript::HandleNpcYellCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1289 {
1290 if (text.empty())
1291 return false;
1292
1293 Creature* creature = handler->getSelectedCreature();
1294 if (!creature)
1295 {
1297 return false;
1298 }
1299
1300 creature->Yell(text, LANG_UNIVERSAL);
1301
1302 // make an emote
1304
1305 return true;
1306 }
@ EMOTE_ONESHOT_SHOUT
Definition SharedDefines.h:1918
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:17189

References EMOTE_ONESHOT_SHOUT, ChatHandler::getSelectedCreature(), Unit::HandleEmoteCommand(), LANG_SELECT_CREATURE, LANG_UNIVERSAL, ChatHandler::SendErrorMessage(), and Unit::Yell().

Referenced by GetCommands().

◆ ShowLootEntry()

static void npc_commandscript::ShowLootEntry ( ChatHandler handler,
LootItem const &  item 
)
inlinestatic
1497 {
1498 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item.itemid);
1499 std::string name = itemTemplate ? itemTemplate->Name1 : "Unknown item";
1500 if (itemTemplate)
1501 if (ItemLocale const* il = sObjectMgr->GetItemLocale(item.itemid))
1502 ObjectMgr::GetLocaleString(il->Name, handler->GetSessionDbLocaleIndex(), name);
1503
1504 uint32 color = ItemQualityColors[itemTemplate ? itemTemplate->Quality : uint32(ITEM_QUALITY_POOR)];
1505 handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_ENTRY, item.count, color, item.itemid, name, item.itemid);
1506 }
@ LANG_COMMAND_NPC_SHOWLOOT_ENTRY
Definition Language.h:1534
const uint32 ItemQualityColors[MAX_ITEM_QUALITY]
Definition SharedDefines.h:341
@ ITEM_QUALITY_POOR
Definition SharedDefines.h:317
virtual int GetSessionDbLocaleIndex() const
Definition Chat.cpp:883
static std::string_view GetLocaleString(std::vector< std::string > const &data, std::size_t locale)
Definition ObjectMgr.h:1490
Definition ItemTemplate.h:834
Definition ItemTemplate.h:619
uint32 Quality
Definition ItemTemplate.h:626
std::string Name1
Definition ItemTemplate.h:624

References LootItem::count, ObjectMgr::GetLocaleString(), ChatHandler::GetSessionDbLocaleIndex(), ITEM_QUALITY_POOR, LootItem::itemid, ItemQualityColors, LANG_COMMAND_NPC_SHOWLOOT_ENTRY, ItemTemplate::Name1, ChatHandler::PSendSysMessage(), ItemTemplate::Quality, and sObjectMgr.

Referenced by HandleNpcShowLootCommand().


The documentation for this class was generated from the following file: