25#include <boost/preprocessor/punctuation/remove_parens.hpp>
98#define VISIBLE_RANGE 166.0f
187 std::string
const&
GetName()
const;
225 virtual void OnNetworkStart();
228 virtual void OnNetworkStop();
231 virtual void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
235 virtual void OnSocketClose(std::shared_ptr<WorldSocket> socket);
257 virtual void OnOpenStateChange(
bool open);
260 virtual void OnConfigLoad(
bool reload);
263 virtual void OnMotdChange(std::string& newMotd);
269 virtual void OnShutdownCancel();
272 virtual void OnUpdate(
uint32 diff);
275 virtual void OnStartup();
278 virtual void OnShutdown();
292 virtual void OnHonorCalculation(
float& honor,
uint8 level,
float multiplier);
295 virtual void OnGrayLevelCalculation(
uint8& grayLevel,
uint8 playerLevel);
301 virtual void OnZeroDifferenceCalculation(
uint8& diff,
uint8 playerLevel);
304 virtual void OnBaseGainCalculation(
uint32& gain,
uint8 playerLevel,
uint8 mobLevel);
310 virtual void OnGroupRateCalculation(
float& rate,
uint32 count,
bool isRaid);
328 virtual void OnCreate(TMap* map);
331 virtual void OnDestroy(TMap* map);
334 virtual void OnPlayerEnter(TMap* map,
Player* player);
337 virtual void OnPlayerLeave(TMap* map,
Player* player);
339 virtual void OnUpdate(TMap* map,
uint32 diff);
392 virtual bool OnQuestAccept(
Player* player,
Item* item,
Quest const* quest);
401 virtual bool OnRemove(
Player* player,
Item* item);
421 virtual void OnDamage(
Unit* attacker,
Unit* victim,
uint32& damage);
424 virtual void ModifyPeriodicDamageAurasTick(
Unit* target,
Unit* attacker,
uint32& damage);
427 virtual void ModifyMeleeDamage(
Unit* target,
Unit* attacker,
uint32& damage);
430 virtual void ModifySpellDamageTaken(
Unit* target,
Unit* attacker,
int32& damage,
SpellInfo const* spellInfo);
533 virtual std::vector<Trinity::ChatCommands::ChatCommandBuilder>
GetCommands()
const = 0;
600 virtual void OnInstall(
Vehicle* veh);
603 virtual void OnUninstall(
Vehicle* veh);
606 virtual void OnReset(
Vehicle* veh);
612 virtual void OnAddPassenger(
Vehicle* veh,
Unit* passenger,
int8 seatId);
615 virtual void OnRemovePassenger(
Vehicle* veh,
Unit* passenger);
651 virtual void OnRelocate(
Transport* transport,
uint32 mapId,
float x,
float y,
float z);
701 virtual void OnPlayerKilledByCreature(
Creature* killer,
Player* killed);
704 virtual void OnLevelChanged(
Player* player,
uint8 oldLevel);
707 virtual void OnFreeTalentPointsChanged(
Player* player,
uint32 points);
710 virtual void OnTalentsReset(
Player* player,
bool noCost);
713 virtual void OnMoneyChanged(
Player* player,
int64& amount);
716 virtual void OnMoneyLimit(
Player* player,
int64 amount);
722 virtual void OnReputationChange(
Player* player,
uint32 factionId,
int32& standing,
bool incremental);
725 virtual void OnDuelRequest(
Player* target,
Player* challenger);
728 virtual void OnDuelStart(
Player* player1,
Player* player2);
745 virtual void OnClearEmote(
Player* player);
750 virtual void OnSpellCast(
Player* player,
Spell* spell,
bool skipCheck);
753 virtual void OnLogin(
Player* player,
bool firstLogin);
756 virtual void OnLogout(
Player* player);
759 virtual void OnCreate(
Player* player);
768 virtual void OnSave(
Player* player);
777 virtual void OnMapChanged(
Player* player);
780 virtual void OnQuestStatusChange(
Player* player,
uint32 questId);
783 virtual void OnPlayerRepop(
Player* player);
786 virtual void OnMovieComplete(
Player* player,
uint32 movieId);
789 virtual void OnPlayerChoiceResponse(
Player* player,
uint32 choiceId,
uint32 responseId);
803 virtual void OnAccountLogin(
uint32 accountId);
806 virtual void OnFailedAccountLogin(
uint32 accountId);
809 virtual void OnEmailChange(
uint32 accountId);
812 virtual void OnFailedEmailChange(
uint32 accountId);
815 virtual void OnPasswordChange(
uint32 accountId);
818 virtual void OnFailedPasswordChange(
uint32 accountId);
835 virtual void OnRemoveMember(
Guild* guild,
ObjectGuid guid,
bool isDisbanding,
bool isKicked);
838 virtual void OnMOTDChanged(
Guild* guild, std::string
const& newMotd);
841 virtual void OnInfoChanged(
Guild* guild, std::string
const& newInfo);
844 virtual void OnCreate(
Guild* guild,
Player* leader, std::string
const& name);
847 virtual void OnDisband(
Guild* guild);
850 virtual void OnMemberWitdrawMoney(
Guild* guild,
Player* player,
uint64& amount,
bool isRepair);
857 bool isDestBank,
uint8 destContainer,
uint8 destSlotId);
887 virtual void OnDisband(
Group* group);
915 virtual void OnConversationCreate(
Conversation* conversation,
Unit* creator);
918 virtual void OnConversationStart(
Conversation* conversation);
941 virtual void OnSceneTriggerEvent(
Player* player,
uint32 sceneInstanceID,
SceneTemplate const* sceneTemplate, std::string
const& triggerName);
964 virtual void OnAcknowledgeAutoAccept(
Player* player,
Quest const* quest);
981 virtual void OnValueChange(
int32 worldStateId,
int32 oldValue,
int32 newValue,
Map const* map);
1012 void FillSpellSummary();
1013 void LoadDatabase();
1025 typedef void(*ScriptLoaderCallbackType)();
1031 _script_loader_callback = script_loader_callback;
1036 void NotifyScriptIDUpdate();
1044 void SetScriptContext(std::string
const& context);
1049 void ReleaseScriptContext(std::string
const& context);
1053 void SwapScriptContext(
bool initialize =
false);
1056 static std::string
const& GetNameOfStaticContext();
1061 std::shared_ptr<ModuleReference> AcquireModuleReferenceOfScriptName(
1062 std::string
const& scriptname)
const;
1070 void CreateSpellScripts(
uint32 spellId, std::vector<SpellScript*>& scriptVector,
Spell* invoker)
const;
1071 void CreateAuraScripts(
uint32 spellId, std::vector<AuraScript*>& scriptVector,
Aura* invoker)
const;
1076 void OnNetworkStart();
1077 void OnNetworkStop();
1078 void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
1079 void OnSocketClose(std::shared_ptr<WorldSocket> socket);
1085 void OnOpenStateChange(
bool open);
1086 void OnConfigLoad(
bool reload);
1087 void OnMotdChange(std::string& newMotd);
1089 void OnShutdownCancel();
1090 void OnWorldUpdate(
uint32 diff);
1096 void OnHonorCalculation(
float& honor,
uint8 level,
float multiplier);
1097 void OnGrayLevelCalculation(
uint8& grayLevel,
uint8 playerLevel);
1099 void OnZeroDifferenceCalculation(
uint8& diff,
uint8 playerLevel);
1100 void OnBaseGainCalculation(
uint32& gain,
uint8 playerLevel,
uint8 mobLevel);
1102 void OnGroupRateCalculation(
float& rate,
uint32 count,
bool isRaid);
1106 void OnCreateMap(
Map* map);
1107 void OnDestroyMap(
Map* map);
1108 void OnPlayerEnterMap(
Map* map,
Player* player);
1109 void OnPlayerLeaveMap(
Map* map,
Player* player);
1110 void OnMapUpdate(
Map* map,
uint32 diff);
1121 bool OnItemRemove(
Player* player,
Item* item);
1126 bool CanCreateCreatureAI(
uint32 scriptId)
const;
1131 bool CanCreateGameObjectAI(
uint32 scriptId)
const;
1152 std::vector<Trinity::ChatCommands::ChatCommandBuilder> GetChatCommands();
1173 void OnUninstall(
Vehicle* veh);
1177 void OnRemovePassenger(
Vehicle* veh,
Unit* passenger);
1189 void OnRelocate(
Transport* transport,
uint32 mapId,
float x,
float y,
float z);
1204 void OnPlayerLevelChanged(
Player* player,
uint8 oldLevel);
1205 void OnPlayerFreeTalentPointsChanged(
Player* player,
uint32 newPoints);
1206 void OnPlayerTalentsReset(
Player* player,
bool noCost);
1207 void OnPlayerMoneyChanged(
Player* player,
int64& amount);
1208 void OnPlayerMoneyLimit(
Player* player,
int64 amount);
1210 void OnPlayerReputationChange(
Player* player,
uint32 factionID,
int32& standing,
bool incremental);
1211 void OnPlayerDuelRequest(
Player* target,
Player* challenger);
1212 void OnPlayerDuelStart(
Player* player1,
Player* player2);
1219 void OnPlayerClearEmote(
Player* player);
1221 void OnPlayerSpellCast(
Player* player,
Spell* spell,
bool skipCheck);
1222 void OnPlayerLogin(
Player* player,
bool firstLogin);
1223 void OnPlayerLogout(
Player* player);
1224 void OnPlayerCreate(
Player* player);
1227 void OnPlayerSave(
Player* player);
1230 void OnQuestStatusChange(
Player* player,
uint32 questId);
1231 void OnPlayerRepop(
Player* player);
1237 void OnAccountLogin(
uint32 accountId);
1238 void OnFailedAccountLogin(
uint32 accountId);
1239 void OnEmailChange(
uint32 accountId);
1240 void OnFailedEmailChange(
uint32 accountId);
1241 void OnPasswordChange(
uint32 accountId);
1242 void OnFailedPasswordChange(
uint32 accountId);
1247 void OnGuildRemoveMember(
Guild* guild,
ObjectGuid guid,
bool isDisbanding,
bool isKicked);
1248 void OnGuildMOTDChanged(
Guild* guild,
const std::string& newMotd);
1249 void OnGuildInfoChanged(
Guild* guild,
const std::string& newInfo);
1250 void OnGuildCreate(
Guild* guild,
Player* leader,
const std::string& name);
1251 void OnGuildDisband(
Guild* guild);
1252 void OnGuildMemberWitdrawMoney(
Guild* guild,
Player* player,
uint64 &amount,
bool isRepair);
1255 bool isDestBank,
uint8 destContainer,
uint8 destSlotId);
1265 void OnGroupDisband(
Group* group);
1271 void ModifyPeriodicDamageAurasTick(
Unit* target,
Unit* attacker,
uint32& damage);
1272 void ModifyMeleeDamage(
Unit* target,
Unit* attacker,
uint32& damage);
1277 bool CanCreateAreaTriggerAI(
uint32 scriptId)
const;
1290 void OnSceneTrigger(
Player* player,
uint32 sceneInstanceID,
SceneTemplate const* sceneTemplate, std::string
const& triggerName);
1297 void OnQuestAcknowledgeAutoAccept(
Player* player,
Quest const* quest);
1319 template<
typename T>
1322 template<
typename T>
1326template <
typename... Ts>
1333 static_assert(!std::conjunction_v<std::is_same<SpellScriptType, Trinity::find_type_end>, std::is_same<AuraScriptType, Trinity::find_type_end>>,
"At least one of SpellScript/AuraScript arguments must be provided for GenericSpellAndAuraScriptLoader");
1341 if constexpr (!std::is_same_v<SpellScriptType, Trinity::find_type_end>)
1342 return Trinity::new_from_tuple<SpellScriptType>(
_args);
1349 if constexpr (!std::is_same_v<AuraScriptType, Trinity::find_type_end>)
1350 return Trinity::new_from_tuple<AuraScriptType>(
_args);
1358#define RegisterSpellScriptWithArgs(spell_script, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(spell_script), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__))
1359#define RegisterSpellScript(spell_script) RegisterSpellScriptWithArgs(spell_script, #spell_script)
1360#define RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(script_1), BOOST_PP_REMOVE_PARENS(script_2), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__))
1361#define RegisterSpellAndAuraScriptPair(script_1, script_2) RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, #script_1)
1370#define RegisterCreatureAI(ai_name) new GenericCreatureScript<ai_name>(#ai_name)
1372template <
class AI, AI* (*AIFactory)(Creature*)>
1379#define RegisterCreatureAIWithFactory(ai_name, factory_fn) new FactoryCreatureScript<ai_name, &factory_fn>(#ai_name)
1388#define RegisterGameObjectAI(ai_name) new GenericGameObjectScript<ai_name>(#ai_name)
1390template <
class AI, AI* (*AIFactory)(GameObject*)>
1397#define RegisterGameObjectAIWithFactory(ai_name, factory_fn) new FactoryGameObjectScript<ai_name, &factory_fn>(#ai_name)
1406#define RegisterAreaTriggerAI(ai_name) new GenericAreaTriggerEntityScript<ai_name>(#ai_name)
1408template<
class Script>
1416#define RegisterBattlegroundMapScript(script_name, mapId) new GenericBattlegroundMapScript<script_name>(#script_name, mapId)
1418#define sScriptMgr ScriptMgr::instance()
T GetEntry(std::unordered_map< uint32, T > const &map, CriteriaTreeEntry const *tree)
virtual bool OnCheck(Player *source, Unit *target)=0
~AchievementCriteriaScript()
~AreaTriggerEntityScript()
AreaTriggerScript(char const *name)
virtual Battlefield * GetBattlefield(Map *map) const =0
virtual std::vector< Trinity::ChatCommands::ChatCommandBuilder > GetCommands() const =0
virtual CreatureAI * GetAI(Creature *creature) const =0
CreatureAI * GetAI(Creature *me) const override
FactoryCreatureScript(char const *name)
GameObjectAI * GetAI(GameObject *me) const override
FactoryGameObjectScript(char const *name)
virtual GameObjectAI * GetAI(GameObject *go) const =0
GenericAreaTriggerEntityScript(char const *name)
AreaTriggerAI * GetAI(AreaTrigger *at) const override
BattlegroundScript * GetBattlegroundScript(BattlegroundMap *map) const override
GenericBattlegroundMapScript(char const *name, uint32 mapId)
GenericCreatureScript(char const *name)
CreatureAI * GetAI(Creature *me) const override
GenericGameObjectScript(char const *name)
GameObjectAI * GetAI(GameObject *go) const override
typename Trinity::find_type_if_t< Trinity::SpellScripts::is_AuraScript, Ts... > AuraScriptType
AuraScript * GetAuraScript() const override
typename Trinity::find_type_if_t< Trinity::SpellScripts::is_SpellScript, Ts... > SpellScriptType
SpellScript * GetSpellScript() const override
typename Trinity::find_type_if_t< Trinity::is_tuple, Ts... > ArgsType
GenericSpellAndAuraScriptLoader(char const *name, ArgsType &&args)
MapEntry const * _mapEntry
virtual bool TryHandleOnce(Player *player, AreaTriggerEntry const *trigger)=0
~OnlyOnceAreaTriggerScript()
virtual OutdoorPvP * GetOutdoorPvP(Map *map) const =0
void IncreaseScriptCount()
void SetScriptLoader(ScriptLoaderCallbackType script_loader_callback)
void DecreaseScriptCount()
ScriptMgr(ScriptMgr &&right)=delete
uint32 GetScriptCount() const
ScriptMgr(ScriptMgr const &right)=delete
ScriptMgr & operator=(ScriptMgr &&right)=delete
std::string const & GetCurrentScriptContext() const
Returns the current script context.
ScriptMgr & operator=(ScriptMgr const &right)=delete
friend class ScriptObject
std::string _currentContext
ScriptLoaderCallbackType _script_loader_callback
ScriptObject(ScriptObject &&right)=delete
ScriptObject & operator=(ScriptObject &&right)=delete
ScriptObject(ScriptObject const &right)=delete
ScriptObject & operator=(ScriptObject const &right)=delete
Player session in the World.
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
std::is_base_of< AuraScript, T > is_AuraScript
std::is_base_of< SpellScript, T > is_SpellScript
typename find_type_if< Check, Ts... >::type find_type_if_t