From abbd2f09bef45d7d9e48aa181f1c5aa93f31d408 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 7 Feb 2011 03:04:14 +0300 Subject: [PATCH] [11112] Implement use cooldown check for trap/goober gameobjects. --- src/game/GameObject.cpp | 11 ++++++++++- src/game/GameObject.h | 12 +++++++++++- src/shared/revision_nr.h | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 9120fe4c6..aa4de140b 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -922,6 +922,15 @@ void GameObject::Use(Unit* user) if (user->GetTypeId() == TYPEID_PLAYER && sScriptMgr.OnGameObjectUse((Player*)user, this)) return; + // test only for exist cooldown data (cooldown timer used for door/buttons reset that not have use cooldown) + if (uint32 cooldown = GetGOInfo()->GetCooldown()) + { + if (m_cooldownTime > sWorld.GetGameTime()) + return; + + m_cooldownTime = sWorld.GetGameTime() + cooldown; + } + switch(GetGoType()) { case GAMEOBJECT_TYPE_DOOR: // 0 @@ -989,7 +998,7 @@ void GameObject::Use(Unit* user) // FIXME: when GO casting will be implemented trap must cast spell to target if (uint32 spellId = GetGOInfo()->trap.spellId) - user->CastSpell(user, spellId, true, NULL, NULL, GetGUID()); + user->CastSpell(user, spellId, true, NULL, NULL, GetObjectGuid()); // TODO: all traps can be activated, also those without spell. // Some may have have animation and/or are expected to despawn. diff --git a/src/game/GameObject.h b/src/game/GameObject.h index f6b4ac065..a5a0dba0d 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -456,6 +456,16 @@ struct GameObjectInfo } } + uint32 GetCooldown() const // not triggering at detection target or use until coolodwn expire + { + switch(type) + { + case GAMEOBJECT_TYPE_TRAP: return trap.cooldown; + case GAMEOBJECT_TYPE_GOOBER: return goober.cooldown; + default: return 0; + } + } + uint32 GetLinkedGameObjectEntry() const { switch(type) @@ -711,7 +721,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject LootState m_lootState; bool m_spawnedByDefault; time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). - // For traps this: spell casting cooldown, for doors/buttons: reset time. + // For traps/goober this: spell casting cooldown, for doors/buttons: reset time. typedef std::set GuidsSet; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0cb33dd85..5928078dc 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11111" + #define REVISION_NR "11112" #endif // __REVISION_NR_H__