1 | /* Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
2 | * |
---|
3 | * Thanks to the original authors: ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> |
---|
4 | * |
---|
5 | * This program is free software licensed under GPL version 2 |
---|
6 | * Please see the included DOCS/LICENSE.TXT for more information */ |
---|
7 | |
---|
8 | #ifndef SCRIPTMGR_H |
---|
9 | #define SCRIPTMGR_H |
---|
10 | |
---|
11 | #include "Common.h" |
---|
12 | #include "Platform/CompilerDefs.h" |
---|
13 | #include "Database/DBCStructure.h" |
---|
14 | |
---|
15 | class Player; |
---|
16 | class Creature; |
---|
17 | class CreatureAI; |
---|
18 | class InstanceData; |
---|
19 | class Quest; |
---|
20 | class Item; |
---|
21 | class GameObject; |
---|
22 | class SpellCastTargets; |
---|
23 | class Map; |
---|
24 | class Unit; |
---|
25 | class WorldObject; |
---|
26 | |
---|
27 | #define MAX_SCRIPTS 1000 //72 bytes each (approx 71kb) |
---|
28 | #define VISIBLE_RANGE (166.0f) //MAX visible range (size of grid) |
---|
29 | #define DEFAULT_TEXT "<Trinity Script Text Entry Missing!>" |
---|
30 | |
---|
31 | struct Script |
---|
32 | { |
---|
33 | Script() : |
---|
34 | pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL), |
---|
35 | pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL), |
---|
36 | pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL), |
---|
37 | pGOChooseReward(NULL),pReceiveEmote(NULL),pItemUse(NULL), GetAI(NULL), GetInstanceData(NULL) |
---|
38 | {} |
---|
39 | |
---|
40 | std::string Name; |
---|
41 | |
---|
42 | // Quest/gossip Methods to be scripted |
---|
43 | bool (*pGossipHello )(Player*, Creature*); |
---|
44 | bool (*pQuestAccept )(Player*, Creature*, Quest const* ); |
---|
45 | bool (*pGossipSelect )(Player*, Creature*, uint32 , uint32 ); |
---|
46 | bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* ); |
---|
47 | bool (*pQuestSelect )(Player*, Creature*, Quest const* ); |
---|
48 | bool (*pQuestComplete )(Player*, Creature*, Quest const* ); |
---|
49 | uint32 (*pNPCDialogStatus )(Player*, Creature* ); |
---|
50 | uint32 (*pGODialogStatus )(Player *player, GameObject * _GO ); |
---|
51 | bool (*pChooseReward )(Player*, Creature*, Quest const*, uint32 ); |
---|
52 | bool (*pItemHello )(Player*, Item*, Quest const* ); |
---|
53 | bool (*pGOHello )(Player*, GameObject* ); |
---|
54 | bool (*pAreaTrigger )(Player*, AreaTriggerEntry* ); |
---|
55 | bool (*pItemQuestAccept )(Player*, Item *, Quest const* ); |
---|
56 | bool (*pGOQuestAccept )(Player*, GameObject*, Quest const* ); |
---|
57 | bool (*pGOChooseReward )(Player*, GameObject*_GO, Quest const*, uint32 ); |
---|
58 | bool (*pReceiveEmote )(Player*, Creature*, uint32 ); |
---|
59 | bool (*pItemUse )(Player*, Item*, SpellCastTargets const& ); |
---|
60 | |
---|
61 | CreatureAI* (*GetAI)(Creature*); |
---|
62 | InstanceData* (*GetInstanceData)(Map*); |
---|
63 | }; |
---|
64 | |
---|
65 | extern int nrscripts; |
---|
66 | extern Script *m_scripts[MAX_SCRIPTS]; |
---|
67 | |
---|
68 | // Localized Text function |
---|
69 | const char* GetEventAILocalizedText(uint32 entry); |
---|
70 | |
---|
71 | //EventAI text function |
---|
72 | const char* GetEventAIText(uint32 entry); // TODO: Locales |
---|
73 | |
---|
74 | //Generic scripting text function |
---|
75 | void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL); |
---|
76 | |
---|
77 | #if COMPILER == COMPILER_GNU |
---|
78 | #define FUNC_PTR(name,callconvention,returntype,parameters) typedef returntype(*name)parameters __attribute__ ((callconvention)); |
---|
79 | #else |
---|
80 | #define FUNC_PTR(name, callconvention, returntype, parameters) typedef returntype(callconvention *name)parameters; |
---|
81 | #endif |
---|
82 | |
---|
83 | #ifdef WIN32 |
---|
84 | #define TRINITY_DLL_EXPORT extern "C" __declspec(dllexport) |
---|
85 | #elif defined( __GNUC__ ) |
---|
86 | #define TRINITY_DLL_EXPORT extern "C" |
---|
87 | #else |
---|
88 | #define TRINITY_DLL_EXPORT extern "C" export |
---|
89 | #endif |
---|
90 | |
---|
91 | #endif |
---|