From f121f4e971a445e1131e11aeb943f17f853c8303 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sat, 11 Dec 2010 10:27:34 +0100 Subject: [PATCH] [10855] Add TARGET_AREAEFFECT_GO_AROUND_DEST(52) (renamed from TARGET_AREAEFFECT_CUSTOM_2) Target selects all gameobject around destination, limited by adding spell with a corresponding gameobject entry in database table spell_script_target. Signed-off-by: NoFantasy --- src/game/GridNotifiers.h | 62 ++++++++++++++++++++++++++++++++++++++++ src/game/SharedDefines.h | 2 +- src/game/Spell.cpp | 32 ++++++++++++++++++++- src/game/SpellMgr.cpp | 4 ++- src/game/SpellMgr.h | 4 +-- src/shared/revision_nr.h | 2 +- 6 files changed, 100 insertions(+), 6 deletions(-) diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 45c6b9050f3..ca104ceeead 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -687,6 +687,68 @@ namespace MaNGOS NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&); }; + // Success at gameobject in range of xyz, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO) + class NearestGameObjectEntryInPosRangeCheck + { + public: + NearestGameObjectEntryInPosRangeCheck(WorldObject const& obj, uint32 entry, float x, float y, float z, float range) + : i_obj(obj), i_x(x), i_y(y), i_z(z), i_entry(entry), i_range(range) {} + + WorldObject const& GetFocusObject() const { return i_obj; } + + bool operator()(GameObject* go) + { + if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range)) + { + // use found GO range as new range limit for next check + i_range = go->GetDistance(i_x,i_y,i_z); + return true; + } + + return false; + } + + float GetLastRange() const { return i_range; } + + private: + WorldObject const& i_obj; + uint32 i_entry; + float i_x, i_y, i_z; + float i_range; + + // prevent clone this object + NearestGameObjectEntryInPosRangeCheck(NearestGameObjectEntryInPosRangeCheck const&); + }; + + // Success at gameobject with entry in range of provided xyz + class GameObjectEntryInPosRangeCheck + { + public: + GameObjectEntryInPosRangeCheck(WorldObject const& obj, uint32 entry, float x, float y, float z, float range) + : i_obj(obj), i_x(x), i_y(y), i_z(z), i_entry(entry), i_range(range) {} + + WorldObject const& GetFocusObject() const { return i_obj; } + + bool operator()(GameObject* go) + { + if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range)) + return true; + + return false; + } + + float GetLastRange() const { return i_range; } + + private: + WorldObject const& i_obj; + uint32 i_entry; + float i_x, i_y, i_z; + float i_range; + + // prevent clone this object + GameObjectEntryInPosRangeCheck(GameObjectEntryInPosRangeCheck const&); + }; + class GameObjectWithDbGUIDCheck { public: diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 16399c04af3..cd41ca9f40a 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1076,7 +1076,7 @@ enum Targets TARGET_DYNAMIC_OBJECT_BEHIND = 48, TARGET_DYNAMIC_OBJECT_LEFT_SIDE = 49, TARGET_DYNAMIC_OBJECT_RIGHT_SIDE = 50, - TARGET_AREAEFFECT_CUSTOM_2 = 52, + TARGET_AREAEFFECT_GO_AROUND_DEST = 52, // gameobject around destination, select by spell_script_target TARGET_CURRENT_ENEMY_COORDINATES = 53, // set unit coordinates as dest, only 16 target B imlemented TARGET_LARGE_FRONTAL_CONE = 54, TARGET_ALL_RAID_AROUND_CASTER = 56, diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index a7206cc9ed2..14caebe9f54 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1588,7 +1588,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case TARGET_TOTEM_FIRE: case TARGET_SELF: case TARGET_SELF2: - case TARGET_AREAEFFECT_CUSTOM_2: targetUnitMap.push_back(m_caster); break; case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA: @@ -1891,6 +1890,37 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& } break; } + case TARGET_AREAEFFECT_GO_AROUND_DEST: + { + // It may be possible to fill targets for some spell effects + // automatically (SPELL_EFFECT_WMO_REPAIR(88) for example) but + // for some/most spells we clearly need/want to limit with spell_target_script + + // Some spells untested, for affected GO type 33. May need further adjustments for spells related. + + SpellScriptTargetBounds bounds = sSpellMgr.GetSpellScriptTargetBounds(m_spellInfo->Id); + + std::list tempTargetGOList; + + for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST) + { + if (i_spellST->second.type == SPELL_TARGET_TYPE_GAMEOBJECT) + { + // search all GO's with entry, within range of m_destN + MaNGOS::GameObjectEntryInPosRangeCheck go_check(*m_caster, i_spellST->second.targetEntry, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, radius); + MaNGOS::GameObjectListSearcher checker(tempTargetGOList, go_check); + Cell::VisitGridObjects(m_caster, checker, radius); + } + } + + if (!tempTargetGOList.empty()) + { + for(std::list::iterator iter = tempTargetGOList.begin(); iter != tempTargetGOList.end(); ++iter) + AddGOTarget(*iter, effIndex); + } + + break; + } case TARGET_ALL_ENEMY_IN_AREA_INSTANT: { // targets the ground, not the units in the area diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index ba56157ab01..e9e0ae9502b 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2964,7 +2964,9 @@ void SpellMgr::LoadSpellScriptTarget() spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_INSTANT || spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_INSTANT || spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_CUSTOM || - spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_CUSTOM) + spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_CUSTOM || + spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_GO_AROUND_DEST || + spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_GO_AROUND_DEST) { targetfound = true; break; diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 1ab7cbad9cb..21030e311ef 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -266,7 +266,7 @@ inline bool IsCasterSourceTarget(uint32 target) case TARGET_TOTEM_WATER: case TARGET_TOTEM_AIR: case TARGET_TOTEM_FIRE: - case TARGET_AREAEFFECT_CUSTOM_2: + case TARGET_AREAEFFECT_GO_AROUND_DEST: case TARGET_ALL_RAID_AROUND_CASTER: case TARGET_SELF2: case TARGET_DIRECTLY_FORWARD: @@ -358,7 +358,7 @@ inline bool IsAreaEffectTarget( Targets target ) case TARGET_ALL_PARTY: case TARGET_ALL_PARTY_AROUND_CASTER_2: case TARGET_AREAEFFECT_PARTY: - case TARGET_AREAEFFECT_CUSTOM_2: + case TARGET_AREAEFFECT_GO_AROUND_DEST: case TARGET_ALL_RAID_AROUND_CASTER: case TARGET_AREAEFFECT_PARTY_AND_CLASS: case TARGET_IN_FRONT_OF_CASTER_30: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 715406f3cad..70519a7d2ce 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 "10854" + #define REVISION_NR "10855" #endif // __REVISION_NR_H__