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 ()
 
const std::string & 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)
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ npc_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable npc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

144 {
145 static ChatCommandTable npcAddCommandTable =
146 {
152 };
153 static ChatCommandTable npcDeleteCommandTable =
154 {
157 };
158 static ChatCommandTable npcFollowCommandTable =
159 {
162 };
163
164 static ChatCommandTable npcFactionCommandTable =
165 {
169 };
170
171 static ChatCommandTable npcSetCommandTable =
172 {
175 { "faction", npcFactionCommandTable},
185 };
186 static ChatCommandTable npcCommandTable =
187 {
199 { "add", npcAddCommandTable },
200 { "delete", npcDeleteCommandTable },
201 { "follow", npcFollowCommandTable },
202 { "load", HandleNpcLoadCommand, SEC_ADMINISTRATOR, Console::Yes },
203 { "set", npcSetCommandTable },
204 { "spawngroup", HandleNpcSpawnGroupCommand, SEC_ADMINISTRATOR, Console::No },
205 { "despawngroup", HandleNpcDespawnGroupCommand, SEC_ADMINISTRATOR, Console::No }
206 };
207 static ChatCommandTable commandTable =
208 {
209 { "npc", npcCommandTable }
210 };
211 return commandTable;
212 }
@ SEC_ADMINISTRATOR
Definition Common.h:60
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:526
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition cs_npc.cpp:1104
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:215
static bool HandleNpcSetOriginalFaction(ChatHandler *handler)
Definition cs_npc.cpp:545
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:746
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition cs_npc.cpp:1080
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:608
static bool HandleNpcInfoCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnIdArg)
Definition cs_npc.cpp:626
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:415
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition cs_npc.cpp:380
static bool HandleNpcDeleteCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > lowGuid)
Definition cs_npc.cpp:438
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:776
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:591
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< bool > addMulti)
Definition cs_npc.cpp:325
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< bool > addMulti)
Definition cs_npc.cpp:463
static bool HandleNpcSetFlagCommand(ChatHandler *handler, uint32 npcFlags)
Definition cs_npc.cpp:566
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition cs_npc.cpp:1416
static bool HandleNpcLoadCommand(ChatHandler *handler, CreatureSpawnId spawnId)
Definition cs_npc.cpp:273
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition cs_npc.cpp:490
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition cs_npc.cpp:395
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition cs_npc.cpp:359
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_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_SET_DATA
Definition RBAC.h:422
@ 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(), 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_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_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_TAME, rbac::RBAC_PERM_COMMAND_NPC_TEXTEMOTE, rbac::RBAC_PERM_COMMAND_NPC_WHISPER, rbac::RBAC_PERM_COMMAND_NPC_YELL, and SEC_ADMINISTRATOR.

◆ HandleNpcAddCommand()

static bool npc_commandscript::HandleNpcAddCommand ( ChatHandler handler,
CreatureEntry  id 
)
inlinestatic
216 {
217 if (!sObjectMgr->GetCreatureTemplate(id))
218 return false;
219
220 Player* chr = handler->GetSession()->GetPlayer();
221 float x = chr->GetPositionX();
222 float y = chr->GetPositionY();
223 float z = chr->GetPositionZ();
224 float o = chr->GetOrientation();
225 Map* map = chr->GetMap();
226
227 if (Transport* tt = chr->GetTransport())
228 if (MotionTransport* trans = tt->ToMotionTransport())
229 {
230 ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
231 CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
232 data.id1 = id;
233 data.phaseMask = chr->GetPhaseMaskForSpawn();
234 data.posX = chr->GetTransOffsetX();
235 data.posY = chr->GetTransOffsetY();
236 data.posZ = chr->GetTransOffsetZ();
237 data.orientation = chr->GetTransOffsetO();
238
239 if (Creature* creature = trans->CreateNPCPassenger(guid, &data))
240 {
241 creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMaskForSpawn());
242 sObjectMgr->AddCreatureToGrid(guid, &data);
243 }
244 return true;
245 }
246
247 Creature* creature = new Creature();
248 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
249 {
250 delete creature;
251 return false;
252 }
253
254 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
255
256 ObjectGuid::LowType spawnId = creature->GetSpawnId();
257
258 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
259 // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
260 creature->CleanupsBeforeDelete();
261 delete creature;
262 creature = new Creature();
263 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
264 {
265 delete creature;
266 return false;
267 }
268
269 sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId));
270 return true;
271 }
#define sObjectMgr
Definition ObjectMgr.h:1723
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:1679
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:69
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData *data=nullptr)
Definition Creature.cpp:1151
void SaveToDB()
Definition Creature.cpp:1380
MotionTransport * ToMotionTransport()
Definition GameObject.h:328
Definition Map.h:166
uint8 GetSpawnMode() const
Definition Map.h:269
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:519
uint32 GetId() const
Definition Map.h:232
Definition Transport.h:51
uint32 LowType
Definition ObjectGuid.h:122
Definition Player.h:1084
uint32 GetPhaseMaskForSpawn() const
Definition Player.cpp:13829
Definition Transport.h:30
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:12620
Map * GetMap() const
Definition Object.h:625
float GetTransOffsetX() const
Definition Object.h:689
float GetTransOffsetY() const
Definition Object.h:690
float GetTransOffsetZ() const
Definition Object.h:691
Transport * GetTransport() const
Definition Object.h:688
float GetTransOffsetO() const
Definition Object.h:692
Player * GetPlayer() const
Definition WorldSession.h:454
Definition CreatureData.h:370
uint32 id1
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::id1, 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:52
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(const Position *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
360 {
361 // attempt check creature existence by DB data
362 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
363 if (!data)
364 {
366 return false;
367 }
368
369 // Update movement type
372 stmt->SetData(1, uint32(lowGuid));
373 WorldDatabase.Execute(stmt);
374
376
377 return true;
378 }
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:46
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, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2393

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
326 {
327 if (!item)
328 {
330 return false;
331 }
332
333 Creature* vendor = handler->getSelectedCreature();
334 if (!vendor)
335 {
337 return false;
338 }
339
340 uint32 itemId = item->ItemId;
341 uint32 maxcount = mc.value_or(0);
342 uint32 incrtime = it.value_or(0);
343 uint32 extendedcost = ec.value_or(0);
344 uint32 vendor_entry = addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry();
345
346 if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, handler->GetSession()->GetPlayer()))
347 {
348 handler->SetSentErrorMessage(true);
349 return false;
350 }
351
352 sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost);
353
354 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1, maxcount, incrtime, extendedcost);
355 return true;
356 }
@ 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:458

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
439 {
440 Creature* creature;
441 if (lowGuid.has_value())
442 creature = handler->GetCreatureFromPlayerMapByDbGuid(*lowGuid);
443 else
444 creature = handler->getSelectedCreature();
445
446 if (!creature || creature->IsPet() || creature->IsTotem())
447 {
449 return false;
450 }
451
452 // Delete the creature
453 creature->CombatStop();
454 creature->DeleteFromDB();
455 creature->AddObjectToRemoveList();
456
458
459 return true;
460 }
@ LANG_COMMAND_DELCREATMESSAGE
Definition Language.h:323
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:586
virtual void DeleteFromDB()
Definition Creature.cpp:1834
bool IsPet() const
Definition Unit.h:797
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7486
bool IsTotem() const
Definition Unit.h:799
void AddObjectToRemoveList()
Definition Object.cpp:2173

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
464 {
465 Creature* vendor = handler->getSelectedCreature();
466 if (!vendor || !vendor->IsVendor())
467 {
469 return false;
470 }
471
472 if (!item)
473 {
475 return false;
476 }
477
478 uint32 itemId = item->ItemId;
479 if (!sObjectMgr->RemoveVendorItem(addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry(), itemId))
480 {
481 handler->SendErrorMessage(LANG_ITEM_NOT_IN_LIST, itemId);
482 return false;
483 }
484
485 handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1);
486 return true;
487 }
@ 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:803

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:1463
@ LANG_SPAWNGROUP_DESPAWN_SUCCESS
Definition Language.h:1462
@ LANG_SPAWNGROUP_NOT_FOUND
Definition Language.h:1469
@ LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR
Definition Language.h:1461
@ SPAWNGROUP_FLAG_SYSTEM
Definition SpawnData.h:44
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false)
Definition Map.cpp:2633
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:47
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:528

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
609 {
610 Player* player = handler->GetSession()->GetPlayer();
611 Creature* creature = handler->getSelectedCreature();
612
613 if (!creature)
614 {
616 return false;
617 }
618
619 // Follow player - Using pet's default dist and angle
620 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
621
623 return true;
624 }
@ 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:447
MotionMaster * GetMotionMaster()
Definition Unit.h:1759
virtual float GetFollowAngle() const
Definition Unit.h:1896

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
747 {
748 Creature* target = handler->getSelectedCreature();
749
750 if (!target)
751 {
753 return false;
754 }
755
756 uint32 faction = target->GetFaction();
757 uint32 npcflags = target->GetNpcFlags();
758 uint32 displayid = target->GetDisplayId();
759 uint32 nativeid = target->GetNativeDisplayId();
760 uint32 entry = target->GetEntry();
761 uint32 id1 = 0;
762 uint32 id2 = 0;
763 uint32 id3 = 0;
764 if (CreatureData const* cData = target->GetCreatureData())
765 {
766 id1 = cData->id1;
767 id2 = cData->id2;
768 id3 = cData->id3;
769 }
770
771 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
772
773 return true;
774 }
@ 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:762
uint32 GetFaction() const
Definition Unit.h:851
uint32 GetDisplayId() const
Definition Unit.h:1975
uint32 GetNativeDisplayId() const
Definition Unit.h:1977

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
627 {
628 Creature* target = handler->getSelectedCreature();
629 ObjectGuid::LowType lowGuid = 0;
630
631 if (spawnIdArg)
632 lowGuid = *spawnIdArg;
633
634 if (!target && lowGuid)
635 target = handler->GetCreatureFromPlayerMapByDbGuid(lowGuid);
636
637 if (target)
638 return HandleNpcInfoCommandShowCreature(handler, target);
639
640 if (!lowGuid)
641 {
643 return false;
644 }
645
646 CreatureData const* cData = sObjectMgr->GetCreatureData(lowGuid);
647 if (!cData)
648 cData = sObjectMgr->LoadCreatureDataFromDB(lowGuid);
649 if (cData)
650 return HandleNpcInfoCommandShowFromDB(handler, lowGuid, cData);
651
653 return false;
654 }
static bool HandleNpcInfoCommandShowFromDB(ChatHandler *handler, ObjectGuid::LowType lowGuid, CreatureData const *cData)
Definition cs_npc.cpp:722
static bool HandleNpcInfoCommandShowCreature(ChatHandler *handler, Creature *target)
Definition cs_npc.cpp:656

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
657 {
658 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
659 uint32 faction = target->GetFaction();
660 uint32 npcflags = target->GetNpcFlags();
661 uint64 mechanicImmuneMask = 0;
662 uint32 spellSchoolImmuneMask = 0;
663
664 if (CreatureImmunities const* immunities = sSpellMgr->GetCreatureImmunities(cInfo->CreatureImmunitiesId))
665 {
666 mechanicImmuneMask = immunities->Mechanic.to_ullong();
667 for (std::size_t j = 0; j < immunities->School.size(); ++j)
668 if (immunities->School[j])
669 spellSchoolImmuneMask |= (1u << j);
670 }
671
672 uint32 displayid = target->GetDisplayId();
673 uint32 nativeid = target->GetNativeDisplayId();
674 uint32 entry = target->GetEntry();
675 uint32 id1 = 0;
676 uint32 id2 = 0;
677 uint32 id3 = 0;
678 if (CreatureData const* cData = target->GetCreatureData())
679 {
680 id1 = cData->id1;
681 id2 = cData->id2;
682 id3 = cData->id3;
683 }
684
685 int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
686 if (curRespawnDelay < 0)
687 curRespawnDelay = 0;
688
689 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
690 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
691
692 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
693 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
695 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
696 handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
697 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr, curRespawnDelayStr);
698 handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
701 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
702 handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
703 handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName(), target->GetScriptName());
704
705 for (auto npcFlagText : npcFlagTexts)
706 if (npcflags & npcFlagText.flag)
707 handler->PSendSysMessage(npcFlagText.text, npcFlagText.flag);
708
709 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, Acore::StringFormat("0x{:X}", mechanicImmuneMask).c_str());
710 for (uint8 i = 1; i < MAX_MECHANIC; ++i)
711 if (mechanicImmuneMask & (1ULL << i))
712 handler->PSendSysMessage(mechanicImmunes[i].text, mechanicImmunes[i].flag);
713
714 handler->PSendSysMessage(LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, spellSchoolImmuneMask);
715 for (auto spellSchoolImmune : spellSchoolImmunes)
716 if (spellSchoolImmuneMask & (1 << spellSchoolImmune.flag))
717 handler->PSendSysMessage(spellSchoolImmune.text, spellSchoolImmune.flag);
718
719 return true;
720 }
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:836
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:3162
time_t GetRespawnTimeEx() const
Definition Creature.cpp:3039
std::string const & GetAIName() const
Definition Creature.cpp:3157
uint32 GetMaxHealth() const
Definition Unit.h:1109
UnitFlags GetUnitFlags() const
Definition Unit.h:746
uint32 GetHealth() const
Definition Unit.h:1108
uint32 GetCreateHealth() const
Definition Unit.h:1112
uint32 GetArmor() const
Definition Unit.h:1157
uint8 GetLevel() const
Definition Unit.h:1103
UnitFlags2 GetUnitFlags2() const
Remove all UnitFlags and set new ones. UnitFlags available in UnitDefines.h.
Definition Unit.h:752
uint32 GetDynamicFlags() const override
Definition Unit.h:768
uint32 GetPhaseMask() const
Definition Object.h:516
uint32 GetInstanceId() const
Definition Object.h:513
NpcFlagText const npcFlagTexts[NPCFLAG_COUNT]
Definition cs_npc.cpp:51
SpellSchoolImmune const spellSchoolImmunes[MAX_SPELL_SCHOOL]
Definition cs_npc.cpp:127
MechanicImmune const mechanicImmunes[MAX_MECHANIC]
Definition cs_npc.cpp:85
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:564
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
723 {
724 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id1);
725 if (!cInfo)
726 {
728 return false;
729 }
730
731 handler->PSendSysMessage("(Not in world - showing DB data)");
732 uint32 scriptId = cData->ScriptId ? cData->ScriptId : cInfo->ScriptID;
733 handler->PSendSysMessage(LANG_NPCINFO_CHAR, lowGuid, ObjectGuid::Create<HighGuid::Unit>(cData->id1, lowGuid).ToString(), cData->id1,
734 cData->id2, cData->id3, cData->displayid, cData->displayid, cInfo->faction,
735 cData->npcflag);
736 handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, cData->phaseMask);
737 handler->PSendSysMessage(LANG_NPCINFO_POSITION, cData->posX, cData->posY, cData->posZ);
738 handler->PSendSysMessage("Map: {} Spawn time: {}s", cData->mapid,
739 cData->spawntimesecs);
740 handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, cData->equipmentId, cData->equipmentId);
742 sObjectMgr->GetScriptName(scriptId));
743 return true;
744 }
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::id1, 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
274 {
275 if (!spawnId)
276 return false;
277
278 if (sObjectMgr->GetCreatureData(spawnId))
279 {
280 handler->SendErrorMessage("Creature spawn {} is already loaded.", uint32(spawnId));
281 return false;
282 }
283
284 CreatureData const* data = sObjectMgr->LoadCreatureDataFromDB(spawnId);
285 if (!data)
286 {
287 handler->SendErrorMessage("Creature spawn {} not found in the database.", uint32(spawnId));
288 return false;
289 }
290
291 if (sPoolMgr->IsPartOfAPool<Creature>(spawnId))
292 {
293 handler->SendErrorMessage("Creature spawn {} is part of a pool and cannot be manually loaded.", uint32(spawnId));
294 return false;
295 }
296
297 QueryResult eventResult = WorldDatabase.Query("SELECT guid FROM game_event_creature WHERE guid = {}", uint32(spawnId));
298 if (eventResult)
299 {
300 handler->SendErrorMessage("Creature spawn {} is managed by the game event system and cannot be manually loaded.", uint32(spawnId));
301 return false;
302 }
303
304 Map* map = sMapMgr->FindBaseNonInstanceMap(data->mapid);
305 if (!map)
306 {
307 handler->SendErrorMessage("Creature spawn {} is on a non-continent map (ID: {}). Only continent maps are supported.", uint32(spawnId), data->mapid);
308 return false;
309 }
310
311 Creature* creature = new Creature();
312 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
313 {
314 delete creature;
315 handler->SendErrorMessage("Failed to load creature spawn {}.", uint32(spawnId));
316 return false;
317 }
318
319 sObjectMgr->AddCreatureToGrid(spawnId, data);
320 handler->PSendSysMessage("Creature spawn {} loaded successfully.", uint32(spawnId));
321 return true;
322 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
#define sMapMgr
Definition MapMgr.h:220
#define sPoolMgr
Definition PoolMgr.h:177
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:49
void setDeathState(DeathState s, bool despawn=false) override
A creature can be in 4 different states: Alive, JustDied, Corpse, and JustRespawned....
Definition Creature.cpp:1946
void Respawn(bool force=false)
Definition Creature.cpp:2017
void SetPosition(float x, float y, float z, float o)
Definition Creature.cpp:3273
void Initialize()
Definition MotionMaster.cpp:75
bool IsAlive() const
Definition Unit.h:1794
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
777 {
778 float distance = dist.value_or(10.0f);
779 uint32 count = 0;
780
781 Player* player = handler->GetSession()->GetPlayer();
782
783 // Grid search - finds all creatures including temporary spawns
784 std::list<Creature*> creatures;
785 Acore::AllWorldObjectsInRange check(player, distance);
787 Cell::VisitObjects(player, searcher, distance);
788
789 std::unordered_set<ObjectGuid::LowType> gridSpawnIds;
790
791 for (Creature* creature : creatures)
792 {
793 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(creature->GetEntry());
794 if (!creatureTemplate)
795 continue;
796
797 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, creature->GetSpawnId(), creature->GetEntry(),
798 creature->GetSpawnId(), creatureTemplate->Name,
799 creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(),
800 creature->GetMapId(), "", "");
801
802 if (creature->GetSpawnId())
803 gridSpawnIds.insert(creature->GetSpawnId());
804 ++count;
805 }
806
807 if (count > 0 && distance <= SIZE_OF_GRIDS)
808 {
809 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
810 return true;
811 }
812
813 // Fallback to DB query
815 stmt->SetData(0, player->GetPositionX());
816 stmt->SetData(1, player->GetPositionY());
817 stmt->SetData(2, player->GetPositionZ());
818 stmt->SetData(3, player->GetMapId());
819 stmt->SetData(4, player->GetPositionX());
820 stmt->SetData(5, player->GetPositionY());
821 stmt->SetData(6, player->GetPositionZ());
822 stmt->SetData(7, distance * distance);
823 stmt->SetData(8, player->GetPhaseMask());
824 PreparedQueryResult result = WorldDatabase.Query(stmt);
825
826 if (result)
827 {
828 do
829 {
830 Field* fields = result->Fetch();
831 ObjectGuid::LowType guid = fields[0].Get<uint32>();
832
833 // Skip entries already emitted via grid search
834 if (gridSpawnIds.count(guid))
835 continue;
836
837 uint32 entry = fields[1].Get<uint32>();
838 //uint32 entry2 = fields[2].Get<uint32>();
839 //uint32 entry3 = fields[3].Get<uint32>();
840 float x = fields[4].Get<float>();
841 float y = fields[5].Get<float>();
842 float z = fields[6].Get<float>();
843 uint16 mapId = fields[7].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:90
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:1616
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:464
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:17358

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:17175
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2197

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
381 {
382 if (sWorld->getAllowMovement())
383 {
384 sWorld->SetAllowMovement(false);
386 }
387 else
388 {
389 sWorld->SetAllowMovement(true);
391 }
392 return true;
393 }
@ LANG_CREATURE_MOVE_ENABLED
Definition Language.h:440
@ LANG_CREATURE_MOVE_DISABLED
Definition Language.h:439
#define sWorld
Definition World.h:317

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
592 {
593 Creature* creature = handler->getSelectedCreature();
594
595 if (!creature)
596 {
598 return false;
599 }
600
601 creature->AI()->SetData(data_1, data_2);
602 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
603 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript);
604 return true;
605 }
@ 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
396 {
397 if (!newEntryNum)
398 return false;
399
400 Unit* unit = handler->getSelectedUnit();
401 if (!unit || !unit->IsCreature())
402 {
404 return false;
405 }
406 Creature* creature = unit->ToCreature();
407 if (creature->UpdateEntry(newEntryNum))
408 handler->SendSysMessage(LANG_DONE);
409 else
410 handler->SendSysMessage(LANG_ERROR);
411 return true;
412 }
@ LANG_ERROR
Definition Language.h:78
@ LANG_DONE
Definition Language.h:75
Unit * getSelectedUnit() const
Definition Chat.cpp:394
bool UpdateEntry(uint32 entry, const CreatureData *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:664

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

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
527 {
528 Player* player = handler->GetSession()->GetPlayer();
529 Unit* unit = player->GetSelectedUnit();
530
531 if (!unit)
532 return false;
533
534 Creature* creature = unit->ToCreature();
535
536 if (!creature)
537 return false;
538
539 creature->SetFaction(tempfaction);
540
541 return true;
542 }
Unit * GetSelectedUnit() const
Definition Player.cpp:11482

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
567 {
568 Creature* creature = handler->getSelectedCreature();
569
570 if (!creature)
571 {
573 return false;
574 }
575
576 creature->ReplaceAllNpcFlags(NPCFlags(npcFlags));
577
579
580 stmt->SetData(0, NPCFlags(npcFlags));
581 stmt->SetData(1, creature->GetEntry());
582
583 WorldDatabase.Execute(stmt);
584
586
587 return true;
588 }
@ LANG_VALUE_SAVED_REJOIN
Definition Language.h:313
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:320
@ WORLD_UPD_CREATURE_NPCFLAG
Definition WorldDatabase.h:48
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:766

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
416 {
417 if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
418 {
420 return false;
421 }
422
423 Creature* creature = handler->getSelectedCreature();
424 if (!creature || creature->IsPet())
425 {
427 return false;
428 }
429
430 creature->SetMaxHealth(100 + 30*lvl);
431 creature->SetHealth(100 + 30*lvl);
432 creature->SetLevel(lvl);
433 creature->SaveToDB();
434
435 return true;
436 }
@ LANG_BAD_VALUE
Definition Language.h:151
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:189
void SetHealth(uint32 val)
Definition Unit.cpp:12341
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:12323
void SetMaxHealth(uint32 val)
Definition Unit.cpp:12391

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:3513
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:1979
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
546 {
547 Player* player = handler->GetSession()->GetPlayer();
548
549 if (!player)
550 return false;
551
552 if (!player->GetSelectedUnit())
553 return false;
554
555 Creature* creature = player->GetSelectedUnit()->ToCreature();
556
557 if (!creature)
558 return false;
559
560 creature->RestoreFaction();
561
562 return true;
563 }
void RestoreFaction()
Definition Unit.cpp:14949

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:15303

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(const std::string &timestring)
Definition Util.cpp:163
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
Definition WorldDatabase.h:51
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:50
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().

◆ 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:1458
@ LANG_SPAWNGROUP_SPAWN_FAILED
Definition Language.h:1460
@ LANG_SPAWNGROUP_SPAWN_SUCCESS
Definition Language.h:1459
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false)
Definition Map.cpp:2549

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:9242
bool CanTameExoticPets() const
Definition Player.h:2209
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition Player.cpp:9248
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:17185

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:961
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:120
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:17190
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition ObjectAccessor.cpp:271

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:17180

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

Referenced by GetCommands().


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