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 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)
 
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 HandleNpcAddFormationCommand (ChatHandler *handler, ObjectGuid::LowType leaderGUID)
 
static bool HandleNpcSetLinkCommand (ChatHandler *handler, ObjectGuid::LowType linkguid)
 

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
134: CommandScript("npc_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable npc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

137 {
138 static ChatCommandTable npcAddCommandTable =
139 {
140 { "formation", HandleNpcAddFormationCommand, SEC_ADMINISTRATOR, Console::No },
141 { "item", HandleNpcAddVendorItemCommand, SEC_ADMINISTRATOR, Console::No },
142 { "move", HandleNpcAddMoveCommand, SEC_ADMINISTRATOR, Console::No },
143 { "temp", HandleNpcAddTempSpawnCommand, SEC_ADMINISTRATOR, Console::No },
144 { "", HandleNpcAddCommand, SEC_ADMINISTRATOR, Console::No }
145 };
146 static ChatCommandTable npcDeleteCommandTable =
147 {
148 { "item", HandleNpcDeleteVendorItemCommand, SEC_ADMINISTRATOR, Console::No },
149 { "", HandleNpcDeleteCommand, SEC_ADMINISTRATOR, Console::No }
150 };
151 static ChatCommandTable npcFollowCommandTable =
152 {
153 { "stop", HandleNpcUnFollowCommand, SEC_GAMEMASTER, Console::No },
154 { "", HandleNpcFollowCommand, SEC_GAMEMASTER, Console::No }
155 };
156
157 static ChatCommandTable npcFactionCommandTable =
158 {
159 { "permanent", HandleNpcSetFactionIdCommand, SEC_ADMINISTRATOR, Console::No },
160 { "temp", HandleNpcSetFactionTempIdCommand, SEC_ADMINISTRATOR, Console::No },
161 { "original", HandleNpcSetOriginalFaction, SEC_ADMINISTRATOR, Console::No }
162 };
163
164 static ChatCommandTable npcSetCommandTable =
165 {
166 { "allowmove", HandleNpcSetAllowMovementCommand, SEC_ADMINISTRATOR, Console::No },
167 { "entry", HandleNpcSetEntryCommand, SEC_ADMINISTRATOR, Console::No },
168 { "faction", npcFactionCommandTable},
169 { "flag", HandleNpcSetFlagCommand, SEC_ADMINISTRATOR, Console::No },
170 { "level", HandleNpcSetLevelCommand, SEC_ADMINISTRATOR, Console::No },
171 { "link", HandleNpcSetLinkCommand, SEC_ADMINISTRATOR, Console::No },
172 { "model", HandleNpcSetModelCommand, SEC_ADMINISTRATOR, Console::No },
173 { "movetype", HandleNpcSetMoveTypeCommand, SEC_ADMINISTRATOR, Console::No },
174 { "phase", HandleNpcSetPhaseCommand, SEC_ADMINISTRATOR, Console::No },
175 { "wanderdistance", HandleNpcSetWanderDistanceCommand, SEC_ADMINISTRATOR, Console::No },
176 { "spawntime", HandleNpcSetSpawnTimeCommand, SEC_ADMINISTRATOR, Console::No },
177 { "data", HandleNpcSetDataCommand, SEC_ADMINISTRATOR, Console::No }
178 };
179 static ChatCommandTable npcCommandTable =
180 {
181 { "info", HandleNpcInfoCommand, SEC_GAMEMASTER, Console::No },
182 { "guid", HandleNpcGuidCommand, SEC_GAMEMASTER, Console::No },
183 { "near", HandleNpcNearCommand, SEC_GAMEMASTER, Console::No },
184 { "move", HandleNpcMoveCommand, SEC_GAMEMASTER, Console::No },
185 { "playemote", HandleNpcPlayEmoteCommand, SEC_GAMEMASTER, Console::No },
186 { "say", HandleNpcSayCommand, SEC_GAMEMASTER, Console::No },
187 { "textemote", HandleNpcTextEmoteCommand, SEC_GAMEMASTER, Console::No },
188 { "whisper", HandleNpcWhisperCommand, SEC_GAMEMASTER, Console::No },
189 { "yell", HandleNpcYellCommand, SEC_GAMEMASTER, Console::No },
190 { "tame", HandleNpcTameCommand, SEC_GAMEMASTER, Console::No },
191 { "add", npcAddCommandTable },
192 { "delete", npcDeleteCommandTable },
193 { "follow", npcFollowCommandTable },
194 { "set", npcSetCommandTable }
195 };
196 static ChatCommandTable commandTable =
197 {
198 { "npc", npcCommandTable }
199 };
200 return commandTable;
201 }
@ SEC_ADMINISTRATOR
Definition Common.h:60
@ SEC_GAMEMASTER
Definition Common.h:59
static bool HandleNpcWhisperCommand(ChatHandler *handler, std::string const &recv, Tail text)
Definition cs_npc.cpp:1124
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
Definition cs_npc.cpp:1215
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:1166
static bool HandleNpcSetFactionTempIdCommand(ChatHandler *handler, uint32 tempfaction)
Definition cs_npc.cpp:464
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition cs_npc.cpp:961
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition cs_npc.cpp:204
static bool HandleNpcSetOriginalFaction(ChatHandler *handler)
Definition cs_npc.cpp:483
static bool HandleNpcTameCommand(ChatHandler *handler)
Definition cs_npc.cpp:1179
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1071
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition cs_npc.cpp:802
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1145
static bool HandleNpcGuidCommand(ChatHandler *handler)
Definition cs_npc.cpp:639
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition cs_npc.cpp:937
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:546
static bool HandleNpcMoveCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > guid)
Definition cs_npc.cpp:718
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition cs_npc.cpp:787
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:837
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition cs_npc.cpp:1090
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
Definition cs_npc.cpp:353
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition cs_npc.cpp:318
static bool HandleNpcDeleteCommand(ChatHandler *handler, Optional< ObjectGuid::LowType > lowGuid)
Definition cs_npc.cpp:376
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
Definition cs_npc.cpp:1045
static bool HandleNpcInfoCommand(ChatHandler *handler)
Definition cs_npc.cpp:564
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
Definition cs_npc.cpp:669
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, std::string spawnTimeStr)
Definition cs_npc.cpp:1005
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
Definition cs_npc.cpp:529
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< bool > addMulti)
Definition cs_npc.cpp:263
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< bool > addMulti)
Definition cs_npc.cpp:401
static bool HandleNpcSetFlagCommand(ChatHandler *handler, uint32 npcFlags)
Definition cs_npc.cpp:504
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition cs_npc.cpp:1259
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition cs_npc.cpp:428
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition cs_npc.cpp:333
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition cs_npc.cpp:297
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleNpcAddCommand(), HandleNpcAddFormationCommand(), HandleNpcAddMoveCommand(), HandleNpcAddTempSpawnCommand(), HandleNpcAddVendorItemCommand(), HandleNpcDeleteCommand(), HandleNpcDeleteVendorItemCommand(), HandleNpcFollowCommand(), HandleNpcGuidCommand(), HandleNpcInfoCommand(), HandleNpcMoveCommand(), HandleNpcNearCommand(), HandleNpcPlayEmoteCommand(), HandleNpcSayCommand(), HandleNpcSetAllowMovementCommand(), HandleNpcSetDataCommand(), HandleNpcSetEntryCommand(), HandleNpcSetFactionIdCommand(), HandleNpcSetFactionTempIdCommand(), HandleNpcSetFlagCommand(), HandleNpcSetLevelCommand(), HandleNpcSetLinkCommand(), HandleNpcSetModelCommand(), HandleNpcSetMoveTypeCommand(), HandleNpcSetOriginalFaction(), HandleNpcSetPhaseCommand(), HandleNpcSetSpawnTimeCommand(), HandleNpcSetWanderDistanceCommand(), HandleNpcTameCommand(), HandleNpcTextEmoteCommand(), HandleNpcUnFollowCommand(), HandleNpcWhisperCommand(), HandleNpcYellCommand(), SEC_ADMINISTRATOR, and SEC_GAMEMASTER.

