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:1265
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
Definition cs_npc.cpp:1370
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:1307
static bool HandleNpcSetFactionTempIdCommand(ChatHandler *handler, uint32 tempfaction)
Definition cs_npc.cpp:526
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition cs_npc.cpp:1102
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:1320
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1212
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition cs_npc.cpp:943
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1286
static bool HandleNpcGuidCommand(ChatHandler *handler)
Definition cs_npc.cpp:746
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition cs_npc.cpp:1078
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:1440
static bool HandleNpcMoveCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > guid)
Definition cs_npc.cpp:859
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition cs_npc.cpp:928
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:978
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:1231
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:1186
static bool HandleNpcDespawnGroupCommand(ChatHandler *handler, uint32 groupId)
Definition cs_npc.cpp:1467
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:1146
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:1414
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:1356
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.id = 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:1732
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
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:13911
Definition Transport.h:30
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:12653
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:464
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
1371 {
1372 Creature* creature = handler->getSelectedCreature();
1373
1374 if (!creature || !creature->GetSpawnId())
1375 {
1377 return false;
1378 }
1379
1380 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1381 if (creature->GetFormation())
1382 {
1383 handler->PSendSysMessage("Selected creature is already member of group {}", creature->GetFormation()->GetId());
1384 return false;
1385 }
1386
1387 if (!lowguid)
1388 return false;
1389
1390 Player* chr = handler->GetSession()->GetPlayer();
1391 FormationInfo group_member;
1392 group_member.follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
1393 group_member.follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2)) + pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
1394 group_member.leaderGUID = leaderGUID;
1395 group_member.groupAI = 0;
1396
1397 sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1398 creature->SearchFormation();
1399
1401 stmt->SetData(0, leaderGUID);
1402 stmt->SetData(1, lowguid);
1403 stmt->SetData(2, group_member.follow_dist);
1404 stmt->SetData(3, group_member.follow_angle);
1405 stmt->SetData(4, uint32(group_member.groupAI));
1406
1407 WorldDatabase.Execute(stmt);
1408
1409 handler->PSendSysMessage("Creature {} added to formation with leader {}", lowguid, leaderGUID);
1410
1411 return true;
1412 }
#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
1308 {
1309 Player* chr = handler->GetSession()->GetPlayer();
1310
1311 if (!id)
1312 return false;
1313
1314 chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1315
1316 return true;
1317 }
@ 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:468

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:1832
bool IsPet() const
Definition Unit.h:797
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:7504
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
1468 {
1469 Player* player = handler->GetSession()->GetPlayer();
1470 if (!player)
1471 return false;
1472
1473 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
1474 if (!groupData)
1475 {
1477 return false;
1478 }
1479
1480 if (groupData->flags & SPAWNGROUP_FLAG_SYSTEM)
1481 {
1482 handler->SendErrorMessage(LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR, groupId, groupData->name);
1483 return false;
1484 }
1485
1486 if (player->GetMap()->SpawnGroupDespawn(groupId, true))
1487 handler->PSendSysMessage(LANG_SPAWNGROUP_DESPAWN_SUCCESS, groupId, groupData->name);
1488 else
1489 handler->SendErrorMessage(LANG_SPAWNGROUP_DESPAWN_FAILED, groupId, groupData->name);
1490
1491 return true;
1492 }
@ LANG_SPAWNGROUP_DESPAWN_FAILED
Definition Language.h:1468
@ LANG_SPAWNGROUP_DESPAWN_SUCCESS
Definition Language.h:1467
@ LANG_SPAWNGROUP_NOT_FOUND
Definition Language.h:1474
@ LANG_SPAWNGROUP_DESPAWN_SYSTEM_ERROR
Definition Language.h:1466
@ SPAWNGROUP_FLAG_SYSTEM
Definition SpawnData.h:44
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false)
Definition Map.cpp:2646
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
1357 {
1358 Creature* creature = handler->getSelectedCreature();
1359 if (!creature)
1360 {
1362 return false;
1363 }
1364
1365 creature->AI()->DoAction(actionId);
1366 handler->PSendSysMessage(LANG_NPC_DO_ACTION, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), actionId);
1367 return true;
1368 }
@ 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:1762
virtual float GetFollowAngle() const
Definition Unit.h:1899

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->id;
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:1978
uint32 GetNativeDisplayId() const
Definition Unit.h:1980

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->id;
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: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:3171
time_t GetRespawnTimeEx() const
Definition Creature.cpp:3048
std::string const & GetAIName() const
Definition Creature.cpp:3166
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: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
723 {
724 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id);
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->id, lowGuid).ToString(), cData->id,
734 cData->id, 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::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
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
860 {
861 Creature* creature;
862 if (guid.has_value())
863 creature = handler->GetCreatureFromPlayerMapByDbGuid(*guid);
864 else
865 creature = handler->getSelectedCreature();
866
867 if (!creature)
868 return false;
869
870 ObjectGuid::LowType lowGuid;
871 if (guid.has_value())
872 lowGuid = *guid;
873 else
874 lowGuid = creature->GetSpawnId();
875
876 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
877 if (!data)
878 {
880 return false;
881 }
882
883 if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
884 {
886 return false;
887 }
888
889 float x = handler->GetSession()->GetPlayer()->GetPositionX();
890 float y = handler->GetSession()->GetPlayer()->GetPositionY();
891 float z = handler->GetSession()->GetPlayer()->GetPositionZ();
892 float o = handler->GetSession()->GetPlayer()->GetOrientation();
893
894 if (creature)
895 {
896 if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
897 {
898 const_cast<CreatureData*>(data)->posX = x;
899 const_cast<CreatureData*>(data)->posY = y;
900 const_cast<CreatureData*>(data)->posZ = z;
901 const_cast<CreatureData*>(data)->orientation = o;
902 }
903
904 creature->SetPosition(x, y, z, o);
905 creature->GetMotionMaster()->Initialize();
906
907 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
908 {
910 creature->Respawn();
911 }
912 }
913
915 stmt->SetData(0, x);
916 stmt->SetData(1, y);
917 stmt->SetData(2, z);
918 stmt->SetData(3, o);
919 stmt->SetData(4, lowGuid);
920
921 WorldDatabase.Execute(stmt);
922
924 return true;
925 }
@ 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:1948
void Respawn(bool force=false)
Definition Creature.cpp:2019
void SetPosition(float x, float y, float z, float o)
Definition Creature.cpp:3282
void Initialize()
Definition MotionMaster.cpp:75
bool IsAlive() const
Definition Unit.h:1797
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 float x = fields[2].Get<float>();
839 float y = fields[3].Get<float>();
840 float z = fields[4].Get<float>();
841 uint16 mapId = fields[5].Get<uint16>();
842
843 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
844 if (!creatureTemplate)
845 continue;
846
847 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, entry, guid, creatureTemplate->Name, x, y, z, mapId, "", "");
848
849 ++count;
850 } while (result->NextRow());
851 }
852
853 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
854
855 return true;
856 }
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:91
creatures
Definition boss_prince_malchezaar.cpp:51
Definition GridNotifiers.h:1646
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:494
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
929 {
930 Creature* target = handler->getSelectedCreature();
931 if (!target)
932 {
934 return false;
935 }
936
937 target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
938
939 return true;
940 }
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17388

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
1187 {
1188 if (text.empty())
1189 return false;
1190
1191 Creature* creature = handler->getSelectedCreature();
1192 if (!creature)
1193 {
1195 return false;
1196 }
1197
1198 creature->Say(text, LANG_UNIVERSAL);
1199
1200 // make some emotes
1201 switch (text.back())
1202 {
1203 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1204 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1205 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1206 }
1207
1208 return true;
1209 }
@ 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:17205
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2215

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

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

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:193
void SetHealth(uint32 val)
Definition Unit.cpp:12374
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:12356
void SetMaxHealth(uint32 val)
Definition Unit.cpp:12424

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
1415 {
1416 Creature* creature = handler->getSelectedCreature();
1417
1418 if (!creature)
1419 {
1421 return false;
1422 }
1423
1424 if (!creature->GetSpawnId())
1425 {
1426 handler->SendErrorMessage("Selected creature {} isn't in creature table", creature->GetGUID().ToString());
1427 return false;
1428 }
1429
1430 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1431 {
1432 handler->SendErrorMessage("Selected creature can't link with guid '{}'", linkguid);
1433 return false;
1434 }
1435
1436 handler->PSendSysMessage("LinkGUID '{}' added to creature with DBTableGUID: '{}'", linkguid, creature->GetSpawnId());
1437 return true;
1438 }

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
944 {
945 Creature* creature = handler->getSelectedCreature();
946
947 if (!creature || creature->IsPet())
948 {
950 return false;
951 }
952
953 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
954 {
956 return false;
957 }
958
959 creature->SetDisplayId(displayId);
960 creature->SetNativeDisplayId(displayId);
961 creature->SaveToDB();
962
963 return true;
964 }
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ LANG_COMMAND_FACTION_INVPARAM
Definition Language.h:359
void SetDisplayId(uint32 displayId, float displayScale=1.f) override
Definition Creature.cpp:3522
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:1982
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

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

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
1079 {
1080 if (phasemask == 0)
1081 {
1083 return false;
1084 }
1085
1086 Creature* creature = handler->getSelectedCreature();
1087 if (!creature)
1088 {
1090 return false;
1091 }
1092
1093 creature->SetPhaseMask(phasemask, true);
1094
1095 if (!creature->IsPet())
1096 creature->SaveToDB();
1097
1098 return true;
1099 }
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition Unit.cpp:15345

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
1147 {
1148 if (spawnTimeStr.empty())
1149 {
1150 return false;
1151 }
1152
1153 if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
1154 {
1156 return false;
1157 }
1158
1159 Creature* creature = handler->getSelectedCreature();
1160 if (!creature)
1161 return false;
1162
1163 int32 spawnTime = TimeStringToSecs(spawnTimeStr);
1164 if (spawnTime <= 0)
1165 {
1166 spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
1167 }
1168
1169 if (spawnTime <= 0)
1170 {
1172 return false;
1173 }
1174
1176 stmt->SetData(0, spawnTime);
1177 stmt->SetData(1, creature->GetSpawnId());
1178 WorldDatabase.Execute(stmt);
1179
1180 creature->SetRespawnDelay(spawnTime);
1181 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true));
1182
1183 return true;
1184 }
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
1103 {
1104 if (option < 0.0f)
1105 {
1107 return false;
1108 }
1109
1111
1112 if (option > 0.0f)
1113 mtype = RANDOM_MOTION_TYPE;
1114
1115 Creature* creature = handler->getSelectedCreature();
1116 ObjectGuid::LowType guidLow = 0;
1117
1118 if (creature)
1119 guidLow = creature->GetSpawnId();
1120 else
1121 return false;
1122
1123 creature->SetWanderDistance((float)option);
1124 creature->SetDefaultMovementType(mtype);
1125 creature->GetMotionMaster()->Initialize();
1126
1127 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1128 {
1130 creature->Respawn();
1131 }
1132
1134
1135 stmt->SetData(0, option);
1136 stmt->SetData(1, uint8(mtype));
1137 stmt->SetData(2, guidLow);
1138
1139 WorldDatabase.Execute(stmt);
1140
1142 return true;
1143 }
@ 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
1441 {
1442 Player* player = handler->GetSession()->GetPlayer();
1443 if (!player)
1444 return false;
1445
1446 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
1447 if (!groupData)
1448 {
1450 return false;
1451 }
1452
1453 if (groupData->flags & SPAWNGROUP_FLAG_SYSTEM)
1454 {
1455 handler->SendErrorMessage(LANG_SPAWNGROUP_SPAWN_SYSTEM_ERROR, groupId, groupData->name);
1456 return false;
1457 }
1458
1459 if (player->GetMap()->SpawnGroupSpawn(groupId, true, true))
1460 handler->PSendSysMessage(LANG_SPAWNGROUP_SPAWN_SUCCESS, groupId, groupData->name);
1461 else
1462 handler->SendErrorMessage(LANG_SPAWNGROUP_SPAWN_FAILED, groupId, groupData->name);
1463
1464 return true;
1465 }
@ LANG_SPAWNGROUP_SPAWN_SYSTEM_ERROR
Definition Language.h:1463
@ LANG_SPAWNGROUP_SPAWN_FAILED
Definition Language.h:1465
@ LANG_SPAWNGROUP_SPAWN_SUCCESS
Definition Language.h:1464
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false)
Definition Map.cpp:2562

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
1321 {
1322 Creature* creatureTarget = handler->getSelectedCreature();
1323 if (!creatureTarget || creatureTarget->IsPet())
1324 {
1326 handler->SetSentErrorMessage(true);
1327 return false;
1328 }
1329
1330 Player* player = handler->GetSession()->GetPlayer();
1331
1332 if (player->IsExistPet())
1333 {
1335 return false;
1336 }
1337
1338 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1339
1340 if (!cInfo->IsTameable(player->CanTameExoticPets()))
1341 {
1343 handler->SetSentErrorMessage (true);
1344 return false;
1345 }
1346
1347 if (!player->CreatePet(creatureTarget))
1348 {
1350 return false;
1351 }
1352
1353 return true;
1354 }
@ LANG_CREATURE_NON_TAMEABLE
Definition Language.h:393
@ LANG_YOU_ALREADY_HAVE_PET
Definition Language.h:394
bool IsExistPet()
Definition Player.cpp:9251
bool CanTameExoticPets() const
Definition Player.h:2212
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition Player.cpp:9257
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
1213 {
1214 if (text.empty())
1215 return false;
1216
1217 Creature* creature = handler->getSelectedCreature();
1218
1219 if (!creature)
1220 {
1222 return false;
1223 }
1224
1225 creature->TextEmote(text);
1226
1227 return true;
1228 }
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:17215

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

