From 35e8af71957f9701ddd8d54ee4d3cc23c5afb5dc Mon Sep 17 00:00:00 2001 From: Lynx3d Date: Sun, 10 Jul 2011 03:54:50 +0200 Subject: [PATCH] [11729] Improve fishing bobber placement and send more correct error messages. --- src/game/SpellEffects.cpp | 44 ++++++++++++++++++++++++++------------- src/shared/revision_nr.h | 2 +- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 3be75dd7a..5f34df16e 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -8739,27 +8739,41 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); float dis = rand_norm_f() * (max_dis - min_dis) + min_dis; - m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); + // special code for fishing bobber (TARGET_SELF_FISHING), should not try to avoid objects + // nor try to find ground level, but randomly vary in angle + if (goinfo->type == GAMEOBJECT_TYPE_FISHINGNODE) + { + // calculate angle variation for roughly equal dimensions of target area + float max_angle = (max_dis - min_dis)/(max_dis + m_caster->GetObjectBoundingRadius()); + float angle_offset = max_angle * (rand_norm_f() - 0.5f); + m_caster->GetNearPoint2D(fx, fy, dis, m_caster->GetOrientation() + angle_offset); + + GridMapLiquidData liqData; + if (!m_caster->GetTerrain()->IsInWater(fx, fy, m_caster->GetPositionZ() + 1.f, &liqData)) + { + SendCastResult(SPELL_FAILED_NOT_FISHABLE); + SendChannelUpdate(0); + return; + } + + fz = liqData.level; + // finally, check LoS + if (!m_caster->IsWithinLOS(fx, fy, fz)) + { + SendCastResult(SPELL_FAILED_LINE_OF_SIGHT); + SendChannelUpdate(0); + return; + } + } + else + m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); } Map *cMap = m_caster->GetMap(); - if(goinfo->type==GAMEOBJECT_TYPE_FISHINGNODE) - { - GridMapLiquidData liqData; - if ( !m_caster->GetTerrain()->IsInWater(fx, fy, fz + 1.f/* -0.5f */, &liqData)) // Hack to prevent fishing bobber from failing to land on fishing hole - { // but this is not proper, we really need to ignore not materialized objects - SendCastResult(SPELL_FAILED_NOT_HERE); - SendChannelUpdate(0); - return; - } - // replace by water level in this case - //fz = cMap->GetWaterLevel(fx, fy); - fz = liqData.level; - } // if gameobject is summoning object, it should be spawned right on caster's position - else if(goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) + if (goinfo->type == GAMEOBJECT_TYPE_SUMMONING_RITUAL) { m_caster->GetPosition(fx, fy, fz); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index eb4c7e2c4..ee31963d3 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 "11728" + #define REVISION_NR "11729" #endif // __REVISION_NR_H__