◆ HandleNpcAddCommand()

static bool npc_commandscript::HandleNpcAddCommand ( ChatHandler handler,
CreatureEntry  id 
)
inlinestatic
205 {
206 if (!sObjectMgr->GetCreatureTemplate(id))
207 return false;
208
209 Player* chr = handler->GetSession()->GetPlayer();
210 float x = chr->GetPositionX();
211 float y = chr->GetPositionY();
212 float z = chr->GetPositionZ();
213 float o = chr->GetOrientation();
214 Map* map = chr->GetMap();
215
216 if (Transport* tt = chr->GetTransport())
217 if (MotionTransport* trans = tt->ToMotionTransport())
218 {
219 ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
220 CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
221 data.id1 = id;
222 data.phaseMask = chr->GetPhaseMaskForSpawn();
223 data.posX = chr->GetTransOffsetX();
224 data.posY = chr->GetTransOffsetY();
225 data.posZ = chr->GetTransOffsetZ();
226 data.orientation = chr->GetTransOffsetO();
227
228 Creature* creature = trans->CreateNPCPassenger(guid, &data);
229
230 creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMaskForSpawn());
231
232 sObjectMgr->AddCreatureToGrid(guid, &data);
233 return true;
234 }
235
236 Creature* creature = new Creature();
237 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
238 {
239 delete creature;
240 return false;
241 }
242
243 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
244
245 ObjectGuid::LowType spawnId = creature->GetSpawnId();
246
247 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
248 // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
249 creature->CleanupsBeforeDelete();
250 delete creature;
251 creature = new Creature();
252 if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
253 {
254 delete creature;
255 return false;
256 }
257
258 sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId));
259 return true;
260 }
#define sObjectMgr
Definition ObjectMgr.h:1636
WorldSession * GetSession()
Definition Chat.h:242
Definition Creature.h:43
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1698
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:65
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:1131
void SaveToDB()
Definition Creature.cpp:1399
MotionTransport * ToMotionTransport()
Definition GameObject.h:326
Definition Map.h:156
uint8 GetSpawnMode() const
Definition Map.h:267
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:487
uint32 GetId() const
Definition Map.h:229
Definition Transport.h:49
uint32 LowType
Definition ObjectGuid.h:122
Definition Player.h:1081
uint32 GetPhaseMaskForSpawn() const
Definition Player.cpp:13828
Definition Transport.h:30
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:15823
Map * GetMap() const
Definition Object.h:536
float GetTransOffsetX() const
Definition Object.h:598
float GetTransOffsetY() const
Definition Object.h:599
float GetTransOffsetZ() const
Definition Object.h:600
Transport * GetTransport() const
Definition Object.h:597
float GetTransOffsetO() const
Definition Object.h:601
Player * GetPlayer() const
Definition WorldSession.h:376
Definition CreatureData.h:370
uint32 phaseMask
Definition CreatureData.h:376
float orientation
Definition CreatureData.h:382
float posY
Definition CreatureData.h:380
float posX
Definition CreatureData.h:379
float posZ
Definition CreatureData.h:381
uint32 id1
Definition CreatureData.h:372
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

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

Referenced by GetCommands().

◆ HandleNpcAddFormationCommand()

static bool npc_commandscript::HandleNpcAddFormationCommand ( ChatHandler handler,
ObjectGuid::LowType  leaderGUID 
)
inlinestatic
1216 {
1217 Creature* creature = handler->getSelectedCreature();
1218
1219 if (!creature || !creature->GetSpawnId())
1220 {
1222 return false;
1223 }
1224
1225 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1226 if (creature->GetFormation())
1227 {
1228 handler->PSendSysMessage("Selected creature is already member of group {}", creature->GetFormation()->GetId());
1229 return false;
1230 }
1231
1232 if (!lowguid)
1233 return false;
1234
1235 Player* chr = handler->GetSession()->GetPlayer();
1236 FormationInfo group_member;
1237 group_member.follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
1238 group_member.follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2)) + pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
1239 group_member.leaderGUID = leaderGUID;
1240 group_member.groupAI = 0;
1241
1242 sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1243 creature->SearchFormation();
1244
1246 stmt->SetData(0, leaderGUID);
1247 stmt->SetData(1, lowguid);
1248 stmt->SetData(2, group_member.follow_dist);
1249 stmt->SetData(3, group_member.follow_angle);
1250 stmt->SetData(4, uint32(group_member.groupAI));
1251
1252 WorldDatabase.Execute(stmt);
1253
1254 handler->PSendSysMessage("Creature {} added to formation with leader {}", lowguid, leaderGUID);
1255
1256 return true;
1257 }
#define sFormationMgr
Definition CreatureGroups.h:127
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:211
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
Creature * getSelectedCreature() const
Definition Chat.cpp:410
uint32 GetId() const
Definition CreatureGroups.h:100
CreatureGroup const * GetFormation() const
Definition Creature.h:357
void SearchFormation()
Definition Creature.cpp:383
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:78

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
298 {
299 // attempt check creature existence by DB data
300 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
301 if (!data)
302 {
304 return false;
305 }
306
307 // Update movement type
310 stmt->SetData(1, uint32(lowGuid));
311 WorldDatabase.Execute(stmt);
312
314
315 return true;
316 }
std::uint8_t uint8
Definition Define.h:109
@ LANG_WAYPOINT_ADDED
Definition Language.h:276
@ LANG_COMMAND_CREATGUIDNOTFOUND
Definition Language.h:333
@ 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:160

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
1167 {
1168 Player* chr = handler->GetSession()->GetPlayer();
1169
1170 if (!id)
1171 return false;
1172
1173 chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1174
1175 return true;
1176 }
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:50
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:2368

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
264 {
265 if (!item)
266 {
268 return false;
269 }
270
271 Creature* vendor = handler->getSelectedCreature();
272 if (!vendor)
273 {
275 return false;
276 }
277
278 uint32 itemId = item->ItemId;
279 uint32 maxcount = mc.value_or(0);
280 uint32 incrtime = it.value_or(0);
281 uint32 extendedcost = ec.value_or(0);
282 uint32 vendor_entry = addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry();
283
284 if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, handler->GetSession()->GetPlayer()))
285 {
286 handler->SetSentErrorMessage(true);
287 return false;
288 }
289
290 sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost);
291
292 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1, maxcount, incrtime, extendedcost);
293 return true;
294 }
@ LANG_COMMAND_NEEDITEMSEND
Definition Language.h:325
@ LANG_ITEM_ADDED_TO_LIST
Definition Language.h:245
void SetSentErrorMessage(bool val)
Definition Chat.h:238
uint32 GetEntry() const
Definition Object.h:115
uint32 GetCurrentVendor() const
Definition WorldSession.h:380

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
377 {
378 Creature* creature;
379 if (lowGuid.has_value())
380 creature = handler->GetCreatureFromPlayerMapByDbGuid(*lowGuid);
381 else
382 creature = handler->getSelectedCreature();
383
384 if (!creature || creature->IsPet() || creature->IsTotem())
385 {
387 return false;
388 }
389
390 // Delete the creature
391 creature->CombatStop();
392 creature->DeleteFromDB();
393 creature->AddObjectToRemoveList();
394
396
397 return true;
398 }
@ LANG_COMMAND_DELCREATMESSAGE
Definition Language.h:316
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
Definition Chat.cpp:578
virtual void DeleteFromDB()
Definition Creature.cpp:1848
void CombatStop(bool includingCast=false)
Definition Unit.cpp:10481
bool IsPet() const
Definition Unit.h:763
bool IsTotem() const
Definition Unit.h:765
void AddObjectToRemoveList()
Definition Object.cpp:2160

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
402 {
403 Creature* vendor = handler->getSelectedCreature();
404 if (!vendor || !vendor->IsVendor())
405 {
407 return false;
408 }
409
410 if (!item)
411 {
413 return false;
414 }
415
416 uint32 itemId = item->ItemId;
417 if (!sObjectMgr->RemoveVendorItem(addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry(), itemId))
418 {
419 handler->SendErrorMessage(LANG_ITEM_NOT_IN_LIST, itemId);
420 return false;
421 }
422
423 handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1);
424 return true;
425 }
@ LANG_COMMAND_VENDORSELECTION
Definition Language.h:324
@ LANG_ITEM_DELETED_FROM_LIST
Definition Language.h:247
@ LANG_ITEM_NOT_IN_LIST
Definition Language.h:248
bool IsVendor() const
Definition Unit.h:769

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().

◆ HandleNpcFollowCommand()

static bool npc_commandscript::HandleNpcFollowCommand ( ChatHandler handler)
inlinestatic
547 {
548 Player* player = handler->GetSession()->GetPlayer();
549 Creature* creature = handler->getSelectedCreature();
550
551 if (!creature)
552 {
554 return false;
555 }
556
557 // Follow player - Using pet's default dist and angle
558 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
559
561 return true;
562 }
@ LANG_CREATURE_FOLLOW_YOU_NOW
Definition Language.h:382
#define PET_FOLLOW_DIST
Definition PetDefines.h:202
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:409
MotionMaster * GetMotionMaster()
Definition Unit.h:1673
virtual float GetFollowAngle() const
Definition Unit.h:1809
std::string const & GetName() const
Definition Object.h:463

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
640 {
641 Creature* target = handler->getSelectedCreature();
642
643 if (!target)
644 {
646 return false;
647 }
648
649 uint32 faction = target->GetFaction();
650 uint32 npcflags = target->GetNpcFlags();
651 uint32 displayid = target->GetDisplayId();
652 uint32 nativeid = target->GetNativeDisplayId();
653 uint32 entry = target->GetEntry();
654 uint32 id1 = 0;
655 uint32 id2 = 0;
656 uint32 id3 = 0;
657 if (CreatureData const* cData = target->GetCreatureData())
658 {
659 id1 = cData->id1;
660 id2 = cData->id2;
661 id3 = cData->id3;
662 }
663
664 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
665
666 return true;
667 }
@ LANG_NPCINFO_CHAR
Definition Language.h:587
CreatureData const * GetCreatureData() const
Definition Creature.h:210
std::string ToString() const
Definition ObjectGuid.cpp:47
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112
NPCFlags GetNpcFlags() const
Clears emote state (looping emote)
Definition Unit.h:733
uint32 GetFaction() const
Definition Unit.h:817
uint32 GetDisplayId() const
Definition Unit.h:1887
uint32 GetNativeDisplayId() const
Definition Unit.h:1889

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)
inlinestatic
565 {
566 Creature* target = handler->getSelectedCreature();
567
568 if (!target)
569 {
571 return false;
572 }
573
574 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
575 uint32 faction = target->GetFaction();
576 uint32 npcflags = target->GetNpcFlags();
577 uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask;
578 uint32 spellSchoolImmuneMask = cInfo->SpellSchoolImmuneMask;
579 uint32 displayid = target->GetDisplayId();
580 uint32 nativeid = target->GetNativeDisplayId();
581 uint32 entry = target->GetEntry();
582 uint32 id1 = 0;
583 uint32 id2 = 0;
584 uint32 id3 = 0;
585 if (CreatureData const* cData = target->GetCreatureData())
586 {
587 id1 = cData->id1;
588 id2 = cData->id2;
589 id3 = cData->id3;
590 }
591
592 int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
593 if (curRespawnDelay < 0)
594 curRespawnDelay = 0;
595 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
596 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
597
598 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
599 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
601 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
602 handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
603 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr, curRespawnDelayStr);
604 handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
607 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
608 handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
609 handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName(), target->GetScriptName());
610
611 for (uint8 i = 0; i < NPCFLAG_COUNT; i++)
612 {
613 if (npcflags & npcFlagTexts[i].flag)
614 {
615 handler->PSendSysMessage(npcFlagTexts[i].text, npcFlagTexts[i].flag);
616 }
617 }
618
619 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, mechanicImmuneMask);
620 for (uint8 i = 1; i < MAX_MECHANIC; ++i)
621 {
622 if (mechanicImmuneMask & (1 << (mechanicImmunes[i].flag - 1)))
623 {
624 handler->PSendSysMessage(mechanicImmunes[i].text, mechanicImmunes[i].flag);
625 }
626 }
627
628 handler->PSendSysMessage(LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, spellSchoolImmuneMask);
629 for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
630 {
631 if (spellSchoolImmuneMask & (1 << spellSchoolImmunes[i].flag))
632 {
633 handler->PSendSysMessage(spellSchoolImmunes[i].text, spellSchoolImmunes[i].flag);
634 }
635 }
636
637 return true;
638 }
std::uint64_t uint64
Definition Define.h:106
std::int64_t int64
Definition Define.h:102
@ LANG_NPCINFO_EQUIPMENT
Definition Language.h:1084
@ LANG_NPCINFO_LOOT
Definition Language.h:591
@ LANG_NPCINFO_POSITION
Definition Language.h:592
@ LANG_NPCINFO_FLAGS
Definition Language.h:590
@ LANG_NPCINFO_AIINFO
Definition Language.h:1079
@ LANG_NPCINFO_SPELL_SCHOOL_IMMUNE
Definition Language.h:1115
@ LANG_NPCINFO_HEALTH
Definition Language.h:589
@ LANG_NPCINFO_PHASEMASK
Definition Language.h:1068
@ LANG_NPCINFO_LEVEL
Definition Language.h:588
@ LANG_COMMAND_RAWPAWNTIMES
Definition Language.h:642
@ LANG_NPCINFO_ARMOR
Definition Language.h:1069
@ LANG_NPCINFO_DUNGEON_ID
Definition Language.h:595
@ LANG_NPCINFO_MECHANIC_IMMUNE
Definition Language.h:1085
constexpr auto MAX_SPELL_SCHOOL
Definition SharedDefines.h:292
@ MAX_MECHANIC
Definition SharedDefines.h:1357
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:209
uint32 GetRespawnDelay() const
Definition Creature.h:295
std::string GetScriptName() const
Definition Creature.cpp:3055
time_t GetRespawnTimeEx() const
Definition Creature.cpp:2947
std::string const & GetAIName() const
Definition Creature.cpp:3050
uint32 GetMaxHealth() const
Definition Unit.h:1039
UnitFlags GetUnitFlags() const
Definition Unit.h:717
uint32 GetHealth() const
Definition Unit.h:1038
uint32 GetCreateHealth() const
Definition Unit.h:1042
uint32 GetArmor() const
Definition Unit.h:1088
uint8 GetLevel() const
Definition Unit.h:1033
UnitFlags2 GetUnitFlags2() const
Remove all UnitFlags and set new ones. UnitFlags available in UnitDefines.h.
Definition Unit.h:723
uint32 GetDynamicFlags() const override
Definition Unit.h:739
uint32 GetPhaseMask() const
Definition Object.h:451
uint32 GetInstanceId() const
Definition Object.h:448
NpcFlagText const npcFlagTexts[NPCFLAG_COUNT]
Definition cs_npc.cpp:44
SpellSchoolImmune const spellSchoolImmunes[MAX_SPELL_SCHOOL]
Definition cs_npc.cpp:120
MechanicImmune const mechanicImmunes[MAX_MECHANIC]
Definition cs_npc.cpp:78
#define NPCFLAG_COUNT
Definition cs_npc.cpp:42
Seconds GetGameTime()
Definition GameTime.cpp:38
Definition CreatureData.h:186
uint32 SkinLootId
Definition CreatureData.h:226
uint32 MechanicImmuneMask
Definition CreatureData.h:244
uint32 pickpocketLootId
Definition CreatureData.h:225
uint32 lootid
Definition CreatureData.h:224
uint8 SpellSchoolImmuneMask
Definition CreatureData.h:245

References 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(), ChatHandler::getSelectedCreature(), 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, LANG_SELECT_CREATURE, CreatureTemplate::lootid, MAX_MECHANIC, MAX_SPELL_SCHOOL, CreatureTemplate::MechanicImmuneMask, mechanicImmunes, NPCFLAG_COUNT, npcFlagTexts, CreatureTemplate::pickpocketLootId, ChatHandler::PSendSysMessage(), secsToTimeString(), ChatHandler::SendErrorMessage(), CreatureTemplate::SkinLootId, CreatureTemplate::SpellSchoolImmuneMask, spellSchoolImmunes, and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleNpcMoveCommand()

static bool npc_commandscript::HandleNpcMoveCommand ( ChatHandler handler,
Optional< ObjectGuid::LowType guid 
)
inlinestatic
719 {
720 Creature* creature;
721 if (guid.has_value())
722 creature = handler->GetCreatureFromPlayerMapByDbGuid(*guid);
723 else
724 creature = handler->getSelectedCreature();
725
726 if (!creature)
727 return false;
728
729 ObjectGuid::LowType lowGuid;
730 if (guid.has_value())
731 lowGuid = *guid;
732 else
733 lowGuid = creature->GetSpawnId();
734
735 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
736 if (!data)
737 {
739 return false;
740 }
741
742 if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
743 {
745 return false;
746 }
747
748 float x = handler->GetSession()->GetPlayer()->GetPositionX();
749 float y = handler->GetSession()->GetPlayer()->GetPositionY();
750 float z = handler->GetSession()->GetPlayer()->GetPositionZ();
751 float o = handler->GetSession()->GetPlayer()->GetOrientation();
752
753 if (creature)
754 {
755 if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
756 {
757 const_cast<CreatureData*>(data)->posX = x;
758 const_cast<CreatureData*>(data)->posY = y;
759 const_cast<CreatureData*>(data)->posZ = z;
760 const_cast<CreatureData*>(data)->orientation = o;
761 }
762
763 creature->SetPosition(x, y, z, o);
764 creature->GetMotionMaster()->Initialize();
765
766 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
767 {
769 creature->Respawn();
770 }
771 }
772
774 stmt->SetData(0, x);
775 stmt->SetData(1, y);
776 stmt->SetData(2, z);
777 stmt->SetData(3, o);
778 stmt->SetData(4, lowGuid);
779
780 WorldDatabase.Execute(stmt);
781
783 return true;
784 }
@ LANG_COMMAND_CREATUREMOVED
Definition Language.h:317
@ LANG_COMMAND_CREATUREATSAMEMAP
Definition Language.h:318
@ 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:1971
void Respawn(bool force=false)
Definition Creature.cpp:2044
void SetPosition(float x, float y, float z, float o)
Definition Creature.cpp:3171
void Initialize()
Definition MotionMaster.cpp:73
bool IsAlive() const
Definition Unit.h:1707
uint32 GetMapId() const
Definition Position.h:280
uint16 mapid
Definition CreatureData.h:375

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, CreatureData::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
670 {
671 float distance = dist.value_or(10.0f);
672 uint32 count = 0;
673
674 Player* player = handler->GetSession()->GetPlayer();
675
677 stmt->SetData(0, player->GetPositionX());
678 stmt->SetData(1, player->GetPositionY());
679 stmt->SetData(2, player->GetPositionZ());
680 stmt->SetData(3, player->GetMapId());
681 stmt->SetData(4, player->GetPositionX());
682 stmt->SetData(5, player->GetPositionY());
683 stmt->SetData(6, player->GetPositionZ());
684 stmt->SetData(7, distance * distance);
685 stmt->SetData(8, player->GetPhaseMask());
686 PreparedQueryResult result = WorldDatabase.Query(stmt);
687
688 if (result)
689 {
690 do
691 {
692 Field* fields = result->Fetch();
693 ObjectGuid::LowType guid = fields[0].Get<uint32>();
694 uint32 entry = fields[1].Get<uint32>();
695 //uint32 entry2 = fields[2].Get<uint32>();
696 //uint32 entry3 = fields[3].Get<uint32>();
697 float x = fields[4].Get<float>();
698 float y = fields[5].Get<float>();
699 float z = fields[6].Get<float>();
700 uint16 mapId = fields[7].Get<uint16>();
701
702 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
703 if (!creatureTemplate)
704 continue;
705
706 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, entry, guid, creatureTemplate->Name, x, y, z, mapId, "", "");
707
708 ++count;
709 } while (result->NextRow());
710 }
711
712 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
713
714 return true;
715 }
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:612
@ LANG_CREATURE_LIST_CHAT
Definition Language.h:559
@ WORLD_SEL_CREATURE_NEAREST
Definition WorldDatabase.h:90
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

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, ChatHandler::PSendSysMessage(), PreparedStatementBase::SetData(), sObjectMgr, WORLD_SEL_CREATURE_NEAREST, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcPlayEmoteCommand()

static bool npc_commandscript::HandleNpcPlayEmoteCommand ( ChatHandler handler,
uint32  emote 
)
inlinestatic
788 {
789 Creature* target = handler->getSelectedCreature();
790 if (!target)
791 {
793 return false;
794 }
795
796 target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
797
798 return true;
799 }
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:21372

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
1046 {
1047 if (text.empty())
1048 return false;
1049
1050 Creature* creature = handler->getSelectedCreature();
1051 if (!creature)
1052 {
1054 return false;
1055 }
1056
1057 creature->Say(text, LANG_UNIVERSAL);
1058
1059 // make some emotes
1060 switch (text.back())
1061 {
1062 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1063 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1064 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1065 }
1066
1067 return true;
1068 }
@ EMOTE_ONESHOT_EXCLAMATION
Definition SharedDefines.h:1899
@ EMOTE_ONESHOT_QUESTION
Definition SharedDefines.h:1900
@ EMOTE_ONESHOT_TALK
Definition SharedDefines.h:1895
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:21189
void HandleEmoteCommand(uint32 emoteId)
Definition Unit.cpp:2011

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
319 {
320 if (sWorld->getAllowMovement())
321 {
322 sWorld->SetAllowMovement(false);
324 }
325 else
326 {
327 sWorld->SetAllowMovement(true);
329 }
330 return true;
331 }
@ LANG_CREATURE_MOVE_ENABLED
Definition Language.h:432
@ LANG_CREATURE_MOVE_DISABLED
Definition Language.h:431
#define sWorld
Definition World.h:363

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
530 {
531 Creature* creature = handler->getSelectedCreature();
532
533 if (!creature)
534 {
536 return false;
537 }
538
539 creature->AI()->SetData(data_1, data_2);
540 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
541 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript);
542 return true;
543 }
@ LANG_NPC_SETDATA
Definition Language.h:609
CreatureAI * AI() const
Definition Creature.h:141
virtual void SetData(uint32, uint32)
Definition UnitAI.h:214

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
334 {
335 if (!newEntryNum)
336 return false;
337
338 Unit* unit = handler->getSelectedUnit();
339 if (!unit || !unit->IsCreature())
340 {
342 return false;
343 }
344 Creature* creature = unit->ToCreature();
345 if (creature->UpdateEntry(newEntryNum))
346 handler->SendSysMessage(LANG_DONE);
347 else
348 handler->SendSysMessage(LANG_ERROR);
349 return true;
350 }
@ LANG_ERROR
Definition Language.h:78
@ LANG_DONE
Definition Language.h:75
Unit * getSelectedUnit() const
Definition Chat.cpp:386
bool UpdateEntry(uint32 entry, const CreatureData *data=nullptr, bool changelevel=true, bool updateAI=false)
Definition Creature.cpp:542
bool IsCreature() const
Definition Object.h:204
Creature * ToCreature()
Definition Object.h:205
Definition Unit.h:636

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
429 {
430 if (!sFactionTemplateStore.LookupEntry(factionId))
431 {
432 handler->SendErrorMessage(LANG_WRONG_FACTION, factionId);
433 return false;
434 }
435
436 Creature* creature = handler->getSelectedCreature();
437
438 if (!creature)
439 {
441 return false;
442 }
443
444 creature->SetFaction(factionId);
445
446 // Faction is set in creature_template - not inside creature
447
448 // Update in memory..
449 if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
450 const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
451
452 // ..and DB
454
455 stmt->SetData(0, uint16(factionId));
456 stmt->SetData(1, creature->GetEntry());
457
458 WorldDatabase.Execute(stmt);
459
460 return true;
461 }
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
@ LANG_WRONG_FACTION
Definition Language.h:164
@ WORLD_UPD_CREATURE_FACTION
Definition WorldDatabase.h:47
void SetFaction(uint32 faction)
Definition Unit.cpp:10097

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
465 {
466 Player* player = handler->GetSession()->GetPlayer();
467 Unit* unit = player->GetSelectedUnit();
468
469 if (!unit)
470 return false;
471
472 Creature* creature = unit->ToCreature();
473
474 if (!creature)
475 return false;
476
477 creature->SetFaction(tempfaction);
478
479 return true;
480 }
Unit * GetSelectedUnit() const
Definition Player.cpp:11600

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
505 {
506 Creature* creature = handler->getSelectedCreature();
507
508 if (!creature)
509 {
511 return false;
512 }
513
514 creature->ReplaceAllNpcFlags(NPCFlags(npcFlags));
515
517
518 stmt->SetData(0, NPCFlags(npcFlags));
519 stmt->SetData(1, creature->GetEntry());
520
521 WorldDatabase.Execute(stmt);
522
524
525 return true;
526 }
@ LANG_VALUE_SAVED_REJOIN
Definition Language.h:306
NPCFlags
Non Player Character flags.
Definition UnitDefines.h:313
@ WORLD_UPD_CREATURE_NPCFLAG
Definition WorldDatabase.h:48
void ReplaceAllNpcFlags(NPCFlags flags)
Definition Unit.h:737

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
354 {
355 if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
356 {
358 return false;
359 }
360
361 Creature* creature = handler->getSelectedCreature();
362 if (!creature || creature->IsPet())
363 {
365 return false;
366 }
367
368 creature->SetMaxHealth(100 + 30*lvl);
369 creature->SetHealth(100 + 30*lvl);
370 creature->SetLevel(lvl);
371 creature->SaveToDB();
372
373 return true;
374 }
@ CONFIG_MAX_PLAYER_LEVEL
Definition IWorld.h:235
@ LANG_BAD_VALUE
Definition Language.h:148
void SetHealth(uint32 val)
Definition Unit.cpp:15530
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:15512
void SetMaxHealth(uint32 val)
Definition Unit.cpp:15580

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
1260 {
1261 Creature* creature = handler->getSelectedCreature();
1262
1263 if (!creature)
1264 {
1266 return false;
1267 }
1268
1269 if (!creature->GetSpawnId())
1270 {
1271 handler->SendErrorMessage("Selected creature {} isn't in creature table", creature->GetGUID().ToString());
1272 return false;
1273 }
1274
1275 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1276 {
1277 handler->SendErrorMessage("Selected creature can't link with guid '{}'", linkguid);
1278 return false;
1279 }
1280
1281 handler->PSendSysMessage("LinkGUID '{}' added to creature with DBTableGUID: '{}'", linkguid, creature->GetSpawnId());
1282 return true;
1283 }

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
803 {
804 Creature* creature = handler->getSelectedCreature();
805
806 if (!creature || creature->IsPet())
807 {
809 return false;
810 }
811
812 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
813 {
815 return false;
816 }
817
818 creature->SetDisplayId(displayId);
819 creature->SetNativeDisplayId(displayId);
820 creature->SaveToDB();
821
822 return true;
823 }
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ LANG_COMMAND_FACTION_INVPARAM
Definition Language.h:351
void SetDisplayId(uint32 displayId, float displayScale=1.f) override
Definition Creature.cpp:3535
void SetNativeDisplayId(uint32 displayId)
Definition Unit.h:1891
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

