I've been searching for a patch to fix blink for some time, and I found one in KAPATEJIb's cumulative patches. I've got to say that patch is really good.
Blink never fails, always removes stun, will never teleport you under the map, and in 99% teleports forward. Why 99%? Because it doesn't work in tunnels, such as Stormwind tunnels that connect districts. My guess is in that zone maps or vmaps are not generated correct, because at the orgrimmar entrace(tunnel), blink works normally. In other zones, works perfect, including arenas and BGs. Doesn't teleport through objects, brings you up to them. Works only if there are vmaps on.
Here are the changes:
Spell.cpp
case SPELL_EFFECT_LEAP:
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
{
- 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 = MapManager::Instance().GetBaseMap(m_caster->GetMapId())->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;
-
- 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;
-
// not allow use this effect at battleground until battleground start
if(m_caster->GetTypeId()==TYPEID_PLAYER)
if(BattleGround const *bg = ((Player*)m_caster)->GetBattleGround())
SpellEffects.cpp
void Spell::EffectMomentMove(uint32 i)
{
if(unitTarget->isInFlight())
return;
if( m_spellInfo->rangeIndex== 1) //self range
{
uint32 mapid = m_caster->GetMapId();
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
// Start Info //
float cx,cy,cz;
float dx,dy,dz;
float angle = unitTarget->GetOrientation();
unitTarget->GetPosition(cx,cy,cz);
//Check use of vamps//
bool useVmap = false;
bool swapZone = true;
if( MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(cx, cy, cz, false) < MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(cx, cy, cz, true) )
useVmap = true;
const int itr = int(dis/0.5f);
const float _dx = 0.5f * cos(angle);
const float _dy = 0.5f * sin(angle);
dx = cx;
dy = cy;
//Going foward 0.5f until max distance
for(float i=0.5f; i<dis; i+=0.5f)
{
//unitTarget->GetNearPoint2D(dx,dy,i,angle);
dx += _dx;
dy += _dy;
MaNGOS::NormalizeMapCoord(dx);
MaNGOS::NormalizeMapCoord(dy);
dz = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(dx, dy, cz, useVmap);
//Prevent climbing and go around object maybe 2.0f is to small? use 3.0f?
if( (dz-cz) < 2.0f && (dz-cz) > -2.0f && (unitTarget->IsWithinLOS(dx, dy, dz)))
{
//No climb, the z differenze between this and prev step is ok. Store this destination for future use or check.
cx = dx;
cy = dy;
cz = dz;
}
else
{
//Something wrong with los or z differenze... maybe we are going from outer world inside a building or viceversa
if(swapZone)
{
//so... change use of vamp and go back 1 step backward and recheck again.
swapZone = false;
useVmap = !useVmap;
//i-=0.5f;
--i;
dx -= _dx;
dy -= _dy;
}
else
{
//bad recheck result... so break this and use last good coord for teleport player...
dz += 0.5f;
break;
}
}
}
//Prevent Falling during swap building/outerspace
unitTarget->UpdateGroundPositionZ(cx, cy, cz);
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
((Player*)unitTarget)->TeleportTo(mapid, cx, cy, cz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
else
MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, cx, cy, cz, unitTarget->GetOrientation());
}
}
In SpellEffects.cpp, the MomentMove function is completely replaced by this one. This function is a modified version of KAPATEJIb's patch, dx, dy coords are computed in other way.
I tested this patch only for 2.4.3. For 3.0.x I'm not sure if it will work. However it should.
P.S. I hope it will help finish your work, Tassader2.