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
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 

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)
 
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)
 
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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable npc_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

144 {
145 static ChatCommandTable npcAddCommandTable =
146 {
147 { "formation", HandleNpcAddFormationCommand, SEC_ADMINISTRATOR, Console::No },
148 { "item", HandleNpcAddVendorItemCommand, SEC_ADMINISTRATOR, Console::No },
149 { "move", HandleNpcAddMoveCommand, SEC_ADMINISTRATOR, Console::No },
150 { "temp", HandleNpcAddTempSpawnCommand, SEC_ADMINISTRATOR, Console::No },
151 { "", HandleNpcAddCommand, SEC_ADMINISTRATOR, Console::No }
152 };
153 static ChatCommandTable npcDeleteCommandTable =
154 {
155 { "item", HandleNpcDeleteVendorItemCommand, SEC_ADMINISTRATOR, Console::No },
156 { "", HandleNpcDeleteCommand, SEC_ADMINISTRATOR, Console::No }
157 };
158 static ChatCommandTable npcFollowCommandTable =
159 {
160 { "stop", HandleNpcUnFollowCommand, SEC_GAMEMASTER, Console::No },
161 { "", HandleNpcFollowCommand, SEC_GAMEMASTER, Console::No }
162 };
163
164 static ChatCommandTable npcFactionCommandTable =
165 {
166 { "permanent", HandleNpcSetFactionIdCommand, SEC_ADMINISTRATOR, Console::No },
167 { "temp", HandleNpcSetFactionTempIdCommand, SEC_ADMINISTRATOR, Console::No },
168 { "original", HandleNpcSetOriginalFaction, SEC_ADMINISTRATOR, Console::No }
169 };
170
171 static ChatCommandTable npcSetCommandTable =
172 {
173 { "allowmove", HandleNpcSetAllowMovementCommand, SEC_ADMINISTRATOR, Console::No },
174 { "entry", HandleNpcSetEntryCommand, SEC_ADMINISTRATOR, Console::No },
175 { "faction", npcFactionCommandTable},
176 { "flag", HandleNpcSetFlagCommand, SEC_ADMINISTRATOR, Console::No },
177 { "level", HandleNpcSetLevelCommand, SEC_ADMINISTRATOR, Console::No },
178 { "link", HandleNpcSetLinkCommand, SEC_ADMINISTRATOR, Console::No },
179 { "model", HandleNpcSetModelCommand, SEC_ADMINISTRATOR, Console::No },
180 { "movetype", HandleNpcSetMoveTypeCommand, SEC_ADMINISTRATOR, Console::No },
181 { "phase", HandleNpcSetPhaseCommand, SEC_ADMINISTRATOR, Console::No },
182 { "wanderdistance", HandleNpcSetWanderDistanceCommand, SEC_ADMINISTRATOR, Console::No },
183 { "spawntime", HandleNpcSetSpawnTimeCommand, SEC_ADMINISTRATOR, Console::No },
184 { "data", HandleNpcSetDataCommand, SEC_ADMINISTRATOR, Console::No }
185 };
186 static ChatCommandTable npcCommandTable =
187 {
188 { "info", HandleNpcInfoCommand, SEC_GAMEMASTER, Console::No },
189 { "guid", HandleNpcGuidCommand, SEC_GAMEMASTER, Console::No },
190 { "near", HandleNpcNearCommand, SEC_GAMEMASTER, Console::No },
191 { "move", HandleNpcMoveCommand, SEC_GAMEMASTER, Console::No },
192 { "playemote", HandleNpcPlayEmoteCommand, SEC_GAMEMASTER, Console::No },
193 { "say", HandleNpcSayCommand, SEC_GAMEMASTER, Console::No },
194 { "textemote", HandleNpcTextEmoteCommand, SEC_GAMEMASTER, Console::No },
195 { "whisper", HandleNpcWhisperCommand, SEC_GAMEMASTER, Console::No },
196 { "yell", HandleNpcYellCommand, SEC_GAMEMASTER, Console::No },
197 { "tame", HandleNpcTameCommand, SEC_GAMEMASTER, Console::No },
198 { "add", npcAddCommandTable },
199 { "delete", npcDeleteCommandTable },
200 { "follow", npcFollowCommandTable },
201 { "set", npcSetCommandTable }
202 };
203 static ChatCommandTable commandTable =
204 {
205 { "npc", npcCommandTable }
206 };
207 return commandTable;
208 }
@ SEC_ADMINISTRATOR
Definition: Common.h:69
@ SEC_GAMEMASTER
Definition: Common.h:68
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleNpcDeleteCommand(ChatHandler *handler)
Definition: cs_npc.cpp:389
static bool HandleNpcMoveCommand(ChatHandler *handler)
Definition: cs_npc.cpp:734
static bool HandleNpcWhisperCommand(ChatHandler *handler, std::string const &recv, Tail text)
Definition: cs_npc.cpp:1147
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
Definition: cs_npc.cpp:1242
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, CreatureEntry id)
Definition: cs_npc.cpp:1191
static bool HandleNpcSetFactionTempIdCommand(ChatHandler *handler, uint32 tempfaction)
Definition: cs_npc.cpp:479
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition: cs_npc.cpp:977
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition: cs_npc.cpp:211
static bool HandleNpcSetOriginalFaction(ChatHandler *handler)
Definition: cs_npc.cpp:498
static bool HandleNpcTameCommand(ChatHandler *handler)
Definition: cs_npc.cpp:1204
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1090
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition: cs_npc.cpp:813
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1169
static bool HandleNpcGuidCommand(ChatHandler *handler)
Definition: cs_npc.cpp:655
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition: cs_npc.cpp:951
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition: cs_npc.cpp:560
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition: cs_npc.cpp:797
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:850
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition: cs_npc.cpp:1110
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
Definition: cs_npc.cpp:364
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition: cs_npc.cpp:328
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1063
static bool HandleNpcInfoCommand(ChatHandler *handler)
Definition: cs_npc.cpp:579
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
Definition: cs_npc.cpp:686
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, std::string spawnTimeStr)
Definition: cs_npc.cpp:1021
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
Definition: cs_npc.cpp:542
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec, Optional< bool > addMulti)
Definition: cs_npc.cpp:270
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< bool > addMulti)
Definition: cs_npc.cpp:411
static bool HandleNpcSetFlagCommand(ChatHandler *handler, uint32 npcFlags)
Definition: cs_npc.cpp:516
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition: cs_npc.cpp:1287
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition: cs_npc.cpp:441
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition: cs_npc.cpp:343
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition: cs_npc.cpp:306

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
212 {
213 if (!sObjectMgr->GetCreatureTemplate(id))
214 return false;
215
216 Player* chr = handler->GetSession()->GetPlayer();
217 float x = chr->GetPositionX();
218 float y = chr->GetPositionY();
219 float z = chr->GetPositionZ();
220 float o = chr->GetOrientation();
221 Map* map = chr->GetMap();
222
223 if (Transport* tt = chr->GetTransport())
224 if (MotionTransport* trans = tt->ToMotionTransport())
225 {
226 ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
227 CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
228 data.id1 = id;
229 data.phaseMask = chr->GetPhaseMaskForSpawn();
230 data.posX = chr->GetTransOffsetX();
231 data.posY = chr->GetTransOffsetY();
232 data.posZ = chr->GetTransOffsetZ();
233 data.orientation = chr->GetTransOffsetO();
234
235 Creature* creature = trans->CreateNPCPassenger(guid, &data);
236
237 creature->SaveToDB(trans->GetGOInfo()->moTransport.mapID, 1 << map->GetSpawnMode(), chr->GetPhaseMaskForSpawn());
238
239 sObjectMgr->AddCreatureToGrid(guid, &data);
240 return true;
241 }
242
243 Creature* creature = new Creature();
244 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
245 {
246 delete creature;
247 return false;
248 }
249
250 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
251
252 ObjectGuid::LowType spawnId = creature->GetSpawnId();
253
254 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
255 // current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
256 creature->CleanupsBeforeDelete();
257 delete creature;
258 creature = new Creature();
259 if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true))
260 {
261 delete creature;
262 return false;
263 }
264
265 sObjectMgr->AddCreatureToGrid(spawnId, sObjectMgr->GetCreatureData(spawnId));
266 return true;
267 }
#define sObjectMgr
Definition: ObjectMgr.h:1640
WorldSession * GetSession()
Definition: Chat.h:122
Definition: Creature.h:46
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:67
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:1101
void SaveToDB()
Definition: Creature.cpp:1365
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool gridLoad=false, bool allowDuplicate=false)
Definition: Creature.cpp:1661
Definition: CreatureData.h:359
uint32 phaseMask
Definition: CreatureData.h:365
float orientation
Definition: CreatureData.h:371
float posY
Definition: CreatureData.h:369
float posX
Definition: CreatureData.h:368
float posZ
Definition: CreatureData.h:370
uint32 id1
Definition: CreatureData.h:361
MotionTransport * ToMotionTransport()
Definition: GameObject.h:331
Map * GetMap() const
Definition: Object.h:517
float GetTransOffsetX() const
Definition: Object.h:586
float GetTransOffsetY() const
Definition: Object.h:587
float GetTransOffsetZ() const
Definition: Object.h:588
Transport * GetTransport() const
Definition: Object.h:585
float GetTransOffsetO() const
Definition: Object.h:589
uint32 LowType
Definition: ObjectGuid.h:124
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Definition: Player.h:1046
uint32 GetPhaseMaskForSpawn() const
Definition: Player.cpp:13652
Definition: Transport.h:29
Definition: Transport.h:48
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:15664
Definition: Map.h:312
uint8 GetSpawnMode() const
Definition: Map.h:419
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:632
uint32 GetId() const
Definition: Map.h:378
Player * GetPlayer() const
Definition: WorldSession.h:361

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, and GameObject::ToMotionTransport().

Referenced by GetCommands().

◆ HandleNpcAddFormationCommand()

static bool npc_commandscript::HandleNpcAddFormationCommand ( ChatHandler handler,
ObjectGuid::LowType  leaderGUID 
)
inlinestatic
1243 {
1244 Creature* creature = handler->getSelectedCreature();
1245
1246 if (!creature || !creature->GetSpawnId())
1247 {
1249 handler->SetSentErrorMessage(true);
1250 return false;
1251 }
1252
1253 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1254 if (creature->GetFormation())
1255 {
1256 handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId());
1257 return false;
1258 }
1259
1260 if (!lowguid)
1261 return false;
1262
1263 Player* chr = handler->GetSession()->GetPlayer();
1264 FormationInfo group_member;
1265 group_member.follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
1266 group_member.follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2)) + pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
1267 group_member.leaderGUID = leaderGUID;
1268 group_member.groupAI = 0;
1269
1270 sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1271 creature->SearchFormation();
1272
1274 stmt->SetData(0, leaderGUID);
1275 stmt->SetData(1, lowguid);
1276 stmt->SetData(2, group_member.follow_dist);
1277 stmt->SetData(3, group_member.follow_angle);
1278 stmt->SetData(4, uint32(group_member.groupAI));
1279
1280 WorldDatabase.Execute(stmt);
1281
1282 handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID);
1283
1284 return true;
1285 }
std::uint32_t uint32
Definition: Define.h:108
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
@ WORLD_INS_CREATURE_FORMATION
Definition: WorldDatabase.h:52
#define sFormationMgr
Definition: CreatureGroups.h:126
@ LANG_SELECT_CREATURE
Definition: Language.h:32
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
Creature * getSelectedCreature() const
Definition: Chat.cpp:337
CreatureGroup const * GetFormation() const
Definition: Creature.h:345
void SearchFormation()
Definition: Creature.cpp:327
Definition: CreatureGroups.h:51
float follow_dist
Definition: CreatureGroups.h:63
float follow_angle
Definition: CreatureGroups.h:64
ObjectGuid::LowType leaderGUID
Definition: CreatureGroups.h:62
uint16 groupAI
Definition: CreatureGroups.h:65
uint32 GetId() const
Definition: CreatureGroups.h:99
float GetAngle(const Position *pos) const
Definition: Position.cpp:77

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::SendSysMessage(), PreparedStatementBase::SetData(), ChatHandler::SetSentErrorMessage(), sFormationMgr, WORLD_INS_CREATURE_FORMATION, and WorldDatabase.

Referenced by GetCommands().

◆ HandleNpcAddMoveCommand()

static bool npc_commandscript::HandleNpcAddMoveCommand ( ChatHandler handler,
CreatureSpawnId  lowGuid 
)
inlinestatic
307 {
308 // attempt check creature existence by DB data
309 CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
310 if (!data)
311 {
313 handler->SetSentErrorMessage(true);
314 return false;
315 }
316
317 // Update movement type
320 stmt->SetData(1, uint32(lowGuid));
321 WorldDatabase.Execute(stmt);
322
324
325 return true;
326 }
std::uint8_t uint8
Definition: Define.h:110
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
Definition: WorldDatabase.h:46
@ LANG_WAYPOINT_ADDED
Definition: Language.h:275
@ LANG_COMMAND_CREATGUIDNOTFOUND
Definition: Language.h:332
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39

References LANG_COMMAND_CREATGUIDNOTFOUND, LANG_WAYPOINT_ADDED, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), ChatHandler::SetSentErrorMessage(), 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
1192 {
1193 Player* chr = handler->GetSession()->GetPlayer();
1194
1195 if (!id)
1196 return false;
1197
1198 chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1199
1200 return true;
1201 }
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: Object.h:46
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:2318

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
271 {
272 if (!item)
273 {
275 handler->SetSentErrorMessage(true);
276 return false;
277 }
278
279 Creature* vendor = handler->getSelectedCreature();
280 if (!vendor)
281 {
283 handler->SetSentErrorMessage(true);
284 return false;
285 }
286
287 uint32 itemId = item->ItemId;
288 uint32 maxcount = mc.value_or(0);
289 uint32 incrtime = it.value_or(0);
290 uint32 extendedcost = ec.value_or(0);
291 uint32 vendor_entry = addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry();
292
293 if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, handler->GetSession()->GetPlayer()))
294 {
295 handler->SetSentErrorMessage(true);
296 return false;
297 }
298
299 sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost);
300
301 handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1.c_str(), maxcount, incrtime, extendedcost);
302 return true;
303 }
@ LANG_COMMAND_NEEDITEMSEND
Definition: Language.h:324
@ LANG_ITEM_ADDED_TO_LIST
Definition: Language.h:244
uint32 GetEntry() const
Definition: Object.h:109
uint32 GetCurrentVendor() const
Definition: WorldSession.h:365

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcDeleteCommand()

static bool npc_commandscript::HandleNpcDeleteCommand ( ChatHandler handler)
inlinestatic
390 {
391 Creature* unit = handler->getSelectedCreature();
392
393 if (!unit || unit->IsPet() || unit->IsTotem())
394 {
396 handler->SetSentErrorMessage(true);
397 return false;
398 }
399
400 // Delete the creature
401 unit->CombatStop();
402 unit->DeleteFromDB();
403 unit->AddObjectToRemoveList();
404
406
407 return true;
408 }
@ LANG_COMMAND_DELCREATMESSAGE
Definition: Language.h:315
virtual void DeleteFromDB()
Definition: Creature.cpp:1821
void AddObjectToRemoveList()
Definition: Object.cpp:2115
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10401
bool IsPet() const
Definition: Unit.h:1413
bool IsTotem() const
Definition: Unit.h:1415

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

Referenced by GetCommands().

◆ HandleNpcDeleteVendorItemCommand()

static bool npc_commandscript::HandleNpcDeleteVendorItemCommand ( ChatHandler handler,
ItemTemplate const *  item,
Optional< bool >  addMulti 
)
inlinestatic
412 {
413 Creature* vendor = handler->getSelectedCreature();
414 if (!vendor || !vendor->IsVendor())
415 {
417 handler->SetSentErrorMessage(true);
418 return false;
419 }
420
421 if (!item)
422 {
424 handler->SetSentErrorMessage(true);
425 return false;
426 }
427
428 uint32 itemId = item->ItemId;
429 if (!sObjectMgr->RemoveVendorItem(addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry(), itemId))
430 {
431 handler->PSendSysMessage(LANG_ITEM_NOT_IN_LIST, itemId);
432 handler->SetSentErrorMessage(true);
433 return false;
434 }
435
436 handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1.c_str());
437 return true;
438 }
@ LANG_COMMAND_VENDORSELECTION
Definition: Language.h:323
@ LANG_ITEM_DELETED_FROM_LIST
Definition: Language.h:246
@ LANG_ITEM_NOT_IN_LIST
Definition: Language.h:247
bool IsVendor() const
Definition: Unit.h:1651

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcFollowCommand()

static bool npc_commandscript::HandleNpcFollowCommand ( ChatHandler handler)
inlinestatic
561 {
562 Player* player = handler->GetSession()->GetPlayer();
563 Creature* creature = handler->getSelectedCreature();
564
565 if (!creature)
566 {
568 handler->SetSentErrorMessage(true);
569 return false;
570 }
571
572 // Follow player - Using pet's default dist and angle
573 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
574
575 handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str());
576 return true;
577 }
#define PET_FOLLOW_DIST
Definition: PetDefines.h:193
@ LANG_CREATURE_FOLLOW_YOU_NOW
Definition: Language.h:381
std::string const & GetName() const
Definition: Object.h:446
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
virtual float GetFollowAngle() const
Definition: Unit.h:2392
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:367

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

Referenced by GetCommands().

◆ HandleNpcGuidCommand()

static bool npc_commandscript::HandleNpcGuidCommand ( ChatHandler handler)
inlinestatic
656 {
657 Creature* target = handler->getSelectedCreature();
658
659 if (!target)
660 {
662 handler->SetSentErrorMessage(true);
663 return false;
664 }
665
666 uint32 faction = target->GetFaction();
667 uint32 npcflags = target->GetNpcFlags();
668 uint32 displayid = target->GetDisplayId();
669 uint32 nativeid = target->GetNativeDisplayId();
670 uint32 entry = target->GetEntry();
671 uint32 id1 = 0;
672 uint32 id2 = 0;
673 uint32 id3 = 0;
674 if (CreatureData const* cData = target->GetCreatureData())
675 {
676 id1 = cData->id1;
677 id2 = cData->id2;
678 id3 = cData->id3;
679 }
680
681 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
682
683 return true;
684 }
@ LANG_NPCINFO_CHAR
Definition: Language.h:569
CreatureData const * GetCreatureData() const
Definition: Creature.h:198
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
LowType GetCounter() const
Definition: ObjectGuid.h:147
NPCFlags GetNpcFlags() const
Definition: Unit.h:1645
uint32 GetFaction() const
Definition: Unit.h:1495
uint32 GetDisplayId() const
Definition: Unit.h:2168
uint32 GetNativeDisplayId() const
Definition: Unit.h:2170

References ObjectGuid::GetCounter(), 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::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleNpcInfoCommand()

static bool npc_commandscript::HandleNpcInfoCommand ( ChatHandler handler)
inlinestatic
580 {
581 Creature* target = handler->getSelectedCreature();
582
583 if (!target)
584 {
586 handler->SetSentErrorMessage(true);
587 return false;
588 }
589
590 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
591 uint32 faction = target->GetFaction();
592 uint32 npcflags = target->GetNpcFlags();
593 uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask;
594 uint32 spellSchoolImmuneMask = cInfo->SpellSchoolImmuneMask;
595 uint32 displayid = target->GetDisplayId();
596 uint32 nativeid = target->GetNativeDisplayId();
597 uint32 entry = target->GetEntry();
598 uint32 id1 = 0;
599 uint32 id2 = 0;
600 uint32 id3 = 0;
601 if (CreatureData const* cData = target->GetCreatureData())
602 {
603 id1 = cData->id1;
604 id2 = cData->id2;
605 id3 = cData->id3;
606 }
607
608 int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
609 if (curRespawnDelay < 0)
610 curRespawnDelay = 0;
611 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
612 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
613
614 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
615 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
617 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
618 handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
619 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
620 handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
623 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
624 handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
625 handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());
626
627 for (uint8 i = 0; i < NPCFLAG_COUNT; i++)
628 {
629 if (npcflags & npcFlagTexts[i].flag)
630 {
631 handler->PSendSysMessage(npcFlagTexts[i].text, npcFlagTexts[i].flag);
632 }
633 }
634
635 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, mechanicImmuneMask);
636 for (uint8 i = 1; i < MAX_MECHANIC; ++i)
637 {
638 if (mechanicImmuneMask & (1 << (mechanicImmunes[i].flag - 1)))
639 {
640 handler->PSendSysMessage(mechanicImmunes[i].text, mechanicImmunes[i].flag);
641 }
642 }
643
644 handler->PSendSysMessage(LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, spellSchoolImmuneMask);
645 for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
646 {
647 if (spellSchoolImmuneMask & (1 << spellSchoolImmunes[i].flag))
648 {
649 handler->PSendSysMessage(spellSchoolImmunes[i].text, spellSchoolImmunes[i].flag);
650 }
651 }
652
653 return true;
654 }
std::uint64_t uint64
Definition: Define.h:107
std::int64_t int64
Definition: Define.h:103
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition: Util.cpp:74
@ LANG_NPCINFO_EQUIPMENT
Definition: Language.h:1090
@ LANG_NPCINFO_LOOT
Definition: Language.h:573
@ LANG_NPCINFO_POSITION
Definition: Language.h:574
@ LANG_NPCINFO_FLAGS
Definition: Language.h:572
@ LANG_NPCINFO_AIINFO
Definition: Language.h:1085
@ LANG_NPCINFO_SPELL_SCHOOL_IMMUNE
Definition: Language.h:1121
@ LANG_NPCINFO_HEALTH
Definition: Language.h:571
@ LANG_NPCINFO_PHASEMASK
Definition: Language.h:1074
@ LANG_NPCINFO_LEVEL
Definition: Language.h:570
@ LANG_COMMAND_RAWPAWNTIMES
Definition: Language.h:624
@ LANG_NPCINFO_ARMOR
Definition: Language.h:1075
@ LANG_NPCINFO_DUNGEON_ID
Definition: Language.h:577
@ LANG_NPCINFO_MECHANIC_IMMUNE
Definition: Language.h:1091
NpcFlagText const npcFlagTexts[NPCFLAG_COUNT]
Definition: cs_npc.cpp:51
SpellSchoolImmune const spellSchoolImmunes[MAX_SPELL_SCHOOL]
Definition: cs_npc.cpp:127
MechanicImmune const mechanicImmunes[MAX_MECHANIC]
Definition: cs_npc.cpp:85
#define NPCFLAG_COUNT
Definition: cs_npc.cpp:49
constexpr auto MAX_SPELL_SCHOOL
Definition: SharedDefines.h:264
@ MAX_MECHANIC
Definition: SharedDefines.h:1329
Seconds GetGameTime()
Definition: GameTime.cpp:38
int8 GetOriginalEquipmentId() const
Definition: Creature.h:185
uint8 GetCurrentEquipmentId()
Definition: Creature.h:186
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:197
uint32 GetRespawnDelay() const
Definition: Creature.h:283
std::string GetScriptName() const
Definition: Creature.cpp:2942
time_t GetRespawnTimeEx() const
Definition: Creature.cpp:2834
std::string const & GetAIName() const
Definition: Creature.cpp:2937
Definition: CreatureData.h:176
uint32 SkinLootId
Definition: CreatureData.h:219
uint32 MechanicImmuneMask
Definition: CreatureData.h:237
uint32 pickpocketLootId
Definition: CreatureData.h:218
uint32 lootid
Definition: CreatureData.h:217
uint8 SpellSchoolImmuneMask
Definition: CreatureData.h:238
uint32 GetPhaseMask() const
Definition: Object.h:434
uint32 GetInstanceId() const
Definition: Object.h:431
uint32 GetMaxHealth() const
Definition: Unit.h:1441
UnitFlags GetUnitFlags() const
Definition: Unit.h:1479
uint32 GetHealth() const
Definition: Unit.h:1440
uint32 GetCreateHealth() const
Definition: Unit.h:2039
uint32 GetArmor() const
Definition: Unit.h:1432
uint8 GetLevel() const
Definition: Unit.h:1420
UnitFlags2 GetUnitFlags2() const
Definition: Unit.h:1485
uint32 GetDynamicFlags() const override
Definition: Unit.h:1325

References Creature::GetAIName(), Unit::GetArmor(), ObjectGuid::GetCounter(), 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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), CreatureTemplate::SkinLootId, CreatureTemplate::SpellSchoolImmuneMask, and spellSchoolImmunes.

Referenced by GetCommands().

◆ HandleNpcMoveCommand()

static bool npc_commandscript::HandleNpcMoveCommand ( ChatHandler handler)
inlinestatic
735 {
736 Creature* creature = handler->getSelectedCreature();
737
738 if (!creature)
739 return false;
740
741 ObjectGuid::LowType lowguid = creature->GetSpawnId();
742
743 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
744 if (!data)
745 {
747 handler->SetSentErrorMessage(true);
748 return false;
749 }
750
751 if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
752 {
754 handler->SetSentErrorMessage(true);
755 return false;
756 }
757
758 float x = handler->GetSession()->GetPlayer()->GetPositionX();
759 float y = handler->GetSession()->GetPlayer()->GetPositionY();
760 float z = handler->GetSession()->GetPlayer()->GetPositionZ();
761 float o = handler->GetSession()->GetPlayer()->GetOrientation();
762
763 if (creature)
764 {
765 if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
766 {
767 const_cast<CreatureData*>(data)->posX = x;
768 const_cast<CreatureData*>(data)->posY = y;
769 const_cast<CreatureData*>(data)->posZ = z;
770 const_cast<CreatureData*>(data)->orientation = o;
771 }
772
773 creature->SetPosition(x, y, z, o);
774 creature->GetMotionMaster()->Initialize();
775
776 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
777 {
778 creature->setDeathState(JUST_DIED);
779 creature->Respawn();
780 }
781 }
782
784 stmt->SetData(0, x);
785 stmt->SetData(1, y);
786 stmt->SetData(2, z);
787 stmt->SetData(3, o);
788 stmt->SetData(4, lowguid);
789
790 WorldDatabase.Execute(stmt);
791
793 return true;
794 }
@ WORLD_UPD_CREATURE_POSITION
Definition: WorldDatabase.h:49
@ JUST_DIED
Definition: Unit.h:317
@ LANG_COMMAND_CREATUREMOVED
Definition: Language.h:316
@ LANG_COMMAND_CREATUREATSAMEMAP
Definition: Language.h:317
void setDeathState(DeathState s, bool despawn=false) override
Definition: Creature.cpp:1934
void Respawn(bool force=false)
Definition: Creature.cpp:2005
void SetPosition(float x, float y, float z, float o)
Definition: Creature.cpp:3055
uint16 mapid
Definition: CreatureData.h:364
uint32 GetMapId() const
Definition: Position.h:276
bool IsAlive() const
Definition: Unit.h:1808
void Initialize()
Definition: MotionMaster.cpp:72

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

Referenced by GetCommands().

◆ HandleNpcNearCommand()

static bool npc_commandscript::HandleNpcNearCommand ( ChatHandler handler,
Optional< float >  dist 
)
inlinestatic
687 {
688 float distance = dist.value_or(10.0f);
689 uint32 count = 0;
690
691 Player* player = handler->GetSession()->GetPlayer();
692
694 stmt->SetData(0, player->GetPositionX());
695 stmt->SetData(1, player->GetPositionY());
696 stmt->SetData(2, player->GetPositionZ());
697 stmt->SetData(3, player->GetMapId());
698 stmt->SetData(4, player->GetPositionX());
699 stmt->SetData(5, player->GetPositionY());
700 stmt->SetData(6, player->GetPositionZ());
701 stmt->SetData(7, distance * distance);
702 stmt->SetData(8, player->GetPhaseMask());
703 PreparedQueryResult result = WorldDatabase.Query(stmt);
704
705 if (result)
706 {
707 do
708 {
709 Field* fields = result->Fetch();
710 ObjectGuid::LowType guid = fields[0].Get<uint32>();
711 uint32 entry = fields[1].Get<uint32>();
712 //uint32 entry2 = fields[2].Get<uint32>();
713 float x = fields[3].Get<float>();
714 float y = fields[4].Get<float>();
715 float z = fields[5].Get<float>();
716 uint16 mapId = fields[6].Get<uint16>();
717
718 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
719 if (!creatureTemplate)
720 continue;
721
722 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId, "", "");
723
724 ++count;
725 } while (result->NextRow());
726 }
727
728 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
729
730 return true;
731 }
std::uint16_t uint16
Definition: Define.h:109
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ WORLD_SEL_CREATURE_NEAREST
Definition: WorldDatabase.h:90
@ LANG_COMMAND_NEAR_NPC_MESSAGE
Old ones now free:
Definition: Language.h:594
@ LANG_CREATURE_LIST_CHAT
Definition: Language.h:541
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113

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
798 {
799 Creature* target = handler->getSelectedCreature();
800 if (!target)
801 {
803 handler->SetSentErrorMessage(true);
804 return false;
805 }
806
807 target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
808
809 return true;
810 }
@ UNIT_NPC_EMOTESTATE
Definition: UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650

References ChatHandler::getSelectedCreature(), LANG_SELECT_CREATURE, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), Object::SetUInt32Value(), and UNIT_NPC_EMOTESTATE.

Referenced by GetCommands().

◆ HandleNpcSayCommand()

static bool npc_commandscript::HandleNpcSayCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1064 {
1065 if (text.empty())
1066 return false;
1067
1068 Creature* creature = handler->getSelectedCreature();
1069 if (!creature)
1070 {
1072 handler->SetSentErrorMessage(true);
1073 return false;
1074 }
1075
1076 creature->Say(text, LANG_UNIVERSAL);
1077
1078 // make some emotes
1079 switch (text.back())
1080 {
1081 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1082 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1083 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1084 }
1085
1086 return true;
1087 }
@ EMOTE_ONESHOT_EXCLAMATION
Definition: SharedDefines.h:1871
@ EMOTE_ONESHOT_QUESTION
Definition: SharedDefines.h:1872
@ EMOTE_ONESHOT_TALK
Definition: SharedDefines.h:1867
@ LANG_UNIVERSAL
Definition: SharedDefines.h:707
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21306
void HandleEmoteCommand(uint32 emoteId)
Definition: Unit.cpp:1970

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

Referenced by GetCommands().

◆ HandleNpcSetAllowMovementCommand()

static bool npc_commandscript::HandleNpcSetAllowMovementCommand ( ChatHandler handler)
inlinestatic
329 {
330 if (sWorld->getAllowMovement())
331 {
332 sWorld->SetAllowMovement(false);
334 }
335 else
336 {
337 sWorld->SetAllowMovement(true);
339 }
340 return true;
341 }
@ LANG_CREATURE_MOVE_ENABLED
Definition: Language.h:414
@ LANG_CREATURE_MOVE_DISABLED
Definition: Language.h:413
#define sWorld
Definition: World.h:451

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
543 {
544 Creature* creature = handler->getSelectedCreature();
545
546 if (!creature)
547 {
549 handler->SetSentErrorMessage(true);
550 return false;
551 }
552
553 creature->AI()->SetData(data_1, data_2);
554 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
555 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().GetCounter(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str());
556 return true;
557 }
@ LANG_NPC_SETDATA
Definition: Language.h:591
virtual void SetData(uint32, uint32)
Definition: UnitAI.h:203
CreatureAI * AI() const
Definition: Creature.h:135

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

Referenced by GetCommands().

◆ HandleNpcSetEntryCommand()

static bool npc_commandscript::HandleNpcSetEntryCommand ( ChatHandler handler,
CreatureEntry  newEntryNum 
)
inlinestatic
344 {
345 if (!newEntryNum)
346 return false;
347
348 Unit* unit = handler->getSelectedUnit();
349 if (!unit || unit->GetTypeId() != TYPEID_UNIT)
350 {
352 handler->SetSentErrorMessage(true);
353 return false;
354 }
355 Creature* creature = unit->ToCreature();
356 if (creature->UpdateEntry(newEntryNum))
357 handler->SendSysMessage(LANG_DONE);
358 else
359 handler->SendSysMessage(LANG_ERROR);
360 return true;
361 }
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ LANG_ERROR
Definition: Language.h:78
@ LANG_DONE
Definition: Language.h:75
Unit * getSelectedUnit() const
Definition: Chat.cpp:313
bool UpdateEntry(uint32 entry, const CreatureData *data=nullptr, bool changelevel=true, bool updateAI=false)
Definition: Creature.cpp:483
TypeID GetTypeId() const
Definition: Object.h:121
Creature * ToCreature()
Definition: Object.h:197
Definition: Unit.h:1290

References ChatHandler::getSelectedUnit(), Object::GetTypeId(), LANG_DONE, LANG_ERROR, LANG_SELECT_CREATURE, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), Object::ToCreature(), TYPEID_UNIT, and Creature::UpdateEntry().

Referenced by GetCommands().

◆ HandleNpcSetFactionIdCommand()

static bool npc_commandscript::HandleNpcSetFactionIdCommand ( ChatHandler handler,
uint32  factionId 
)
inlinestatic
442 {
443 if (!sFactionTemplateStore.LookupEntry(factionId))
444 {
445 handler->PSendSysMessage(LANG_WRONG_FACTION, factionId);
446 handler->SetSentErrorMessage(true);
447 return false;
448 }
449
450 Creature* creature = handler->getSelectedCreature();
451
452 if (!creature)
453 {
455 handler->SetSentErrorMessage(true);
456 return false;
457 }
458
459 creature->SetFaction(factionId);
460
461 // Faction is set in creature_template - not inside creature
462
463 // Update in memory..
464 if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
465 const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
466
467 // ..and DB
469
470 stmt->SetData(0, uint16(factionId));
471 stmt->SetData(1, creature->GetEntry());
472
473 WorldDatabase.Execute(stmt);
474
475 return true;
476 }
@ WORLD_UPD_CREATURE_FACTION
Definition: WorldDatabase.h:47
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
@ LANG_WRONG_FACTION
Definition: Language.h:163
void SetFaction(uint32 faction)
Definition: Unit.cpp:10029

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

Referenced by GetCommands().

◆ HandleNpcSetFactionTempIdCommand()

static bool npc_commandscript::HandleNpcSetFactionTempIdCommand ( ChatHandler handler,
uint32  tempfaction 
)
inlinestatic
480 {
481 Player* player = handler->GetSession()->GetPlayer();
482 Unit* unit = player->GetSelectedUnit();
483
484 if (!unit)
485 return false;
486
487 Creature* creature = unit->ToCreature();
488
489 if (!creature)
490 return false;
491
492 creature->SetFaction(tempfaction);
493
494 return true;
495 }
Unit * GetSelectedUnit() const
Definition: Player.cpp:11433

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
517 {
518 Creature* creature = handler->getSelectedCreature();
519
520 if (!creature)
521 {
523 handler->SetSentErrorMessage(true);
524 return false;
525 }
526
527 creature->ReplaceAllNpcFlags(NPCFlags(npcFlags));
528
530
531 stmt->SetData(0, NPCFlags(npcFlags));
532 stmt->SetData(1, creature->GetEntry());
533
534 WorldDatabase.Execute(stmt);
535
537
538 return true;
539 }
@ WORLD_UPD_CREATURE_NPCFLAG
Definition: WorldDatabase.h:48
NPCFlags
Non Player Character flags.
Definition: Unit.h:514
@ LANG_VALUE_SAVED_REJOIN
Definition: Language.h:305
void ReplaceAllNpcFlags(NPCFlags flags)
Definition: Unit.h:1649

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

Referenced by GetCommands().

◆ HandleNpcSetLevelCommand()

static bool npc_commandscript::HandleNpcSetLevelCommand ( ChatHandler handler,
uint8  lvl 
)
inlinestatic
365 {
366 if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3)
367 {
369 handler->SetSentErrorMessage(true);
370 return false;
371 }
372
373 Creature* creature = handler->getSelectedCreature();
374 if (!creature || creature->IsPet())
375 {
377 handler->SetSentErrorMessage(true);
378 return false;
379 }
380
381 creature->SetMaxHealth(100 + 30*lvl);
382 creature->SetHealth(100 + 30*lvl);
383 creature->SetLevel(lvl);
384 creature->SaveToDB();
385
386 return true;
387 }
@ LANG_BAD_VALUE
Definition: Language.h:147
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:234
void SetHealth(uint32 val)
Definition: Unit.cpp:15370
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition: Unit.cpp:15352
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:15420

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

Referenced by GetCommands().

◆ HandleNpcSetLinkCommand()

static bool npc_commandscript::HandleNpcSetLinkCommand ( ChatHandler handler,
ObjectGuid::LowType  linkguid 
)
inlinestatic
1288 {
1289 Creature* creature = handler->getSelectedCreature();
1290
1291 if (!creature)
1292 {
1294 handler->SetSentErrorMessage(true);
1295 return false;
1296 }
1297
1298 if (!creature->GetSpawnId())
1299 {
1300 handler->PSendSysMessage("Selected creature %u isn't in creature table", creature->GetGUID().GetCounter());
1301 handler->SetSentErrorMessage(true);
1302 return false;
1303 }
1304
1305 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1306 {
1307 handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid);
1308 handler->SetSentErrorMessage(true);
1309 return false;
1310 }
1311
1312 handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, creature->GetSpawnId());
1313 return true;
1314 }

References ObjectGuid::GetCounter(), Object::GetGUID(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleNpcSetModelCommand()

static bool npc_commandscript::HandleNpcSetModelCommand ( ChatHandler handler,
uint32  displayId 
)
inlinestatic
814 {
815 Creature* creature = handler->getSelectedCreature();
816
817 if (!creature || creature->IsPet())
818 {
820 handler->SetSentErrorMessage(true);
821 return false;
822 }
823
824 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
825 {
827 handler->SetSentErrorMessage(true);
828 return false;
829 }
830
831 creature->SetDisplayId(displayId);
832 creature->SetNativeDisplayId(displayId);
833 creature->SaveToDB();
834
835 return true;
836 }
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ LANG_COMMAND_FACTION_INVPARAM
Definition: Language.h:350
std::string ToString(Type &&val, Params &&... params)
Definition: StringConvert.h:250
void SetDisplayId(uint32 modelId) override
Definition: Creature.cpp:3405
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:2172

References ChatHandler::getSelectedCreature(), Unit::IsPet(), LANG_COMMAND_FACTION_INVPARAM, LANG_SELECT_CREATURE, ChatHandler::PSendSysMessage(), Creature::SaveToDB(), sCreatureDisplayInfoStore, ChatHandler::SendSysMessage(), Creature::SetDisplayId(), Unit::SetNativeDisplayId(), ChatHandler::SetSentErrorMessage(), 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

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

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

Referenced by GetCommands().

◆ HandleNpcSetOriginalFaction()

static bool npc_commandscript::HandleNpcSetOriginalFaction ( ChatHandler handler)
inlinestatic
499 {
500 Player* player = handler->GetSession()->GetPlayer();
501
502 if (!player)
503 return false;
504
505 Creature* creature = player->GetSelectedUnit()->ToCreature();
506
507 if (!creature)
508 return false;
509
510 creature->RestoreFaction();
511
512 return true;
513 }
void RestoreFaction()
Definition: Unit.cpp:18863

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
952 {
953 if (phasemask == 0)
954 {
956 handler->SetSentErrorMessage(true);
957 return false;
958 }
959
960 Creature* creature = handler->getSelectedCreature();
961 if (!creature)
962 {
964 handler->SetSentErrorMessage(true);
965 return false;
966 }
967
968 creature->SetPhaseMask(phasemask, true);
969
970 if (!creature->IsPet())
971 creature->SaveToDB();
972
973 return true;
974 }
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19217

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

Referenced by GetCommands().

◆ HandleNpcSetSpawnTimeCommand()

static bool npc_commandscript::HandleNpcSetSpawnTimeCommand ( ChatHandler handler,
std::string  spawnTimeStr 
)
inlinestatic
1022 {
1023 if (spawnTimeStr.empty())
1024 {
1025 return false;
1026 }
1027
1028 if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
1029 {
1031 handler->SetSentErrorMessage(true);
1032 return false;
1033 }
1034
1035 Creature* creature = handler->getSelectedCreature();
1036 if (!creature)
1037 return false;
1038
1039 int32 spawnTime = TimeStringToSecs(spawnTimeStr);
1040 if (spawnTime <= 0)
1041 {
1042 spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
1043 }
1044
1045 if (spawnTime <= 0)
1046 {
1048 handler->SetSentErrorMessage(true);
1049 return false;
1050 }
1051
1053 stmt->SetData(0, spawnTime);
1054 stmt->SetData(1, creature->GetSpawnId());
1055 WorldDatabase.Execute(stmt);
1056
1057 creature->SetRespawnDelay(spawnTime);
1058 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true).c_str());
1059
1060 return true;
1061 }
std::int32_t int32
Definition: Define.h:104
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:164
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
Definition: WorldDatabase.h:51
@ LANG_COMMAND_SPAWNTIME
Definition: Language.h:337
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:284

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

