Skip to content
Permalink
Browse files

Core/Spells: Fix various issues related to fishing

-Correctly show escaped, instead of not hooked for timer expire.
-Double down on failed LOS checks in GetNearPoint
-Prevent handling spell effects potentially multiple times per spell
  • Loading branch information...
AbraKabastard committed May 15, 2019
1 parent 1b56eed commit a6cde8f3ca6e5478b6f4f79408adc284eae97ec8
Showing with 43 additions and 40 deletions.
  1. +1 −1 src/game/GameObject.cpp
  2. +24 −0 src/game/Object.cpp
  3. +14 −27 src/game/Spell.cpp
  4. +4 −12 src/game/SpellEffects.cpp
@@ -305,7 +305,7 @@ void GameObject::Update(uint32 diff)
{
caster->FinishSpell(CURRENT_CHANNELED_SPELL);

WorldPacket data(SMSG_FISH_NOT_HOOKED, 0);
WorldPacket data(SMSG_FISH_ESCAPED, 0);
caster->ToPlayer()->GetSession()->SendPacket(&data);
}
// can be delete
@@ -2354,6 +2354,30 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float& x, float&
GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
z = GetPositionZ();
UpdateAllowedPositionZ(x, y, z);

// return if the point is already in LoS
if (IsWithinLOS(x, y, z))
return;

// remember first point
float first_x = x;
float first_y = y;
float first_z = z;

// loop in a circle to look for a point in LoS using small steps
for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8)
{
GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
z = GetPositionZ();
UpdateAllowedPositionZ(x, y, z);
if (IsWithinLOS(x, y, z))
return;
}

// still not in LoS, give up and return first position found
x = first_x;
y = first_y;
z = first_z;
}

Position WorldObject::GetNearPosition(float dist, float angle)
@@ -1587,8 +1587,8 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex));
float dis = rand_norm() * (max_dis - min_dis) + min_dis;
float x, y, z, angle;
angle = (float)rand_norm() * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
float x, y, z;
float angle = float(rand_norm()) * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis, angle);

float ground = z;
@@ -2693,22 +2693,6 @@ void Spell::_handle_immediate_phase()
TakeCastItem();

m_needSpellLog = m_isNeedSendToClient;
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (m_spellInfo->Effect[j] == 0)
continue;

// apply Send Event effect to ground in case empty target lists
if (m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT || m_spellInfo->Effect[j] == SPELL_EFFECT_TRANS_DOOR && !HaveTargetsForEffect(j))
{
HandleEffects(NULL, NULL, NULL, j);
continue;
}

// Don't do spell log, if is school damage spell
if (m_spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || m_spellInfo->Effect[j] == 0)
m_needSpellLog = false;
}

// initialize Diminishing Returns Data
m_diminishLevel = DIMINISHING_LEVEL_1;
@@ -2720,17 +2704,20 @@ void Spell::_handle_immediate_phase()

if (!m_originalCaster)
return;
// process ground

// handle effects with SPELL_EFFECT_HANDLE_HIT mode
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (sSpellMgr.EffectTargetType[m_spellInfo->Effect[j]] == SPELL_REQUIRE_DEST)
{
if (!m_targets.HasDst()) // FIXME: this will ignore dest set in effect
m_targets.setDst(m_caster);
HandleEffects(m_originalCaster, NULL, NULL, j);
}
else if (sSpellMgr.EffectTargetType[m_spellInfo->Effect[j]] == SPELL_REQUIRE_NONE)
HandleEffects(m_originalCaster, NULL, NULL, j);
// don't do anything for empty effect
if (m_spellInfo->Effect[j] == 0)
continue;

// call effect handlers to handle destination hit
HandleEffects(nullptr, nullptr, nullptr, j);

// Don't do spell log, if is school damage spell
if (m_spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE)
m_needSpellLog = false;
}
}

@@ -6888,18 +6888,10 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
int32 lastSec = 0;
switch (urand(0, 3))
{
case 0:
lastSec = 3;
break;
case 1:
lastSec = 7;
break;
case 2:
lastSec = 13;
break;
case 3:
lastSec = 17;
break;
case 0: lastSec = 3; break;
case 1: lastSec = 7; break;
case 2: lastSec = 13; break;
case 3: lastSec = 17; break;
}

duration = duration - lastSec * IN_MILLISECONDS + FISHING_BOBBER_READY_TIME * IN_MILLISECONDS;

0 comments on commit a6cde8f

Please sign in to comment.
You can’t perform that action at this time.