[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); SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
// TODO: allow all traps to be activated, some are without spell // The range to search for linked trap is weird. We set 0.5 as default. Most (all?)
// but will have animation and/or are expected to despawn // traps are probably expected to be pretty much at the same location as the used GO,
if(!trapSpell) // checked at load already // so it appears that using range from spell is obsolete.
return; 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 // search nearest linked GO
GameObject* trapGO = NULL; 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::NearestGameObjectEntryInObjectRangeCheck go_check(*this, trapEntry, range);
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(trapGO, go_check); MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(trapGO, go_check);
@ -854,12 +856,8 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
} }
// found correct GO // found correct GO
if (trapGO)
// TODO: handle the GO with Use() trapGO->Use(target);
// FIXME: when GO casting will be implemented trap must cast spell to target
if(trapGO)
target->CastSpell(target, trapSpell, true, NULL, NULL, GetGUID());
} }
GameObject* GameObject::LookupFishingHoleAround(float range) GameObject* GameObject::LookupFishingHoleAround(float range)
@ -986,6 +984,20 @@ void GameObject::Use(Unit* user)
SetLootState(GO_JUST_DEACTIVATED); SetLootState(GO_JUST_DEACTIVATED);
return; 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 case GAMEOBJECT_TYPE_CHAIR: //7 Sitting: Wooden bench, chairs
{ {
GameObjectInfo const* info = GetGOInfo(); GameObjectInfo const* info = GetGOInfo();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10859" #define REVISION_NR "10860"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__