[10860] Handle GAMEOBJECT_TYPE_TRAP in Use, as done for other GO types.

This just move parts of existing code from TriggeringLinkedGameObject and does not affect summoned trap type GO's (or related to summoned).

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-12-11 21:36:53 +01:00
parent a2e068659c
commit 6aab362980
2 changed files with 25 additions and 13 deletions

View file

@ -836,17 +836,19 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
// TODO: allow all traps to be activated, some are without spell
// but will have animation and/or are expected to despawn
if(!trapSpell) // checked at load already
return;
// The range to search for linked trap is weird. We set 0.5 as default. Most (all?)
// traps are probably expected to be pretty much at the same location as the used GO,
// so it appears that using range from spell is obsolete.
float range = 0.5f;
float range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex));
if (trapSpell) // checked at load already
range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex));
// search nearest linked GO
GameObject* trapGO = NULL;
{
// search closest with base of used GO, using max range of trap spell as search radius
// search closest with base of used GO, using max range of trap spell as search radius (why? See above)
MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*this, trapEntry, range);
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(trapGO, go_check);
@ -854,12 +856,8 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
}
// found correct GO
// TODO: handle the GO with Use()
// FIXME: when GO casting will be implemented trap must cast spell to target
if(trapGO)
target->CastSpell(target, trapSpell, true, NULL, NULL, GetGUID());
if (trapGO)
trapGO->Use(target);
}
GameObject* GameObject::LookupFishingHoleAround(float range)
@ -986,6 +984,20 @@ void GameObject::Use(Unit* user)
SetLootState(GO_JUST_DEACTIVATED);
return;
}
case GAMEOBJECT_TYPE_TRAP: // 6
{
// Currently we do not expect trap code below to be Use()
// directly (except from spell effect). Code here will be called by TriggeringLinkedGameObject.
// 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());
// TODO: all traps can be activated, also those without spell.
// Some may have have animation and/or are expected to despawn.
return;
}
case GAMEOBJECT_TYPE_CHAIR: //7 Sitting: Wooden bench, chairs
{
GameObjectInfo const* info = GetGOInfo();