Advertisement
Guest User

ScriptMgr.h

a guest
Sep 24th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 45.00 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
  3.  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify it
  6.  * under the terms of the GNU General Public License as published by the
  7.  * Free Software Foundation; either version 2 of the License, or (at your
  8.  * option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT
  11.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13.  * more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License along
  16.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #ifndef SC_SCRIPTMGR_H
  20. #define SC_SCRIPTMGR_H
  21.  
  22. #include "Common.h"
  23. #include <atomic>
  24. #include "DBCStores.h"
  25. #include "QuestDef.h"
  26. #include "SharedDefines.h"
  27. #include "World.h"
  28. #include "Weather.h"
  29.  
  30. class AccountMgr;
  31. class AuctionHouseObject;
  32. class AuraScript;
  33. class Battleground;
  34. class BattlegroundMap;
  35. class Channel;
  36. class ChatCommand;
  37. class Creature;
  38. class CreatureAI;
  39. class DynamicObject;
  40. class GameObject;
  41. class GameObjectAI;
  42. class Guild;
  43. class GridMap;
  44. class Group;
  45. class InstanceMap;
  46. class InstanceScript;
  47. class Item;
  48. class Map;
  49. class ModuleReference;
  50. class OutdoorPvP;
  51. class Player;
  52. class Quest;
  53. class ScriptMgr;
  54. class Spell;
  55. class SpellScript;
  56. class SpellCastTargets;
  57. class Transport;
  58. class Unit;
  59. class Vehicle;
  60. class WorldPacket;
  61. class WorldSocket;
  62. class WorldObject;
  63. class WorldSession;
  64.  
  65. struct AchievementCriteriaData;
  66. struct AuctionEntry;
  67. struct ConditionSourceInfo;
  68. struct Condition;
  69. struct ItemTemplate;
  70. struct OutdoorPvPData;
  71.  
  72. #define VISIBLE_RANGE       166.0f                          //MAX visible range (size of grid)
  73.  
  74.  
  75. /*
  76.     @todo Add more script type classes.
  77.  
  78.     MailScript
  79.     SessionScript
  80.     CollisionScript
  81.     ArenaTeamScript
  82.  
  83. */
  84.  
  85. /*
  86.     Standard procedure when adding new script type classes:
  87.  
  88.     First of all, define the actual class, and have it inherit from ScriptObject, like so:
  89.  
  90.     class MyScriptType : public ScriptObject
  91.     {
  92.         uint32 _someId;
  93.  
  94.         private:
  95.  
  96.             void RegisterSelf();
  97.  
  98.         protected:
  99.  
  100.             MyScriptType(const char* name, uint32 someId)
  101.                 : ScriptObject(name), _someId(someId)
  102.             {
  103.                 ScriptRegistry<MyScriptType>::AddScript(this);
  104.             }
  105.  
  106.         public:
  107.  
  108.             // If a virtual function in your script type class is not necessarily
  109.             // required to be overridden, just declare it virtual with an empty
  110.             // body. If, on the other hand, it's logical only to override it (i.e.
  111.            // if it's the only method in the class), make it pure virtual, by adding
  112.             // = 0 to it.
  113.             virtual void OnSomeEvent(uint32 someArg1, std::string& someArg2) { }
  114.  
  115.             // This is a pure virtual function:
  116.             virtual void OnAnotherEvent(uint32 someArg) = 0;
  117.     }
  118.  
  119.     Next, you need to add a specialization for ScriptRegistry. Put this in the bottom of
  120.     ScriptMgr.cpp:
  121.  
  122.     template class ScriptRegistry<MyScriptType>;
  123.  
  124.     Now, add a cleanup routine in ScriptMgr::~ScriptMgr:
  125.  
  126.     SCR_CLEAR(MyScriptType);
  127.  
  128.     Now your script type is good to go with the script system. What you need to do now
  129.     is add functions to ScriptMgr that can be called from the core to actually trigger
  130.     certain events. For example, in ScriptMgr.h:
  131.  
  132.     void OnSomeEvent(uint32 someArg1, std::string& someArg2);
  133.     void OnAnotherEvent(uint32 someArg);
  134.  
  135.     In ScriptMgr.cpp:
  136.  
  137.     void ScriptMgr::OnSomeEvent(uint32 someArg1, std::string& someArg2)
  138.     {
  139.         FOREACH_SCRIPT(MyScriptType)->OnSomeEvent(someArg1, someArg2);
  140.     }
  141.  
  142.     void ScriptMgr::OnAnotherEvent(uint32 someArg)
  143.     {
  144.         FOREACH_SCRIPT(MyScriptType)->OnAnotherEvent(someArg1, someArg2);
  145.     }
  146.  
  147.     Now you simply call these two functions from anywhere in the core to trigger the
  148.     event on all registered scripts of that type.
  149. */
  150.  
  151. class TC_GAME_API ScriptObject
  152. {
  153.     friend class ScriptMgr;
  154.  
  155.     public:
  156.  
  157.         const std::string& GetName() const { return _name; }
  158.  
  159.     protected:
  160.  
  161.         ScriptObject(const char* name);
  162.         virtual ~ScriptObject();
  163.  
  164.     private:
  165.  
  166.         const std::string _name;
  167. };
  168.  
  169. template<class TObject> class UpdatableScript
  170. {
  171.     protected:
  172.  
  173.         UpdatableScript()
  174.         {
  175.         }
  176.  
  177.         virtual ~UpdatableScript() { }
  178.  
  179.     public:
  180.  
  181.         virtual void OnUpdate(TObject* /*obj*/, uint32 /*diff*/) { }
  182. };
  183.  
  184. class TC_GAME_API SpellScriptLoader : public ScriptObject
  185. {
  186.     protected:
  187.  
  188.         SpellScriptLoader(const char* name);
  189.  
  190.     public:
  191.  
  192.         // Should return a fully valid SpellScript pointer.
  193.         virtual SpellScript* GetSpellScript() const { return NULL; }
  194.  
  195.         // Should return a fully valid AuraScript pointer.
  196.         virtual AuraScript* GetAuraScript() const { return NULL; }
  197. };
  198.  
  199. class TC_GAME_API ServerScript : public ScriptObject
  200. {
  201.     protected:
  202.  
  203.         ServerScript(const char* name);
  204.  
  205.     public:
  206.  
  207.         // Called when reactive socket I/O is started (WorldTcpSessionMgr).
  208.         virtual void OnNetworkStart() { }
  209.  
  210.         // Called when reactive I/O is stopped.
  211.         virtual void OnNetworkStop() { }
  212.  
  213.         // Called when a remote socket establishes a connection to the server. Do not store the socket object.
  214.         virtual void OnSocketOpen(std::shared_ptr<WorldSocket> /*socket*/) { }
  215.  
  216.         // Called when a socket is closed. Do not store the socket object, and do not rely on the connection
  217.         // being open; it is not.
  218.         virtual void OnSocketClose(std::shared_ptr<WorldSocket> /*socket*/) { }
  219.  
  220.         // Called when a packet is sent to a client. The packet object is a copy of the original packet, so reading
  221.         // and modifying it is safe.
  222.         virtual void OnPacketSend(WorldSession* /*session*/, WorldPacket& /*packet*/) { }
  223.  
  224.         // Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so
  225.         // reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets
  226.         virtual void OnPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { }
  227. };
  228.  
  229. class TC_GAME_API WorldScript : public ScriptObject
  230. {
  231.     protected:
  232.  
  233.         WorldScript(const char* name);
  234.  
  235.     public:
  236.  
  237.         // Called when the open/closed state of the world changes.
  238.         virtual void OnOpenStateChange(bool /*open*/) { }
  239.  
  240.         // Called after the world configuration is (re)loaded.
  241.         virtual void OnConfigLoad(bool /*reload*/) { }
  242.  
  243.         // Called before the message of the day is changed.
  244.         virtual void OnMotdChange(std::string& /*newMotd*/) { }
  245.  
  246.         // Called when a world shutdown is initiated.
  247.         virtual void OnShutdownInitiate(ShutdownExitCode /*code*/, ShutdownMask /*mask*/) { }
  248.  
  249.         // Called when a world shutdown is cancelled.
  250.         virtual void OnShutdownCancel() { }
  251.  
  252.         // Called on every world tick (don't execute too heavy code here).
  253.        virtual void OnUpdate(uint32 /*diff*/) { }
  254.  
  255.        // Called when the world is started.
  256.        virtual void OnStartup() { }
  257.  
  258.        // Called when the world is actually shut down.
  259.        virtual void OnShutdown() { }
  260. };
  261.  
  262. class TC_GAME_API FormulaScript : public ScriptObject
  263. {
  264.    protected:
  265.  
  266.        FormulaScript(const char* name);
  267.  
  268.    public:
  269.  
  270.        // Called after calculating honor.
  271.        virtual void OnHonorCalculation(float& /*honor*/, uint8 /*level*/, float /*multiplier*/) { }
  272.  
  273.        // Called after gray level calculation.
  274.        virtual void OnGrayLevelCalculation(uint8& /*grayLevel*/, uint8 /*playerLevel*/) { }
  275.  
  276.        // Called after calculating experience color.
  277.        virtual void OnColorCodeCalculation(XPColorChar& /*color*/, uint8 /*playerLevel*/, uint8 /*mobLevel*/) { }
  278.  
  279.        // Called after calculating zero difference.
  280.        virtual void OnZeroDifferenceCalculation(uint8& /*diff*/, uint8 /*playerLevel*/) { }
  281.  
  282.        // Called after calculating base experience gain.
  283.        virtual void OnBaseGainCalculation(uint32& /*gain*/, uint8 /*playerLevel*/, uint8 /*mobLevel*/, ContentLevels /*content*/) { }
  284.  
  285.        // Called after calculating experience gain.
  286.        virtual void OnGainCalculation(uint32& /*gain*/, Player* /*player*/, Unit* /*unit*/) { }
  287.  
  288.        // Called when calculating the experience rate for group experience.
  289.        virtual void OnGroupRateCalculation(float& /*rate*/, uint32 /*count*/, bool /*isRaid*/) { }
  290. };
  291.  
  292. template<class TMap> class MapScript : public UpdatableScript<TMap>
  293. {
  294.    MapEntry const* _mapEntry;
  295.  
  296.    protected:
  297.  
  298.        MapScript(uint32 mapId)
  299.            : _mapEntry(sMapStore.LookupEntry(mapId))
  300.        {
  301.            if (!_mapEntry)
  302.                TC_LOG_ERROR("scripts", "Invalid MapScript for %u; no such map ID.", mapId);
  303.        }
  304.  
  305.    public:
  306.  
  307.        // Gets the MapEntry structure associated with this script. Can return NULL.
  308.        MapEntry const* GetEntry() { return _mapEntry; }
  309.  
  310.        // Called when the map is created.
  311.        virtual void OnCreate(TMap* /*map*/) { }
  312.  
  313.        // Called just before the map is destroyed.
  314.        virtual void OnDestroy(TMap* /*map*/) { }
  315.  
  316.        // Called when a grid map is loaded.
  317.        virtual void OnLoadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/) { }
  318.  
  319.        // Called when a grid map is unloaded.
  320.        virtual void OnUnloadGridMap(TMap* /*map*/, GridMap* /*gmap*/, uint32 /*gx*/, uint32 /*gy*/)  { }
  321.  
  322.        // Called when a player enters the map.
  323.        virtual void OnPlayerEnter(TMap* /*map*/, Player* /*player*/) { }
  324.  
  325.        // Called when a player leaves the map.
  326.        virtual void OnPlayerLeave(TMap* /*map*/, Player* /*player*/) { }
  327. };
  328.  
  329. class TC_GAME_API WorldMapScript : public ScriptObject, public MapScript<Map>
  330. {
  331.    protected:
  332.  
  333.        WorldMapScript(const char* name, uint32 mapId);
  334. };
  335.  
  336. class TC_GAME_API InstanceMapScript
  337.    : public ScriptObject, public MapScript<InstanceMap>
  338. {
  339.    protected:
  340.  
  341.        InstanceMapScript(const char* name, uint32 mapId);
  342.  
  343.    public:
  344.  
  345.        // Gets an InstanceScript object for this instance.
  346.        virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; }
  347. };
  348.  
  349. class TC_GAME_API BattlegroundMapScript : public ScriptObject, public MapScript<BattlegroundMap>
  350. {
  351.    protected:
  352.  
  353.        BattlegroundMapScript(const char* name, uint32 mapId);
  354. };
  355.  
  356. class TC_GAME_API ItemScript : public ScriptObject
  357. {
  358.    protected:
  359.  
  360.        ItemScript(const char* name);
  361.  
  362.    public:
  363.  
  364.        // Called when a dummy spell effect is triggered on the item.
  365.        virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; }
  366.  
  367.        // Called when a player accepts a quest from the item.
  368.        virtual bool OnQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return false; }
  369.  
  370.        // Called when a player uses the item.
  371.        virtual bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; }
  372.  
  373.        // Called when the item expires (is destroyed).
  374.        virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
  375.  
  376.        // Called when the item is destroyed.
  377.        virtual bool OnRemove(Player* /*player*/, Item* /*item*/) { return false; }
  378.  
  379.        // Called when a player selects an option in an item gossip window
  380.        virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
  381.  
  382.        // Called when a player selects an option in an item gossip window
  383.        virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
  384. };
  385.  
  386. class TC_GAME_API UnitScript : public ScriptObject
  387. {
  388.    protected:
  389.  
  390.        UnitScript(const char* name, bool addToScripts = true);
  391.  
  392.    public:
  393.        // Called when a unit deals healing to another unit
  394.        virtual void OnHeal(Unit* /*healer*/, Unit* /*reciever*/, uint32& /*gain*/) { }
  395.  
  396.        // Called when a unit deals damage to another unit
  397.        virtual void OnDamage(Unit* /*attacker*/, Unit* /*victim*/, uint32& /*damage*/) { }
  398.  
  399.        // Called when DoT's Tick Damage is being Dealt
  400.         virtual void ModifyPeriodicDamageAurasTick(Unit* /*target*/, Unit* /*attacker*/, uint32& /*damage*/) { }
  401.  
  402.         // Called when Melee Damage is being Dealt
  403.         virtual void ModifyMeleeDamage(Unit* /*target*/, Unit* /*attacker*/, uint32& /*damage*/) { }
  404.  
  405.         // Called when Spell Damage is being Dealt
  406.         virtual void ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, int32& /*damage*/) { }
  407. };
  408.  
  409. class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScript<Creature>
  410. {
  411.     protected:
  412.  
  413.         CreatureScript(const char* name);
  414.  
  415.     public:
  416.  
  417.         // Called when a dummy spell effect is triggered on the creature.
  418.         virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Creature* /*target*/) { return false; }
  419.  
  420.         // Called when a player opens a gossip dialog with the creature.
  421.         virtual bool OnGossipHello(Player* /*player*/, Creature* /*creature*/) { return false; }
  422.  
  423.         // Called when a player selects a gossip item in the creature's gossip menu.
  424.        virtual bool OnGossipSelect(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
  425.  
  426.        // Called when a player selects a gossip with a code in the creature's gossip menu.
  427.         virtual bool OnGossipSelectCode(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
  428.  
  429.         // Called when a player accepts a quest from the creature.
  430.         virtual bool OnQuestAccept(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }
  431.  
  432.         // Called when a player selects a quest in the creature's quest menu.
  433.        virtual bool OnQuestSelect(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }
  434.  
  435.        // Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
  436.         virtual bool OnQuestReward(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
  437.  
  438.         // Called when the dialog status between a player and the creature is requested.
  439.         virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
  440.  
  441.         // Called when a CreatureAI object is needed for the creature.
  442.         virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; }
  443. };
  444.  
  445. class TC_GAME_API GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
  446. {
  447.     protected:
  448.  
  449.         GameObjectScript(const char* name);
  450.  
  451.     public:
  452.  
  453.         // Called when a dummy spell effect is triggered on the gameobject.
  454.         virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, GameObject* /*target*/) { return false; }
  455.  
  456.         // Called when a player opens a gossip dialog with the gameobject.
  457.         virtual bool OnGossipHello(Player* /*player*/, GameObject* /*go*/) { return false; }
  458.  
  459.         // Called when a player selects a gossip item in the gameobject's gossip menu.
  460.        virtual bool OnGossipSelect(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
  461.  
  462.        // Called when a player selects a gossip with a code in the gameobject's gossip menu.
  463.         virtual bool OnGossipSelectCode(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
  464.  
  465.         // Called when a player accepts a quest from the gameobject.
  466.         virtual bool OnQuestAccept(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/) { return false; }
  467.  
  468.         // Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
  469.        virtual bool OnQuestReward(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
  470.  
  471.        // Called when the dialog status between a player and the gameobject is requested.
  472.        virtual uint32 GetDialogStatus(Player* /*player*/, GameObject* /*go*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; }
  473.  
  474.        // Called when the game object is destroyed (destructible buildings only).
  475.        virtual void OnDestroyed(GameObject* /*go*/, Player* /*player*/) { }
  476.  
  477.        // Called when the game object is damaged (destructible buildings only).
  478.        virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/) { }
  479.  
  480.        // Called when the game object loot state is changed.
  481.        virtual void OnLootStateChanged(GameObject* /*go*/, uint32 /*state*/, Unit* /*unit*/) { }
  482.  
  483.        // Called when the game object state is changed.
  484.        virtual void OnGameObjectStateChanged(GameObject* /*go*/, uint32 /*state*/) { }
  485.  
  486.        // Called when a GameObjectAI object is needed for the gameobject.
  487.        virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return NULL; }
  488. };
  489.  
  490. class TC_GAME_API AreaTriggerScript : public ScriptObject
  491. {
  492.    protected:
  493.  
  494.        AreaTriggerScript(const char* name);
  495.  
  496.    public:
  497.  
  498.        // Called when the area trigger is activated by a player.
  499.        virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/) { return false; }
  500. };
  501.  
  502. class TC_GAME_API BattlegroundScript : public ScriptObject
  503. {
  504.    protected:
  505.  
  506.        BattlegroundScript(const char* name);
  507.  
  508.    public:
  509.  
  510.        // Should return a fully valid Battleground object for the type ID.
  511.        virtual Battleground* GetBattleground() const = 0;
  512. };
  513.  
  514. class TC_GAME_API OutdoorPvPScript : public ScriptObject
  515. {
  516.    protected:
  517.  
  518.        OutdoorPvPScript(const char* name);
  519.  
  520.    public:
  521.  
  522.        // Should return a fully valid OutdoorPvP object for the type ID.
  523.        virtual OutdoorPvP* GetOutdoorPvP() const = 0;
  524. };
  525.  
  526. class TC_GAME_API CommandScript : public ScriptObject
  527. {
  528.    protected:
  529.  
  530.        CommandScript(const char* name);
  531.  
  532.    public:
  533.  
  534.        // Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler.
  535.        virtual std::vector<ChatCommand> GetCommands() const = 0;
  536. };
  537.  
  538. class TC_GAME_API WeatherScript : public ScriptObject, public UpdatableScript<Weather>
  539. {
  540.    protected:
  541.  
  542.        WeatherScript(const char* name);
  543.  
  544.    public:
  545.  
  546.        // Called when the weather changes in the zone this script is associated with.
  547.        virtual void OnChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { }
  548. };
  549.  
  550. class TC_GAME_API AuctionHouseScript : public ScriptObject
  551. {
  552.    protected:
  553.  
  554.        AuctionHouseScript(const char* name);
  555.  
  556.    public:
  557.  
  558.        // Called when an auction is added to an auction house.
  559.        virtual void OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionEntry* /*entry*/) { }
  560.  
  561.        // Called when an auction is removed from an auction house.
  562.        virtual void OnAuctionRemove(AuctionHouseObject* /*ah*/, AuctionEntry* /*entry*/) { }
  563.  
  564.        // Called when an auction was succesfully completed.
  565.        virtual void OnAuctionSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* /*entry*/) { }
  566.  
  567.        // Called when an auction expires.
  568.        virtual void OnAuctionExpire(AuctionHouseObject* /*ah*/, AuctionEntry* /*entry*/) { }
  569. };
  570.  
  571. class TC_GAME_API ConditionScript : public ScriptObject
  572. {
  573.    protected:
  574.  
  575.        ConditionScript(const char* name);
  576.  
  577.    public:
  578.  
  579.        // Called when a single condition is checked for a player.
  580.        virtual bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) { return true; }
  581. };
  582.  
  583. class TC_GAME_API VehicleScript : public ScriptObject
  584. {
  585.    protected:
  586.  
  587.        VehicleScript(const char* name);
  588.  
  589.    public:
  590.  
  591.        // Called after a vehicle is installed.
  592.        virtual void OnInstall(Vehicle* /*veh*/) { }
  593.  
  594.        // Called after a vehicle is uninstalled.
  595.        virtual void OnUninstall(Vehicle* /*veh*/) { }
  596.  
  597.        // Called when a vehicle resets.
  598.        virtual void OnReset(Vehicle* /*veh*/) { }
  599.  
  600.        // Called after an accessory is installed in a vehicle.
  601.        virtual void OnInstallAccessory(Vehicle* /*veh*/, Creature* /*accessory*/) { }
  602.  
  603.        // Called after a passenger is added to a vehicle.
  604.        virtual void OnAddPassenger(Vehicle* /*veh*/, Unit* /*passenger*/, int8 /*seatId*/) { }
  605.  
  606.        // Called after a passenger is removed from a vehicle.
  607.        virtual void OnRemovePassenger(Vehicle* /*veh*/, Unit* /*passenger*/) { }
  608. };
  609.  
  610. class TC_GAME_API DynamicObjectScript : public ScriptObject, public UpdatableScript<DynamicObject>
  611. {
  612.    protected:
  613.  
  614.        DynamicObjectScript(const char* name);
  615. };
  616.  
  617. class TC_GAME_API TransportScript : public ScriptObject, public UpdatableScript<Transport>
  618. {
  619.    protected:
  620.  
  621.        TransportScript(const char* name);
  622.  
  623.    public:
  624.  
  625.        // Called when a player boards the transport.
  626.        virtual void OnAddPassenger(Transport* /*transport*/, Player* /*player*/) { }
  627.  
  628.        // Called when a creature boards the transport.
  629.        virtual void OnAddCreaturePassenger(Transport* /*transport*/, Creature* /*creature*/) { }
  630.  
  631.        // Called when a player exits the transport.
  632.        virtual void OnRemovePassenger(Transport* /*transport*/, Player* /*player*/) { }
  633.  
  634.        // Called when a transport moves.
  635.        virtual void OnRelocate(Transport* /*transport*/, uint32 /*waypointId*/, uint32 /*mapId*/, float /*x*/, float /*y*/, float /*z*/) { }
  636. };
  637.  
  638. class TC_GAME_API AchievementCriteriaScript : public ScriptObject
  639. {
  640.    protected:
  641.  
  642.        AchievementCriteriaScript(const char* name);
  643.  
  644.    public:
  645.  
  646.        // Called when an additional criteria is checked.
  647.        virtual bool OnCheck(Player* source, Unit* target) = 0;
  648. };
  649.  
  650. class TC_GAME_API PlayerScript : public UnitScript
  651. {
  652.    protected:
  653.  
  654.        PlayerScript(const char* name);
  655.  
  656.    public:
  657.  
  658.        // Called when a player kills another player
  659.        virtual void OnPVPKill(Player* /*killer*/, Player* /*killed*/) { }
  660.  
  661.        // Called when a player kills a creature
  662.        virtual void OnCreatureKill(Player* /*killer*/, Creature* /*killed*/) { }
  663.  
  664.        // Called when a player is killed by a creature
  665.        virtual void OnPlayerKilledByCreature(Creature* /*killer*/, Player* /*killed*/) { }
  666.  
  667.        // Called when a player's level changes (after the level is applied)
  668.         virtual void OnLevelChanged(Player* /*player*/, uint8 /*oldLevel*/) { }
  669.  
  670.         // Called when a player's free talent points change (right before the change is applied)
  671.        virtual void OnFreeTalentPointsChanged(Player* /*player*/, uint32 /*points*/) { }
  672.  
  673.        // Called when a player's talent points are reset (right before the reset is done)
  674.         virtual void OnTalentsReset(Player* /*player*/, bool /*noCost*/) { }
  675.  
  676.         // Called when a player's money is modified (before the modification is done)
  677.        virtual void OnMoneyChanged(Player* /*player*/, int32& /*amount*/) { }
  678.  
  679.        // Called when a player's money is at limit (amount = money tried to add)
  680.         virtual void OnMoneyLimit(Player* /*player*/, int32 /*amount*/) { }
  681.  
  682.         // Called when a player gains XP (before anything is given)
  683.         virtual void OnGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/) { }
  684.  
  685.         // Called when a player's reputation changes (before it is actually changed)
  686.        virtual void OnReputationChange(Player* /*player*/, uint32 /*factionId*/, int32& /*standing*/, bool /*incremental*/) { }
  687.  
  688.        // Called when a duel is requested
  689.        virtual void OnDuelRequest(Player* /*target*/, Player* /*challenger*/) { }
  690.  
  691.        // Called when a duel starts (after 3s countdown)
  692.        virtual void OnDuelStart(Player* /*player1*/, Player* /*player2*/) { }
  693.  
  694.        // Called when a duel ends
  695.        virtual void OnDuelEnd(Player* /*winner*/, Player* /*loser*/, DuelCompleteType /*type*/) { }
  696.  
  697.        // The following methods are called when a player sends a chat message.
  698.        virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/) { }
  699.  
  700.        virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Player* /*receiver*/) { }
  701.  
  702.        virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Group* /*group*/) { }
  703.  
  704.        virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Guild* /*guild*/) { }
  705.  
  706.        virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Channel* /*channel*/) { }
  707.  
  708.        // Both of the below are called on emote opcodes.
  709.        virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { }
  710.  
  711.        virtual void OnTextEmote(Player* /*player*/, uint32 /*textEmote*/, uint32 /*emoteNum*/, ObjectGuid /*guid*/) { }
  712.  
  713.        // Called in Spell::Cast.
  714.        virtual void OnSpellCast(Player* /*player*/, Spell* /*spell*/, bool /*skipCheck*/) { }
  715.  
  716.        // Called when a player logs in.
  717.        virtual void OnLogin(Player* /*player*/, bool /*firstLogin*/) { }
  718.  
  719.        // Called when a player logs out.
  720.        virtual void OnLogout(Player* /*player*/) { }
  721.  
  722.        // Called when a player is created.
  723.        virtual void OnCreate(Player* /*player*/) { }
  724.  
  725.        // Called when a player is deleted.
  726.        virtual void OnDelete(ObjectGuid /*guid*/, uint32 /*accountId*/) { }
  727.  
  728.        // Called when a player delete failed
  729.        virtual void OnFailedDelete(ObjectGuid /*guid*/, uint32 /*accountId*/) { }
  730.  
  731.        // Called when a player is about to be saved.
  732.        virtual void OnSave(Player* /*player*/) { }
  733.  
  734.        // Called when a player is bound to an instance
  735.        virtual void OnBindToInstance(Player* /*player*/, Difficulty /*difficulty*/, uint32 /*mapId*/, bool /*permanent*/, uint8 /*extendState*/) { }
  736.  
  737.        // Called when a player switches to a new zone
  738.        virtual void OnUpdateZone(Player* /*player*/, uint32 /*newZone*/, uint32 /*newArea*/) { }
  739.  
  740.        // Called when a player changes to a new map (after moving to new map)
  741.        virtual void OnMapChanged(Player* /*player*/) { }
  742.        
  743.        // Called when a player selects an option in a player gossip window
  744.        virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { }
  745.  
  746.        // Called when a player selects an option in a player gossip window
  747.        virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
  748.  
  749.        // Called after a player's quest status has been changed
  750.         virtual void OnQuestStatusChange(Player* /*player*/, uint32 /*questId*/, QuestStatus /*status*/) { }
  751. };
  752.  
  753. class TC_GAME_API AccountScript : public ScriptObject
  754. {
  755.     protected:
  756.  
  757.         AccountScript(const char* name);
  758.  
  759.     public:
  760.  
  761.         // Called when an account logged in succesfully
  762.         virtual void OnAccountLogin(uint32 /*accountId*/) {}
  763.  
  764.         // Called when an account login failed
  765.         virtual void OnFailedAccountLogin(uint32 /*accountId*/) {}
  766.  
  767.         // Called when Email is successfully changed for Account
  768.         virtual void OnEmailChange(uint32 /*accountId*/) {}
  769.  
  770.         // Called when Email failed to change for Account
  771.         virtual void OnFailedEmailChange(uint32 /*accountId*/) {}
  772.  
  773.         // Called when Password is successfully changed for Account
  774.         virtual void OnPasswordChange(uint32 /*accountId*/) {}
  775.  
  776.         // Called when Password failed to change for Account
  777.         virtual void OnFailedPasswordChange(uint32 /*accountId*/) {}
  778. };
  779.  
  780. class TC_GAME_API GuildScript : public ScriptObject
  781. {
  782.     protected:
  783.  
  784.         GuildScript(const char* name);
  785.  
  786.     public:
  787.  
  788.         // Called when a member is added to the guild.
  789.         virtual void OnAddMember(Guild* /*guild*/, Player* /*player*/, uint8& /*plRank*/) { }
  790.  
  791.         // Called when a member is removed from the guild.
  792.         virtual void OnRemoveMember(Guild* /*guild*/, Player* /*player*/, bool /*isDisbanding*/, bool /*isKicked*/) { }
  793.  
  794.         // Called when the guild MOTD (message of the day) changes.
  795.         virtual void OnMOTDChanged(Guild* /*guild*/, const std::string& /*newMotd*/) { }
  796.  
  797.         // Called when the guild info is altered.
  798.         virtual void OnInfoChanged(Guild* /*guild*/, const std::string& /*newInfo*/) { }
  799.  
  800.         // Called when a guild is created.
  801.         virtual void OnCreate(Guild* /*guild*/, Player* /*leader*/, const std::string& /*name*/) { }
  802.  
  803.         // Called when a guild is disbanded.
  804.         virtual void OnDisband(Guild* /*guild*/) { }
  805.  
  806.         // Called when a guild member withdraws money from a guild bank.
  807.         virtual void OnMemberWitdrawMoney(Guild* /*guild*/, Player* /*player*/, uint32& /*amount*/, bool /*isRepair*/) { }
  808.  
  809.         // Called when a guild member deposits money in a guild bank.
  810.         virtual void OnMemberDepositMoney(Guild* /*guild*/, Player* /*player*/, uint32& /*amount*/) { }
  811.  
  812.         // Called when a guild member moves an item in a guild bank.
  813.         virtual void OnItemMove(Guild* /*guild*/, Player* /*player*/, Item* /*pItem*/, bool /*isSrcBank*/, uint8 /*srcContainer*/, uint8 /*srcSlotId*/,
  814.             bool /*isDestBank*/, uint8 /*destContainer*/, uint8 /*destSlotId*/) { }
  815.  
  816.         virtual void OnEvent(Guild* /*guild*/, uint8 /*eventType*/, ObjectGuid::LowType /*playerGuid1*/, ObjectGuid::LowType /*playerGuid2*/, uint8 /*newRank*/) { }
  817.  
  818.         virtual void OnBankEvent(Guild* /*guild*/, uint8 /*eventType*/, uint8 /*tabId*/, ObjectGuid::LowType /*playerGuid*/, uint32 /*itemOrMoney*/, uint16 /*itemStackCount*/, uint8 /*destTabId*/) { }
  819. };
  820.  
  821. class TC_GAME_API GroupScript : public ScriptObject
  822. {
  823.     protected:
  824.  
  825.         GroupScript(const char* name);
  826.  
  827.     public:
  828.  
  829.         // Called when a member is added to a group.
  830.         virtual void OnAddMember(Group* /*group*/, ObjectGuid /*guid*/) { }
  831.  
  832.         // Called when a member is invited to join a group.
  833.         virtual void OnInviteMember(Group* /*group*/, ObjectGuid /*guid*/) { }
  834.  
  835.         // Called when a member is removed from a group.
  836.         virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, const char* /*reason*/) { }
  837.  
  838.         // Called when the leader of a group is changed.
  839.         virtual void OnChangeLeader(Group* /*group*/, ObjectGuid /*newLeaderGuid*/, ObjectGuid /*oldLeaderGuid*/) { }
  840.  
  841.         // Called when a group is disbanded.
  842.         virtual void OnDisband(Group* /*group*/) { }
  843. };
  844.  
  845. // Manages registration, loading, and execution of scripts.
  846. class TC_GAME_API ScriptMgr
  847. {
  848.     friend class ScriptObject;
  849.  
  850.     private:
  851.         ScriptMgr();
  852.         virtual ~ScriptMgr();
  853.  
  854.         void FillSpellSummary();
  855.         void LoadDatabase();
  856.  
  857.         void IncreaseScriptCount() { ++_scriptCount; }
  858.         void DecreaseScriptCount() { --_scriptCount; }
  859.  
  860.     public: /* Initialization */
  861.         static ScriptMgr* instance();
  862.  
  863.         void Initialize();
  864.  
  865.         uint32 GetScriptCount() const { return _scriptCount; }
  866.  
  867.         typedef void(*ScriptLoaderCallbackType)();
  868.  
  869.         /// Sets the script loader callback which is invoked to load scripts
  870.         /// (Workaround for circular dependency game <-> scripts)
  871.         void SetScriptLoader(ScriptLoaderCallbackType script_loader_callback)
  872.         {
  873.             _script_loader_callback = script_loader_callback;
  874.         }
  875.  
  876.     public: /* Script contexts */
  877.         /// Set the current script context, which allows the ScriptMgr
  878.         /// to accept new scripts in this context.
  879.         /// Requires a SwapScriptContext() call afterwards to load the new scripts.
  880.         void SetScriptContext(std::string const& context);
  881.         /// Returns the current script context.
  882.         std::string const& GetCurrentScriptContext() const { return _currentContext; }
  883.         /// Releases all scripts associated with the given script context immediately.
  884.         /// Requires a SwapScriptContext() call afterwards to finish the unloading.
  885.         void ReleaseScriptContext(std::string const& context);
  886.         /// Executes all changed introduced by SetScriptContext and ReleaseScriptContext.
  887.         /// It is possible to combine multiple SetScriptContext and ReleaseScriptContext
  888.         /// calls for better performance (bulk changes).
  889.         void SwapScriptContext(bool initialize = false);
  890.  
  891.         /// Acquires a strong module reference to the module containing the given script name,
  892.         /// which prevents the shared library which contains the script from unloading.
  893.         /// The shared library is lazy unloaded as soon as all references to it are released.
  894.         std::shared_ptr<ModuleReference> AcquireModuleReferenceOfScriptName(
  895.             std::string const& scriptname) const;
  896.  
  897.     public: /* Unloading */
  898.  
  899.         void Unload();
  900.  
  901.     public: /* SpellScriptLoader */
  902.  
  903.         void CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector);
  904.         void CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector);
  905.         SpellScriptLoader* GetSpellScriptLoader(uint32 scriptId);
  906.  
  907.     public: /* ServerScript */
  908.  
  909.         void OnNetworkStart();
  910.         void OnNetworkStop();
  911.         void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
  912.         void OnSocketClose(std::shared_ptr<WorldSocket> socket);
  913.         void OnPacketReceive(WorldSession* session, WorldPacket const& packet);
  914.         void OnPacketSend(WorldSession* session, WorldPacket const& packet);
  915.  
  916.     public: /* WorldScript */
  917.  
  918.         void OnOpenStateChange(bool open);
  919.         void OnConfigLoad(bool reload);
  920.         void OnMotdChange(std::string& newMotd);
  921.         void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
  922.         void OnShutdownCancel();
  923.         void OnWorldUpdate(uint32 diff);
  924.         void OnStartup();
  925.         void OnShutdown();
  926.  
  927.     public: /* FormulaScript */
  928.  
  929.         void OnHonorCalculation(float& honor, uint8 level, float multiplier);
  930.         void OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel);
  931.         void OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel);
  932.         void OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel);
  933.         void OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content);
  934.         void OnGainCalculation(uint32& gain, Player* player, Unit* unit);
  935.         void OnGroupRateCalculation(float& rate, uint32 count, bool isRaid);
  936.  
  937.     public: /* MapScript */
  938.  
  939.         void OnCreateMap(Map* map);
  940.         void OnDestroyMap(Map* map);
  941.         void OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy);
  942.         void OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy);
  943.         void OnPlayerEnterMap(Map* map, Player* player);
  944.         void OnPlayerLeaveMap(Map* map, Player* player);
  945.         void OnMapUpdate(Map* map, uint32 diff);
  946.  
  947.     public: /* InstanceMapScript */
  948.  
  949.         InstanceScript* CreateInstanceData(InstanceMap* map);
  950.  
  951.     public: /* ItemScript */
  952.  
  953.         bool OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Item* target);
  954.         bool OnQuestAccept(Player* player, Item* item, Quest const* quest);
  955.         bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
  956.         bool OnItemExpire(Player* player, ItemTemplate const* proto);
  957.         bool OnItemRemove(Player* player, Item* item);
  958.         void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action);
  959.         void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code);
  960.  
  961.     public: /* CreatureScript */
  962.  
  963.         bool OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target);
  964.         bool OnGossipHello(Player* player, Creature* creature);
  965.         bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action);
  966.         bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code);
  967.         bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);
  968.         bool OnQuestSelect(Player* player, Creature* creature, Quest const* quest);
  969.         bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt);
  970.         uint32 GetDialogStatus(Player* player, Creature* creature);
  971.         CreatureAI* GetCreatureAI(Creature* creature);
  972.         void OnCreatureUpdate(Creature* creature, uint32 diff);
  973.  
  974.     public: /* GameObjectScript */
  975.  
  976.         bool OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, GameObject* target);
  977.         bool OnGossipHello(Player* player, GameObject* go);
  978.         bool OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action);
  979.         bool OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code);
  980.         bool OnQuestAccept(Player* player, GameObject* go, Quest const* quest);
  981.         bool OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt);
  982.         uint32 GetDialogStatus(Player* player, GameObject* go);
  983.         void OnGameObjectDestroyed(GameObject* go, Player* player);
  984.         void OnGameObjectDamaged(GameObject* go, Player* player);
  985.         void OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit);
  986.         void OnGameObjectStateChanged(GameObject* go, uint32 state);
  987.         void OnGameObjectUpdate(GameObject* go, uint32 diff);
  988.         GameObjectAI* GetGameObjectAI(GameObject* go);
  989.  
  990.     public: /* AreaTriggerScript */
  991.  
  992.         bool OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger);
  993.  
  994.     public: /* BattlegroundScript */
  995.  
  996.         Battleground* CreateBattleground(BattlegroundTypeId typeId);
  997.  
  998.     public: /* OutdoorPvPScript */
  999.  
  1000.         OutdoorPvP* CreateOutdoorPvP(OutdoorPvPData const* data);
  1001.  
  1002.     public: /* CommandScript */
  1003.  
  1004.         std::vector<ChatCommand> GetChatCommands();
  1005.  
  1006.     public: /* WeatherScript */
  1007.  
  1008.         void OnWeatherChange(Weather* weather, WeatherState state, float grade);
  1009.         void OnWeatherUpdate(Weather* weather, uint32 diff);
  1010.  
  1011.     public: /* AuctionHouseScript */
  1012.  
  1013.         void OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry);
  1014.         void OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry);
  1015.         void OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry);
  1016.         void OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry);
  1017.  
  1018.     public: /* ConditionScript */
  1019.  
  1020.         bool OnConditionCheck(Condition const* condition, ConditionSourceInfo& sourceInfo);
  1021.  
  1022.     public: /* VehicleScript */
  1023.  
  1024.         void OnInstall(Vehicle* veh);
  1025.         void OnUninstall(Vehicle* veh);
  1026.         void OnReset(Vehicle* veh);
  1027.         void OnInstallAccessory(Vehicle* veh, Creature* accessory);
  1028.         void OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId);
  1029.         void OnRemovePassenger(Vehicle* veh, Unit* passenger);
  1030.  
  1031.     public: /* DynamicObjectScript */
  1032.  
  1033.         void OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff);
  1034.  
  1035.     public: /* TransportScript */
  1036.  
  1037.         void OnAddPassenger(Transport* transport, Player* player);
  1038.         void OnAddCreaturePassenger(Transport* transport, Creature* creature);
  1039.         void OnRemovePassenger(Transport* transport, Player* player);
  1040.         void OnTransportUpdate(Transport* transport, uint32 diff);
  1041.         void OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z);
  1042.  
  1043.     public: /* AchievementCriteriaScript */
  1044.  
  1045.         bool OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target);
  1046.  
  1047.     public: /* PlayerScript */
  1048.  
  1049.         void OnPVPKill(Player* killer, Player* killed);
  1050.         void OnCreatureKill(Player* killer, Creature* killed);
  1051.         void OnPlayerKilledByCreature(Creature* killer, Player* killed);
  1052.         void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
  1053.         void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
  1054.         void OnPlayerTalentsReset(Player* player, bool noCost);
  1055.         void OnPlayerMoneyChanged(Player* player, int32& amount);
  1056.         void OnPlayerMoneyLimit(Player* player, int32 amount);
  1057.         void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim);
  1058.         void OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
  1059.         void OnPlayerDuelRequest(Player* target, Player* challenger);
  1060.         void OnPlayerDuelStart(Player* player1, Player* player2);
  1061.         void OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type);
  1062.         void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg);
  1063.         void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver);
  1064.         void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group);
  1065.         void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild);
  1066.         void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel);
  1067.         void OnPlayerEmote(Player* player, uint32 emote);
  1068.         void OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid);
  1069.         void OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck);
  1070.         void OnPlayerLogin(Player* player, bool firstLogin);
  1071.         void OnPlayerLogout(Player* player);
  1072.         void OnPlayerCreate(Player* player);
  1073.         void OnPlayerDelete(ObjectGuid guid, uint32 accountId);
  1074.         void OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId);
  1075.         void OnPlayerSave(Player* player);
  1076.         void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent, uint8 extendState);
  1077.         void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea);
  1078.         void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action);
  1079.         void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code);
  1080.         void OnQuestStatusChange(Player* player, uint32 questId, QuestStatus status);
  1081.  
  1082.     public: /* AccountScript */
  1083.  
  1084.         void OnAccountLogin(uint32 accountId);
  1085.         void OnFailedAccountLogin(uint32 accountId);
  1086.         void OnEmailChange(uint32 accountId);
  1087.         void OnFailedEmailChange(uint32 accountId);
  1088.         void OnPasswordChange(uint32 accountId);
  1089.         void OnFailedPasswordChange(uint32 accountId);
  1090.  
  1091.     public: /* GuildScript */
  1092.  
  1093.         void OnGuildAddMember(Guild* guild, Player* player, uint8& plRank);
  1094.         void OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked);
  1095.         void OnGuildMOTDChanged(Guild* guild, const std::string& newMotd);
  1096.         void OnGuildInfoChanged(Guild* guild, const std::string& newInfo);
  1097.         void OnGuildCreate(Guild* guild, Player* leader, const std::string& name);
  1098.         void OnGuildDisband(Guild* guild);
  1099.         void OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32 &amount, bool isRepair);
  1100.         void OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount);
  1101.         void OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
  1102.             bool isDestBank, uint8 destContainer, uint8 destSlotId);
  1103.         void OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank);
  1104.         void OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
  1105.  
  1106.     public: /* GroupScript */
  1107.  
  1108.         void OnGroupAddMember(Group* group, ObjectGuid guid);
  1109.         void OnGroupInviteMember(Group* group, ObjectGuid guid);
  1110.         void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason);
  1111.         void OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid);
  1112.         void OnGroupDisband(Group* group);
  1113.  
  1114.     public: /* UnitScript */
  1115.  
  1116.         void OnHeal(Unit* healer, Unit* reciever, uint32& gain);
  1117.         void OnDamage(Unit* attacker, Unit* victim, uint32& damage);
  1118.         void ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage);
  1119.         void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage);
  1120.         void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage);
  1121.  
  1122.     private:
  1123.         uint32 _scriptCount;
  1124.  
  1125.         ScriptLoaderCallbackType _script_loader_callback;
  1126.  
  1127.         std::string _currentContext;
  1128. };
  1129.  
  1130. #define sScriptMgr ScriptMgr::instance()
  1131.  
  1132. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement