Core/Gameobject: Respect cooldown for trap and goober gameobjects.

Original patch by VladimirMangos
This commit is contained in:
Machiavelli
2011-03-14 23:16:34 +01:00
parent cd5744f2c5
commit 1c3082446e
2 changed files with 23 additions and 2 deletions
@@ -451,7 +451,7 @@ void GameObject::Update(uint32 diff)
if (goInfo->trap.spellId)
CastSpell(ok, goInfo->trap.spellId);
m_cooldownTime = time(NULL) + 4; // 4 seconds
m_cooldownTime = time(NULL) + goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4); // template or 4 seconds
if (owner) // || goInfo->trap.charges == 1)
SetLootState(GO_JUST_DEACTIVATED);
@@ -1048,7 +1048,16 @@ void GameObject::Use(Unit* user)
AI()->GossipHello(playerUser);
}
switch(GetGoType())
// If cooldown data present in template
if (uint32 cooldown = GetGOInfo()->GetCooldown())
{
if (m_cooldownTime > sWorld->GetGameTime())
return;
m_cooldownTime = sWorld->GetGameTime() + cooldown;
}
switch (GetGoType())
{
case GAMEOBJECT_TYPE_DOOR: //0
case GAMEOBJECT_TYPE_BUTTON: //1
@@ -495,6 +495,7 @@ struct GameObjectInfo
default: return 0;
}
}
uint32 GetGossipMenuId() const
{
switch(type)
@@ -504,6 +505,7 @@ struct GameObjectInfo
default: return 0;
}
}
uint32 GetEventScriptId() const
{
switch(type)
@@ -514,6 +516,16 @@ struct GameObjectInfo
default: return 0;
}
}
uint32 GetCooldown() const // Cooldown preventing goober and traps to cast spell
{
switch (type)
{
case GAMEOBJECT_TYPE_TRAP: return trap.cooldown;
case GAMEOBJECT_TYPE_GOOBER: return goober.cooldown;
default: return 0;
}
}
};
class OPvPCapturePoint;