TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
npc_commandscript Class Reference

Public Member Functions

 npc_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleNpcAddCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcAddVendorItemCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcAddMoveCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetAllowMovementCommand (ChatHandler *handler, char const *)
 
static bool HandleNpcSetEntryCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetLevelCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcDeleteCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcDeleteVendorItemCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetFactionIdCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetFlagCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetDataCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcFollowCommand (ChatHandler *handler, char const *)
 
static bool HandleNpcInfoCommand (ChatHandler *handler, char const *)
 
static bool HandleNpcNearCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcMoveCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcPlayEmoteCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetModelCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetMoveTypeCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetPhaseGroup (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetPhaseCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetSpawnDistCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetSpawnTimeCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSayCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcTextEmoteCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcUnFollowCommand (ChatHandler *handler, char const *)
 
static bool HandleNpcWhisperCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcYellCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcAddTempSpawnCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcTameCommand (ChatHandler *handler, char const *)
 
static bool HandleNpcAddFormationCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcSetLinkCommand (ChatHandler *handler, char const *args)
 
static bool HandleNpcAddWeaponCommand (ChatHandler *, char const *)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

npc_commandscript::npc_commandscript ( )
inline
175 : CommandScript("npc_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> npc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

178  {
179  static std::vector<ChatCommand> npcAddCommandTable =
180  {
185  //{ "weapon", rbac::RBAC_PERM_COMMAND_NPC_ADD_WEAPON, false, &HandleNpcAddWeaponCommand, "" },
187  };
188  static std::vector<ChatCommand> npcDeleteCommandTable =
189  {
192  };
193  static std::vector<ChatCommand> npcFollowCommandTable =
194  {
197  };
198  static std::vector<ChatCommand> npcSetCommandTable =
199  {
209  { "phasegroup", rbac::RBAC_PERM_COMMAND_NPC_SET_PHASE, false, &HandleNpcSetPhaseGroup, "" },
213  };
214  static std::vector<ChatCommand> npcCommandTable =
215  {
225  { "add", rbac::RBAC_PERM_COMMAND_NPC_ADD, false, NULL, "", npcAddCommandTable },
226  { "delete", rbac::RBAC_PERM_COMMAND_NPC_DELETE, false, NULL, "", npcDeleteCommandTable },
227  { "follow", rbac::RBAC_PERM_COMMAND_NPC_FOLLOW, false, NULL, "", npcFollowCommandTable },
228  { "set", rbac::RBAC_PERM_COMMAND_NPC_SET, false, NULL, "", npcSetCommandTable },
229  };
230  static std::vector<ChatCommand> commandTable =
231  {
232  { "npc", rbac::RBAC_PERM_COMMAND_NPC, false, NULL, "", npcCommandTable },
233  };
234  return commandTable;
235  }
static bool HandleNpcDeleteCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:480
Definition: RBAC.h:508
Definition: RBAC.h:502
Definition: RBAC.h:500
static bool HandleNpcAddFormationCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1454
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:519
static bool HandleNpcTameCommand(ChatHandler *handler, char const *)
Definition: cs_npc.cpp:1388
static bool HandleNpcSetLinkCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1506
static bool HandleNpcSetFlagCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:600
Definition: RBAC.h:504
Definition: RBAC.h:501
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1104
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1364
static bool HandleNpcFollowCommand(ChatHandler *handler, char const *)
Definition: cs_npc.cpp:664
Definition: RBAC.h:487
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:507
static bool HandleNpcSayCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1215
static bool HandleNpcAddCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:238
static bool HandleNpcSetSpawnDistCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1129
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:304
static bool HandleNpcWhisperCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1300
static bool HandleNpcMoveCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:808
Definition: RBAC.h:477
static bool HandleNpcYellCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1338
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:557
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:884
static bool HandleNpcSetDataCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:631
static bool HandleNpcInfoCommand(ChatHandler *handler, char const *)
Definition: cs_npc.cpp:683
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1175
static bool HandleNpcSetPhaseGroup(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1074
static bool HandleNpcSetMoveTypeCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:938
static bool HandleNpcSetLevelCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:439
static bool HandleNpcUnFollowCommand(ChatHandler *handler, char const *)
Definition: cs_npc.cpp:1263
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler, char const *)
Definition: cs_npc.cpp:399
static bool HandleNpcAddMoveCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:362
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:1243
Definition: RBAC.h:478
static bool HandleNpcSetModelCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:902
static bool HandleNpcNearCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:761
static bool HandleNpcSetEntryCommand(ChatHandler *handler, char const *args)
Definition: cs_npc.cpp:414

+ Here is the call graph for this function:

static bool npc_commandscript::HandleNpcAddCommand ( ChatHandler handler,
char const args 
)
inlinestatic
239  {
240  if (!*args)
241  return false;
242 
243  char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
244  if (!charID)
245  return false;
246 
247  uint32 id = atoi(charID);
248  if (!sObjectMgr->GetCreatureTemplate(id))
249  return false;
250 
251  Player* chr = handler->GetSession()->GetPlayer();
252  float x = chr->GetPositionX();
253  float y = chr->GetPositionY();
254  float z = chr->GetPositionZ();
255  float o = chr->GetOrientation();
256  Map* map = chr->GetMap();
257 
258  if (Transport* trans = chr->GetTransport())
259  {
261  CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
262  data.id = id;
263  data.phaseMask = chr->GetPhaseMask();
264  data.posX = chr->GetTransOffsetX();
265  data.posY = chr->GetTransOffsetY();
266  data.posZ = chr->GetTransOffsetZ();
267  data.orientation = chr->GetTransOffsetO();
268 
269  Creature* creature = trans->CreateNPCPassenger(guid, &data);
270 
271  creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMask());
272 
273  sObjectMgr->AddCreatureToGrid(guid, &data);
274  return true;
275  }
276 
277  Creature* creature = new Creature();
278  if (!creature->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, chr->GetPhaseMask(), id, x, y, z, o))
279  {
280  delete creature;
281  return false;
282  }
283 
284  creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
285 
286  ObjectGuid::LowType db_guid = creature->GetSpawnId();
287 
288  // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
289  // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
290  creature->CleanupsBeforeDelete();
291  delete creature;
292  creature = new Creature();
293  if (!creature->LoadCreatureFromDB(db_guid, map))
294  {
295  delete creature;
296  return false;
297  }
298 
299  sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
300  return true;
301  }
Definition: Creature.h:287
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:11802
uint8 GetSpawnMode() const
Definition: Map.h:369
void SaveToDB()
Definition: Creature.cpp:1034
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const *data=nullptr, uint32 vehId=0)
Definition: Creature.cpp:834
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
Definition: Transport.h:28
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetId(void) const
Definition: Map.h:325
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Transport * GetTransport() const
Definition: Object.h:602
WorldSession * GetSession()
Definition: Chat.h:59
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1327

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcAddFormationCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1455  {
1456  if (!*args)
1457  return false;
1458 
1459  ObjectGuid::LowType leaderGUID = strtoull(args, nullptr, 10);
1460  Creature* creature = handler->getSelectedCreature();
1461 
1462  if (!creature || !creature->GetSpawnId())
1463  {
1465  handler->SetSentErrorMessage(true);
1466  return false;
1467  }
1468 
1469  ObjectGuid::LowType lowguid = creature->GetSpawnId();
1470  if (creature->GetFormation())
1471  {
1472  handler->PSendSysMessage("Selected creature is already member of group " UI64FMTD, creature->GetFormation()->GetId());
1473  return false;
1474  }
1475 
1476  if (!lowguid)
1477  return false;
1478 
1479  Player* chr = handler->GetSession()->GetPlayer();
1480  FormationInfo* group_member;
1481 
1482  group_member = new FormationInfo;
1483  group_member->follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / float(M_PI);
1484  group_member->follow_dist = std::sqrt(std::pow(chr->GetPositionX() - creature->GetPositionX(), 2.f) + std::pow(chr->GetPositionY() - creature->GetPositionY(), 2.f));
1485  group_member->leaderGUID = leaderGUID;
1486  group_member->groupAI = 0;
1487 
1488  sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1489  creature->SearchFormation();
1490 
1492 
1493  stmt->setUInt64(0, leaderGUID);
1494  stmt->setUInt64(1, lowguid);
1495  stmt->setFloat(2, group_member->follow_dist);
1496  stmt->setFloat(3, group_member->follow_angle);
1497  stmt->setUInt32(4, uint32(group_member->groupAI));
1498 
1499  WorldDatabase.Execute(stmt);
1500 
1501  handler->PSendSysMessage("Creature " UI64FMTD " added to formation with leader " UI64FMTD, lowguid, leaderGUID);
1502 
1503  return true;
1504  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
ObjectGuid::LowType leaderGUID
Definition: CreatureGroups.h:31
#define M_PI
Definition: Common.h:163
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: CreatureGroups.h:29
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: WorldDatabase.h:53
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
Definition: Language.h:33
float GetPositionY() const
Definition: Position.h:105
float follow_dist
Definition: CreatureGroups.h:32
#define UI64FMTD
Definition: Define.h:137
float GetAngle(Position const *pos) const
Definition: Position.cpp:63
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CreatureGroup * GetFormation()
Definition: Creature.h:687
G3D::Quat pow(const G3D::Quat &q, double x)
Definition: Quat.h:761
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
#define sFormationMgr
Definition: CreatureGroups.h:84
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
void SearchFormation()
Definition: Creature.cpp:266
ObjectGuid::LowType GetId() const
Definition: CreatureGroups.h:72
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
float GetPositionX() const
Definition: Position.h:104
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
float follow_angle
Definition: CreatureGroups.h:33
uint8 groupAI
Definition: CreatureGroups.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcAddMoveCommand ( ChatHandler handler,
char const args 
)
inlinestatic
363  {
364  if (!*args)
365  return false;
366 
367  char* guidStr = strtok((char*)args, " ");
368  char* waitStr = strtok((char*)NULL, " ");
369 
370  ObjectGuid::LowType lowGuid = strtoull(guidStr, nullptr, 10);
371 
372  // attempt check creature existence by DB data
373  CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
374  if (!data)
375  {
377  handler->SetSentErrorMessage(true);
378  return false;
379  }
380 
381  int wait = waitStr ? atoi(waitStr) : 0;
382 
383  if (wait < 0)
384  wait = 0;
385 
386  // Update movement type
388 
390  stmt->setUInt64(1, lowGuid);
391 
392  WorldDatabase.Execute(stmt);
393 
395 
396  return true;
397  }
Definition: Creature.h:287
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Language.h:319
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: Language.h:262
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
uint8_t uint8
Definition: g3dmath.h:164
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: WorldDatabase.h:47
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: MotionMaster.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcAddTempSpawnCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1365  {
1366  if (!*args)
1367  return false;
1368 
1369  char* charID = handler->extractKeyFromLink((char*)args, "Hcreature_entry");
1370  if (!charID)
1371  return false;
1372 
1373  Player* chr = handler->GetSession()->GetPlayer();
1374 
1375  uint32 id = atoi(charID);
1376  if (!id)
1377  return false;
1378 
1379  if (!sObjectMgr->GetCreatureTemplate(id))
1380  return false;
1381 
1382  chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1383 
1384  return true;
1385  }
Definition: Object.h:58
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32_t uint32
Definition: Define.h:150
WorldSession * GetSession()
Definition: Chat.h:59
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcAddVendorItemCommand ( ChatHandler handler,
char const args 
)
inlinestatic
305  {
306  if (!*args)
307  return false;
308 
309  const uint8 type = 1; // FIXME: make type (1 item, 2 currency) an argument
310 
311  char* pitem = handler->extractKeyFromLink((char*)args, "Hitem");
312  if (!pitem)
313  {
315  handler->SetSentErrorMessage(true);
316  return false;
317  }
318 
319  int32 item_int = atol(pitem);
320  if (item_int <= 0)
321  return false;
322 
323  uint32 itemId = item_int;
324 
325  char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0
326  uint32 maxcount = 0;
327  if (fmaxcount)
328  maxcount = atoul(fmaxcount);
329 
330  char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0
331  uint32 incrtime = 0;
332  if (fincrtime)
333  incrtime = atoul(fincrtime);
334 
335  char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0
336  uint32 extendedcost = fextendedcost ? atoul(fextendedcost) : 0;
337  Creature* vendor = handler->getSelectedCreature();
338  if (!vendor)
339  {
341  handler->SetSentErrorMessage(true);
342  return false;
343  }
344 
345  uint32 vendor_entry = vendor->GetEntry();
346 
347  if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, type, handler->GetSession()->GetPlayer()))
348  {
349  handler->SetSentErrorMessage(true);
350  return false;
351  }
352 
353  sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost, type);
354 
355  ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
356 
357  handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, itemTemplate->GetDefaultLocaleName(), maxcount, incrtime, extendedcost);
358  return true;
359  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Language.h:231
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:311
Definition: Language.h:33
unsigned long atoul(char const *str)
Definition: Common.h:90
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: ItemTemplate.h:647
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 GetEntry() const
Definition: Object.h:107
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcAddWeaponCommand ( ChatHandler ,
char const  
)
inlinestatic
Todo:
NpcCommands that need to be fixed :
1542  {
1543  /*if (!*args)
1544  return false;
1545 
1546  uint64 guid = handler->GetSession()->GetPlayer()->GetSelection();
1547  if (guid == 0)
1548  {
1549  handler->SendSysMessage(LANG_NO_SELECTION);
1550  return true;
1551  }
1552 
1553  Creature* creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), guid);
1554 
1555  if (!creature)
1556  {
1557  handler->SendSysMessage(LANG_SELECT_CREATURE);
1558  return true;
1559  }
1560 
1561  char* pSlotID = strtok((char*)args, " ");
1562  if (!pSlotID)
1563  return false;
1564 
1565  char* pItemID = strtok(NULL, " ");
1566  if (!pItemID)
1567  return false;
1568 
1569  uint32 ItemID = atoi(pItemID);
1570  uint32 SlotID = atoi(pSlotID);
1571 
1572  ItemTemplate* tmpItem = sObjectMgr->GetItemTemplate(ItemID);
1573 
1574  bool added = false;
1575  if (tmpItem)
1576  {
1577  switch (SlotID)
1578  {
1579  case 1:
1580  creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID);
1581  added = true;
1582  break;
1583  case 2:
1584  creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID);
1585  added = true;
1586  break;
1587  case 3:
1588  creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID);
1589  added = true;
1590  break;
1591  default:
1592  handler->PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST, SlotID);
1593  added = false;
1594  break;
1595  }
1596 
1597  if (added)
1598  handler->PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT, ItemID, tmpItem->Name1, SlotID);
1599  }
1600  else
1601  {
1602  handler->PSendSysMessage(LANG_ITEM_NOT_FOUND, ItemID);
1603  return true;
1604  }
1605  */
1606  return true;
1607  }
static bool npc_commandscript::HandleNpcDeleteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
481  {
482  Creature* unit = NULL;
483 
484  if (*args)
485  {
486  // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
487  char* cId = handler->extractKeyFromLink((char*)args, "Hcreature");
488  if (!cId)
489  return false;
490 
491  ObjectGuid::LowType lowguid = strtoull(cId, nullptr, 10);
492  if (!lowguid)
493  return false;
494 
495  if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
496  unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Creature>(cr_data->mapid, cr_data->id, lowguid));
497  }
498  else
499  unit = handler->getSelectedCreature();
500 
501  if (!unit || unit->IsPet() || unit->IsTotem())
502  {
504  handler->SetSentErrorMessage(true);
505  return false;
506  }
507 
508  // Delete the creature
509  unit->CombatStop();
510  unit->DeleteFromDB();
511  unit->AddObjectToRemoveList();
512 
514 
515  return true;
516  }
Definition: Creature.h:287
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
virtual void DeleteFromDB()
Definition: Creature.cpp:1474
Definition: Language.h:33
void AddObjectToRemoveList()
Definition: Object.cpp:2205
bool IsPet() const
Definition: Unit.h:1403
bool IsTotem() const
Definition: Unit.h:1405
Definition: Language.h:302
WorldSession * GetSession()
Definition: Chat.h:59
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcDeleteVendorItemCommand ( ChatHandler handler,
char const args 
)
inlinestatic
520  {
521  if (!*args)
522  return false;
523 
524  Creature* vendor = handler->getSelectedCreature();
525  if (!vendor || !vendor->IsVendor())
526  {
528  handler->SetSentErrorMessage(true);
529  return false;
530  }
531 
532  char* pitem = handler->extractKeyFromLink((char*)args, "Hitem");
533  if (!pitem)
534  {
536  handler->SetSentErrorMessage(true);
537  return false;
538  }
539  uint32 itemId = atoul(pitem);
540 
541  const uint8 type = 1; // FIXME: make type (1 item, 2 currency) an argument
542 
543  if (!sObjectMgr->RemoveVendorItem(vendor->GetEntry(), itemId, type))
544  {
545  handler->PSendSysMessage(LANG_ITEM_NOT_IN_LIST, itemId);
546  handler->SetSentErrorMessage(true);
547  return false;
548  }
549 
550  ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
551 
552  handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, itemTemplate->GetDefaultLocaleName());
553  return true;
554  }
bool IsVendor() const
Definition: Unit.h:1564
Definition: Language.h:233
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Creature.h:467
Definition: Language.h:310
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:311
unsigned long atoul(char const *str)
Definition: Common.h:90
uint32_t uint32
Definition: Define.h:150
Definition: ItemTemplate.h:647
uint8_t uint8
Definition: Define.h:152
Definition: Language.h:234
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 GetEntry() const
Definition: Object.h:107
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcFollowCommand ( ChatHandler handler,
char const  
)
inlinestatic
665  {
666  Player* player = handler->GetSession()->GetPlayer();
667  Creature* creature = handler->getSelectedCreature();
668 
669  if (!creature)
670  {
672  handler->SetSentErrorMessage(true);
673  return false;
674  }
675 
676  // Follow player - Using pet's default dist and angle
677  creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
678 
679  handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str());
680  return true;
681  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
std::string const & GetName() const
Definition: Object.h:479
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:33
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:368
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
virtual float GetFollowAngle() const
Definition: Unit.h:2194
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcInfoCommand ( ChatHandler handler,
char const  
)
inlinestatic
684  {
685  Creature* target = handler->getSelectedCreature();
686 
687  if (!target)
688  {
690  handler->SetSentErrorMessage(true);
691  return false;
692  }
693 
694  CreatureTemplate const* cInfo = target->GetCreatureTemplate();
695 
696  uint32 faction = target->getFaction();
697  uint64 npcflags = target->GetUInt64Value(UNIT_NPC_FLAGS);
698  uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask;
699  uint32 displayid = target->GetDisplayId();
700  uint32 nativeid = target->GetNativeDisplayId();
701  uint32 Entry = target->GetEntry();
702 
703  int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
704  if (curRespawnDelay < 0)
705  curRespawnDelay = 0;
706  std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
707  std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
708 
709  handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString().c_str(), faction, npcflags, Entry, displayid, nativeid);
710  handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
712  handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
714 
716  for (uint8 i = 0; i < MAX_UNIT_FLAGS; ++i)
717  if (target->GetUInt32Value(UNIT_FIELD_FLAGS) & unitFlags[i].Value)
718  handler->PSendSysMessage("%s (0x%X)", unitFlags[i].Name, unitFlags[i].Value);
719 
721  handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
722  handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
724 
725  if (CreatureData const* data = sObjectMgr->GetCreatureData(target->GetSpawnId()))
726  {
727  handler->PSendSysMessage(LANG_NPCINFO_PHASES, data->phaseid, data->phaseGroup);
728  if (data->phaseGroup)
729  {
730  std::set<uint32> _phases = target->GetPhases();
731 
732  if (!_phases.empty())
733  {
735  for (uint32 phaseId : _phases)
736  handler->PSendSysMessage("%u", phaseId);
737  }
738  }
739  }
740 
741  handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
742  handler->PSendSysMessage(LANG_NPCINFO_POSITION, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
743  handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());
745  for (uint8 i = 0; i < FLAGS_EXTRA_COUNT; ++i)
746  if (cInfo->flags_extra & flagsExtra[i].Value)
747  handler->PSendSysMessage("%s (0x%X)", flagsExtra[i].Name, flagsExtra[i].Value);
748 
749  for (uint8 i = 0; i < NPCFLAG_COUNT; i++)
750  if (npcflags & npcFlagTexts[i].Value)
751  handler->PSendSysMessage(npcFlagTexts[i].Name, npcFlagTexts[i].Value);
752 
753  handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, mechanicImmuneMask);
754  for (uint8 i = 1; i < MAX_MECHANIC; ++i)
755  if (mechanicImmuneMask & (1 << (mechanicImmunes[i].Value - 1)))
756  handler->PSendSysMessage("%s (0x%X)", mechanicImmunes[i].Name, mechanicImmunes[i].Value);
757 
758  return true;
759  }
EnumName< CreatureFlagsExtra > const flagsExtra[FLAGS_EXTRA_COUNT]
Definition: cs_npc.cpp:149
Definition: Creature.h:287
Definition: Language.h:558
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
uint32 GetRespawnDelay() const
Definition: Creature.h:637
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
uint32 SkinLootId
Definition: Creature.h:121
uint32 GetMaxHealth() const
Definition: Unit.h:1427
Creature * getSelectedCreature()
Definition: Chat.cpp:615
EnumName< Mechanics > const mechanicImmunes[MAX_MECHANIC]
Definition: cs_npc.cpp:76
uint32 GetDisplayId() const
Definition: Unit.h:2012
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
Definition: Util.cpp:109
Definition: Language.h:560
int64_t int64
Definition: Define.h:145
uint32 getFaction() const
Definition: Unit.h:1466
uint32 InhabitType
Definition: Creature.h:129
Definition: Language.h:1215
#define NPCFLAG_COUNT
Definition: cs_npc.cpp:45
Definition: Language.h:1087
Definition: Language.h:608
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: UpdateFields.h:110
Definition: Language.h:1214
uint64_t uint64
Definition: g3dmath.h:170
Definition: Language.h:561
Definition: Unit.h:705
Definition: Creature.h:467
uint32 MechanicImmuneMask
Definition: Creature.h:141
uint32 flags_extra
Definition: Creature.h:142
Definition: SharedDefines.h:1823
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint8 getLevel() const
Definition: Unit.h:1408
Definition: Language.h:564
Definition: Language.h:1103
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
time_t GetRespawnTimeEx() const
Definition: Creature.cpp:2346
Entry
Definition: boss_headless_horseman.cpp:50
Definition: Language.h:1097
int8 GetOriginalEquipmentId() const
Definition: Creature.h:546
Definition: Language.h:33
Definition: Language.h:556
float GetPositionY() const
Definition: Position.h:105
#define FLAGS_EXTRA_COUNT
Definition: cs_npc.cpp:46
uint32 GetInstanceId() const
Definition: Object.h:451
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: Language.h:1084
EnumName< UnitFlags > const unitFlags[MAX_UNIT_FLAGS]
Definition: cs_npc.cpp:113
EnumName< NPCFlags, int32 > const npcFlagTexts[NPCFLAG_COUNT]
Definition: cs_npc.cpp:48
uint32 GetArmor() const
Definition: Unit.h:1419
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::set< uint32 > const & GetPhases() const
Definition: Object.h:465
std::string GetScriptName() const
Definition: Creature.cpp:2422
uint32 GetNativeDisplayId() const
Definition: Unit.h:2014
Definition: Language.h:557
Definition: UpdateFields.h:109
Definition: Language.h:559
uint32 GetCreateHealth() const
Definition: Unit.h:1895
uint8_t uint8
Definition: Define.h:152
uint8 GetCurrentEquipmentId() const
Definition: Creature.h:547
Definition: UpdateFields.h:135
Definition: UpdateFields.h:30
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 GetEntry() const
Definition: Object.h:107
Definition: Language.h:1104
Definition: Language.h:1102
uint32 lootid
Definition: Creature.h:119
uint32 pickpocketLootId
Definition: Creature.h:120
float GetPositionX() const
Definition: Position.h:104
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:1086
uint32 GetHealth() const
Definition: Unit.h:1426
std::string GetAIName() const
Definition: Creature.cpp:2417
uint64 GetUInt64Value(uint16 index) const
Definition: Object.cpp:306
Definition: Creature.h:79
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcMoveCommand ( ChatHandler handler,
char const args 
)
inlinestatic
809  {
810  ObjectGuid::LowType lowguid = UI64LIT(0);
811 
812  Creature* creature = handler->getSelectedCreature();
813 
814  if (!creature)
815  {
816  // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
817  char* cId = handler->extractKeyFromLink((char*)args, "Hcreature");
818  if (!cId)
819  return false;
820 
821  lowguid = strtoull(cId, nullptr, 10);
822 
823  // Attempting creature load from DB data
824  CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
825  if (!data)
826  {
828  handler->SetSentErrorMessage(true);
829  return false;
830  }
831 
832  uint32 map_id = data->mapid;
833 
834  if (handler->GetSession()->GetPlayer()->GetMapId() != map_id)
835  {
837  handler->SetSentErrorMessage(true);
838  return false;
839  }
840  }
841  else
842  {
843  lowguid = creature->GetSpawnId();
844  }
845 
846  float x = handler->GetSession()->GetPlayer()->GetPositionX();
847  float y = handler->GetSession()->GetPlayer()->GetPositionY();
848  float z = handler->GetSession()->GetPlayer()->GetPositionZ();
849  float o = handler->GetSession()->GetPlayer()->GetOrientation();
850 
851  if (creature)
852  {
853  if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
854  {
855  const_cast<CreatureData*>(data)->posX = x;
856  const_cast<CreatureData*>(data)->posY = y;
857  const_cast<CreatureData*>(data)->posZ = z;
858  const_cast<CreatureData*>(data)->orientation = o;
859  }
860  creature->SetPosition(x, y, z, o);
861  creature->GetMotionMaster()->Initialize();
862  if (creature->IsAlive()) // dead creature will reset movement generator at respawn
863  {
864  creature->setDeathState(JUST_DIED);
865  creature->Respawn();
866  }
867  }
868 
870 
871  stmt->setFloat(0, x);
872  stmt->setFloat(1, y);
873  stmt->setFloat(2, z);
874  stmt->setFloat(3, o);
875  stmt->setUInt64(4, lowguid);
876 
877  WorldDatabase.Execute(stmt);
878 
880  return true;
881  }
Definition: Creature.h:287
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Unit.h:542
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
#define UI64LIT(N)
Definition: Define.h:138
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
Definition: Language.h:304
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Language.h:319
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:303
uint64 LowType
Definition: ObjectGuid.h:199
Definition: System.cpp:71
Definition: WorldDatabase.h:50
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
void SetPosition(float x, float y, float z, float o)
Definition: Creature.cpp:2537
void setDeathState(DeathState s) override
Definition: Creature.cpp:1624
bool IsAlive() const
Definition: Unit.h:1692
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void Respawn(bool force=false)
Definition: Creature.cpp:1697
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
uint16 mapid
Definition: Creature.h:294
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
void Initialize()
Definition: MotionMaster.cpp:39
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcNearCommand ( ChatHandler handler,
char const args 
)
inlinestatic
762  {
763  float distance = (!*args) ? 10.0f : float((atof(args)));
764  uint32 count = 0;
765 
766  Player* player = handler->GetSession()->GetPlayer();
767 
769  stmt->setFloat(0, player->GetPositionX());
770  stmt->setFloat(1, player->GetPositionY());
771  stmt->setFloat(2, player->GetPositionZ());
772  stmt->setUInt32(3, player->GetMapId());
773  stmt->setFloat(4, player->GetPositionX());
774  stmt->setFloat(5, player->GetPositionY());
775  stmt->setFloat(6, player->GetPositionZ());
776  stmt->setFloat(7, distance * distance);
777  PreparedQueryResult result = WorldDatabase.Query(stmt);
778 
779  if (result)
780  {
781  do
782  {
783  Field* fields = result->Fetch();
784  ObjectGuid::LowType guid = fields[0].GetUInt64();
785  uint32 entry = fields[1].GetUInt32();
786  float x = fields[2].GetFloat();
787  float y = fields[3].GetFloat();
788  float z = fields[4].GetFloat();
789  uint16 mapId = fields[5].GetUInt16();
790 
791  CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
792  if (!creatureTemplate)
793  continue;
794 
795  handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId);
796 
797  ++count;
798  }
799  while (result->NextRow());
800  }
801 
802  handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
803 
804  return true;
805  }
std::string Name
Definition: Creature.h:88
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Old ones now free:
Definition: Language.h:578
float GetFloat() const
Definition: Field.h:222
Class used to access individual fields of database query result.
Definition: Field.h:56
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
double distance(double x, double y)
Definition: g3dmath.h:731
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint16_t uint16
Definition: Define.h:151
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: WorldDatabase.h:90
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Creature.h:79
Definition: Language.h:528

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcPlayEmoteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
885  {
886  uint32 emote = atoi((char*)args);
887 
888  Creature* target = handler->getSelectedCreature();
889  if (!target)
890  {
892  handler->SetSentErrorMessage(true);
893  return false;
894  }
895 
896  target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
897 
898  return true;
899  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: UpdateFields.h:136
Creature * getSelectedCreature()
Definition: Chat.cpp:615
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: Creature.h:467
Definition: Language.h:33
uint32_t uint32
Definition: Define.h:150
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSayCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1216  {
1217  if (!*args)
1218  return false;
1219 
1220  Creature* creature = handler->getSelectedCreature();
1221  if (!creature)
1222  {
1224  handler->SetSentErrorMessage(true);
1225  return false;
1226  }
1227 
1228  creature->Say(args, LANG_UNIVERSAL);
1229 
1230  // make some emotes
1231  char lastchar = args[strlen(args) - 1];
1232  switch (lastchar)
1233  {
1234  case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1235  case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1236  default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1237  }
1238 
1239  return true;
1240  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: SharedDefines.h:2417
Definition: SharedDefines.h:961
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Creature.h:467
Definition: SharedDefines.h:2413
Definition: Language.h:33
Definition: SharedDefines.h:2418
virtual void Say(std::string const &text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:16393
void HandleEmoteCommand(uint32 anim_id)
Definition: Unit.cpp:1444
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetAllowMovementCommand ( ChatHandler handler,
char const  
)
inlinestatic
400  {
401  if (sWorld->getAllowMovement())
402  {
403  sWorld->SetAllowMovement(false);
405  }
406  else
407  {
408  sWorld->SetAllowMovement(true);
410  }
411  return true;
412  }
Definition: Language.h:401
Definition: Language.h:400
#define sWorld
Definition: World.h:887
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetDataCommand ( ChatHandler handler,
char const args 
)
inlinestatic
632  {
633  if (!*args)
634  return false;
635 
636  char* arg1 = strtok((char*)args, " ");
637  char* arg2 = strtok((char*)NULL, "");
638 
639  if (!arg1 || !arg2)
640  return false;
641 
642  uint32 data_1 = (uint32)atoi(arg1);
643  uint32 data_2 = (uint32)atoi(arg2);
644 
645  if (!data_1 || !data_2)
646  return false;
647 
648  Creature* creature = handler->getSelectedCreature();
649 
650  if (!creature)
651  {
653  handler->SetSentErrorMessage(true);
654  return false;
655  }
656 
657  creature->AI()->SetData(data_1, data_2);
658  std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
659  handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().ToString().c_str(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str());
660  return true;
661  }
virtual void SetData(uint32, uint32)
Definition: UnitAI.h:140
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
std::string const & GetName() const
Definition: Object.h:479
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Definition: Language.h:33
CreatureAI * AI() const
Definition: Creature.h:525
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:575
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::string GetScriptName() const
Definition: Creature.cpp:2422
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::string GetAIName() const
Definition: Creature.cpp:2417
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetEntryCommand ( ChatHandler handler,
char const args 
)
inlinestatic
415  {
416  if (!*args)
417  return false;
418 
419  uint32 newEntryNum = atoi(args);
420  if (!newEntryNum)
421  return false;
422 
423  Unit* unit = handler->getSelectedUnit();
424  if (!unit || unit->GetTypeId() != TYPEID_UNIT)
425  {
427  handler->SetSentErrorMessage(true);
428  return false;
429  }
430  Creature* creature = unit->ToCreature();
431  if (creature->UpdateEntry(newEntryNum))
432  handler->SendSysMessage(LANG_DONE);
433  else
434  handler->SendSysMessage(LANG_ERROR);
435  return true;
436  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Unit * getSelectedUnit()
Definition: Chat.cpp:591
Definition: ObjectGuid.h:32
Definition: Creature.h:467
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Language.h:33
Definition: Language.h:79
uint32_t uint32
Definition: Define.h:150
Creature * ToCreature()
Definition: Object.h:194
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Unit.h:1305
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr)
Definition: Creature.cpp:407
Definition: Language.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetFactionIdCommand ( ChatHandler handler,
char const args 
)
inlinestatic
558  {
559  if (!*args)
560  return false;
561 
562  uint32 factionId = (uint32) atoi((char*)args);
563 
564  if (!sFactionTemplateStore.LookupEntry(factionId))
565  {
566  handler->PSendSysMessage(LANG_WRONG_FACTION, factionId);
567  handler->SetSentErrorMessage(true);
568  return false;
569  }
570 
571  Creature* creature = handler->getSelectedCreature();
572 
573  if (!creature)
574  {
576  handler->SetSentErrorMessage(true);
577  return false;
578  }
579 
580  creature->setFaction(factionId);
581 
582  // Faction is set in creature_template - not inside creature
583 
584  // Update in memory..
585  if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
586  const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
587 
588  // ..and DB
590 
591  stmt->setUInt16(0, uint16(factionId));
592  stmt->setUInt32(1, creature->GetEntry());
593 
594  WorldDatabase.Execute(stmt);
595 
596  return true;
597  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Creature.h:467
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
void setFaction(uint32 faction)
Definition: Unit.h:1467
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
Definition: Language.h:33
Definition: Language.h:155
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: WorldDatabase.h:48
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 GetEntry() const
Definition: Object.h:107
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplatefmt)
Definition: Creature.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetFlagCommand ( ChatHandler handler,
char const args 
)
inlinestatic
601  {
602  if (!*args)
603  return false;
604 
605  uint64 npcFlags = std::strtoull(args, nullptr, 10);
606 
607  Creature* creature = handler->getSelectedCreature();
608 
609  if (!creature)
610  {
612  handler->SetSentErrorMessage(true);
613  return false;
614  }
615 
616  creature->SetUInt64Value(UNIT_NPC_FLAGS, npcFlags);
617 
619 
620  stmt->setUInt64(0, npcFlags);
621  stmt->setUInt32(1, creature->GetEntry());
622 
623  WorldDatabase.Execute(stmt);
624 
626 
627  return true;
628  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: WorldDatabase.h:49
Definition: Language.h:292
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Creature.h:467
Definition: PreparedStatement.h:74
Definition: Language.h:33
uint64_t uint64
Definition: Define.h:149
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: UpdateFields.h:135
uint32 GetEntry() const
Definition: Object.h:107
void SetUInt64Value(uint16 index, uint64 value)
Definition: Object.cpp:1017
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetLevelCommand ( ChatHandler handler,
char const args 
)
inlinestatic
440  {
441  if (!*args)
442  return false;
443 
444  uint8 lvl = (uint8) atoi((char*)args);
445  if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
446  {
447  handler->SendSysMessage(LANG_BAD_VALUE);
448  handler->SetSentErrorMessage(true);
449  return false;
450  }
451 
452  Creature* creature = handler->getSelectedCreature();
453  if (!creature)
454  {
456  handler->SetSentErrorMessage(true);
457  return false;
458  }
459 
460  if (creature->IsPet())
461  {
462  if (((Pet*)creature)->getPetType() == HUNTER_PET)
463  {
464  creature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr->GetXPForLevel(lvl)/4);
466  }
467  ((Pet*)creature)->GivePetLevel(lvl);
468  }
469  else
470  {
471  creature->SetMaxHealth(100 + 30*lvl);
472  creature->SetHealth(100 + 30*lvl);
473  creature->SetLevel(lvl);
474  creature->SaveToDB();
475  }
476 
477  return true;
478  }
Definition: UpdateFields.h:128
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
void SaveToDB()
Definition: Creature.cpp:1034
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: Creature.h:467
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PetDefines.h:25
Definition: UpdateFields.h:127
Definition: Language.h:33
void SetLevel(uint8 lvl)
Definition: Unit.cpp:11523
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:11565
bool IsPet() const
Definition: Unit.h:1403
Definition: Language.h:139
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
void SetHealth(uint32 val)
Definition: Unit.cpp:11537
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: World.h:235
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetLinkCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1507  {
1508  if (!*args)
1509  return false;
1510 
1511  ObjectGuid::LowType linkguid = strtoull(args, nullptr, 10);
1512 
1513  Creature* creature = handler->getSelectedCreature();
1514 
1515  if (!creature)
1516  {
1518  handler->SetSentErrorMessage(true);
1519  return false;
1520  }
1521 
1522  if (!creature->GetSpawnId())
1523  {
1524  handler->PSendSysMessage("Selected %s isn't in creature table", creature->GetGUID().ToString().c_str());
1525  handler->SetSentErrorMessage(true);
1526  return false;
1527  }
1528 
1529  if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1530  {
1531  handler->PSendSysMessage("Selected creature can't link with guid '" UI64FMTD "'", linkguid);
1532  handler->SetSentErrorMessage(true);
1533  return false;
1534  }
1535 
1536  handler->PSendSysMessage("LinkGUID '" UI64FMTD "' added to creature with DBTableGUID: '" UI64FMTD "'", linkguid, creature->GetSpawnId());
1537  return true;
1538  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
Definition: Creature.h:467
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:33
#define UI64FMTD
Definition: Define.h:137
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetModelCommand ( ChatHandler handler,
char const args 
)
inlinestatic
903  {
904  if (!*args)
905  return false;
906 
907  uint32 displayId = (uint32) atoi((char*)args);
908 
909  Creature* creature = handler->getSelectedCreature();
910 
911  if (!creature || creature->IsPet())
912  {
914  handler->SetSentErrorMessage(true);
915  return false;
916  }
917 
918  creature->SetDisplayId(displayId);
919  creature->SetNativeDisplayId(displayId);
920 
921  creature->SaveToDB();
922 
923  return true;
924  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
void SaveToDB()
Definition: Creature.cpp:1034
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:2016
Definition: Creature.h:467
Definition: Language.h:33
uint32_t uint32
Definition: Define.h:150
bool IsPet() const
Definition: Unit.h:1403
void SetDisplayId(uint32 modelId) override
Definition: Creature.cpp:2664
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetMoveTypeCommand ( ChatHandler handler,
char const args 
)
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 spawndist
  • way - NPC will move with given waypoints set

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

939  {
940  if (!*args)
941  return false;
942 
943  // 3 arguments:
944  // GUID (optional - you can also select the creature)
945  // stay|random|way (determines the kind of movement)
946  // NODEL (optional - tells the system NOT to delete any waypoints)
947  // this is very handy if you want to do waypoints, that are
948  // later switched on/off according to special events (like escort
949  // quests, etc)
950  char* guid_str = strtok((char*)args, " ");
951  char* type_str = strtok((char*)NULL, " ");
952  char* dontdel_str = strtok((char*)NULL, " ");
953 
954  bool doNotDelete = false;
955 
956  if (!guid_str)
957  return false;
958 
959  ObjectGuid::LowType lowguid = UI64LIT(0);
960  Creature* creature = NULL;
961 
962  if (dontdel_str)
963  {
964  //TC_LOG_ERROR("misc", "DEBUG: All 3 params are set");
965 
966  // All 3 params are set
967  // GUID
968  // type
969  // doNotDEL
970  if (stricmp(dontdel_str, "NODEL") == 0)
971  {
972  //TC_LOG_ERROR("misc", "DEBUG: doNotDelete = true;");
973  doNotDelete = true;
974  }
975  }
976  else
977  {
978  // Only 2 params - but maybe NODEL is set
979  if (type_str)
980  {
981  TC_LOG_ERROR("misc", "DEBUG: Only 2 params ");
982  if (stricmp(type_str, "NODEL") == 0)
983  {
984  //TC_LOG_ERROR("misc", "DEBUG: type_str, NODEL ");
985  doNotDelete = true;
986  type_str = NULL;
987  }
988  }
989  }
990 
991  if (!type_str) // case .setmovetype $move_type (with selected creature)
992  {
993  type_str = guid_str;
994  creature = handler->getSelectedCreature();
995  if (!creature || creature->IsPet())
996  return false;
997  lowguid = creature->GetSpawnId();
998  }
999  else // case .setmovetype #creature_guid $move_type (with selected creature)
1000  {
1001  lowguid = strtoull(guid_str, nullptr, 10);
1002 
1003  /* impossible without entry
1004  if (lowguid)
1005  creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HIGHGUID_UNIT));
1006  */
1007 
1008  // attempt check creature existence by DB data
1009  if (!creature)
1010  {
1011  CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
1012  if (!data)
1013  {
1015  handler->SetSentErrorMessage(true);
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 NULL
1027 
1028  MovementGeneratorType move_type;
1029 
1030  std::string type = type_str;
1031 
1032  if (type == "stay")
1033  move_type = IDLE_MOTION_TYPE;
1034  else if (type == "random")
1035  move_type = RANDOM_MOTION_TYPE;
1036  else if (type == "way")
1037  move_type = WAYPOINT_MOTION_TYPE;
1038  else
1039  return false;
1040 
1041  // update movement type
1042  //if (doNotDelete == false)
1043  // WaypointMgr.DeletePath(lowguid);
1044 
1045  if (creature)
1046  {
1047  // update movement type
1048  if (doNotDelete == false)
1049  creature->LoadPath(0);
1050 
1051  creature->SetDefaultMovementType(move_type);
1052  creature->GetMotionMaster()->Initialize();
1053  if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1054  {
1055  creature->setDeathState(JUST_DIED);
1056  creature->Respawn();
1057  }
1058  creature->SaveToDB();
1059  }
1060  if (doNotDelete == false)
1061  {
1062  handler->PSendSysMessage(LANG_MOVE_TYPE_SET, type_str);
1063  }
1064  else
1065  {
1066  handler->PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, type_str);
1067  }
1068 
1069  return true;
1070  }
Definition: Creature.h:287
Definition: MotionMaster.h:37
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Unit.h:542
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
#define UI64LIT(N)
Definition: Define.h:138
void SaveToDB()
Definition: Creature.cpp:1034
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: MotionMaster.h:38
Definition: Language.h:319
Definition: Creature.h:467
void LoadPath(uint32 pathid)
Definition: Creature.h:681
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
void setDeathState(DeathState s) override
Definition: Creature.cpp:1624
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition: Creature.h:625
bool IsAlive() const
Definition: Unit.h:1692
bool IsPet() const
Definition: Unit.h:1403
void Respawn(bool force=false)
Definition: Creature.cpp:1697
#define stricmp
Definition: FileSystem.cpp:39
Definition: Language.h:288
MovementGeneratorType
Definition: MotionMaster.h:35
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void Initialize()
Definition: MotionMaster.cpp:39
Definition: Language.h:289
Definition: MotionMaster.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetPhaseCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1105  {
1106  if (!*args)
1107  return false;
1108 
1109  uint32 phase = (uint32) atoi((char*)args);
1110 
1111  Creature* creature = handler->getSelectedCreature();
1112  if (!creature || creature->IsPet())
1113  {
1115  handler->SetSentErrorMessage(true);
1116  return false;
1117  }
1118 
1119  creature->ClearPhases();
1120  creature->SetInPhase(phase, true, true);
1121  creature->SetDBPhase(phase);
1122 
1123  creature->SaveToDB();
1124 
1125  return true;
1126  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
void SetDBPhase(int32 p)
Definition: Object.h:471
void SaveToDB()
Definition: Creature.cpp:1034
Definition: Creature.h:467
bool SetInPhase(uint32 id, bool update, bool apply) override
Definition: Unit.cpp:14578
void ClearPhases(bool update=false)
Definition: Object.cpp:2927
Definition: Language.h:33
uint32_t uint32
Definition: Define.h:150
bool IsPet() const
Definition: Unit.h:1403
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetPhaseGroup ( ChatHandler handler,
char const args 
)
inlinestatic
1075  {
1076  if (!*args)
1077  return false;
1078 
1079  uint32 phaseGroupId = (uint32)atoi((char*)args);
1080 
1081  Creature* creature = handler->getSelectedCreature();
1082  if (!creature || creature->IsPet())
1083  {
1085  handler->SetSentErrorMessage(true);
1086  return false;
1087  }
1088 
1089  creature->ClearPhases();
1090 
1091  for (uint32 id : sDB2Manager.GetPhasesForGroup(phaseGroupId))
1092  creature->SetInPhase(id, false, true); // don't send update here for multiple phases, only send it once after adding all phases
1093 
1094  creature->UpdateObjectVisibility();
1095  creature->SetDBPhase(-int(phaseGroupId));
1096 
1097  creature->SaveToDB();
1098 
1099  return true;
1100  }
#define sDB2Manager
Definition: DB2Stores.h:224
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
void SetDBPhase(int32 p)
Definition: Object.h:471
void SaveToDB()
Definition: Creature.cpp:1034
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
Definition: Creature.h:467
bool SetInPhase(uint32 id, bool update, bool apply) override
Definition: Unit.cpp:14578
void ClearPhases(bool update=false)
Definition: Object.cpp:2927
Definition: Language.h:33
uint32_t uint32
Definition: Define.h:150
bool IsPet() const
Definition: Unit.h:1403
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetSpawnDistCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1130  {
1131  if (!*args)
1132  return false;
1133 
1134  float option = (float)(atof((char*)args));
1135  if (option < 0.0f)
1136  {
1137  handler->SendSysMessage(LANG_BAD_VALUE);
1138  return false;
1139  }
1140 
1142  if (option >0.0f)
1143  mtype = RANDOM_MOTION_TYPE;
1144 
1145  Creature* creature = handler->getSelectedCreature();
1146  ObjectGuid::LowType guidLow = UI64LIT(0);
1147 
1148  if (creature)
1149  guidLow = creature->GetSpawnId();
1150  else
1151  return false;
1152 
1153  creature->SetRespawnRadius(option);
1154  creature->SetDefaultMovementType(mtype);
1155  creature->GetMotionMaster()->Initialize();
1156  if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1157  {
1158  creature->setDeathState(JUST_DIED);
1159  creature->Respawn();
1160  }
1161 
1163 
1164  stmt->setFloat(0, option);
1165  stmt->setUInt8(1, uint8(mtype));
1166  stmt->setUInt64(2, guidLow);
1167 
1168  WorldDatabase.Execute(stmt);
1169 
1170  handler->PSendSysMessage(LANG_COMMAND_SPAWNDIST, option);
1171  return true;
1172  }
Definition: MotionMaster.h:37
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Unit.h:542
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
#define UI64LIT(N)
Definition: Define.h:138
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: MotionMaster.h:38
Definition: Creature.h:467
uint64 LowType
Definition: ObjectGuid.h:199
Definition: Language.h:323
Definition: PreparedStatement.h:74
void setDeathState(DeathState s) override
Definition: Creature.cpp:1624
void SetRespawnRadius(float dist)
Definition: Creature.h:641
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition: Creature.h:625
bool IsAlive() const
Definition: Unit.h:1692
Definition: WorldDatabase.h:51
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Language.h:139
void Respawn(bool force=false)
Definition: Creature.cpp:1697
uint8_t uint8
Definition: g3dmath.h:164
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
MovementGeneratorType
Definition: MotionMaster.h:35
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
void Initialize()
Definition: MotionMaster.cpp:39
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcSetSpawnTimeCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1176  {
1177  if (!*args)
1178  return false;
1179 
1180  char* stime = strtok((char*)args, " ");
1181 
1182  if (!stime)
1183  return false;
1184 
1185  int spawnTime = atoi((char*)stime);
1186 
1187  if (spawnTime < 0)
1188  {
1189  handler->SendSysMessage(LANG_BAD_VALUE);
1190  handler->SetSentErrorMessage(true);
1191  return false;
1192  }
1193 
1194  Creature* creature = handler->getSelectedCreature();
1195  ObjectGuid::LowType guidLow = UI64LIT(0);
1196 
1197  if (creature)
1198  guidLow = creature->GetSpawnId();
1199  else
1200  return false;
1201 
1203 
1204  stmt->setUInt32(0, uint32(spawnTime));
1205  stmt->setUInt64(1, guidLow);
1206 
1207  WorldDatabase.Execute(stmt);
1208 
1209  creature->SetRespawnDelay((uint32)spawnTime);
1210  handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime);
1211 
1212  return true;
1213  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Creature * getSelectedCreature()
Definition: Chat.cpp:615
#define UI64LIT(N)
Definition: Define.h:138
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Language.h:324
Definition: Creature.h:467
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: Language.h:139
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:638
Definition: WorldDatabase.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcTameCommand ( ChatHandler handler,
char const  
)
inlinestatic
1389  {
1390  Creature* creatureTarget = handler->getSelectedCreature();
1391  if (!creatureTarget || creatureTarget->IsPet())
1392  {
1394  handler->SetSentErrorMessage (true);
1395  return false;
1396  }
1397 
1398  Player* player = handler->GetSession()->GetPlayer();
1399 
1400  if (!player->GetPetGUID().IsEmpty())
1401  {
1403  handler->SetSentErrorMessage (true);
1404  return false;
1405  }
1406 
1407  CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1408 
1409  if (!cInfo->IsTameable (player->CanTameExoticPets()))
1410  {
1412  handler->SetSentErrorMessage (true);
1413  return false;
1414  }
1415 
1416  // Everything looks OK, create new pet
1417  Pet* pet = player->CreateTamedPetFrom(creatureTarget);
1418  if (!pet)
1419  {
1421  handler->SetSentErrorMessage (true);
1422  return false;
1423  }
1424 
1425  // place pet before player
1426  float x, y, z;
1427  player->GetClosePoint (x, y, z, creatureTarget->GetObjectSize(), CONTACT_DISTANCE);
1428  pet->Relocate(x, y, z, float(M_PI) - player->GetOrientation());
1429 
1430  // set pet to defensive mode by default (some classes can't control controlled pets in fact).
1432 
1433  // calculate proper level
1434  uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
1435 
1436  // prepare visual effect for levelup
1437  pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
1438 
1439  // add to world
1440  pet->GetMap()->AddToMap(pet->ToCreature());
1441 
1442  // visual effect for levelup
1443  pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
1444 
1445  // caster have pet now
1446  player->SetMinion(pet, true);
1447 
1449  player->PetSpellInitialize();
1450 
1451  return true;
1452  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Map * GetMap() const
Definition: Object.h:543
#define M_PI
Definition: Common.h:163
Definition: Unit.h:1130
Pet * CreateTamedPetFrom(Creature *creatureTarget, uint32 spell_id=0)
Definition: Unit.cpp:13181
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: UpdateFields.h:105
uint8 getLevel() const
Definition: Unit.h:1408
Definition: PetDefines.h:35
Definition: Language.h:372
void SavePetToDB(PetSaveMode mode)
Definition: Pet.cpp:372
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Language.h:33
uint32 Entry
Definition: Creature.h:81
G3D::int16 z
Definition: Vector3int16.h:46
bool AddToMap(T *)
Definition: Map.cpp:566
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Language.h:371
bool IsPet() const
Definition: Unit.h:1403
Creature * ToCreature()
Definition: Object.h:194
WorldSession * GetSession()
Definition: Chat.h:59
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define CONTACT_DISTANCE
Definition: Object.h:33
G3D::int16 x
Definition: Vector2int16.h:37
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
float GetObjectSize() const
Definition: Object.cpp:2656
bool IsTameable(bool canTameExotic) const
Definition: Creature.h:167
void SetReactState(ReactStates st)
Definition: Creature.h:502
Definition: Creature.h:79
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcTextEmoteCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1244  {
1245  if (!*args)
1246  return false;
1247 
1248  Creature* creature = handler->getSelectedCreature();
1249 
1250  if (!creature)
1251  {
1253  handler->SetSentErrorMessage(true);
1254  return false;
1255  }
1256 
1257  creature->TextEmote(args);
1258 
1259  return true;
1260  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
virtual void TextEmote(std::string const &text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:16403
Definition: Creature.h:467
Definition: Language.h:33
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler,
char const  
)
inlinestatic
1264  {
1265  Player* player = handler->GetSession()->GetPlayer();
1266  Creature* creature = handler->getSelectedCreature();
1267 
1268  if (!creature)
1269  {
1271  handler->SetSentErrorMessage(true);
1272  return false;
1273  }
1274 
1275  if (/*creature->GetMotionMaster()->empty() ||*/
1277  {
1278  handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1279  handler->SetSentErrorMessage(true);
1280  return false;
1281  }
1282 
1284 
1285  if (mgen->GetTarget() != player)
1286  {
1287  handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1288  handler->SetSentErrorMessage(true);
1289  return false;
1290  }
1291 
1292  // reset movement
1293  creature->GetMotionMaster()->MovementExpired(true);
1294 
1295  handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
1296  return true;
1297  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Creature * getSelectedCreature()
Definition: Chat.cpp:615
std::string const & GetName() const
Definition: Object.h:479
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:663
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
_Ty top() const
Definition: MotionMaster.h:123
Definition: Language.h:33
Definition: Language.h:369
Unit * GetTarget() const
Definition: TargetedMovementGenerator.h:51
Definition: TargetedMovementGenerator.h:91
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:370
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define const
Definition: zconf.h:217
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:151
Definition: MotionMaster.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcWhisperCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1301  {
1302  if (!*args)
1303  {
1304  handler->SendSysMessage(LANG_CMD_SYNTAX);
1305  handler->SetSentErrorMessage(true);
1306  return false;
1307  }
1308 
1309  char* receiver_str = strtok((char*)args, " ");
1310  char* text = strtok(NULL, "");
1311 
1312  if (!receiver_str || !text)
1313  {
1314  handler->SendSysMessage(LANG_CMD_SYNTAX);
1315  handler->SetSentErrorMessage(true);
1316  return false;
1317  }
1318 
1319  Creature* creature = handler->getSelectedCreature();
1320  if (!creature)
1321  {
1323  handler->SetSentErrorMessage(true);
1324  return false;
1325  }
1326 
1327  ObjectGuid receiver_guid = ObjectGuid::Create<HighGuid::Player>(strtoull(receiver_str, nullptr, 10));
1328 
1329  // check online security
1330  Player* receiver = ObjectAccessor::FindPlayer(receiver_guid);
1331  if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1332  return false;
1333 
1334  creature->Whisper(text, LANG_UNIVERSAL, receiver);
1335  return true;
1336  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: SharedDefines.h:961
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Language.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:77
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: Language.h:33
virtual void Whisper(std::string const &text, Language language, Player *target, bool isBossWhisper=false)
Definition: Unit.cpp:16408
Definition: ObjectGuid.h:189
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool npc_commandscript::HandleNpcYellCommand ( ChatHandler handler,
char const args 
)
inlinestatic
1339  {
1340  if (!*args)
1341  {
1342  handler->SendSysMessage(LANG_CMD_SYNTAX);
1343  handler->SetSentErrorMessage(true);
1344  return false;
1345  }
1346 
1347  Creature* creature = handler->getSelectedCreature();
1348  if (!creature)
1349  {
1351  handler->SetSentErrorMessage(true);
1352  return false;
1353  }
1354 
1355  creature->Yell(args, LANG_UNIVERSAL);
1356 
1357  // make an emote
1359 
1360  return true;
1361  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: SharedDefines.h:961
Creature * getSelectedCreature()
Definition: Chat.cpp:615
Definition: Language.h:43
Definition: Creature.h:467
Definition: SharedDefines.h:2432
Definition: Language.h:33
virtual void Yell(std::string const &text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:16398
void HandleEmoteCommand(uint32 anim_id)
Definition: Unit.cpp:1444
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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