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