838 {
839 // 3 arguments:
840 // GUID (optional - you can also select the creature)
841 // stay|random|way (determines the kind of movement)
842 // NODEL (optional - tells the system NOT to delete any waypoints)
843 // this is very handy if you want to do waypoints, that are
844 // later switched on/off according to special events (like escort
845 // quests, etc)
846
847 bool doNotDelete = nodel.has_value();
848
849 ObjectGuid::LowType lowguid = 0;
850 Creature* creature = nullptr;
851
852 if (!lowGuid) // case .setmovetype $move_type (with selected creature)
853 {
854 creature = handler->getSelectedCreature();
855 if (!creature || creature->IsPet())
856 return false;
857 lowguid = creature->GetSpawnId();
858 }
859 else // case .setmovetype #creature_guid $move_type (with selected creature)
860 {
861 lowguid = *lowGuid;
862
863 if (lowguid)
864 creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
865
866 // attempt check creature existence by DB data
867 if (!creature)
868 {
869 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
870 if (!data)
871 {
873 return false;
874 }
875 }
876 else
877 {
878 lowguid = creature->GetSpawnId();
879 }
880 }
881
882 // now lowguid is low guid really existed creature
883 // and creature point (maybe) to this creature or nullptr
884
885 MovementGeneratorType move_type;
886 switch (type.index())
887 {
888 case 0:
889 move_type = IDLE_MOTION_TYPE;
890 break;
891 case 1:
892 move_type = RANDOM_MOTION_TYPE;
893 break;
894 case 2:
895 move_type = WAYPOINT_MOTION_TYPE;
896 break;
897 default:
898 return false;
899 }
900
901 // update movement type
902 //if (doNotDelete == false)
903 // WaypointMgr.DeletePath(lowguid);
904
905 if (creature)
906 {
907 // update movement type
908 if (!doNotDelete)
909 creature->LoadPath(0);
910
911 creature->SetDefaultMovementType(move_type);
912 creature->GetMotionMaster()->Initialize();
913
914 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
915 {
917 creature->Respawn();
918 }
919
920 creature->SaveToDB();
921 }
922
923 if (!doNotDelete)
924 {
925 handler->PSendSysMessage(LANG_MOVE_TYPE_SET, move_type);
926 }
927 else
928 {
929 handler->PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, move_type);
930 }
931
932 return true;
933 }
@ LANG_MOVE_TYPE_SET
Definition Language.h:302
@ LANG_MOVE_TYPE_SET_NODEL
Definition Language.h:303
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:87
void LoadPath(uint32 pathid)
Definition Creature.h:351

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
484 {
485 Player* player = handler->GetSession()->GetPlayer();
486
487 if (!player)
488 return false;
489
490 if (!player->GetSelectedUnit())
491 return false;
492
493 Creature* creature = player->GetSelectedUnit()->ToCreature();
494
495 if (!creature)
496 return false;
497
498 creature->RestoreFaction();
499
500 return true;
501 }
void RestoreFaction()
Definition Unit.cpp:18747

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
938 {
939 if (phasemask == 0)
940 {
942 return false;
943 }
944
945 Creature* creature = handler->getSelectedCreature();
946 if (!creature)
947 {
949 return false;
950 }
951
952 creature->SetPhaseMask(phasemask, true);
953
954 if (!creature->IsPet())
955 creature->SaveToDB();
956
957 return true;
958 }
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition Unit.cpp:19101

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
1006 {
1007 if (spawnTimeStr.empty())
1008 {
1009 return false;
1010 }
1011
1012 if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
1013 {
1015 return false;
1016 }
1017
1018 Creature* creature = handler->getSelectedCreature();
1019 if (!creature)
1020 return false;
1021
1022 int32 spawnTime = TimeStringToSecs(spawnTimeStr);
1023 if (spawnTime <= 0)
1024 {
1025 spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
1026 }
1027
1028 if (spawnTime <= 0)
1029 {
1031 return false;
1032 }
1033
1035 stmt->SetData(0, spawnTime);
1036 stmt->SetData(1, creature->GetSpawnId());
1037 WorldDatabase.Execute(stmt);
1038
1039 creature->SetRespawnDelay(spawnTime);
1040 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true));
1041
1042 return true;
1043 }
std::int32_t int32
Definition Define.h:103
@ LANG_COMMAND_SPAWNTIME
Definition Language.h:338
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:296

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
962 {
963 if (option < 0.0f)
964 {
966 return false;
967 }
968
970
971 if (option > 0.0f)
972 mtype = RANDOM_MOTION_TYPE;
973
974 Creature* creature = handler->getSelectedCreature();
975 ObjectGuid::LowType guidLow = 0;
976
977 if (creature)
978 guidLow = creature->GetSpawnId();
979 else
980 return false;
981
982 creature->SetWanderDistance((float)option);
983 creature->SetDefaultMovementType(mtype);
984 creature->GetMotionMaster()->Initialize();
985
986 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
987 {
989 creature->Respawn();
990 }
991
993
994 stmt->SetData(0, option);
995 stmt->SetData(1, uint8(mtype));
996 stmt->SetData(2, guidLow);
997
998 WorldDatabase.Execute(stmt);
999
1001 return true;
1002 }
@ LANG_COMMAND_WANDER_DISTANCE
Definition Language.h:337
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
Definition WorldDatabase.h:50
void SetWanderDistance(float dist)
Definition Creature.h:307

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().

