[11112] Implement use cooldown check for trap/goober gameobjects.

This commit is contained in:
VladimirMangos 2011-02-07 03:04:14 +03:00
parent b120464db7
commit abbd2f09be
3 changed files with 22 additions and 3 deletions

View file

@ -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.