mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11729] Improve fishing bobber placement and send more correct error messages.
This commit is contained in:
parent
776ef3885a
commit
35e8af7195
2 changed files with 30 additions and 16 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11728"
|
||||
#define REVISION_NR "11729"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue