Rewrite parts of GameObject use for GO type 10, by NoFantasy.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-01-16 19:31:10 +03:00
parent 7be4b2a85c
commit ed5152316f
2 changed files with 46 additions and 38 deletions

View File

@@ -410,7 +410,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;
}
@@ -427,15 +437,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));
// For now we do not support go cast
//if (owner) owner->CastSpell(owner, spellId, false, 0, 0, GetGUID());
if (owner) owner->CastSpell(owner, spellId, false);
if (Unit* owner = Unit::GetUnit(*this, uint64(*it)))
owner->CastSpell(owner, spellId, false);
}
m_unique_users.clear();
m_usetimes = 0;
}
SetGoState(GO_STATE_READY);
//any return here in case battleground traps
}
@@ -1096,13 +1107,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 && objmgr.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)
SendCustomAnim();
else
SetGoState(GO_STATE_ACTIVE);
m_cooldownTime = time(NULL) + time_to_restore;
// cast this spell later if provided
spellId = info->goober.spellId;

View File

@@ -3278,36 +3278,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);
gameObjTarget->EventInform(gameObjTarget->GetGOInfo()->goober.eventId);
}
// 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;
Script->GOHello(player, gameObjTarget);
gameObjTarget->GetMap()->ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget);
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: