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
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:62
@ SEC_GAMEMASTER
Definition: Common.h:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleNpcDeleteCommand(ChatHandler *handler)
Definition: cs_npc.cpp:376
static bool HandleNpcMoveCommand(ChatHandler *handler)
Definition: cs_npc.cpp:710
static bool HandleNpcWhisperCommand(ChatHandler *handler, std::string const &recv, Tail text)
Definition: cs_npc.cpp:1108
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
Definition: cs_npc.cpp:1199
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, CreatureEntry id)
Definition: cs_npc.cpp:1150
static bool HandleNpcSetFactionTempIdCommand(ChatHandler *handler, uint32 tempfaction)
Definition: cs_npc.cpp:460
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
Definition: cs_npc.cpp:945
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
Definition: cs_npc.cpp:204
static bool HandleNpcSetOriginalFaction(ChatHandler *handler)
Definition: cs_npc.cpp:479
static bool HandleNpcTameCommand(ChatHandler *handler)
Definition: cs_npc.cpp:1163
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1055
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
Definition: cs_npc.cpp:786
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1129
static bool HandleNpcGuidCommand(ChatHandler *handler)
Definition: cs_npc.cpp:632
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
Definition: cs_npc.cpp:921
static bool HandleNpcFollowCommand(ChatHandler *handler)
Definition: cs_npc.cpp:539
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, uint32 emote)
Definition: cs_npc.cpp:771
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:821
static bool HandleNpcUnFollowCommand(ChatHandler *handler)
Definition: cs_npc.cpp:1074
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
Definition: cs_npc.cpp:353
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
Definition: cs_npc.cpp:318
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
Definition: cs_npc.cpp:1029
static bool HandleNpcInfoCommand(ChatHandler *handler)
Definition: cs_npc.cpp:557
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
Definition: cs_npc.cpp:662
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, std::string spawnTimeStr)
Definition: cs_npc.cpp:989
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
Definition: cs_npc.cpp:522
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:397
static bool HandleNpcSetFlagCommand(ChatHandler *handler, uint32 npcFlags)
Definition: cs_npc.cpp:497
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
Definition: cs_npc.cpp:1243
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
Definition: cs_npc.cpp:424
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
Definition: cs_npc.cpp:333
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
Definition: cs_npc.cpp:297

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, false, 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:1640
WorldSession * GetSession()
Definition: Chat.h:139
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:1067
void SaveToDB()
Definition: Creature.cpp:1331
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool gridLoad=false, bool allowDuplicate=false)
Definition: Creature.cpp:1630
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:1056
uint32 GetPhaseMaskForSpawn() const
Definition: Player.cpp:13685
Definition: Transport.h:29
Definition: Transport.h:48
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:15758
Definition: Map.h:313
uint8 GetSpawnMode() const
Definition: Map.h:420
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:637
uint32 GetId() const
Definition: Map.h:379
Player * GetPlayer() const
Definition: WorldSession.h:364

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
1200 {
1201 Creature* creature = handler->getSelectedCreature();
1202
1203 if (!creature || !creature->GetSpawnId())
1204 {
1206 return false;
1207 }
1208
1209 ObjectGuid::LowType lowguid = creature->GetSpawnId();
1210 if (creature->GetFormation())
1211 {
1212 handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId());
1213 return false;
1214 }
1215
1216 if (!lowguid)
1217 return false;
1218
1219 Player* chr = handler->GetSession()->GetPlayer();
1220 FormationInfo group_member;
1221 group_member.follow_angle = (creature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI;
1222 group_member.follow_dist = sqrtf(pow(chr->GetPositionX() - creature->GetPositionX(), int(2)) + pow(chr->GetPositionY() - creature->GetPositionY(), int(2)));
1223 group_member.leaderGUID = leaderGUID;
1224 group_member.groupAI = 0;
1225
1226 sFormationMgr->CreatureGroupMap[lowguid] = group_member;
1227 creature->SearchFormation();
1228
1230 stmt->SetData(0, leaderGUID);
1231 stmt->SetData(1, lowguid);
1232 stmt->SetData(2, group_member.follow_dist);
1233 stmt->SetData(3, group_member.follow_angle);
1234 stmt->SetData(4, uint32(group_member.groupAI));
1235
1236 WorldDatabase.Execute(stmt);
1237
1238 handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID);
1239
1240 return true;
1241 }
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 SendErrorMessage(uint32 entry)
Definition: Chat.cpp:152
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
Creature * getSelectedCreature() const
Definition: Chat.cpp:346
CreatureGroup const * GetFormation() const
Definition: Creature.h:347
void SearchFormation()
Definition: Creature.cpp:326
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::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: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
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101

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
1151 {
1152 Player* chr = handler->GetSession()->GetPlayer();
1153
1154 if (!id)
1155 return false;
1156
1157 chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120);
1158
1159 return true;
1160 }
@ 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:2343

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.c_str(), maxcount, incrtime, extendedcost);
293 return true;
294 }
@ LANG_COMMAND_NEEDITEMSEND
Definition: Language.h:324
@ LANG_ITEM_ADDED_TO_LIST
Definition: Language.h:244
void SetSentErrorMessage(bool val)
Definition: Chat.h:135
uint32 GetEntry() const
Definition: Object.h:109
uint32 GetCurrentVendor() const
Definition: WorldSession.h:368

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)
inlinestatic
377 {
378 Creature* unit = handler->getSelectedCreature();
379
380 if (!unit || unit->IsPet() || unit->IsTotem())
381 {
383 return false;
384 }
385
386 // Delete the creature
387 unit->CombatStop();
388 unit->DeleteFromDB();
389 unit->AddObjectToRemoveList();
390
392
393 return true;
394 }
@ LANG_COMMAND_DELCREATMESSAGE
Definition: Language.h:315
virtual void DeleteFromDB()
Definition: Creature.cpp:1790
void AddObjectToRemoveList()
Definition: Object.cpp:2140
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:10440
bool IsPet() const
Definition: Unit.h:1425
bool IsTotem() const
Definition: Unit.h:1427

References WorldObject::AddObjectToRemoveList(), Unit::CombatStop(), Creature::DeleteFromDB(), 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
398 {
399 Creature* vendor = handler->getSelectedCreature();
400 if (!vendor || !vendor->IsVendor())
401 {
403 return false;
404 }
405
406 if (!item)
407 {
409 return false;
410 }
411
412 uint32 itemId = item->ItemId;
413 if (!sObjectMgr->RemoveVendorItem(addMulti.value_or(false) ? handler->GetSession()->GetCurrentVendor() : vendor->GetEntry(), itemId))
414 {
415 handler->SendErrorMessage(LANG_ITEM_NOT_IN_LIST, itemId);
416 return false;
417 }
418
419 handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1.c_str());
420 return true;
421 }
@ 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:1665

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
540 {
541 Player* player = handler->GetSession()->GetPlayer();
542 Creature* creature = handler->getSelectedCreature();
543
544 if (!creature)
545 {
547 return false;
548 }
549
550 // Follow player - Using pet's default dist and angle
551 creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle());
552
553 handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str());
554 return true;
555 }
#define PET_FOLLOW_DIST
Definition: PetDefines.h:198
@ LANG_CREATURE_FOLLOW_YOU_NOW
Definition: Language.h:381
std::string const & GetName() const
Definition: Object.h:446
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
virtual float GetFollowAngle() const
Definition: Unit.h:2406
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:394

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
633 {
634 Creature* target = handler->getSelectedCreature();
635
636 if (!target)
637 {
639 return false;
640 }
641
642 uint32 faction = target->GetFaction();
643 uint32 npcflags = target->GetNpcFlags();
644 uint32 displayid = target->GetDisplayId();
645 uint32 nativeid = target->GetNativeDisplayId();
646 uint32 entry = target->GetEntry();
647 uint32 id1 = 0;
648 uint32 id2 = 0;
649 uint32 id3 = 0;
650 if (CreatureData const* cData = target->GetCreatureData())
651 {
652 id1 = cData->id1;
653 id2 = cData->id2;
654 id3 = cData->id3;
655 }
656
657 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
658
659 return true;
660 }
@ LANG_NPCINFO_CHAR
Definition: Language.h:569
CreatureData const * GetCreatureData() const
Definition: Creature.h:200
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
LowType GetCounter() const
Definition: ObjectGuid.h:147
NPCFlags GetNpcFlags() const
Definition: Unit.h:1659
uint32 GetFaction() const
Definition: Unit.h:1509
uint32 GetDisplayId() const
Definition: Unit.h:2182
uint32 GetNativeDisplayId() const
Definition: Unit.h:2184

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

Referenced by GetCommands().

◆ HandleNpcInfoCommand()

static bool npc_commandscript::HandleNpcInfoCommand ( ChatHandler handler)
inlinestatic
558 {
559 Creature* target = handler->getSelectedCreature();
560
561 if (!target)
562 {
564 return false;
565 }
566
567 CreatureTemplate const* cInfo = target->GetCreatureTemplate();
568 uint32 faction = target->GetFaction();
569 uint32 npcflags = target->GetNpcFlags();
570 uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask;
571 uint32 spellSchoolImmuneMask = cInfo->SpellSchoolImmuneMask;
572 uint32 displayid = target->GetDisplayId();
573 uint32 nativeid = target->GetNativeDisplayId();
574 uint32 entry = target->GetEntry();
575 uint32 id1 = 0;
576 uint32 id2 = 0;
577 uint32 id3 = 0;
578 if (CreatureData const* cData = target->GetCreatureData())
579 {
580 id1 = cData->id1;
581 id2 = cData->id2;
582 id3 = cData->id3;
583 }
584
585 int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
586 if (curRespawnDelay < 0)
587 curRespawnDelay = 0;
588 std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
589 std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
590
591 handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
592 handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->GetLevel());
594 handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
595 handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUnitFlags(), target->GetUnitFlags2(), target->GetDynamicFlags(), target->GetFaction());
596 handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
597 handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
600 handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor());
601 handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
602 handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str());
603
604 for (uint8 i = 0; i < NPCFLAG_COUNT; i++)
605 {
606 if (npcflags & npcFlagTexts[i].flag)
607 {
608 handler->PSendSysMessage(npcFlagTexts[i].text, npcFlagTexts[i].flag);
609 }
610 }
611
612 handler->PSendSysMessage(LANG_NPCINFO_MECHANIC_IMMUNE, mechanicImmuneMask);
613 for (uint8 i = 1; i < MAX_MECHANIC; ++i)
614 {
615 if (mechanicImmuneMask & (1 << (mechanicImmunes[i].flag - 1)))
616 {
617 handler->PSendSysMessage(mechanicImmunes[i].text, mechanicImmunes[i].flag);
618 }
619 }
620
621 handler->PSendSysMessage(LANG_NPCINFO_SPELL_SCHOOL_IMMUNE, spellSchoolImmuneMask);
622 for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i)
623 {
624 if (spellSchoolImmuneMask & (1 << spellSchoolImmunes[i].flag))
625 {
626 handler->PSendSysMessage(spellSchoolImmunes[i].text, spellSchoolImmunes[i].flag);
627 }
628 }
629
630 return true;
631 }
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:73
@ LANG_NPCINFO_EQUIPMENT
Definition: Language.h:1099
@ 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:1094
@ LANG_NPCINFO_SPELL_SCHOOL_IMMUNE
Definition: Language.h:1130
@ LANG_NPCINFO_HEALTH
Definition: Language.h:571
@ LANG_NPCINFO_PHASEMASK
Definition: Language.h:1083
@ LANG_NPCINFO_LEVEL
Definition: Language.h:570
@ LANG_COMMAND_RAWPAWNTIMES
Definition: Language.h:624
@ LANG_NPCINFO_ARMOR
Definition: Language.h:1084
@ LANG_NPCINFO_DUNGEON_ID
Definition: Language.h:577
@ LANG_NPCINFO_MECHANIC_IMMUNE
Definition: Language.h:1100
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
constexpr auto MAX_SPELL_SCHOOL
Definition: SharedDefines.h:292
@ MAX_MECHANIC
Definition: SharedDefines.h:1357
Seconds GetGameTime()
Definition: GameTime.cpp:38
int8 GetOriginalEquipmentId() const
Definition: Creature.h:187
uint8 GetCurrentEquipmentId()
Definition: Creature.h:188
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:199
uint32 GetRespawnDelay() const
Definition: Creature.h:285
std::string GetScriptName() const
Definition: Creature.cpp:2959
time_t GetRespawnTimeEx() const
Definition: Creature.cpp:2851
std::string const & GetAIName() const
Definition: Creature.cpp:2954
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:1455
UnitFlags GetUnitFlags() const
Definition: Unit.h:1493
uint32 GetHealth() const
Definition: Unit.h:1454
uint32 GetCreateHealth() const
Definition: Unit.h:2053
uint32 GetArmor() const
Definition: Unit.h:1446
uint8 GetLevel() const
Definition: Unit.h:1432
UnitFlags2 GetUnitFlags2() const
Definition: Unit.h:1499
uint32 GetDynamicFlags() const override
Definition: Unit.h:1337

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::SendErrorMessage(), CreatureTemplate::SkinLootId, CreatureTemplate::SpellSchoolImmuneMask, and spellSchoolImmunes.

Referenced by GetCommands().

◆ HandleNpcMoveCommand()

static bool npc_commandscript::HandleNpcMoveCommand ( ChatHandler handler)
inlinestatic
711 {
712 Creature* creature = handler->getSelectedCreature();
713
714 if (!creature)
715 return false;
716
717 ObjectGuid::LowType lowguid = creature->GetSpawnId();
718
719 CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
720 if (!data)
721 {
723 return false;
724 }
725
726 if (handler->GetSession()->GetPlayer()->GetMapId() != data->mapid)
727 {
729 return false;
730 }
731
732 float x = handler->GetSession()->GetPlayer()->GetPositionX();
733 float y = handler->GetSession()->GetPlayer()->GetPositionY();
734 float z = handler->GetSession()->GetPlayer()->GetPositionZ();
735 float o = handler->GetSession()->GetPlayer()->GetOrientation();
736
737 if (creature)
738 {
739 if (CreatureData const* data = sObjectMgr->GetCreatureData(creature->GetSpawnId()))
740 {
741 const_cast<CreatureData*>(data)->posX = x;
742 const_cast<CreatureData*>(data)->posY = y;
743 const_cast<CreatureData*>(data)->posZ = z;
744 const_cast<CreatureData*>(data)->orientation = o;
745 }
746
747 creature->SetPosition(x, y, z, o);
748 creature->GetMotionMaster()->Initialize();
749
750 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
751 {
752 creature->setDeathState(DeathState::JustDied);
753 creature->Respawn();
754 }
755 }
756
758 stmt->SetData(0, x);
759 stmt->SetData(1, y);
760 stmt->SetData(2, z);
761 stmt->SetData(3, o);
762 stmt->SetData(4, lowguid);
763
764 WorldDatabase.Execute(stmt);
765
767 return true;
768 }
@ WORLD_UPD_CREATURE_POSITION
Definition: WorldDatabase.h:49
@ 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:1903
void Respawn(bool force=false)
Definition: Creature.cpp:1974
void SetPosition(float x, float y, float z, float o)
Definition: Creature.cpp:3072
uint16 mapid
Definition: CreatureData.h:364
uint32 GetMapId() const
Definition: Position.h:276
bool IsAlive() const
Definition: Unit.h:1822
void Initialize()
Definition: MotionMaster.cpp:73

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(), 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
663 {
664 float distance = dist.value_or(10.0f);
665 uint32 count = 0;
666
667 Player* player = handler->GetSession()->GetPlayer();
668
670 stmt->SetData(0, player->GetPositionX());
671 stmt->SetData(1, player->GetPositionY());
672 stmt->SetData(2, player->GetPositionZ());
673 stmt->SetData(3, player->GetMapId());
674 stmt->SetData(4, player->GetPositionX());
675 stmt->SetData(5, player->GetPositionY());
676 stmt->SetData(6, player->GetPositionZ());
677 stmt->SetData(7, distance * distance);
678 stmt->SetData(8, player->GetPhaseMask());
679 PreparedQueryResult result = WorldDatabase.Query(stmt);
680
681 if (result)
682 {
683 do
684 {
685 Field* fields = result->Fetch();
686 ObjectGuid::LowType guid = fields[0].Get<uint32>();
687 uint32 entry = fields[1].Get<uint32>();
688 //uint32 entry2 = fields[2].Get<uint32>();
689 float x = fields[3].Get<float>();
690 float y = fields[4].Get<float>();
691 float z = fields[5].Get<float>();
692 uint16 mapId = fields[6].Get<uint16>();
693
694 CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
695 if (!creatureTemplate)
696 continue;
697
698 handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, entry, guid, creatureTemplate->Name.c_str(), x, y, z, mapId, "", "");
699
700 ++count;
701 } while (result->NextRow());
702 }
703
704 handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count);
705
706 return true;
707 }
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
772 {
773 Creature* target = handler->getSelectedCreature();
774 if (!target)
775 {
777 return false;
778 }
779
780 target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
781
782 return true;
783 }
@ UNIT_NPC_EMOTESTATE
Definition: UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650

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

Referenced by GetCommands().

◆ HandleNpcSayCommand()

static bool npc_commandscript::HandleNpcSayCommand ( ChatHandler handler,
Tail  text 
)
inlinestatic
1030 {
1031 if (text.empty())
1032 return false;
1033
1034 Creature* creature = handler->getSelectedCreature();
1035 if (!creature)
1036 {
1038 return false;
1039 }
1040
1041 creature->Say(text, LANG_UNIVERSAL);
1042
1043 // make some emotes
1044 switch (text.back())
1045 {
1046 case '?': creature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break;
1047 case '!': creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break;
1048 default: creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break;
1049 }
1050
1051 return true;
1052 }
@ 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:21420
void HandleEmoteCommand(uint32 emoteId)
Definition: Unit.cpp:1980

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:414
@ LANG_CREATURE_MOVE_DISABLED
Definition: Language.h:413
#define sWorld
Definition: World.h:447

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
523 {
524 Creature* creature = handler->getSelectedCreature();
525
526 if (!creature)
527 {
529 return false;
530 }
531
532 creature->AI()->SetData(data_1, data_2);
533 std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
534 handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().GetCounter(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str());
535 return true;
536 }
@ LANG_NPC_SETDATA
Definition: Language.h:591
virtual void SetData(uint32, uint32)
Definition: UnitAI.h:203
CreatureAI * AI() const
Definition: Creature.h:136

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::SendErrorMessage(), and UnitAI::SetData().

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->GetTypeId() != TYPEID_UNIT)
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 }
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
@ LANG_ERROR
Definition: Language.h:78
@ LANG_DONE
Definition: Language.h:75
Unit * getSelectedUnit() const
Definition: Chat.cpp:322
bool UpdateEntry(uint32 entry, const CreatureData *data=nullptr, bool changelevel=true, bool updateAI=false)
Definition: Creature.cpp:482
TypeID GetTypeId() const
Definition: Object.h:121
Creature * ToCreature()
Definition: Object.h:197
Definition: Unit.h:1302

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

Referenced by GetCommands().

◆ HandleNpcSetFactionIdCommand()

static bool npc_commandscript::HandleNpcSetFactionIdCommand ( ChatHandler handler,
uint32  factionId 
)
inlinestatic
425 {
426 if (!sFactionTemplateStore.LookupEntry(factionId))
427 {
428 handler->SendErrorMessage(LANG_WRONG_FACTION, factionId);
429 return false;
430 }
431
432 Creature* creature = handler->getSelectedCreature();
433
434 if (!creature)
435 {
437 return false;
438 }
439
440 creature->SetFaction(factionId);
441
442 // Faction is set in creature_template - not inside creature
443
444 // Update in memory..
445 if (CreatureTemplate const* cinfo = creature->GetCreatureTemplate())
446 const_cast<CreatureTemplate*>(cinfo)->faction = factionId;
447
448 // ..and DB
450
451 stmt->SetData(0, uint16(factionId));
452 stmt->SetData(1, creature->GetEntry());
453
454 WorldDatabase.Execute(stmt);
455
456 return true;
457 }
@ 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:10064

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

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
498 {
499 Creature* creature = handler->getSelectedCreature();
500
501 if (!creature)
502 {
504 return false;
505 }
506
507 creature->ReplaceAllNpcFlags(NPCFlags(npcFlags));
508
510
511 stmt->SetData(0, NPCFlags(npcFlags));
512 stmt->SetData(1, creature->GetEntry());
513
514 WorldDatabase.Execute(stmt);
515
517
518 return true;
519 }
@ 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:1663

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 }
@ LANG_BAD_VALUE
Definition: Language.h:147
@ CONFIG_MAX_PLAYER_LEVEL
Definition: IWorld.h:236
void SetHealth(uint32 val)
Definition: Unit.cpp:15464
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition: Unit.cpp:15446
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:15514

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
1244 {
1245 Creature* creature = handler->getSelectedCreature();
1246
1247 if (!creature)
1248 {
1250 return false;
1251 }
1252
1253 if (!creature->GetSpawnId())
1254 {
1255 handler->SendErrorMessage("Selected creature %u isn't in creature table", creature->GetGUID().GetCounter());
1256 return false;
1257 }
1258
1259 if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid))
1260 {
1261 handler->SendErrorMessage("Selected creature can't link with guid '%u'", linkguid);
1262 return false;
1263 }
1264
1265 handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, creature->GetSpawnId());
1266 return true;
1267 }

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

Referenced by GetCommands().

◆ HandleNpcSetModelCommand()

static bool npc_commandscript::HandleNpcSetModelCommand ( ChatHandler handler,
uint32  displayId 
)
inlinestatic
787 {
788 Creature* creature = handler->getSelectedCreature();
789
790 if (!creature || creature->IsPet())
791 {
793 return false;
794 }
795
796 if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
797 {
799 return false;
800 }
801
802 creature->SetDisplayId(displayId);
803 creature->SetNativeDisplayId(displayId);
804 creature->SaveToDB();
805
806 return true;
807 }
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:3422
void SetNativeDisplayId(uint32 modelId)
Definition: Unit.h:2186

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

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

References ChatHandler::GetCreatureFromPlayerMapByDbGuid(), Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), Unit::IsAlive(), Unit::IsPet(), 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
480 {
481 Player* player = handler->GetSession()->GetPlayer();
482
483 if (!player)
484 return false;
485
486 Creature* creature = player->GetSelectedUnit()->ToCreature();
487
488 if (!creature)
489 return false;
490
491 creature->RestoreFaction();
492
493 return true;
494 }
void RestoreFaction()
Definition: Unit.cpp:18959

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
922 {
923 if (phasemask == 0)
924 {
926 return false;
927 }
928
929 Creature* creature = handler->getSelectedCreature();
930 if (!creature)
931 {
933 return false;
934 }
935
936 creature->SetPhaseMask(phasemask, true);
937
938 if (!creature->IsPet())
939 creature->SaveToDB();
940
941 return true;
942 }
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19313

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
990 {
991 if (spawnTimeStr.empty())
992 {
993 return false;
994 }
995
996 if (Acore::StringTo<int32>(spawnTimeStr).value_or(0) < 0)
997 {
999 return false;
1000 }
1001
1002 Creature* creature = handler->getSelectedCreature();
1003 if (!creature)
1004 return false;
1005
1006 int32 spawnTime = TimeStringToSecs(spawnTimeStr);
1007 if (spawnTime <= 0)
1008 {
1009 spawnTime = Acore::StringTo<int32>(spawnTimeStr).value_or(0);
1010 }
1011
1012 if (spawnTime <= 0)
1013 {
1015 return false;
1016 }
1017
1019 stmt->SetData(0, spawnTime);
1020 stmt->SetData(1, creature->GetSpawnId());
1021 WorldDatabase.Execute(stmt);
1022
1023 creature->SetRespawnDelay(spawnTime);
1024 handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, secsToTimeString(spawnTime, true).c_str());
1025
1026 return true;
1027 }
std::int32_t int32
Definition: Define.h:104
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:163
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
Definition: WorldDatabase.h:51
@ LANG_COMMAND_SPAWNTIME
Definition: Language.h:337
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:286

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
946 {
947 if (option < 0.0f)
948 {
950 return false;
951 }
952
954
955 if (option > 0.0f)
956 mtype = RANDOM_MOTION_TYPE;
957
958 Creature* creature = handler->getSelectedCreature();
959 ObjectGuid::LowType guidLow = 0;
960
961 if (creature)
962 guidLow = creature->GetSpawnId();
963 else
964 return false;
965
966 creature->SetWanderDistance((float)option);
967 creature->SetDefaultMovementType(mtype);
968 creature->GetMotionMaster()->Initialize();
969
970 if (creature->IsAlive()) // dead creature will reset movement generator at respawn
971 {
972 creature->setDeathState(DeathState::JustDied);
973 creature->Respawn();
974 }
975
977
978 stmt->SetData(0, option);
979 stmt->SetData(1, uint8(mtype));
980 stmt->SetData(2, guidLow);
981
982 WorldDatabase.Execute(stmt);
983
985 return true;
986 }
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
Definition: WorldDatabase.h:50
@ LANG_COMMAND_WANDER_DISTANCE
Definition: Language.h:336
void SetWanderDistance(float dist)
Definition: Creature.h:297

References Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), Unit::IsAlive(), 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
1164 {
1165 Creature* creatureTarget = handler->getSelectedCreature();
1166 if (!creatureTarget || creatureTarget->IsPet())
1167 {
1169 handler->SetSentErrorMessage (true);
1170 return false;
1171 }
1172
1173 Player* player = handler->GetSession()->GetPlayer();
1174
1175 if (player->IsExistPet())
1176 {
1178 return false;
1179 }
1180
1181 CreatureTemplate const* cInfo = creatureTarget->GetCreatureTemplate();
1182
1183 if (!cInfo->IsTameable(player->CanTameExoticPets()))
1184 {
1186 handler->SetSentErrorMessage (true);
1187 return false;
1188 }
1189
1190 if (!player->CreatePet(creatureTarget))
1191 {
1193 return false;
1194 }
1195
1196 return true;
1197 }
@ 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:9108
bool CanTameExoticPets() const
Definition: Player.h:2151
Pet * CreatePet(Creature *creatureTarget, uint32 spellID=0)
Definition: Player.cpp:9114

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
1056 {
1057 if (text.empty())
1058 return false;
1059
1060 Creature* creature = handler->getSelectedCreature();
1061
1062 if (!creature)
1063 {
1065 return false;
1066 }
1067
1068 creature->TextEmote(text);
1069
1070 return true;
1071 }
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:21430

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

Referenced by GetCommands().

◆ HandleNpcUnFollowCommand()

static bool npc_commandscript::HandleNpcUnFollowCommand ( ChatHandler handler)
inlinestatic
1075 {
1076 Player* player = handler->GetSession()->GetPlayer();
1077 Creature* creature = handler->getSelectedCreature();
1078
1079 if (!creature)
1080 {
1082 return false;
1083 }
1084
1085 if (/*creature->GetMotionMaster()->empty() ||*/
1087 {
1088 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1089 return false;
1090 }
1091
1092 FollowMovementGenerator<Creature> const* mgen = static_cast<FollowMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top()));
1093
1094 if (mgen->GetTarget() != player)
1095 {
1096 handler->SendErrorMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
1097 return false;
1098 }
1099
1100 // reset movement
1101 creature->GetMotionMaster()->MovementExpired(true);
1102
1103 handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
1104 return true;
1105 }
@ 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:859
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::SendErrorMessage(), and MotionMaster::top().

Referenced by GetCommands().

◆ HandleNpcWhisperCommand()

static bool npc_commandscript::HandleNpcWhisperCommand ( ChatHandler handler,
std::string const &  recv,
Tail  text 
)
inlinestatic
1109 {
1110 if (text.empty())
1111 return false;
1112
1113 Creature* creature = handler->getSelectedCreature();
1114 if (!creature)
1115 {
1117 return false;
1118 }
1119
1120 // check online security
1121 Player* receiver = ObjectAccessor::FindPlayerByName(recv);
1122 if (handler->HasLowerSecurity(receiver, ObjectGuid::Empty))
1123 return false;
1124
1125 creature->Whisper(text, LANG_UNIVERSAL, receiver);
1126 return true;
1127 }
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:274
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:21435

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
1130 {
1131 if (text.empty())
1132 return false;
1133
1134 Creature* creature = handler->getSelectedCreature();
1135 if (!creature)
1136 {
1138 return false;
1139 }
1140
1141 creature->Yell(text, LANG_UNIVERSAL);
1142
1143 // make an emote
1145
1146 return true;
1147 }
@ EMOTE_ONESHOT_SHOUT
Definition: SharedDefines.h:1914
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21425

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

Referenced by GetCommands().