root/trunk/src/arcemu-world/GameObject.h @ 2860

Revision 2860, 10.0 kB (checked in by Vlack, 12 months ago)

Notice: Trunk is now 3.2.0

FIXED: Mail sending (by providing a missing item for the world database, this item is necessary for the client - for the item, thanks goes to Darkgrööm)
FIXED: Battleground selection crash (now the server will queue you on Isle of Conquest - note: this does not mean you can play on it, but it solves the instant crash when players selected it)
FIXED: Glyphs (till we properly implement dual spec)
FIXED: A9 target GUID sending (on flags & UPDATEFLAG_HAS_TARGET - thanks Alleycat)
FIXED: Re-enabled ground targeted spells (on m_targetMask & TARGET_FLAG_DEST_LOCATION - if a spell where you can select the area of its effect crashes the client in the future, we'll revise this part)
FIXED: A9 (actually just moved the already existing code pieces up/down to better suit the required format, but to know the format right, I had looked into Mangos code too, as I haven't got months to figure out the right structure)
FIXED: TaxiMgr::GetGlobalTaxiNodeMask? (index check, as with the new DBCs we have a "to" with value "-1", and when that's used as an uint, it'll result in an index of 255, while the structure is from 0 to 11).
ADDED: Override support (this extends the core with special features for special gameobjects, like what's required for trams and transports, which include features as: "override update fields", "never despawn on same map", "announce on greater range" and "push to player on map entry").
FIXED: static map object pushing (repaired the buffer handling error which duplicated buffer content in a pretty unique way).
ADDED: SQL fixes for Deeprun and Ulduar Trams (retail data, but it works right only with the override system).
UPDATED: UpdateFields?.h
UPDATED: DBCs (thanks Xuni)
UPDATED: Error codes (thanks Hopla)
FIXED: various packets, especially the following ones: character enumeration, mail list, group details (raid difficulty), movement-related packets
FIXED: The display of quest rewards the player can choose from on the quest page before accepting it.
FIXED: A nasty bug when un-equipping an item to a bag and not to the backpack. The problem was that I have missed 2 for loops where the visible items get nulled out on unequip, it erased 17 fields instead of just 2, so it made the character pretty much naked.

  • Property svn:eol-style set to native
  • Property ff set to
    *.cpp = svn:eol-style=native
    Makefile = svn:eol-style=native
    README = svn:eol-style=native
    CHANGELOG = svn:eol-style=native
    LICENSE = svn:eol-style=native
Line 
1/*
2 * ArcEmu MMORPG Server
3 * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
4 * Copyright (C) 2008-2009 <http://www.ArcEmu.org/>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef WOWSERVER_GAMEOBJECT_H
22#define WOWSERVER_GAMEOBJECT_H
23
24class Player;
25class GameObjectAIScript;
26class GameObjectTemplate;
27
28struct GOQuestItem
29{
30        uint32 itemid;
31        uint32 requiredcount;
32};
33
34struct GOQuestGameObject
35{
36        uint32 goid;
37        uint32 requiredcount;
38};
39
40enum GAMEOBJECT_FLAG_BIT
41{
42        GAMEOBJECT_UNCLICKABLE = 0x01,
43        GAMEOBJECT_CLICKABLE = 0x20,
44};
45
46enum GAMEOBJECT_OVERRIDES //by VLack
47{
48        GAMEOBJECT_INFVIS = 0x01,               //Makes the gameobject forever visible on the map after you saw it at least once - for various transports; actually it just doesn't erase it while you're on the same map.
49        GAMEOBJECT_MAPWIDE = 0x02,              //When you enter its map, the gameobject gets pushed to you no matter how far it is (but only for players), especially for Deeprun and Ulduar Trams.
50        GAMEOBJECT_AREAWIDE = 0x04,             //UNIMPLEMENTED, but will work like this: the Map will get marked that it contains an object like this, and on player movement these objects will get distance-checked to spawn them from a greater distance than normal if needed - for few objects on smaller maps, like on battlegrounds; maybe they'll get area-triggered, haven't decided yet.
51        GAMEOBJECT_ONMOVEWIDE = 0x08,           //When this gameobject moves and sends updates about it's position, do so in the second range - MapMgr::ChangeObjectLocation, +/- 6 units wide instead of +/- 1.
52        GAMEOBJECT_OVERRIDE_FLAGS = 0x10,       //UNIMPLEMENTED, Let the core decide about the flags sent in the A9 - example: 252 instead of 352 for Deeprun Tram.
53        GAMEOBJECT_OVERRIDE_BYTES1 = 0x20,      //UNIMPLEMENTED, Let the core use the full field instead an uint8 in GAMEOBJECT_BYTES_1, if the database creator knows what to do with it.
54        GAMEOBJECT_OVERRIDE_PARENTROT = 0x40,   //Makes it possible for the core to skip calculating these fields and use whatever was specified in the spawn.
55        //Later other types might folow, or the upper bytes might get used for the AREAWIDE option in the overrides variable...
56};
57
58#if ENABLE_SHITTY_STL_HACKS == 1
59typedef HM_NAMESPACE::hash_map<Quest*, uint32 > GameObjectGOMap;
60#else
61namespace HM_NAMESPACE
62{
63        template <>
64        struct hash<Quest*>
65        {
66                union __vp
67                {
68                        size_t s;
69                        Quest* p;
70                };
71
72                size_t operator()(Quest* __x) const
73                {
74                        __vp vp;
75                        vp.p = __x;
76                        return vp.s;
77                }
78        };
79};
80
81typedef HM_NAMESPACE::hash_map<Quest*, uint32, HM_NAMESPACE::hash<Quest*> > GameObjectGOMap;
82#endif
83
84typedef HM_NAMESPACE::hash_map<Quest*, std::map<uint32, uint32> > GameObjectItemMap;
85
86#pragma pack(push,1)
87struct GameObjectInfo
88{
89        uint32 ID;
90        uint32 Type;
91        uint32 DisplayID;
92        char * Name;
93        char * Name2;
94        char * Name3;
95        char * Name4;
96        char * Category;
97        char * Castbartext;
98        char * Unkstr;
99        float Size;
100        uint32 QuestItems[6];
101        uint32 SpellFocus;
102        uint32 sound1;
103        uint32 sound2;
104        uint32 sound3;
105        uint32 sound4;
106        uint32 sound5;
107        uint32 sound6;
108        uint32 sound7;
109        uint32 sound8;
110        uint32 sound9;
111        uint32 Unknown1;
112        uint32 Unknown2;
113        uint32 Unknown3;
114        uint32 Unknown4;
115        uint32 Unknown5;
116        uint32 Unknown6;
117        uint32 Unknown7;
118        uint32 Unknown8;
119        uint32 Unknown9;
120        uint32 Unknown10;
121        uint32 Unknown11;
122        uint32 Unknown12;
123        uint32 Unknown13;
124        uint32 Unknown14;
125        // Quests
126        GameObjectGOMap goMap;
127        GameObjectItemMap itemMap;
128    GossipScript * gossip_script;
129};
130#pragma pack(pop)
131
132enum GAMEOBJECT_BYTES
133{
134        GAMEOBJECT_BYTES_STATE                  = 0,
135        GAMEOBJECT_BYTES_TYPE_ID                = 1,
136        GAMEOBJECT_BYTES_UNK                    = 2, // todo: unknown atm
137        GAMEOBJECT_BYTES_ANIMPROGRESS   = 3,
138};
139
140enum GAMEOBJECT_TYPES
141{
142        GAMEOBJECT_TYPE_DOOR                                    = 0,
143        GAMEOBJECT_TYPE_BUTTON                                  = 1,
144        GAMEOBJECT_TYPE_QUESTGIVER                              = 2,
145        GAMEOBJECT_TYPE_CHEST                                   = 3,
146        GAMEOBJECT_TYPE_BINDER                                  = 4,
147        GAMEOBJECT_TYPE_GENERIC                                 = 5,
148        GAMEOBJECT_TYPE_TRAP                                    = 6,
149        GAMEOBJECT_TYPE_CHAIR                                   = 7,
150        GAMEOBJECT_TYPE_SPELL_FOCUS                             = 8,
151        GAMEOBJECT_TYPE_TEXT                                    = 9,
152        GAMEOBJECT_TYPE_GOOBER                                  = 10,
153        GAMEOBJECT_TYPE_TRANSPORT                               = 11,
154        GAMEOBJECT_TYPE_AREADAMAGE                              = 12,
155        GAMEOBJECT_TYPE_CAMERA                                  = 13,
156        GAMEOBJECT_TYPE_MAP_OBJECT                              = 14,
157        GAMEOBJECT_TYPE_MO_TRANSPORT                    = 15,
158        GAMEOBJECT_TYPE_DUEL_ARBITER                    = 16,
159        GAMEOBJECT_TYPE_FISHINGNODE                             = 17,
160        GAMEOBJECT_TYPE_RITUAL                                  = 18,
161        GAMEOBJECT_TYPE_MAILBOX                                 = 19,
162        GAMEOBJECT_TYPE_AUCTIONHOUSE                    = 20,
163        GAMEOBJECT_TYPE_GUARDPOST                               = 21,
164        GAMEOBJECT_TYPE_SPELLCASTER                             = 22,
165        GAMEOBJECT_TYPE_MEETINGSTONE                    = 23,
166        GAMEOBJECT_TYPE_FLAGSTAND                               = 24,
167        GAMEOBJECT_TYPE_FISHINGHOLE                             = 25,
168        GAMEOBJECT_TYPE_FLAGDROP                                = 26,
169        GAMEOBJECT_TYPE_MINI_GAME                               = 27,
170        GAMEOBJECT_TYPE_LOTTERY_KIOSK                   = 28,
171        GAMEOBJECT_TYPE_CAPTURE_POINT                   = 29,
172        GAMEOBJECT_TYPE_AURA_GENERATOR                  = 30,
173        GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY              = 31,
174        GAMEOBJECT_TYPE_BARBER_CHAIR                    = 32,
175        GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING   = 33,
176        GAMEOBJECT_TYPE_GUILD_BANK                              = 34,
177        GAMEOBJECT_TYPE_TRAPDOOR                                = 35};
178
179#define CALL_GO_SCRIPT_EVENT(obj, func) if(obj->GetTypeId() == TYPEID_GAMEOBJECT && static_cast<GameObject*>(obj)->GetScript() != NULL) static_cast<GameObject*>(obj)->GetScript()->func
180
181class SERVER_DECL GameObject : public Object
182{
183public:
184        /************************************************************************/
185        /* LUA Stuff                                                            */
186        /************************************************************************/
187/*      typedef struct { const char *name; int(*mfunc)(lua_State*,GameObject*); } RegType;
188        static const char className[];
189        static RegType methods[];
190
191        // a lua script cannot create a unit.
192        GameObject(lua_State * L) { ASSERT(false); }*/
193
194        GameObject(uint64 guid);
195        ~GameObject( );
196
197        ARCEMU_INLINE GameObjectInfo* GetInfo() { return pInfo; }
198        ARCEMU_INLINE void SetInfo(GameObjectInfo * goi) { pInfo = goi; }
199
200        //void Create ( uint32 display_id, uint8 state, uint32 obj_field_entry, float scale, uint16 type, uint16 faction, uint32 mapid, float x, float y, float z, float ang );
201   // void Create ( uint32 mapid, float x, float y, float z, float ang);
202        bool CreateFromProto(uint32 entry,uint32 mapid, float x, float y, float z, float ang, float r0=0.0f, float r1=0.0f, float r2=0.0f, float r3=0.0f, uint32 overrides=0);
203   
204        bool Load(GOSpawn *spawn);
205
206        virtual void Update(uint32 p_time);
207
208        void Spawn(MapMgr * m);
209        void Despawn(uint32 delay, uint32 respawntime);
210        Loot loot;
211        //void _EnvironmentalDamageUpdate();
212        void UpdateTrapState();
213        // Serialization
214        void SaveToDB();
215        void SaveToFile(std::stringstream & name);
216        //bool LoadFromDB(uint32 guid);
217        //void LoadFromDB(GameObjectTemplate *t);
218        void DeleteFromDB();
219        void EventCloseDoor();
220        void EventCastSpell(uint32 guid, uint32 sp, bool triggered);
221        void SetRotation(float rad);
222        uint64 m_rotation;
223        void UpdateRotation();
224
225        //Fishing stuff
226        void UseFishingNode(Player *player);
227        void EndFishing(Player* player,bool abort);
228        void FishHooked(Player * player);
229       
230        // Quests
231        void _LoadQuests();
232        bool HasQuests() { return m_quests != NULL; };
233        void AddQuest(QuestRelation *Q);
234        void DeleteQuest(QuestRelation *Q);
235        Quest *FindQuest(uint32 quest_id, uint8 quest_relation);
236        uint16 GetQuestRelation(uint32 quest_id);
237        uint32 NumOfQuests();
238        std::list<QuestRelation *>::iterator QuestsBegin() { return m_quests->begin(); };
239        std::list<QuestRelation *>::iterator QuestsEnd() { return m_quests->end(); };
240        void SetQuestList(std::list<QuestRelation *>* qst_lst) { m_quests = qst_lst; };
241
242        void SetSummoned(Unit *mob)
243        {
244                m_summoner = mob;
245                m_summonedGo = true;
246        }
247        void _Expire();
248       
249        void ExpireAndDelete();
250
251        void Deactivate();
252
253        ARCEMU_INLINE bool isQuestGiver()
254        {
255                //from GameObject::CreateFromProto - SetByte( GAMEOBJECT_BYTES_1, 1, pInfo->Type );
256                if(GetByte(GAMEOBJECT_BYTES_1, 1) == 2) 
257                        return true;
258                else
259                        return false;
260        };
261
262        /// Quest data
263        std::list<QuestRelation *>* m_quests;
264   
265        uint32 *m_ritualmembers;
266        uint32 m_ritualcaster,m_ritualtarget;
267        uint16 m_ritualspell;
268
269        void InitAI();
270        SpellEntry* spell;
271       
272        float range;
273        uint8 checkrate;
274        uint16 counter;
275        int32 charges;//used for type==22,to limit number of usages.
276        bool invisible;//invisible
277        uint8 invisibilityFlag;
278        Unit* m_summoner;
279        int8 bannerslot;
280        int8 bannerauraslot;
281        CBattleground * m_battleground;
282
283        void CallScriptUpdate();
284   
285
286        ARCEMU_INLINE GameObjectAIScript* GetScript() { return myScript; }
287
288        void TrapSearchTarget();        // Traps need to find targets faster :P
289
290        ARCEMU_INLINE bool HasAI() { return spell != 0; }
291        GOSpawn * m_spawn;
292        void OnPushToWorld();
293        void OnRemoveInRangeObject(Object* pObj);
294        void RemoveFromWorld(bool free_guid);
295
296        ARCEMU_INLINE bool CanMine(){return (usage_remaining > 0);}
297        ARCEMU_INLINE void UseMine(){ if(usage_remaining) usage_remaining--;}
298        void CalcMineRemaining(bool force)
299        {
300                if(force || !usage_remaining)
301                        usage_remaining = GetInfo()->sound4 + RandomUInt(GetInfo()->sound5 - GetInfo()->sound4) - 1;
302        }
303        ARCEMU_INLINE bool CanFish() { return ( usage_remaining > 0 ); }
304        ARCEMU_INLINE void CatchFish() { if ( usage_remaining ) usage_remaining--; }
305        void CalcFishRemaining( bool force )
306        {
307                if ( force || !usage_remaining )
308                        usage_remaining = GetInfo()->sound2 + RandomUInt( GetInfo()->sound3 - GetInfo()->sound2 ) - 1;
309        }
310        bool HasLoot();
311        uint32 GetGOReqSkill();
312        MapCell * m_respawnCell;
313
314        void SetState(uint8 state);
315        uint8 GetState();
316
317        ARCEMU_INLINE uint32 GetOverrides() { return m_overrides; }
318
319protected:
320
321        bool m_summonedGo;
322        bool m_deleted;
323        GameObjectInfo *pInfo;
324        GameObjectAIScript * myScript;
325        uint32 _fields[GAMEOBJECT_END];
326        uint32 usage_remaining; //used for mining to mark times it can be mined
327
328        uint32 m_overrides; //See enum GAMEOBJECT_OVERRIDES!
329};
330
331#endif
332
333
Note: See TracBrowser for help on using the browser.