Rewrite of EffectMomentMove, this should finally fix blink.
* Even when player cannot move, only effect will fail, which means other spelleffects will work. * Vmaps are required for proper work (as expected) Please test and report bugs. --HG-- branch : trunk
This commit is contained in:
+1
-14
@@ -4116,20 +4116,7 @@ uint8 Spell::CanCast(bool strict)
|
|||||||
case SPELL_EFFECT_LEAP:
|
case SPELL_EFFECT_LEAP:
|
||||||
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
|
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
|
||||||
{
|
{
|
||||||
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
|
//Do not allow to cast it before BG starts.
|
||||||
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(m_caster->GetTypeId()==TYPEID_PLAYER)
|
||||||
if(BattleGround const *bg = ((Player*)m_caster)->GetBattleGround())
|
if(BattleGround const *bg = ((Player*)m_caster)->GetBattleGround())
|
||||||
if(bg->GetStatus() != STATUS_IN_PROGRESS)
|
if(bg->GetStatus() != STATUS_IN_PROGRESS)
|
||||||
|
|||||||
+33
-46
@@ -5482,64 +5482,51 @@ void Spell::EffectMomentMove(uint32 i)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 mapid = m_caster->GetMapId();
|
uint32 mapid = m_caster->GetMapId();
|
||||||
float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
|
float dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
|
||||||
|
float x,y,z;
|
||||||
|
float destx,desty,destz,ground,floor;
|
||||||
|
float orientation = unitTarget->GetOrientation(), step = dist/10.0f;
|
||||||
|
|
||||||
// src point
|
unitTarget->GetPosition(x,y,z);
|
||||||
float *fx = new float[11], *fy = new float[11], *fz = new float[11];
|
destx = x + dist * cos(orientation);
|
||||||
unitTarget->GetPosition(fx[0], fy[0], fz[0]);
|
desty = y + dist * sin(orientation);
|
||||||
|
ground = unitTarget->GetMap()->GetHeight(destx,desty,MAX_HEIGHT,true);
|
||||||
|
floor = unitTarget->GetMap()->GetHeight(destx,desty,z, true);
|
||||||
|
destz = fabs(ground - z) <= fabs(floor - z) ? ground:floor;
|
||||||
|
|
||||||
float orientation = unitTarget->GetOrientation(), itr_i, step = dis / 10.0, fx2, fy2, fz2, ground, floor;
|
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid,x,y,z+0.5f,destx,desty,destz+0.5f,destx,desty,destz,-0.5f);
|
||||||
int itr_j = 1, last_valid = 0;
|
|
||||||
bool hit = false;
|
|
||||||
|
|
||||||
for (itr_i = step; itr_i <= dis; itr_i += step)
|
if(col) // We had a collision!
|
||||||
{
|
{
|
||||||
fx[itr_j] = fx[0] + itr_i * cos(orientation);
|
destx -= 0.6 * cos(orientation);
|
||||||
fy[itr_j] = fy[0] + itr_i * sin(orientation);
|
desty -= 0.6 * sin(orientation);
|
||||||
ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true);
|
dist = sqrt((x-destx)*(x-destx) + (y-desty)*(y-desty));
|
||||||
floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true);
|
step = dist/10.0f;
|
||||||
fz[itr_j] = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor;
|
}
|
||||||
if (fabs(fz[itr_j] - fz[0]) <= 6.0)
|
|
||||||
|
|
||||||
|
for(int i = 0;i<10;i++)
|
||||||
{
|
{
|
||||||
if (VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, fx[last_valid], fy[last_valid], fz[last_valid] + 0.5, fx[itr_j], fy[itr_j], fz[itr_j] + 0.5, fx2, fy2, fz2, -0.5))
|
if(fabs(z - destz) > 6)
|
||||||
{
|
{
|
||||||
hit = true;
|
destx -= step * cos(orientation);
|
||||||
fx[itr_j] = fx2 - 0.6 * cos(orientation);
|
desty -= step * sin(orientation);
|
||||||
fy[itr_j] = fy2 - 0.6 * sin(orientation);
|
ground = unitTarget->GetMap()->GetHeight(destx,desty,MAX_HEIGHT,true);
|
||||||
ground = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], MAX_HEIGHT, true);
|
floor = unitTarget->GetMap()->GetHeight(destx,desty,z, true);
|
||||||
floor = MapManager::Instance().GetMap(mapid, unitTarget)->GetHeight(fx[itr_j], fy[itr_j], fz[last_valid], true);
|
destz = fabs(ground - z) <= fabs(floor - z) ? ground:floor;
|
||||||
float tempz = fabs(ground - fz[last_valid]) <= fabs(floor - fz[last_valid]) ? ground : floor;
|
}else
|
||||||
fz[itr_j] = fabs(tempz - fz[last_valid]) <= fabs(fz2 - fz[last_valid]) ? tempz : fz2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
if(i == 9)
|
||||||
last_valid = itr_j;
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
itr_j++;
|
|
||||||
}
|
|
||||||
if (hit == false)
|
|
||||||
itr_j = last_valid;
|
|
||||||
|
|
||||||
|
|
||||||
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
|
|
||||||
((Player*)unitTarget)->TeleportTo(mapid, fx[itr_j], fy[itr_j], fz[itr_j] + 0.07531, orientation, 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, fx[itr_j], fy[itr_j], fz[itr_j] + 0.07531, orientation);
|
|
||||||
|
|
||||||
delete [] fx; delete [] fy; delete [] fz;
|
|
||||||
|
|
||||||
/* uint32 mapid = unitTarget->GetMapId();
|
|
||||||
float ox,oy,oz;
|
|
||||||
unitTarget->GetPosition(ox,oy,oz);
|
|
||||||
|
|
||||||
float fx,fy,fz; // getObjectHitPos overwrite last args in any result case
|
|
||||||
if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, ox,oy,oz+0.5, m_targets.m_destX,m_targets.m_destY,oz+0.5,fx,fy,fz, -0.5))
|
|
||||||
unitTarget->UpdateGroundPositionZ(fx,fy,fz);
|
|
||||||
|
|
||||||
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
if(unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||||
((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
((Player*)unitTarget)->TeleportTo(mapid, destx, desty, destz+0.07531f, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
|
||||||
else
|
else
|
||||||
MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation());*/
|
unitTarget->GetMap()->CreatureRelocation((Creature*)unitTarget, destx, desty, destz,unitTarget->GetOrientation());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::EffectReputation(uint32 i)
|
void Spell::EffectReputation(uint32 i)
|
||||||
|
|||||||
Reference in New Issue
Block a user