◆ HandleNpcTameCommand()

static bool npc_commandscript::HandleNpcTameCommand ( ChatHandler handler)
inlinestatic
1180 {
1181 Creature* creatureTarget = handler->getSelectedCreature();
1182 if (!creatureTarget || creatureTarget->IsPet())
1183 {
1185 handler->SetSentErrorMessage(true);
1186 return false;
1187 }
1188
1189 Player* player = handler->GetSession()->GetPlayer();
1190
1191 if (player->IsExistPet())
1192 {
1194 return false;
1195 }
1196
1197 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1198
1199 if (!cInfo->IsTameable(player->CanTameExoticPets()))
1200 {
1202 handler->SetSentErrorMessage (true);
1203 return false;
1204 }
1205
1206 if (!player->CreatePet(creatureTarget))
1207 {
1209 return false;
1210 }
1211
1212 return true;
1213 }
@ LANG_CREATURE_NON_TAMEABLE
Definition Language.h:385
@ LANG_YOU_ALREADY_HAVE_PET
Definition Language.h:386
bool IsExistPet()
Definition Player.cpp:9256
bool CanTameExoticPets() const
Definition Player.h:2197
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition Player.cpp:9262
uint32 Entry
Definition CreatureData.h:187
bool IsTameable(bool exotic) const
Definition CreatureData.h:274

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
1072 {
1073 if (text.empty())
1074 return false;
1075
1076 Creature* creature = handler->getSelectedCreature();
1077
1078 if (!creature)
1079 {
1081 return false;
1082 }
1083
1084 creature->TextEmote(text);
1085
1086 return true;
1087 }
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:21199

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

Referenced by GetCommands().

◆ HandleNpcUnFollowCommand()

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler)
inlinestatic
1091 {
1092 Player* player = handler->GetSession()->GetPlayer();
1093 Creature* creature = handler->getSelectedCreature();
1094
1095 if (!creature)
1096 {
1098 return false;
1099 }
1100
1101 if (/*creature->GetMotionMaster()->empty() ||*/
1103 {
1104 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1105 return false;
1106 }
1107
1108 FollowMovementGenerator<Creature> const* mgen = static_cast<FollowMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top()));
1109
1110 if (mgen->GetTarget() != player)
1111 {
1112 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1113 return false;
1114 }
1115
1116 // reset movement
1117 creature->GetMotionMaster()->MovementExpired(true);
1118
1120 return true;
1121 }
@ LANG_CREATURE_NOT_FOLLOW_YOU
Definition Language.h:383
@ LANG_CREATURE_NOT_FOLLOW_YOU_NOW
Definition Language.h:384
@ FOLLOW_MOTION_TYPE
Definition MotionMaster.h:54
Definition TargetedMovementGenerator.h:76
Unit * GetTarget() const
Definition TargetedMovementGenerator.h:90
_Ty top() const
Definition MotionMaster.h:150
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition MotionMaster.cpp:913
void MovementExpired(bool reset=true)
Definition MotionMaster.h:180

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
1125 {
1126 if (text.empty())
1127 return false;
1128
1129 Creature* creature = handler->getSelectedCreature();
1130 if (!creature)
1131 {
1133 return false;
1134 }
1135
1136 // check online security
1137 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1138 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1139 return false;
1140
1141 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1142 return true;
1143 }
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition Chat.cpp:57
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:21204
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
1146 {
1147 if (text.empty())
1148 return false;
1149
1150 Creature* creature = handler->getSelectedCreature();
1151 if (!creature)
1152 {
1154 return false;
1155 }
1156
1157 creature->Yell(text, LANG_UNIVERSAL);
1158
1159 // make an emote
1161
1162 return true;
1163 }
@ EMOTE_ONESHOT_SHOUT
Definition SharedDefines.h:1914
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:21194

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: