[9181] Rewrite parts of GameObject use for GO type 10

This implement using autoclose time for type 10 and also sending a custom animation for some.
To avoid duplicate code, remove code from SendLoot() (handled in Use() instead)

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-01-15 01:23:11 +01:00
parent a461652636
commit 0d6b7f144c
3 changed files with 47 additions and 33 deletions

View file

@ -377,7 +377,17 @@ void GameObject::Update(uint32 /*p_time*/)
if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
ResetDoorOrButton();
break;
default: break;
case GAMEOBJECT_TYPE_GOOBER:
if (m_cooldownTime < time(NULL))
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}
break;
default:
break;
}
break;
}
@ -394,13 +404,16 @@ void GameObject::Update(uint32 /*p_time*/)
std::set<uint32>::const_iterator end = m_unique_users.end();
for (; it != end; it++)
{
Unit* owner = Unit::GetUnit(*this, uint64(*it));
if (owner) owner->CastSpell(owner, spellId, false, 0, 0, GetGUID());
if (Unit* owner = Unit::GetUnit(*this, uint64(*it)))
owner->CastSpell(owner, spellId, false, NULL, NULL, GetGUID());
}
m_unique_users.clear();
m_usetimes = 0;
}
SetGoState(GO_STATE_READY);
//any return here in case battleground traps
}
@ -960,13 +973,39 @@ void GameObject::Use(Unit* user)
player->SendPreparedGossip(this);
}
// possible quest objective for active quests
player->CastedCreatureOrGO(info->id, GetGUID(), 0);
if (info->goober.eventId)
{
sLog.outDebug("Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
}
// possible quest objective for active quests
if (info->goober.questId && sObjectMgr.GetQuestTemplate(info->goober.questId))
{
//Quest require to be active for GO using
if (player->GetQuestStatus(info->goober.questId) != QUEST_STATUS_INCOMPLETE)
break;
}
player->CastedCreatureOrGO(info->id, GetGUID(), 0);
}
if (uint32 trapEntry = info->goober.linkedTrapId)
TriggeringLinkedGameObject(trapEntry, user);
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetLootState(GO_ACTIVATED);
uint32 time_to_restore = info->GetAutoCloseTime();
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
if (time_to_restore && info->goober.customAnim)
SendGameObjectCustomAnim(GetGUID());
else
SetGoState(GO_STATE_ACTIVE);
m_cooldownTime = time(NULL) + time_to_restore;
// cast this spell later if provided
spellId = info->goober.spellId;

View file

@ -3116,32 +3116,7 @@ void Spell::SendLoot(uint64 guid, LootType loottype)
return;
case GAMEOBJECT_TYPE_GOOBER:
// goober_scripts can be triggered if the player don't have the quest
if (gameObjTarget->GetGOInfo()->goober.eventId)
{
sLog.outDebug("Goober ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->goober.eventId,gameObjTarget->GetDBTableGUIDLow());
player->GetMap()->ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->goober.eventId, player, gameObjTarget);
}
// cast goober spell
if (gameObjTarget->GetGOInfo()->goober.questId)
///Quest require to be active for GO using
if (player->GetQuestStatus(gameObjTarget->GetGOInfo()->goober.questId) != QUEST_STATUS_INCOMPLETE)
return;
gameObjTarget->AddUniqueUse(player);
gameObjTarget->SetLootState(GO_JUST_DEACTIVATED);
//TODO? Objective counting called without spell check but with quest objective check
// if send spell id then this line will duplicate to spell casting call (double counting)
// So we or have this line and not required in quest_template have reqSpellIdN
// or must remove this line and required in DB have data in quest_template have reqSpellIdN for all quest using cases.
player->CastedCreatureOrGO(gameObjTarget->GetEntry(), gameObjTarget->GetGUID(), 0);
// triggering linked GO
if (uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId)
gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster);
gameObjTarget->Use(m_caster);
return;
case GAMEOBJECT_TYPE_CHEST:

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9180"
#define REVISION_NR "9181"
#endif // __REVISION_NR_H__