diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 9f064b9f8..8977f4e8c 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -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 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(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 38c652f15..08265f645 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10859" + #define REVISION_NR "10860" #endif // __REVISION_NR_H__