[9362] Make specs work at least for action bars
[getmangos.git] / src / game / GameObject.h
blob91d3eaca84cf49d6750d9a8b7c5bf2187c06bd5c
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_GAMEOBJECT_H
20 #define MANGOSSERVER_GAMEOBJECT_H
22 #include "Common.h"
23 #include "SharedDefines.h"
24 #include "Object.h"
25 #include "LootMgr.h"
26 #include "Database/DatabaseEnv.h"
28 // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
29 #if defined( __GNUC__ )
30 #pragma pack(1)
31 #else
32 #pragma pack(push,1)
33 #endif
35 // from `gameobject_template`
36 struct GameObjectInfo
38 uint32 id;
39 uint32 type;
40 uint32 displayId;
41 char *name;
42 char *IconName;
43 char *castBarCaption;
44 char *unk1;
45 uint32 faction;
46 uint32 flags;
47 float size;
48 uint32 questItems[6];
49 union // different GO types have different data field
51 //0 GAMEOBJECT_TYPE_DOOR
52 struct
54 uint32 startOpen; //0 used client side to determine GO_ACTIVATED means open/closed
55 uint32 lockId; //1 -> Lock.dbc
56 uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
57 uint32 noDamageImmune; //3 break opening whenever you recieve damage?
58 uint32 openTextID; //4 can be used to replace castBarCaption?
59 uint32 closeTextID; //5
60 uint32 ignoredByPathing; //6
61 } door;
62 //1 GAMEOBJECT_TYPE_BUTTON
63 struct
65 uint32 startOpen; //0
66 uint32 lockId; //1 -> Lock.dbc
67 uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
68 uint32 linkedTrapId; //3
69 uint32 noDamageImmune; //4 isBattlegroundObject
70 uint32 large; //5
71 uint32 openTextID; //6 can be used to replace castBarCaption?
72 uint32 closeTextID; //7
73 uint32 losOK; //8
74 } button;
75 //2 GAMEOBJECT_TYPE_QUESTGIVER
76 struct
78 uint32 lockId; //0 -> Lock.dbc
79 uint32 questList; //1
80 uint32 pageMaterial; //2
81 uint32 gossipID; //3
82 uint32 customAnim; //4
83 uint32 noDamageImmune; //5
84 uint32 openTextID; //6 can be used to replace castBarCaption?
85 uint32 losOK; //7
86 uint32 allowMounted; //8
87 uint32 large; //9
88 } questgiver;
89 //3 GAMEOBJECT_TYPE_CHEST
90 struct
92 uint32 lockId; //0 -> Lock.dbc
93 uint32 lootId; //1
94 uint32 chestRestockTime; //2
95 uint32 consumable; //3
96 uint32 minSuccessOpens; //4
97 uint32 maxSuccessOpens; //5
98 uint32 eventId; //6 lootedEvent
99 uint32 linkedTrapId; //7
100 uint32 questId; //8 not used currently but store quest required for GO activation for player
101 uint32 level; //9
102 uint32 losOK; //10
103 uint32 leaveLoot; //11
104 uint32 notInCombat; //12
105 uint32 logLoot; //13
106 uint32 openTextID; //14 can be used to replace castBarCaption?
107 uint32 groupLootRules; //15
108 uint32 floatingTooltip; //16
109 } chest;
110 //4 GAMEOBJECT_TYPE_BINDER - empty
111 //5 GAMEOBJECT_TYPE_GENERIC
112 struct
114 uint32 floatingTooltip; //0
115 uint32 highlight; //1
116 uint32 serverOnly; //2
117 uint32 large; //3
118 uint32 floatOnWater; //4
119 uint32 questID; //5
120 } _generic;
121 //6 GAMEOBJECT_TYPE_TRAP
122 struct
124 uint32 lockId; //0 -> Lock.dbc
125 uint32 level; //1
126 uint32 radius; //2 radius for trap activation
127 uint32 spellId; //3
128 uint32 charges; //4 need respawn (if > 0)
129 uint32 cooldown; //5 time in secs
130 uint32 autoCloseTime; //6 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
131 uint32 startDelay; //7
132 uint32 serverOnly; //8
133 uint32 stealthed; //9
134 uint32 large; //10
135 uint32 stealthAffected; //11
136 uint32 openTextID; //12 can be used to replace castBarCaption?
137 uint32 closeTextID; //13
138 uint32 ignoreTotems; //14
139 } trap;
140 //7 GAMEOBJECT_TYPE_CHAIR
141 struct
143 uint32 slots; //0
144 uint32 height; //1
145 uint32 onlyCreatorUse; //2
146 uint32 triggeredEvent; //3
147 } chair;
148 //8 GAMEOBJECT_TYPE_SPELL_FOCUS
149 struct
151 uint32 focusId; //0
152 uint32 dist; //1
153 uint32 linkedTrapId; //2
154 uint32 serverOnly; //3
155 uint32 questID; //4
156 uint32 large; //5
157 uint32 floatingTooltip; //6
158 } spellFocus;
159 //9 GAMEOBJECT_TYPE_TEXT
160 struct
162 uint32 pageID; //0
163 uint32 language; //1
164 uint32 pageMaterial; //2
165 uint32 allowMounted; //3
166 } text;
167 //10 GAMEOBJECT_TYPE_GOOBER
168 struct
170 uint32 lockId; //0 -> Lock.dbc
171 uint32 questId; //1
172 uint32 eventId; //2
173 uint32 autoCloseTime; //3 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
174 uint32 customAnim; //4
175 uint32 consumable; //5
176 uint32 cooldown; //6
177 uint32 pageId; //7
178 uint32 language; //8
179 uint32 pageMaterial; //9
180 uint32 spellId; //10
181 uint32 noDamageImmune; //11
182 uint32 linkedTrapId; //12
183 uint32 large; //13
184 uint32 openTextID; //14 can be used to replace castBarCaption?
185 uint32 closeTextID; //15
186 uint32 losOK; //16 isBattlegroundObject
187 uint32 allowMounted; //17
188 uint32 floatingTooltip; //18
189 uint32 gossipID; //19
190 uint32 WorldStateSetsState; //20
191 } goober;
192 //11 GAMEOBJECT_TYPE_TRANSPORT
193 struct
195 uint32 pause; //0
196 uint32 startOpen; //1
197 uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
198 uint32 pause1EventID; //3
199 uint32 pause2EventID; //4
200 } transport;
201 //12 GAMEOBJECT_TYPE_AREADAMAGE
202 struct
204 uint32 lockId; //0
205 uint32 radius; //1
206 uint32 damageMin; //2
207 uint32 damageMax; //3
208 uint32 damageSchool; //4
209 uint32 autoCloseTime; //5 secs till autoclose = autoCloseTime / IN_MILISECONDS (previous was 0x10000)
210 uint32 openTextID; //6
211 uint32 closeTextID; //7
212 } areadamage;
213 //13 GAMEOBJECT_TYPE_CAMERA
214 struct
216 uint32 lockId; //0 -> Lock.dbc
217 uint32 cinematicId; //1
218 uint32 eventID; //2
219 uint32 openTextID; //3 can be used to replace castBarCaption?
220 } camera;
221 //14 GAMEOBJECT_TYPE_MAPOBJECT - empty
222 //15 GAMEOBJECT_TYPE_MO_TRANSPORT
223 struct
225 uint32 taxiPathId; //0
226 uint32 moveSpeed; //1
227 uint32 accelRate; //2
228 uint32 startEventID; //3
229 uint32 stopEventID; //4
230 uint32 transportPhysics; //5
231 uint32 mapID; //6
232 uint32 worldState1; //7
233 } moTransport;
234 //16 GAMEOBJECT_TYPE_DUELFLAG - empty
235 //17 GAMEOBJECT_TYPE_FISHINGNODE - empty
236 //18 GAMEOBJECT_TYPE_SUMMONING_RITUAL
237 struct
239 uint32 reqParticipants; //0
240 uint32 spellId; //1
241 uint32 animSpell; //2
242 uint32 ritualPersistent; //3
243 uint32 casterTargetSpell; //4
244 uint32 casterTargetSpellTargets; //5
245 uint32 castersGrouped; //6
246 uint32 ritualNoTargetCheck; //7
247 } summoningRitual;
248 //19 GAMEOBJECT_TYPE_MAILBOX - empty
249 //20 GAMEOBJECT_TYPE_DONOTUSE - empty
250 //21 GAMEOBJECT_TYPE_GUARDPOST
251 struct
253 uint32 creatureID; //0
254 uint32 charges; //1
255 } guardpost;
256 //22 GAMEOBJECT_TYPE_SPELLCASTER
257 struct
259 uint32 spellId; //0
260 uint32 charges; //1
261 uint32 partyOnly; //2
262 uint32 allowMounted; //3
263 uint32 large; //4
264 } spellcaster;
265 //23 GAMEOBJECT_TYPE_MEETINGSTONE
266 struct
268 uint32 minLevel; //0
269 uint32 maxLevel; //1
270 uint32 areaID; //2
271 } meetingstone;
272 //24 GAMEOBJECT_TYPE_FLAGSTAND
273 struct
275 uint32 lockId; //0
276 uint32 pickupSpell; //1
277 uint32 radius; //2
278 uint32 returnAura; //3
279 uint32 returnSpell; //4
280 uint32 noDamageImmune; //5
281 uint32 openTextID; //6
282 uint32 losOK; //7
283 } flagstand;
284 //25 GAMEOBJECT_TYPE_FISHINGHOLE // not implemented yet
285 struct
287 uint32 radius; //0 how close bobber must land for sending loot
288 uint32 lootId; //1
289 uint32 minSuccessOpens; //2
290 uint32 maxSuccessOpens; //3
291 uint32 lockId; //4 -> Lock.dbc; possibly 1628 for all?
292 } fishinghole;
293 //26 GAMEOBJECT_TYPE_FLAGDROP
294 struct
296 uint32 lockId; //0
297 uint32 eventID; //1
298 uint32 pickupSpell; //2
299 uint32 noDamageImmune; //3
300 uint32 openTextID; //4
301 } flagdrop;
302 //27 GAMEOBJECT_TYPE_MINI_GAME
303 struct
305 uint32 gameType; //0
306 } miniGame;
307 //29 GAMEOBJECT_TYPE_CAPTURE_POINT
308 struct
310 uint32 radius; //0
311 uint32 spell; //1
312 uint32 worldState1; //2
313 uint32 worldstate2; //3
314 uint32 winEventID1; //4
315 uint32 winEventID2; //5
316 uint32 contestedEventID1; //6
317 uint32 contestedEventID2; //7
318 uint32 progressEventID1; //8
319 uint32 progressEventID2; //9
320 uint32 neutralEventID1; //10
321 uint32 neutralEventID2; //11
322 uint32 neutralPercent; //12
323 uint32 worldstate3; //13
324 uint32 minSuperiority; //14
325 uint32 maxSuperiority; //15
326 uint32 minTime; //16
327 uint32 maxTime; //17
328 uint32 large; //18
329 uint32 highlight; //19
330 uint32 startingValue; //20
331 uint32 unidirectional; //21
332 } capturePoint;
333 //30 GAMEOBJECT_TYPE_AURA_GENERATOR
334 struct
336 uint32 startOpen; //0
337 uint32 radius; //1
338 uint32 auraID1; //2
339 uint32 conditionID1; //3
340 uint32 auraID2; //4
341 uint32 conditionID2; //5
342 uint32 serverOnly; //6
343 } auraGenerator;
344 //31 GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY
345 struct
347 uint32 mapID; //0
348 uint32 difficulty; //1
349 } dungeonDifficulty;
350 //32 GAMEOBJECT_TYPE_BARBER_CHAIR
351 struct
353 uint32 chairheight; //0
354 uint32 heightOffset; //1
355 } barberChair;
356 //33 GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
357 struct
359 uint32 intactNumHits; //0
360 uint32 creditProxyCreature; //1
361 uint32 empty1; //2
362 uint32 intactEvent; //3
363 uint32 empty2; //4
364 uint32 damagedNumHits; //5
365 uint32 empty3; //6
366 uint32 empty4; //7
367 uint32 empty5; //8
368 uint32 damagedEvent; //9
369 uint32 empty6; //10
370 uint32 empty7; //11
371 uint32 empty8; //12
372 uint32 empty9; //13
373 uint32 destroyedEvent; //14
374 uint32 empty10; //15
375 uint32 debuildingTimeSecs; //16
376 uint32 empty11; //17
377 uint32 destructibleData; //18
378 uint32 rebuildingEvent; //19
379 uint32 empty12; //20
380 uint32 empty13; //21
381 uint32 damageEvent; //22
382 uint32 empty14; //23
383 } destructibleBuilding;
384 //34 GAMEOBJECT_TYPE_GUILDBANK - empty
385 //35 GAMEOBJECT_TYPE_TRAPDOOR
386 struct
388 uint32 whenToPause; // 0
389 uint32 startOpen; // 1
390 uint32 autoClose; // 2
391 } trapDoor;
393 // not use for specific field access (only for output with loop by all filed), also this determinate max union size
394 struct
396 uint32 data[24];
397 } raw;
399 uint32 ScriptId;
401 // helpers
402 bool IsDespawnAtAction() const
404 switch(type)
406 case GAMEOBJECT_TYPE_CHEST: return chest.consumable;
407 case GAMEOBJECT_TYPE_GOOBER: return goober.consumable;
408 default: return false;
412 uint32 GetLockId() const
414 switch(type)
416 case GAMEOBJECT_TYPE_DOOR: return door.lockId;
417 case GAMEOBJECT_TYPE_BUTTON: return button.lockId;
418 case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.lockId;
419 case GAMEOBJECT_TYPE_CHEST: return chest.lockId;
420 case GAMEOBJECT_TYPE_TRAP: return trap.lockId;
421 case GAMEOBJECT_TYPE_GOOBER: return goober.lockId;
422 case GAMEOBJECT_TYPE_AREADAMAGE: return areadamage.lockId;
423 case GAMEOBJECT_TYPE_CAMERA: return camera.lockId;
424 case GAMEOBJECT_TYPE_FLAGSTAND: return flagstand.lockId;
425 case GAMEOBJECT_TYPE_FISHINGHOLE:return fishinghole.lockId;
426 case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.lockId;
427 default: return 0;
431 bool GetDespawnPossibility() const // despawn at targeting of cast?
433 switch(type)
435 case GAMEOBJECT_TYPE_DOOR: return door.noDamageImmune;
436 case GAMEOBJECT_TYPE_BUTTON: return button.noDamageImmune;
437 case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.noDamageImmune;
438 case GAMEOBJECT_TYPE_GOOBER: return goober.noDamageImmune;
439 case GAMEOBJECT_TYPE_FLAGSTAND: return flagstand.noDamageImmune;
440 case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.noDamageImmune;
441 default: return true;
445 uint32 GetCharges() const // despawn at uses amount
447 switch(type)
449 case GAMEOBJECT_TYPE_TRAP: return trap.charges;
450 case GAMEOBJECT_TYPE_GUARDPOST: return guardpost.charges;
451 case GAMEOBJECT_TYPE_SPELLCASTER: return spellcaster.charges;
452 default: return 0;
456 uint32 GetLinkedGameObjectEntry() const
458 switch(type)
460 case GAMEOBJECT_TYPE_BUTTON: return button.linkedTrapId;
461 case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId;
462 case GAMEOBJECT_TYPE_SPELL_FOCUS: return spellFocus.linkedTrapId;
463 case GAMEOBJECT_TYPE_GOOBER: return goober.linkedTrapId;
464 default: return 0;
468 uint32 GetAutoCloseTime() const
470 uint32 autoCloseTime = 0;
471 switch(type)
473 case GAMEOBJECT_TYPE_DOOR: autoCloseTime = door.autoCloseTime; break;
474 case GAMEOBJECT_TYPE_BUTTON: autoCloseTime = button.autoCloseTime; break;
475 case GAMEOBJECT_TYPE_TRAP: autoCloseTime = trap.autoCloseTime; break;
476 case GAMEOBJECT_TYPE_GOOBER: autoCloseTime = goober.autoCloseTime; break;
477 case GAMEOBJECT_TYPE_TRANSPORT: autoCloseTime = transport.autoCloseTime; break;
478 case GAMEOBJECT_TYPE_AREADAMAGE: autoCloseTime = areadamage.autoCloseTime; break;
479 default: break;
481 return autoCloseTime / IN_MILISECONDS; // prior to 3.0.3, conversion was / 0x10000;
484 uint32 GetLootId() const
486 switch(type)
488 case GAMEOBJECT_TYPE_CHEST: return chest.lootId;
489 case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lootId;
490 default: return 0;
494 uint32 GetGossipMenuId() const
496 switch(type)
498 case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.gossipID;
499 case GAMEOBJECT_TYPE_GOOBER: return goober.gossipID;
500 default: return 0;
505 // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
506 #if defined( __GNUC__ )
507 #pragma pack()
508 #else
509 #pragma pack(pop)
510 #endif
512 struct GameObjectLocale
514 std::vector<std::string> Name;
515 std::vector<std::string> CastBarCaption;
518 // client side GO show states
519 enum GOState
521 GO_STATE_ACTIVE = 0, // show in world as used and not reset (closed door open)
522 GO_STATE_READY = 1, // show in world as ready (closed door close)
523 GO_STATE_ACTIVE_ALTERNATIVE = 2 // show in world as used in alt way and not reset (closed door open by cannon fire)
526 #define MAX_GO_STATE 3
528 // from `gameobject`
529 struct GameObjectData
531 uint32 id; // entry in gamobject_template
532 uint16 mapid;
533 uint16 phaseMask;
534 float posX;
535 float posY;
536 float posZ;
537 float orientation;
538 float rotation0;
539 float rotation1;
540 float rotation2;
541 float rotation3;
542 int32 spawntimesecs;
543 uint32 animprogress;
544 GOState go_state;
545 uint8 spawnMask;
548 // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
549 // For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
550 // For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
551 // For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ...
552 enum LootState
554 GO_NOT_READY = 0,
555 GO_READY, // can be ready but despawned, and then not possible activate until spawn
556 GO_ACTIVATED,
557 GO_JUST_DEACTIVATED
560 class Unit;
562 // 5 sec for bobber catch
563 #define FISHING_BOBBER_READY_TIME 5
565 class MANGOS_DLL_SPEC GameObject : public WorldObject
567 public:
568 explicit GameObject();
569 ~GameObject();
571 void AddToWorld();
572 void RemoveFromWorld();
574 bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state);
575 void Update(uint32 p_time);
576 GameObjectInfo const* GetGOInfo() const;
578 bool IsTransport() const;
580 uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
582 void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
584 void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
585 void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
586 void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
587 void Whisper(int32 textId, uint64 receiver) { MonsterWhisper(textId,receiver); }
588 void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); }
590 // overwrite WorldObject function for proper name localization
591 const char* GetNameForLocaleIdx(int32 locale_idx) const;
593 void SaveToDB();
594 void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
595 bool LoadFromDB(uint32 guid, Map *map);
596 void DeleteFromDB();
598 void SetOwnerGUID(uint64 owner)
600 m_spawnedByDefault = false; // all object with owner is despawned after delay
601 SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
603 uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
604 Unit* GetOwner() const;
606 void SetSpellId(uint32 id)
608 m_spawnedByDefault = false; // all summoned object is despawned after delay
609 m_spellId = id;
611 uint32 GetSpellId() const { return m_spellId;}
613 time_t GetRespawnTime() const { return m_respawnTime; }
614 time_t GetRespawnTimeEx() const
616 time_t now = time(NULL);
617 if(m_respawnTime > now)
618 return m_respawnTime;
619 else
620 return now;
623 void SetRespawnTime(int32 respawn)
625 m_respawnTime = respawn > 0 ? time(NULL) + respawn : 0;
626 m_respawnDelayTime = respawn > 0 ? respawn : 0;
628 void Respawn();
629 bool isSpawned() const
631 return m_respawnDelayTime == 0 ||
632 (m_respawnTime > 0 && !m_spawnedByDefault) ||
633 (m_respawnTime == 0 && m_spawnedByDefault);
635 bool isSpawnedByDefault() const { return m_spawnedByDefault; }
636 uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
637 void Refresh();
638 void Delete();
639 void getFishLoot(Loot *loot, Player* loot_owner);
640 GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
641 void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
642 GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
643 void SetGoState(GOState state) { SetByteValue(GAMEOBJECT_BYTES_1, 0, state); }
644 uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
645 void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); }
646 uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
647 void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
649 void Use(Unit* user);
651 LootState getLootState() const { return m_lootState; }
652 void SetLootState(LootState s) { m_lootState = s; }
654 void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
655 bool IsInSkillupList(uint32 PlayerGuidLow) const
657 for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
658 if (*i == PlayerGuidLow) return true;
659 return false;
661 void ClearSkillupList() { m_SkillupList.clear(); }
663 void AddUniqueUse(Player* player);
664 void AddUse() { ++m_usetimes; }
666 uint32 GetUseCount() const { return m_usetimes; }
667 uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
669 void SaveRespawnTime();
671 Loot loot;
673 bool hasQuest(uint32 quest_id) const;
674 bool hasInvolvedQuest(uint32 quest_id) const;
675 bool ActivateToQuest(Player *pTarget) const;
676 void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false);
677 // 0 = use `gameobject`.`spawntimesecs`
678 void ResetDoorOrButton();
681 void SummonLinkedTrapIfAny();
682 void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);
684 bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
686 GameObject* LookupFishingHoleAround(float range);
688 GridReference<GameObject> &GetGridRef() { return m_gridRef; }
690 bool isActiveObject() const { return false; }
691 uint64 GetRotation() const { return m_rotation; }
692 protected:
693 uint32 m_spellId;
694 time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
695 uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
696 LootState m_lootState;
697 bool m_spawnedByDefault;
698 time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
699 // For traps this: spell casting cooldown, for doors/buttons: reset time.
700 std::list<uint32> m_SkillupList;
702 std::set<uint32> m_unique_users;
703 uint32 m_usetimes;
705 uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
706 GameObjectInfo const* m_goInfo;
707 uint64 m_rotation;
708 private:
709 void SwitchDoorOrButton(bool activate, bool alternative = false);
711 GridReference<GameObject> m_gridRef;
713 #endif