FeenixServerProject/Phoenix_1.12_Bugtracker — Issue #204: Mage Blink Bug
Author: MagezZ
Created: 2011-10-31 08:45:10+00:00
State: open

Often Blink doesnt even work. All mages know this bug.

Found this on a 2.4.3 mangos server, may fixs some blink bugs, even its not perfect (its not my script).

diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 6738973..d377139 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4753,15 +4753,67 @@ SpellCastResult Spell::CheckCast(bool strict)
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation());
float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation());
- // teleport a bit above terrain level to avoid falling below it
float fz = m_caster->GetTerrain()->GetHeight(fx, fy, m_caster->GetPositionZ(), true);
- if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled
- return SPELL_FAILED_TRY_AGAIN;
+ // teleport a bit above terrain level to avoid falling below it
+ if (!m_caster->GetTerrain()->IsInWater(fx, fy, m_caster->GetPositionZ()))
+ {
+ if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled
+ {
+ float fLevel = m_caster->GetTerrain()->GetWaterOrGroundLevel(fx, fy, m_caster->GetPositionZ(), NULL, true);
+ if (m_caster->GetPositionZ() <= fLevel || fLevel <= INVALID_HEIGHT)
+ return SPELL_FAILED_TRY_AGAIN;
+ }

- float caster_pos_z = m_caster->GetPositionZ();
- // Control the caster to not climb or drop when +-fz > 8
- if(!(fz <= caster_pos_z + 8 && fz >= caster_pos_z - 8))
- return SPELL_FAILED_TRY_AGAIN;
+ float caster_pos_z = m_caster->GetPositionZ();
+ // Control the caster to not climb or drop when +-fz > 8
+ if(!(fz <= caster_pos_z + 8 && fz >= caster_pos_z - 8))
+ {
+ bool bSuccess = false;
+ if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ {
+ if (Player* pPlayer = (Player*)m_caster)
+ {
+ // if player not on ground
+ float fLevel = pPlayer->GetTerrain()->GetWaterOrGroundLevel(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), NULL, true);
+ if (fLevel > INVALID_HEIGHT && m_caster->GetPositionZ() > fLevel+2)
+ {
+ if (!strict)
+ pPlayer->SetPosition(m_caster->GetPositionX(), m_caster->GetPositionY(), fLevel+2, m_caster->GetOrientation(), false);
+ bSuccess = true;
+ }
+ }
+ }
+ if (!bSuccess)
+ return SPELL_FAILED_TRY_AGAIN;
+ }
+ }
+ else // if target point is in water
+ {
+ if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ {
+ if (Player* pPlayer = (Player*)m_caster)
+ {
+ bool bSuccess = false;
+ // if player not on ground
+ float fGroundLevel = 0;
+ float fLevel = pPlayer->GetTerrain()->GetWaterOrGroundLevel(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), &fGroundLevel, true);
+ if (pPlayer->IsInWater())
+ {
+ if (fLevel > INVALID_HEIGHT && fGroundLevel > INVALID_HEIGHT)
+ bSuccess = true;
+ }
+ else if (fLevel > INVALID_HEIGHT && m_caster->GetPositionZ() > fLevel)
+ {
+ if (!strict)
+ pPlayer->SetPosition(m_caster->GetPositionX(), m_caster->GetPositionY(), fLevel, m_caster->GetOrientation(), false);
+ bSuccess = true;
+ }
+
+ if (!bSuccess)
+ return SPELL_FAILED_TRY_AGAIN;
+ }
+ }
+ }

// not allow use this effect at battleground until battleground start
if(m_caster->GetTypeId() == TYPEID_PLAYER)
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index bf637a6..b5cde57 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -5613,7 +5613,7 @@ void Spell::EffectLeapForward(SpellEffectIndex eff_idx)
unitTarget->UpdateAllowedPositionZ(fx, fy, fz);
}

- unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(), unitTarget == m_caster);
+ unitTarget->NearTeleportTo(fx, fy, fz+1, unitTarget->GetOrientation(), unitTarget == m_caster);
}
}