Referenced by GetCommands().

◆ HandleNpcUnFollowCommand()

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler)
inlinestatic
1232 {
1233 Player* player = handler->GetSession()->GetPlayer();
1234 Creature* creature = handler->getSelectedCreature();
1235
1236 if (!creature)
1237 {
1239 return false;
1240 }
1241
1242 if (/*creature->GetMotionMaster()->empty() ||*/
1244 {
1245 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1246 return false;
1247 }
1248
1249 FollowMovementGenerator<Creature> const* mgen = static_cast<FollowMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top()));
1250
1251 if (mgen->GetTarget() != player)
1252 {
1253 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1254 return false;
1255 }
1256
1257 // reset movement
1258 creature->GetMotionMaster()->MovementExpired(true);
1259
1261 return true;
1262 }
@ 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
1266 {
1267 if (text.empty())
1268 return false;
1269
1270 Creature* creature = handler->getSelectedCreature();
1271 if (!creature)
1272 {
1274 return false;
1275 }
1276
1277 // check online security
1278 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1279 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1280 return false;
1281
1282 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1283 return true;
1284 }
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:17220
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
1287 {
1288 if (text.empty())
1289 return false;
1290
1291 Creature* creature = handler->getSelectedCreature();
1292 if (!creature)
1293 {
1295 return false;
1296 }
1297
1298 creature->Yell(text, LANG_UNIVERSAL);
1299
1300 // make an emote
1302
1303 return true;
1304 }
@ EMOTE_ONESHOT_SHOUT
Definition SharedDefines.h:1918
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:17210

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: