89 {
"add", npcAddCommandTable },
90 {
"set", npcSetCommandTable },
111 {
"npc", npcCommandTable },
134 if (
Creature* creature = trans->CreateNPCPassenger(guid, &data))
158 if (!creature->
LoadFromDB(db_guid, map,
true,
true))
187 uint32 maxcount = mc.value_or(0);
188 uint32 incrtime = it.value_or(0);
189 uint32 extendedcost = ec.value_or(0);
198 sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost);
231 if (
sWorld->getAllowMovement())
233 sWorld->SetAllowMovement(
false);
238 sWorld->SetAllowMovement(
true);
275 if (!creature || creature->
IsPet())
294 spawnId = *spawnIdArg;
298 if (!creature || creature->
IsPet() || creature->
IsTotem())
480 if (curRespawnDelay < 0)
498 for (
UnitFlags flag : EnumUtils::Iterate<UnitFlags>())
520 for (
NPCFlags flag : EnumUtils::Iterate<NPCFlags>())
525 for (
Mechanics m : EnumUtils::Iterate<Mechanics>())
526 if (m && (mechanicImmuneMask & (1 << (m-1))))
534 float distance = dist.value_or(10.0f);
547 stmt->
setFloat(7, distance * distance);
554 Field* fields = result->Fetch();
563 if (!creatureTemplate)
570 while (result->NextRow());
586 if (!spawnid && !creature)
607 sObjectMgr->RemoveCreatureFromGrid(lowguid, data);
608 const_cast<CreatureData*
>(data)->spawnPoint.Relocate(*player);
649 if (!creature || creature->
IsPet())
693 bool doNotDelete = nodel.has_value();
701 if (!creature || creature->
IsPet())
733 switch (type.index())
755 if (doNotDelete ==
false)
767 if (doNotDelete ==
false)
800 if (!creature->
IsPet())
929 FollowMovementGenerator const* followMovement = dynamic_cast<FollowMovementGenerator const*>(a);
930 return followMovement && followMovement->GetTarget() == player;
1018 if (!creatureTarget || creatureTarget->
IsPet())
1084 if (!creatureTarget || creatureTarget->
IsPet())
1109 char const* name =
nullptr;
1112 if ((!name || !*name) && itemTemplate)
1113 name = itemTemplate->
Name1.c_str();
1115 name =
"Unknown item";
1121 for (NotNormalLootItemMap::value_type
const& pair : map)
1128 for (
auto it = pair.second->cbegin(); it != pair.second->cend(); ++it)
1130 LootItem const& item = items[it->index];
1131 if (!(it->is_looted) && !item.
is_looted)
1139 if (!creatureTarget || creatureTarget->
IsPet())
1146 Loot const& loot = creatureTarget->
loot;
1161 if (!item.is_looted)
1166 if (!item.is_looted)
1173 if (!item.is_looted && !item.freeforall && item.conditions.empty())
1224 sFormationMgr->AddFormationMember(lowguid, followAngle, followDist, leaderGUID, groupAI);
1236 handler->
PSendSysMessage(
"Creature %u added to formation with leader %u", lowguid, leaderGUID);
1261 handler->
PSendSysMessage(
"Selected creature can't link with guid '%u'", linkguid);
1327 bool ignoreRespawn =
false;
1332 for (
auto const& variant : opts)
1334 switch (variant.index())
1337 groupId = variant.get<
uint32>();
1343 ignoreRespawn =
true;
1350 std::vector <WorldObject*> creatureList;
1368 bool deleteRespawnTimes =
false;
1372 for (
auto const& variant : opts)
1374 if (variant.holds_alternative<
uint32>())
1375 groupId = variant.get<
uint32>();
1377 deleteRespawnTimes =
true;
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define STRING_VIEW_FMT_ARG(str)
@ LANG_OBJECTINFO_STRINGIDS
@ LANG_COMMAND_NPC_SHOWLOOT_ENTRY
@ LANG_SPAWNGROUP_SPAWNCOUNT
@ LANG_CREATURE_NON_TAMEABLE
@ LANG_CREATURE_NOT_FOLLOW_YOU
@ LANG_CREATURE_FOLLOW_YOU_NOW
@ LANG_YOU_ALREADY_HAVE_PET
@ LANG_CREATURE_NOT_AI_ENABLED
@ LANG_CREATURE_MOVE_ENABLED
@ LANG_COMMAND_NOT_DEAD_OR_NO_LOOT
@ LANG_NPCINFO_UNIT_FIELD_FLAGS
@ LANG_VALUE_SAVED_REJOIN
@ LANG_COMMAND_CREATUREMOVED
@ LANG_NPCINFO_REACTSTATE
@ LANG_COMMAND_DELCREATMESSAGE
@ LANG_CREATURE_NOT_FOLLOW_YOU_NOW
@ LANG_COMMAND_CREATUREATSAMEMAP
@ LANG_COMMAND_NEAR_NPC_MESSAGE
Old ones now free:
@ LANG_COMMAND_NEEDITEMSEND
@ LANG_COMMAND_NPC_SHOWLOOT_ENTRY_2
@ LANG_COMMAND_VENDORSELECTION
@ LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL
@ LANG_CREATURE_MOVE_DISABLED
@ LANG_ITEM_ADDED_TO_LIST
@ LANG_NPCINFO_MOVEMENT_DATA
@ LANG_ITEM_DELETED_FROM_LIST
@ LANG_MOVE_TYPE_SET_NODEL
@ LANG_COMMAND_INVALID_PARAM
@ LANG_SPAWNINFO_GROUP_ID
@ LANG_COMMAND_WANDER_DISTANCE
@ LANG_COMMAND_CREATGUIDNOTFOUND
@ LANG_NPCINFO_FLAGS_EXTRA
@ LANG_CREATURE_LIST_CHAT
@ LANG_SPAWNINFO_COMPATIBILITY_MODE
@ LANG_COMMAND_RAWPAWNTIMES
@ LANG_COMMAND_NPC_SHOWLOOT_LABEL
@ LANG_SPAWNGROUP_BADGROUP
@ LANG_COMMAND_NPC_SHOWLOOT_LABEL_2
@ LANG_COMMAND_NPC_SHOWLOOT_HEADER
@ LANG_NPCINFO_DUNGEON_ID
@ LANG_NPCINFO_MECHANIC_IMMUNE
@ LANG_COMMAND_NPC_SHOWLOOT_MONEY
std::unordered_map< ObjectGuid, NotNormalLootItemList * > NotNormalLootItemMap
@ TEMPSUMMON_CORPSE_DESPAWN
@ TEMPSUMMON_CORPSE_TIMED_DESPAWN
std::optional< T > Optional
Optional helper class to wrap optional values within.
Role Based Access Control related classes definition.
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ EMOTE_ONESHOT_EXCLAMATION
NPCFlags
Non Player Character flags.
char const * DescribeReactState(ReactStates state)
bool StringEqualI(std::string_view a, std::string_view b)
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
@ WORLD_UPD_CREATURE_POSITION
@ WORLD_UPD_CREATURE_NPCFLAG
@ WORLD_SEL_CREATURE_NEAREST
@ WORLD_INS_CREATURE_FORMATION
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
@ WORLD_UPD_CREATURE_SPAWN_TIME_SECS
@ WORLD_UPD_CREATURE_WANDER_DISTANCE
@ WORLD_UPD_CREATURE_FACTION
WorldSession * GetSession()
virtual LocaleConstant GetSessionDbcLocale() const
Creature * GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowguid)
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Creature * getSelectedCreature()
void SetSentErrorMessage(bool val)
void PSendSysMessage(char const *fmt, Args &&... args)
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
ObjectGuid::LowType GetLeaderSpawnId() const
void SetPhaseMask(uint32 newPhaseMask, bool update) override
int8 GetOriginalEquipmentId() const
void Respawn(bool force=false)
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
void setDeathState(DeathState s) override
void SetDisplayId(uint32 modelId) override
void SetReactState(ReactStates st)
bool GetRespawnCompatibilityMode()
void SetRespawnDelay(uint32 delay)
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
bool UpdateEntry(uint32 entry, CreatureData const *data=nullptr, bool updateLevel=true)
CreatureData const * GetCreatureData() const
ObjectGuid::LowType GetSpawnId() const
CreatureTemplate const * GetCreatureTemplate() const
uint32 GetRespawnDelay() const
static bool DeleteFromDB(ObjectGuid::LowType spawnId)
CreatureGroup * GetFormation()
std::string_view GetStringId(StringIdType type) const
ReactStates GetReactState() const
void SetWanderDistance(float dist)
std::string GetScriptName() const
uint8 GetCurrentEquipmentId() const
CreatureMovementData const & GetMovementTemplate() const
time_t GetRespawnTimeEx() const
std::string const & GetAIName() const
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, Position const &pos, CreatureData const *data=nullptr, uint32 vehId=0, bool dynamic=false)
void SetDefaultMovementType(MovementGeneratorType mgt)
void LoadPath(uint32 pathid)
static char const * ToTitle(Enum value)
Class used to access individual fields of database query result.
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
uint8 GetSpawnMode() const
ObjectGuid::LowType GenerateLowGuid()
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
bool IsSpawnGroupActive(uint32 groupId) const
bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
void MoveFollow(Unit *target, float dist, ChaseAngle angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
MovementGenerator * GetMovementGenerator(std::function< bool(MovementGenerator const *)> const &filter, MovementSlot slot=MOTION_SLOT_ACTIVE) const
void Remove(MovementGenerator *movement, MovementSlot slot=MOTION_SLOT_ACTIVE)
virtual MovementGeneratorType GetMovementGeneratorType() const =0
LowType GetCounter() const
static ObjectGuid const Empty
std::string ToString() const
static Creature * ToCreature(Object *o)
static ObjectGuid GetGUID(Object const *o)
void SetUInt32Value(uint16 index, uint32 value)
void SavePetToDB(PetSaveMode mode)
bool CanTameExoticPets() const
void PetSpellInitialize()
uint32 GetPhaseMaskForSpawn() const
void setUInt16(uint8 index, uint16 value)
void setUInt32(uint8 index, uint32 value)
void setFloat(uint8 index, float value)
void setUInt8(uint8 index, uint8 value)
virtual void SetData(uint32, uint32)
void ClearUnitState(uint32 f)
void SetMinion(Minion *minion, bool apply)
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
NPCFlags GetNpcFlags() const
void SetFaction(uint32 faction) override
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Pet * CreateTamedPetFrom(Creature *creatureTarget, uint32 spell_id=0)
MotionMaster * GetMotionMaster()
bool HasUnitFlag(UnitFlags flags) const
void CleanupsBeforeDelete(bool finalCleanup=true) override
uint32 GetMaxHealth() const
float GetCombatReach() const override
void SetHealth(uint32 val)
UnitFlags GetUnitFlags() const
TempSummon * ToTempSummon()
void SetNativeDisplayId(uint32 displayId)
void SetEmoteState(Emote emote)
uint32 GetDisplayId() const
uint32 GetNativeDisplayId() const
uint32 GetFaction() const override
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
uint32 GetCreateHealth() const
virtual float GetFollowAngle() const
void SetLevel(uint8 lvl, bool sendUpdate=true)
void HandleEmoteCommand(Emote emoteId)
void SetMaxHealth(uint32 val)
void ReplaceAllNpcFlags(NPCFlags flags)
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
UnitFlags2 GetUnitFlags2() const
uint32 GetDynamicFlags() const override
ObjectGuid GetPetGUID() const
uint32 GetPhaseMask() const
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
float GetTransOffsetX() const
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
uint32 GetInstanceId() const
float GetTransOffsetY() const
std::string const & GetName() const
float GetTransOffsetZ() const
Transport * GetTransport() const
float GetTransOffsetO() const
Player * GetPlayer() const
static bool HandleNpcAddFormationCommand(ChatHandler *handler, ObjectGuid::LowType leaderGUID)
static bool HandleNpcSetWanderDistanceCommand(ChatHandler *handler, float option)
static bool HandleNpcAddCommand(ChatHandler *handler, CreatureEntry id)
static bool HandleNpcTameCommand(ChatHandler *handler)
static bool HandleNpcTextEmoteCommand(ChatHandler *handler, Tail text)
static bool HandleNpcAddVendorItemCommand(ChatHandler *handler, ItemTemplate const *item, Optional< uint32 > mc, Optional< uint32 > it, Optional< uint32 > ec)
static void _IterateNotNormalLootMap(ChatHandler *handler, NotNormalLootItemMap const &map, std::vector< LootItem > const &items)
static bool HandleNpcDeleteCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnIdArg)
static bool HandleNpcSetModelCommand(ChatHandler *handler, uint32 displayId)
static bool HandleNpcYellCommand(ChatHandler *handler, Tail text)
static bool HandleNpcSetPhaseCommand(ChatHandler *handler, uint32 phasemask)
static bool HandleNpcFollowCommand(ChatHandler *handler)
static bool HandleNpcSetSpawnTimeCommand(ChatHandler *handler, uint32 spawnTime)
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 HandleNpcUnFollowCommand(ChatHandler *handler)
static bool HandleNpcSetLevelCommand(ChatHandler *handler, uint8 lvl)
static bool HandleNpcSetAllowMovementCommand(ChatHandler *handler)
static bool HandleNpcShowLootCommand(ChatHandler *handler, Optional< EXACT_SEQUENCE("all")> all)
static bool HandleNpcSayCommand(ChatHandler *handler, Tail text)
static bool HandleNpcInfoCommand(ChatHandler *handler)
static bool HandleNpcAddWeaponCommand(ChatHandler *handler, uint32 SlotID, ItemTemplate const *tmpItem)
static bool HandleNpcNearCommand(ChatHandler *handler, Optional< float > dist)
static bool HandleNpcDeleteVendorItemCommand(ChatHandler *handler, ItemTemplate const *item)
static bool HandleNpcSetDataCommand(ChatHandler *handler, uint32 data_1, uint32 data_2)
static void _ShowLootEntry(ChatHandler *handler, uint32 itemId, uint8 itemCount, bool alternateString=false)
static bool HandleNpcPlayEmoteCommand(ChatHandler *handler, Emote emote)
static bool HandleNpcSetFlagCommand(ChatHandler *handler, NPCFlags npcFlags)
static bool HandleNpcEvadeCommand(ChatHandler *handler, Optional< CreatureAI::EvadeReason > why, Optional< EXACT_SEQUENCE("force")> force)
static bool HandleNpcSetLinkCommand(ChatHandler *handler, ObjectGuid::LowType linkguid)
static bool HandleNpcWhisperCommand(ChatHandler *handler, Variant< Hyperlink< player >, std::string_view > recv, Tail text)
ChatCommandTable GetCommands() const override
static bool HandleNpcMoveCommand(ChatHandler *handler, Optional< CreatureSpawnId > spawnid)
static bool HandleNpcSetFactionIdCommand(ChatHandler *handler, uint32 factionId)
static bool HandleNpcSetEntryCommand(ChatHandler *handler, CreatureEntry newEntryNum)
static bool HandleNpcAddMoveCommand(ChatHandler *handler, CreatureSpawnId lowGuid)
static bool HandleNpcAddTempSpawnCommand(ChatHandler *handler, Optional< std::string_view > lootStr, CreatureEntry id)
bool HandleNpcSpawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("force"), EXACT_SEQUENCE("ignorerespawn")> > const &opts)
void AddSC_npc_commandscript()
bool HandleNpcDespawnGroup(ChatHandler *handler, std::vector< Variant< uint32, EXACT_SEQUENCE("removerespawntime")> > const &opts)
@ CONFIG_MAX_PLAYER_LEVEL
TC_GAME_API Player * FindPlayerByName(std::string_view name)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
std::vector< ChatCommandBuilder > ChatCommandTable
std::string ToString(Type &&val, Params &&... params)
std::string GetTypeName()
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
@ RBAC_PERM_COMMAND_NPC_SET_LEVEL
@ RBAC_PERM_COMMAND_NPC_PLAYEMOTE
@ RBAC_PERM_COMMAND_NPC_FOLLOW
@ RBAC_PERM_COMMAND_NPC_EVADE
@ RBAC_PERM_COMMAND_NPC_INFO
@ RBAC_PERM_COMMAND_NPC_TEXTEMOTE
@ RBAC_PERM_COMMAND_NPC_ADD_FORMATION
@ RBAC_PERM_COMMAND_NPC_ADD
@ RBAC_PERM_COMMAND_NPC_NEAR
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNDIST
@ RBAC_PERM_COMMAND_NPC_SET_PHASE
@ RBAC_PERM_COMMAND_NPC_DELETE
@ RBAC_PERM_COMMAND_NPC_SET_ENTRY
@ RBAC_PERM_COMMAND_NPC_DESPAWNGROUP
@ RBAC_PERM_COMMAND_NPC_TAME
@ RBAC_PERM_COMMAND_NPC_MOVE
@ RBAC_PERM_COMMAND_NPC_ADD_ITEM
@ RBAC_PERM_COMMAND_NPC_SET_SPAWNTIME
@ RBAC_PERM_COMMAND_NPC_SET_FACTIONID
@ RBAC_PERM_COMMAND_NPC_SET_MOVETYPE
@ RBAC_PERM_COMMAND_NPC_SPAWNGROUP
@ RBAC_PERM_COMMAND_NPC_SET_DATA
@ RBAC_PERM_COMMAND_NPC_SHOWLOOT
@ RBAC_PERM_COMMAND_NPC_SET_ALLOWMOVE
@ RBAC_PERM_COMMAND_NPC_SET_MODEL
@ RBAC_PERM_COMMAND_NPC_ADD_MOVE
@ RBAC_PERM_COMMAND_NPC_SET_LINK
@ RBAC_PERM_COMMAND_NPC_WHISPER
@ RBAC_PERM_COMMAND_NPC_SET_FLAG
@ RBAC_PERM_COMMAND_NPC_YELL
@ RBAC_PERM_COMMAND_NPC_SAY
@ RBAC_PERM_COMMAND_NPC_ADD_TEMP
@ RBAC_PERM_COMMAND_NPC_DELETE_ITEM
std::string ToString() const
uint32 MechanicImmuneMask
bool IsTameable(bool canTameExotic) const
std::vector< std::string > Name
NotNormalLootItemMap const & GetPlayerQuestItems() const
NotNormalLootItemMap const & GetPlayerNonQuestNonFFAConditionalItems() const
std::vector< LootItem > items
NotNormalLootItemMap const & GetPlayerFFAItems() const
std::vector< LootItem > quest_items
float GetPositionZ() const
float GetOrientation() const
float GetAbsoluteAngle(float x, float y) const
float GetPositionX() const
void GetPosition(float &x, float &y) const
float GetPositionY() const
void Relocate(float x, float y)