Referenced by GetCommands().

◆ HandleNpcSetWanderDistanceCommand()

static bool npc_commandscript::HandleNpcSetWanderDistanceCommand ( ChatHandler handler,
float  option 
)
inlinestatic
978 {
979 if (option < 0.0f)
980 {
982 return false;
983 }
984
986
987 if (option > 0.0f)
988 mtype = RANDOM_MOTION_TYPE;
989
990 Creature* creature = handler->getSelectedCreature();
991 ObjectGuid::LowType guidLow = 0;
992
993 if (creature)
994 guidLow = creature->GetSpawnId();
995 else
996 return false;
997
998 creature->SetWanderDistance((float)option);
999 creature->SetDefaultMovementType(mtype);
1000 creature->GetMotionMaster()->Initialize();
1001
1002 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
1003 {
1004 creature->setDeathState(JUST_DIED);
1005 creature->Respawn();
1006 }
1007
1009
1010 stmt->SetData(0, option);
1011 stmt->SetData(1, uint8(mtype));
1012 stmt->SetData(2, guidLow);
1013
1014 WorldDatabase.Execute(stmt);
1015
1017 return true;
1018 }
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
Definition: WorldDatabase.h:50
@ LANG_COMMAND_WANDER_DISTANCE
Definition: Language.h:336
void SetWanderDistance(float dist)
Definition: Creature.h:295

References Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), Unit::IsAlive(), JUST_DIED, 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
1205 {
1206 Creature* creatureTarget = handler->getSelectedCreature();
1207 if (!creatureTarget || creatureTarget->IsPet())
1208 {
1210 handler->SetSentErrorMessage (true);
1211 return false;
1212 }
1213
1214 Player* player = handler->GetSession()->GetPlayer();
1215
1216 if (player->IsExistPet())
1217 {
1219 handler->SetSentErrorMessage(true);
1220 return false;
1221 }
1222
1223 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1224
1225 if (!cInfo->IsTameable(player->CanTameExoticPets()))
1226 {
1228 handler->SetSentErrorMessage (true);
1229 return false;
1230 }
1231
1232 if (!player->CreatePet(creatureTarget))
1233 {
1235 handler->SetSentErrorMessage(true);
1236 return false;
1237 }
1238
1239 return true;
1240 }
@ LANG_CREATURE_NON_TAMEABLE
Definition: Language.h:384
@ LANG_YOU_ALREADY_HAVE_PET
Definition: Language.h:385
uint32 Entry
Definition: CreatureData.h:177
bool IsTameable(bool exotic) const
Definition: CreatureData.h:263
bool IsExistPet()
Definition: Player.cpp:9087
bool CanTameExoticPets() const
Definition: Player.h:2138
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition: Player.cpp:9093

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::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleNpcTextEmoteCommand()

static bool npc_commandscript::HandleNpcTextEmoteCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1091 {
1092 if (text.empty())
1093 return false;
1094
1095 Creature* creature = handler->getSelectedCreature();
1096
1097 if (!creature)
1098 {
1100 handler->SetSentErrorMessage(true);
1101 return false;
1102 }
1103
1104 creature->TextEmote(text);
1105
1106 return true;
1107 }
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:21316

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

Referenced by GetCommands().

◆ HandleNpcUnFollowCommand()

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler)
inlinestatic
1111 {
1112 Player* player = handler->GetSession()->GetPlayer();
1113 Creature* creature = handler->getSelectedCreature();
1114
1115 if (!creature)
1116 {
1118 handler->SetSentErrorMessage(true);
1119 return false;
1120 }
1121
1122 if (/*creature->GetMotionMaster()->empty() ||*/
1124 {
1125 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1126 handler->SetSentErrorMessage(true);
1127 return false;
1128 }
1129
1130 FollowMovementGenerator<Creature> const* mgen = static_cast<FollowMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top()));
1131
1132 if (mgen->GetTarget() != player)
1133 {
1134 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1135 handler->SetSentErrorMessage(true);
1136 return false;
1137 }
1138
1139 // reset movement
1140 creature->GetMotionMaster()->MovementExpired(true);
1141
1142 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
1143 return true;
1144 }
@ LANG_CREATURE_NOT_FOLLOW_YOU
Definition: Language.h:382
@ LANG_CREATURE_NOT_FOLLOW_YOU_NOW
Definition: Language.h:383
@ FOLLOW_MOTION_TYPE
Definition: MotionMaster.h:52
_Ty top() const
Definition: MotionMaster.h:148
MovementGeneratorType GetCurrentMovementGeneratorType() const
Definition: MotionMaster.cpp:817
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Definition: TargetedMovementGenerator.h:75
Unit * GetTarget() const
Definition: TargetedMovementGenerator.h:89

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::SetSentErrorMessage(), and MotionMaster::top().

Referenced by GetCommands().

◆ HandleNpcWhisperCommand()

static bool npc_commandscript::HandleNpcWhisperCommand ( ChatHandler handler,
std::string const &  recv,
Tail  text 
)
inlinestatic
1148 {
1149 if (text.empty())
1150 return false;
1151
1152 Creature* creature = handler->getSelectedCreature();
1153 if (!creature)
1154 {
1156 handler->SetSentErrorMessage(true);
1157 return false;
1158 }
1159
1160 // check online security
1161 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1162 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1163 return false;
1164
1165 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1166 return true;
1167 }
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:276
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition: Unit.cpp:21321

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

Referenced by GetCommands().

◆ HandleNpcYellCommand()

static bool npc_commandscript::HandleNpcYellCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1170 {
1171 if (text.empty())
1172 return false;
1173
1174 Creature* creature = handler->getSelectedCreature();
1175 if (!creature)
1176 {
1178 handler->SetSentErrorMessage(true);
1179 return false;
1180 }
1181
1182 creature->Yell(text, LANG_UNIVERSAL);
1183
1184 // make an emote
1186
1187 return true;
1188 }
@ EMOTE_ONESHOT_SHOUT
Definition: SharedDefines.h:1886
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21311

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

Referenced by GetCommands().