[2] | 1 | /* |
---|
| 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
| 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. |
---|
| 8 | * |
---|
| 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. |
---|
| 13 | * |
---|
| 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 |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef MANGOSSERVER_GAMEOBJECT_H |
---|
| 20 | #define MANGOSSERVER_GAMEOBJECT_H |
---|
| 21 | |
---|
| 22 | #include "Common.h" |
---|
| 23 | #include "SharedDefines.h" |
---|
| 24 | #include "Object.h" |
---|
| 25 | #include "LootMgr.h" |
---|
| 26 | #include "Database/DatabaseEnv.h" |
---|
| 27 | |
---|
| 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 |
---|
| 34 | |
---|
| 35 | // from `gameobject_template` |
---|
| 36 | struct GameObjectInfo |
---|
| 37 | { |
---|
| 38 | uint32 id; |
---|
| 39 | uint32 type; |
---|
| 40 | uint32 displayId; |
---|
| 41 | char *name; |
---|
| 42 | char *castBarCaption; |
---|
| 43 | uint32 faction; |
---|
| 44 | uint32 flags; |
---|
| 45 | float size; |
---|
| 46 | union // different GO types have different data field |
---|
| 47 | { |
---|
| 48 | //0 GAMEOBJECT_TYPE_DOOR |
---|
| 49 | struct |
---|
| 50 | { |
---|
| 51 | uint32 startOpen; //0 used client side to determine GO_ACTIVATED means open/closed |
---|
| 52 | uint32 lockId; //1 -> Lock.dbc |
---|
| 53 | uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / 0x10000 |
---|
| 54 | uint32 noDamageImmune; //3 break opening whenever you recieve damage? |
---|
| 55 | uint32 openTextID; //4 can be used to replace castBarCaption? |
---|
| 56 | uint32 closeTextID; //5 |
---|
| 57 | } door; |
---|
| 58 | //1 GAMEOBJECT_TYPE_BUTTON |
---|
| 59 | struct |
---|
| 60 | { |
---|
| 61 | uint32 startOpen; //0 |
---|
| 62 | uint32 lockId; //1 -> Lock.dbc |
---|
| 63 | uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / 0x10000 |
---|
| 64 | uint32 linkedTrap; //3 |
---|
| 65 | uint32 noDamageImmune; //4 isBattlegroundObject |
---|
| 66 | uint32 large; //5 |
---|
| 67 | uint32 openTextID; //6 can be used to replace castBarCaption? |
---|
| 68 | uint32 closeTextID; //7 |
---|
| 69 | uint32 losOK; //8 |
---|
| 70 | } button; |
---|
| 71 | //2 GAMEOBJECT_TYPE_QUESTGIVER |
---|
| 72 | struct |
---|
| 73 | { |
---|
| 74 | uint32 lockId; //0 -> Lock.dbc |
---|
| 75 | uint32 questList; //1 |
---|
| 76 | uint32 pageMaterial; //2 |
---|
| 77 | uint32 gossipID; //3 |
---|
| 78 | uint32 customAnim; //4 |
---|
| 79 | uint32 noDamageImmune; //5 |
---|
| 80 | uint32 openTextID; //6 can be used to replace castBarCaption? |
---|
| 81 | uint32 losOK; //7 |
---|
| 82 | uint32 allowMounted; //8 |
---|
| 83 | uint32 large; //9 |
---|
| 84 | } questgiver; |
---|
| 85 | //3 GAMEOBJECT_TYPE_CHEST |
---|
| 86 | struct |
---|
| 87 | { |
---|
| 88 | uint32 lockId; //0 -> Lock.dbc |
---|
| 89 | uint32 lootId; //1 |
---|
| 90 | uint32 chestRestockTime; //2 |
---|
| 91 | uint32 consumable; //3 |
---|
| 92 | uint32 minSuccessOpens; //4 |
---|
| 93 | uint32 maxSuccessOpens; //5 |
---|
| 94 | uint32 eventId; //6 lootedEvent |
---|
| 95 | uint32 linkedTrapId; //7 |
---|
| 96 | uint32 questId; //8 not used currently but store quest required for GO activation for player |
---|
| 97 | uint32 level; //9 |
---|
| 98 | uint32 losOK; //10 |
---|
| 99 | uint32 leaveLoot; //11 |
---|
| 100 | uint32 notInCombat; //12 |
---|
| 101 | uint32 logLoot; //13 |
---|
| 102 | uint32 openTextID; //14 can be used to replace castBarCaption? |
---|
| 103 | uint32 groupLootRules; //15 |
---|
| 104 | } chest; |
---|
| 105 | //5 GAMEOBJECT_TYPE_GENERIC |
---|
| 106 | struct |
---|
| 107 | { |
---|
| 108 | uint32 floatingTooltip; //0 |
---|
| 109 | uint32 highlight; //1 |
---|
| 110 | uint32 serverOnly; //2 |
---|
| 111 | uint32 large; //3 |
---|
| 112 | uint32 floatOnWater; //4 |
---|
| 113 | uint32 questID; //5 |
---|
| 114 | } _generic; |
---|
| 115 | //6 GAMEOBJECT_TYPE_TRAP |
---|
| 116 | struct |
---|
| 117 | { |
---|
| 118 | uint32 lockId; //0 -> Lock.dbc |
---|
| 119 | uint32 level; //1 |
---|
| 120 | uint32 radius; //2 radius for trap activation |
---|
| 121 | uint32 spellId; //3 |
---|
| 122 | uint32 charges; //4 need respawn (if > 0) |
---|
| 123 | uint32 cooldown; //5 time in secs |
---|
| 124 | uint32 autoCloseTime; //6 |
---|
| 125 | uint32 startDelay; //7 |
---|
| 126 | uint32 serverOnly; //8 |
---|
| 127 | uint32 stealthed; //9 |
---|
| 128 | uint32 large; //10 |
---|
| 129 | uint32 stealthAffected; //11 |
---|
| 130 | uint32 openTextID; //12 can be used to replace castBarCaption? |
---|
| 131 | uint32 closeTextID; //13 |
---|
| 132 | } trap; |
---|
| 133 | //7 GAMEOBJECT_TYPE_CHAIR |
---|
| 134 | struct |
---|
| 135 | { |
---|
| 136 | uint32 slots; //0 |
---|
| 137 | uint32 height; //1 |
---|
| 138 | uint32 onlyCreatorUse; //2 |
---|
| 139 | } chair; |
---|
| 140 | //8 GAMEOBJECT_TYPE_SPELL_FOCUS |
---|
| 141 | struct |
---|
| 142 | { |
---|
| 143 | uint32 focusId; //0 |
---|
| 144 | uint32 dist; //1 |
---|
| 145 | uint32 linkedTrapId; //2 |
---|
| 146 | uint32 serverOnly; //3 |
---|
| 147 | uint32 questID; //4 |
---|
| 148 | uint32 large; //5 |
---|
| 149 | } spellFocus; |
---|
| 150 | //9 GAMEOBJECT_TYPE_TEXT |
---|
| 151 | struct |
---|
| 152 | { |
---|
| 153 | uint32 pageID; //0 |
---|
| 154 | uint32 language; //1 |
---|
| 155 | uint32 pageMaterial; //2 |
---|
| 156 | uint32 allowMounted; //3 |
---|
| 157 | } text; |
---|
| 158 | //10 GAMEOBJECT_TYPE_GOOBER |
---|
| 159 | struct |
---|
| 160 | { |
---|
| 161 | uint32 lockId; //0 -> Lock.dbc |
---|
| 162 | uint32 questId; //1 |
---|
| 163 | uint32 eventId; //2 |
---|
| 164 | uint32 autoCloseTime; //3 |
---|
| 165 | uint32 customAnim; //4 |
---|
| 166 | uint32 consumable; //5 |
---|
| 167 | uint32 cooldown; //6 |
---|
| 168 | uint32 pageId; //7 |
---|
| 169 | uint32 language; //8 |
---|
| 170 | uint32 pageMaterial; //9 |
---|
| 171 | uint32 spellId; //10 |
---|
| 172 | uint32 noDamageImmune; //11 |
---|
| 173 | uint32 linkedTrapId; //12 |
---|
| 174 | uint32 large; //13 |
---|
| 175 | uint32 openTextID; //14 can be used to replace castBarCaption? |
---|
| 176 | uint32 closeTextID; //15 |
---|
| 177 | uint32 losOK; //16 isBattlegroundObject |
---|
| 178 | uint32 allowMounted; //17 |
---|
| 179 | } goober; |
---|
| 180 | //11 GAMEOBJECT_TYPE_TRANSPORT |
---|
| 181 | struct |
---|
| 182 | { |
---|
| 183 | uint32 pause; //0 |
---|
| 184 | uint32 startOpen; //1 |
---|
| 185 | uint32 autoCloseTime; //2 secs till autoclose = autoCloseTime / 0x10000 |
---|
| 186 | } transport; |
---|
| 187 | //12 GAMEOBJECT_TYPE_AREADAMAGE |
---|
| 188 | struct |
---|
| 189 | { |
---|
| 190 | uint32 lockId; //0 |
---|
| 191 | uint32 radius; //1 |
---|
| 192 | uint32 damageMin; //2 |
---|
| 193 | uint32 damageMax; //3 |
---|
| 194 | uint32 damageSchool; //4 |
---|
| 195 | uint32 autoCloseTime; //5 secs till autoclose = autoCloseTime / 0x10000 |
---|
| 196 | uint32 openTextID; //6 |
---|
| 197 | uint32 closeTextID; //7 |
---|
| 198 | } areadamage; |
---|
| 199 | //13 GAMEOBJECT_TYPE_CAMERA |
---|
| 200 | struct |
---|
| 201 | { |
---|
| 202 | uint32 lockId; //0 -> Lock.dbc |
---|
| 203 | uint32 cinematicId; //1 |
---|
| 204 | uint32 eventID; //2 |
---|
| 205 | uint32 openTextID; //3 can be used to replace castBarCaption? |
---|
| 206 | } camera; |
---|
| 207 | //15 GAMEOBJECT_TYPE_MO_TRANSPORT |
---|
| 208 | struct |
---|
| 209 | { |
---|
| 210 | uint32 taxiPathId; //0 |
---|
| 211 | uint32 moveSpeed; //1 |
---|
| 212 | uint32 accelRate; //2 |
---|
| 213 | uint32 startEventID; //3 |
---|
| 214 | uint32 stopEventID; //4 |
---|
| 215 | uint32 transportPhysics; //5 |
---|
| 216 | uint32 mapID; //6 |
---|
| 217 | } moTransport; |
---|
| 218 | //17 GAMEOBJECT_TYPE_FISHINGNODE |
---|
| 219 | struct |
---|
| 220 | { |
---|
| 221 | uint32 _data0; //0 |
---|
| 222 | uint32 lootId; //1 |
---|
| 223 | } fishnode; |
---|
| 224 | //18 GAMEOBJECT_TYPE_SUMMONING_RITUAL |
---|
| 225 | struct |
---|
| 226 | { |
---|
| 227 | uint32 reqParticipants; //0 |
---|
| 228 | uint32 spellId; //1 |
---|
| 229 | uint32 animSpell; //2 |
---|
| 230 | uint32 ritualPersistent; //3 |
---|
| 231 | uint32 casterTargetSpell; //4 |
---|
| 232 | uint32 casterTargetSpellTargets; //5 |
---|
| 233 | uint32 castersGrouped; //6 |
---|
| 234 | uint32 ritualNoTargetCheck; //7 |
---|
| 235 | } summoningRitual; |
---|
| 236 | //20 GAMEOBJECT_TYPE_AUCTIONHOUSE |
---|
| 237 | struct |
---|
| 238 | { |
---|
| 239 | uint32 actionHouseID; //0 |
---|
| 240 | } auctionhouse; |
---|
| 241 | //21 GAMEOBJECT_TYPE_GUARDPOST |
---|
| 242 | struct |
---|
| 243 | { |
---|
| 244 | uint32 creatureID; //0 |
---|
| 245 | uint32 charges; //1 |
---|
| 246 | } guardpost; |
---|
| 247 | //22 GAMEOBJECT_TYPE_SPELLCASTER |
---|
| 248 | struct |
---|
| 249 | { |
---|
| 250 | uint32 spellId; //0 |
---|
| 251 | uint32 charges; //1 |
---|
| 252 | uint32 partyOnly; //2 |
---|
| 253 | } spellcaster; |
---|
| 254 | //23 GAMEOBJECT_TYPE_MEETINGSTONE |
---|
| 255 | struct |
---|
| 256 | { |
---|
| 257 | uint32 minLevel; //0 |
---|
| 258 | uint32 maxLevel; //1 |
---|
| 259 | uint32 areaID; //2 |
---|
| 260 | } meetingstone; |
---|
| 261 | //24 GAMEOBJECT_TYPE_FLAGSTAND |
---|
| 262 | struct |
---|
| 263 | { |
---|
| 264 | uint32 lockId; //0 |
---|
| 265 | uint32 pickupSpell; //1 |
---|
| 266 | uint32 radius; //2 |
---|
| 267 | uint32 returnAura; //3 |
---|
| 268 | uint32 returnSpell; //4 |
---|
| 269 | uint32 noDamageImmune; //5 |
---|
| 270 | uint32 openTextID; //6 |
---|
| 271 | uint32 losOK; //7 |
---|
| 272 | } flagstand; |
---|
| 273 | //25 GAMEOBJECT_TYPE_FISHINGHOLE // not implemented yet |
---|
| 274 | struct |
---|
| 275 | { |
---|
| 276 | uint32 radius; //0 how close bobber must land for sending loot |
---|
| 277 | uint32 lootId; //1 |
---|
| 278 | uint32 minSuccessOpens; //2 |
---|
| 279 | uint32 maxSuccessOpens; //3 |
---|
| 280 | uint32 lockId; //4 -> Lock.dbc; possibly 1628 for all? |
---|
| 281 | } fishinghole; |
---|
| 282 | //26 GAMEOBJECT_TYPE_FLAGDROP |
---|
| 283 | struct |
---|
| 284 | { |
---|
| 285 | uint32 lockId; //0 |
---|
| 286 | uint32 eventID; //1 |
---|
| 287 | uint32 pickupSpell; //2 |
---|
| 288 | uint32 noDamageImmune; //3 |
---|
| 289 | uint32 openTextID; //4 |
---|
| 290 | } flagdrop; |
---|
| 291 | //27 GAMEOBJECT_TYPE_MINI_GAME |
---|
| 292 | struct |
---|
| 293 | { |
---|
| 294 | uint32 gameType; //0 |
---|
| 295 | } miniGame; |
---|
| 296 | //29 GAMEOBJECT_TYPE_CAPTURE_POINT |
---|
| 297 | struct |
---|
| 298 | { |
---|
| 299 | uint32 radius; //0 |
---|
| 300 | uint32 spell; //1 |
---|
| 301 | uint32 worldState1; //2 |
---|
| 302 | uint32 worldstate2; //3 |
---|
| 303 | uint32 winEventID1; //4 |
---|
| 304 | uint32 winEventID2; //5 |
---|
| 305 | uint32 contestedEventID1; //6 |
---|
| 306 | uint32 contestedEventID2; //7 |
---|
| 307 | uint32 progressEventID1; //8 |
---|
| 308 | uint32 progressEventID2; //9 |
---|
| 309 | uint32 neutralEventID1; //10 |
---|
| 310 | uint32 neutralEventID2; //11 |
---|
| 311 | uint32 neutralPercent; //12 |
---|
| 312 | uint32 worldstate3; //13 |
---|
| 313 | uint32 minSuperiority; //14 |
---|
| 314 | uint32 maxSuperiority; //15 |
---|
| 315 | uint32 minTime; //16 |
---|
| 316 | uint32 maxTime; //17 |
---|
| 317 | uint32 large; //18 |
---|
| 318 | uint32 highlight; //19 |
---|
| 319 | } capturePoint; |
---|
| 320 | //30 GAMEOBJECT_TYPE_AURA_GENERATOR |
---|
| 321 | struct |
---|
| 322 | { |
---|
| 323 | uint32 startOpen; //0 |
---|
| 324 | uint32 radius; //1 |
---|
| 325 | uint32 auraID1; //2 |
---|
| 326 | uint32 conditionID1; //3 |
---|
| 327 | uint32 auraID2; //4 |
---|
| 328 | uint32 conditionID2; //5 |
---|
| 329 | uint32 serverOnly; //6 |
---|
| 330 | } auraGenerator; |
---|
| 331 | //31 GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY |
---|
| 332 | struct |
---|
| 333 | { |
---|
| 334 | uint32 mapID; //0 |
---|
| 335 | uint32 difficulty; //1 |
---|
| 336 | } dungeonDifficulty; |
---|
| 337 | //32 GAMEOBJECT_TYPE_DO_NOT_USE_YET |
---|
| 338 | struct |
---|
| 339 | { |
---|
| 340 | uint32 mapID; //0 |
---|
| 341 | uint32 difficulty; //1 |
---|
| 342 | } doNotUseYet; |
---|
| 343 | //33 GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING |
---|
| 344 | struct |
---|
| 345 | { |
---|
| 346 | uint32 dmgPctState1; //0 |
---|
| 347 | uint32 dmgPctState2; //1 |
---|
| 348 | uint32 state1Name; //2 |
---|
| 349 | uint32 state2Name; //3 |
---|
| 350 | } destructibleBuilding; |
---|
| 351 | |
---|
| 352 | // not use for specific field access (only for output with loop by all filed), also this determinate max union size |
---|
| 353 | struct // GAMEOBJECT_TYPE_SPELLCASTER |
---|
| 354 | { |
---|
| 355 | uint32 data[24]; |
---|
| 356 | } raw; |
---|
| 357 | }; |
---|
| 358 | char *ScriptName; |
---|
| 359 | }; |
---|
| 360 | |
---|
| 361 | struct GameObjectLocale |
---|
| 362 | { |
---|
| 363 | std::vector<std::string> Name; |
---|
| 364 | std::vector<std::string> CastBarCaption; |
---|
| 365 | }; |
---|
| 366 | |
---|
| 367 | // from `gameobject` |
---|
| 368 | struct GameObjectData |
---|
| 369 | { |
---|
| 370 | uint32 id; // entry in gamobject_template |
---|
| 371 | uint32 mapid; |
---|
| 372 | float posX; |
---|
| 373 | float posY; |
---|
| 374 | float posZ; |
---|
| 375 | float orientation; |
---|
| 376 | float rotation0; |
---|
| 377 | float rotation1; |
---|
| 378 | float rotation2; |
---|
| 379 | float rotation3; |
---|
| 380 | int32 spawntimesecs; |
---|
| 381 | uint32 animprogress; |
---|
| 382 | uint32 go_state; |
---|
| 383 | uint8 spawnMask; |
---|
| 384 | }; |
---|
| 385 | |
---|
| 386 | // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform |
---|
| 387 | #if defined( __GNUC__ ) |
---|
| 388 | #pragma pack() |
---|
| 389 | #else |
---|
| 390 | #pragma pack(pop) |
---|
| 391 | #endif |
---|
| 392 | |
---|
| 393 | // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ... |
---|
| 394 | // For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted> |
---|
| 395 | // For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ... |
---|
| 396 | // For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ... |
---|
| 397 | enum LootState |
---|
| 398 | { |
---|
| 399 | GO_NOT_READY = 0, |
---|
| 400 | GO_READY, // can be ready but despawned, and then not possible activate until spawn |
---|
| 401 | GO_ACTIVATED, |
---|
| 402 | GO_JUST_DEACTIVATED |
---|
| 403 | }; |
---|
| 404 | |
---|
| 405 | class Unit; |
---|
| 406 | |
---|
| 407 | // 5 sec for bobber catch |
---|
| 408 | #define FISHING_BOBBER_READY_TIME 5 |
---|
| 409 | |
---|
| 410 | class MANGOS_DLL_SPEC GameObject : public WorldObject |
---|
| 411 | { |
---|
| 412 | public: |
---|
| 413 | explicit GameObject(); |
---|
| 414 | ~GameObject(); |
---|
| 415 | |
---|
| 416 | void AddToWorld(); |
---|
| 417 | void RemoveFromWorld(); |
---|
| 418 | |
---|
| 419 | bool Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state); |
---|
| 420 | void Update(uint32 p_time); |
---|
| 421 | static GameObject* GetGameObject(WorldObject& object, uint64 guid); |
---|
| 422 | GameObjectInfo const* GetGOInfo() const; |
---|
| 423 | |
---|
| 424 | bool IsTransport() const; |
---|
| 425 | |
---|
| 426 | void SetOwnerGUID(uint64 owner) |
---|
| 427 | { |
---|
| 428 | m_spawnedByDefault = false; // all object with owner is despawned after delay |
---|
| 429 | SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner); |
---|
| 430 | } |
---|
| 431 | uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); } |
---|
| 432 | Unit* GetOwner() const; |
---|
| 433 | |
---|
| 434 | uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } |
---|
| 435 | |
---|
| 436 | void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); } |
---|
| 437 | void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); } |
---|
| 438 | void TextEmote(const char* text, uint64 TargetGuid) { MonsterTextEmote(text,TargetGuid); } |
---|
| 439 | void Whisper(const char* text,uint64 receiver) { MonsterWhisper(text,receiver); } |
---|
| 440 | void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); } |
---|
| 441 | void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); } |
---|
| 442 | void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); } |
---|
| 443 | void Whisper(int32 textId, uint64 receiver) { MonsterWhisper(textId,receiver); } |
---|
| 444 | |
---|
| 445 | void SaveToDB(); |
---|
| 446 | void SaveToDB(uint32 mapid, uint8 spawnMask); |
---|
| 447 | bool LoadFromDB(uint32 guid, Map *map); |
---|
| 448 | void DeleteFromDB(); |
---|
| 449 | void SetLootState(LootState s) { m_lootState = s; } |
---|
| 450 | static uint32 GetLootId(GameObjectInfo const* info); |
---|
| 451 | uint32 GetLootId() const { return GetLootId(GetGOInfo()); } |
---|
| 452 | uint32 GetLockId() const |
---|
| 453 | { |
---|
| 454 | switch(GetGoType()) |
---|
| 455 | { |
---|
| 456 | case GAMEOBJECT_TYPE_DOOR: return GetGOInfo()->door.lockId; |
---|
| 457 | case GAMEOBJECT_TYPE_BUTTON: return GetGOInfo()->button.lockId; |
---|
| 458 | case GAMEOBJECT_TYPE_QUESTGIVER: return GetGOInfo()->questgiver.lockId; |
---|
| 459 | case GAMEOBJECT_TYPE_CHEST: return GetGOInfo()->chest.lockId; |
---|
| 460 | case GAMEOBJECT_TYPE_TRAP: return GetGOInfo()->trap.lockId; |
---|
| 461 | case GAMEOBJECT_TYPE_GOOBER: return GetGOInfo()->goober.lockId; |
---|
| 462 | case GAMEOBJECT_TYPE_AREADAMAGE: return GetGOInfo()->areadamage.lockId; |
---|
| 463 | case GAMEOBJECT_TYPE_CAMERA: return GetGOInfo()->camera.lockId; |
---|
| 464 | case GAMEOBJECT_TYPE_FLAGSTAND: return GetGOInfo()->flagstand.lockId; |
---|
| 465 | case GAMEOBJECT_TYPE_FISHINGHOLE:return GetGOInfo()->fishinghole.lockId; |
---|
| 466 | case GAMEOBJECT_TYPE_FLAGDROP: return GetGOInfo()->flagdrop.lockId; |
---|
| 467 | default: return 0; |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | time_t GetRespawnTime() const { return m_respawnTime; } |
---|
| 472 | time_t GetRespawnTimeEx() const |
---|
| 473 | { |
---|
| 474 | time_t now = time(NULL); |
---|
| 475 | if(m_respawnTime > now) |
---|
| 476 | return m_respawnTime; |
---|
| 477 | else |
---|
| 478 | return now; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | void SetRespawnTime(int32 respawn) |
---|
| 482 | { |
---|
| 483 | m_respawnTime = respawn > 0 ? time(NULL) + respawn : 0; |
---|
| 484 | m_respawnDelayTime = respawn > 0 ? respawn : 0; |
---|
| 485 | } |
---|
| 486 | void Respawn(); |
---|
| 487 | bool isSpawned() const |
---|
| 488 | { |
---|
| 489 | return m_respawnDelayTime == 0 || |
---|
| 490 | (m_respawnTime > 0 && !m_spawnedByDefault) || |
---|
| 491 | (m_respawnTime == 0 && m_spawnedByDefault); |
---|
| 492 | } |
---|
| 493 | bool isSpawnedByDefault() const { return m_spawnedByDefault; } |
---|
| 494 | uint32 GetRespawnDelay() const { return m_respawnDelayTime; } |
---|
| 495 | void Refresh(); |
---|
| 496 | void Delete(); |
---|
| 497 | void SetSpellId(uint32 id) { m_spellId = id;} |
---|
| 498 | uint32 GetSpellId() const { return m_spellId;} |
---|
| 499 | void getFishLoot(Loot *loot); |
---|
| 500 | GameobjectTypes GetGoType() const { return GameobjectTypes(GetUInt32Value(GAMEOBJECT_TYPE_ID)); } |
---|
| 501 | void SetGoType(GameobjectTypes type) { SetUInt32Value(GAMEOBJECT_TYPE_ID, type); } |
---|
| 502 | uint32 GetGoState() const { return GetUInt32Value(GAMEOBJECT_STATE); } |
---|
| 503 | void SetGoState(uint32 state) { SetUInt32Value(GAMEOBJECT_STATE, state); } |
---|
| 504 | uint32 GetGoArtKit() const { return GetUInt32Value(GAMEOBJECT_ARTKIT); } |
---|
| 505 | void SetGoArtKit(uint32 artkit) { SetUInt32Value(GAMEOBJECT_ARTKIT, artkit); } |
---|
| 506 | uint32 GetGoAnimProgress() const { return GetUInt32Value(GAMEOBJECT_ANIMPROGRESS); } |
---|
| 507 | void SetGoAnimProgress(uint32 animprogress) { SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, animprogress); } |
---|
| 508 | |
---|
| 509 | void Use(Unit* user); |
---|
| 510 | |
---|
| 511 | LootState getLootState() const { return m_lootState; } |
---|
| 512 | |
---|
| 513 | void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } |
---|
| 514 | bool IsInSkillupList(uint32 PlayerGuidLow) const |
---|
| 515 | { |
---|
| 516 | for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) |
---|
| 517 | if (*i == PlayerGuidLow) return true; |
---|
| 518 | return false; |
---|
| 519 | } |
---|
| 520 | void ClearSkillupList() { m_SkillupList.clear(); } |
---|
| 521 | |
---|
| 522 | void AddUniqueUse(Player* player); |
---|
| 523 | void AddUse() { ++m_usetimes; } |
---|
| 524 | |
---|
| 525 | uint32 GetUseCount() const { return m_usetimes; } |
---|
| 526 | uint32 GetUniqueUseCount() const { return m_unique_users.size(); } |
---|
| 527 | |
---|
| 528 | void SaveRespawnTime(); |
---|
| 529 | |
---|
| 530 | Loot loot; |
---|
| 531 | |
---|
| 532 | bool hasQuest(uint32 quest_id) const; |
---|
| 533 | bool hasInvolvedQuest(uint32 quest_id) const; |
---|
| 534 | bool ActivateToQuest(Player *pTarget) const; |
---|
| 535 | void UseDoorOrButton(uint32 time_to_restore = 0); // 0 = use `gameobject`.`spawntimesecs` |
---|
| 536 | |
---|
| 537 | uint32 GetLinkedGameObjectEntry() const |
---|
| 538 | { |
---|
| 539 | switch(GetGoType()) |
---|
| 540 | { |
---|
| 541 | case GAMEOBJECT_TYPE_CHEST: return GetGOInfo()->chest.linkedTrapId; |
---|
| 542 | case GAMEOBJECT_TYPE_SPELL_FOCUS: return GetGOInfo()->spellFocus.linkedTrapId; |
---|
| 543 | case GAMEOBJECT_TYPE_GOOBER: return GetGOInfo()->goober.linkedTrapId; |
---|
| 544 | default: return 0; |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | uint32 GetAutoCloseTime() const |
---|
| 549 | { |
---|
| 550 | uint32 autoCloseTime = 0; |
---|
| 551 | switch(GetGoType()) |
---|
| 552 | { |
---|
| 553 | case GAMEOBJECT_TYPE_DOOR: autoCloseTime = GetGOInfo()->door.autoCloseTime; break; |
---|
| 554 | case GAMEOBJECT_TYPE_BUTTON: autoCloseTime = GetGOInfo()->button.autoCloseTime; break; |
---|
| 555 | case GAMEOBJECT_TYPE_TRAP: autoCloseTime = GetGOInfo()->trap.autoCloseTime; break; |
---|
| 556 | case GAMEOBJECT_TYPE_GOOBER: autoCloseTime = GetGOInfo()->goober.autoCloseTime; break; |
---|
| 557 | case GAMEOBJECT_TYPE_TRANSPORT: autoCloseTime = GetGOInfo()->transport.autoCloseTime; break; |
---|
| 558 | case GAMEOBJECT_TYPE_AREADAMAGE: autoCloseTime = GetGOInfo()->areadamage.autoCloseTime; break; |
---|
| 559 | default: break; |
---|
| 560 | } |
---|
| 561 | return autoCloseTime / 0x10000; |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target); |
---|
| 565 | |
---|
| 566 | bool isVisibleForInState(Player const* u, bool inVisibleList) const; |
---|
| 567 | |
---|
| 568 | GameObject* LookupFishingHoleAround(float range); |
---|
| 569 | |
---|
| 570 | GridReference<GameObject> &GetGridRef() { return m_gridRef; } |
---|
| 571 | protected: |
---|
| 572 | uint32 m_charges; // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22) |
---|
| 573 | uint32 m_spellId; |
---|
| 574 | time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()), |
---|
| 575 | uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer |
---|
| 576 | LootState m_lootState; |
---|
| 577 | bool m_spawnedByDefault; |
---|
| 578 | time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). |
---|
| 579 | // For traps this: spell casting cooldown, for doors/buttons: reset time. |
---|
| 580 | std::list<uint32> m_SkillupList; |
---|
| 581 | |
---|
| 582 | std::set<uint32> m_unique_users; |
---|
| 583 | uint32 m_usetimes; |
---|
| 584 | |
---|
| 585 | uint32 m_DBTableGuid; |
---|
| 586 | GameObjectInfo const* m_goInfo; |
---|
| 587 | private: |
---|
| 588 | void SwitchDoorOrButton(bool activate); |
---|
| 589 | |
---|
| 590 | GridReference<GameObject> m_gridRef; |
---|
| 591 | }; |
---|
| 592 | #endif |
---|