*Move target handling of TARGET_DEST_CASTER_FRONT_LEAP out of SPELL_EFFECT_LEAP handler, this fixes spells with SPELL_EFFECT_LEAP using other target types.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-07-21 02:06:51 +02:00
parent 1944cd17a1
commit dd89c54c6e
5 changed files with 65 additions and 45 deletions
@@ -2223,6 +2223,56 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
pos.m_orientation = m_orientation;
}
void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle)
{
angle += m_orientation;
float destx, desty, destz, ground, floor;
destx = pos.m_positionX + dist * cos(angle);
desty = pos.m_positionY + dist * sin(angle);
ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(),pos.m_positionX,pos.m_positionY,pos.m_positionZ+0.5f,destx,desty,destz+0.5f,destx,desty,destz,-0.5f);
// collision occured
if (col)
{
// move back a bit
destx -= CONTACT_DISTANCE * cos(angle);
desty -= CONTACT_DISTANCE * sin(angle);
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
}
float step = dist/10.0f;
int j = 0;
for (j; j < 10; j++)
{
// do not allow too big z changes
if (fabs(pos.m_positionZ - destz) > 6)
{
destx -= step * cos(angle);
desty -= step * sin(angle);
ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
}
// we have correct destz now
else
{
pos.Relocate(destx, desty, destz);
break;
}
}
Trinity::NormalizeMapCoord(pos.m_positionX);
Trinity::NormalizeMapCoord(pos.m_positionY);
UpdateGroundPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
pos.m_orientation = m_orientation;
}
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{
m_phaseMask = newPhaseMask;
+6
View File
@@ -487,6 +487,12 @@ class WorldObject : public Object, public WorldLocation
GetPosition(&pos);
MovePosition(pos, dist, angle);
}
void MovePositionToFirstCollision(Position &pos, float dist, float angle);
void GetFirstCollisionPosition(Position &pos, float dist, float angle)
{
GetPosition(&pos);
MovePositionToFirstCollision(pos, dist, angle);
}
void GetRandomNearPosition(Position &pos, float radius)
{
GetPosition(&pos);
+5 -1
View File
@@ -2005,6 +2005,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
float objSize = m_caster->GetObjectSize();
dist = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if (modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, dist, this);
if (dist < objSize)
dist = objSize;
else if (cur == TARGET_DEST_CASTER_RANDOM)
@@ -2026,7 +2027,10 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
}
Position pos;
m_caster->GetNearPosition(pos, dist, angle);
if (cur == TARGET_DEST_CASTER_FRONT_LEAP)
m_caster->GetFirstCollisionPosition(pos, dist, angle);
else
m_caster->GetNearPosition(pos, dist, angle);
m_targets.setDst(&pos); // also flag
break;
}
+1 -1
View File
@@ -338,7 +338,7 @@ class Spell
void EffectResurrect(uint32 i);
void EffectParry(uint32 i);
void EffectBlock(uint32 i);
void EffectLeapForward(uint32 i);
void EffectLeap(uint32 i);
void EffectTransmitted(uint32 i);
void EffectDisEnchant(uint32 i);
void EffectInebriate(uint32 i);
+3 -43
View File
@@ -94,7 +94,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
&Spell::EffectUnused, // 26 SPELL_EFFECT_DEFENSE one spell: Defense
&Spell::EffectPersistentAA, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA
&Spell::EffectSummonType, // 28 SPELL_EFFECT_SUMMON
&Spell::EffectLeapForward, // 29 SPELL_EFFECT_LEAP
&Spell::EffectLeap, // 29 SPELL_EFFECT_LEAP
&Spell::EffectEnergize, // 30 SPELL_EFFECT_ENERGIZE
&Spell::EffectWeaponDmg, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE
&Spell::EffectTriggerMissileSpell, // 32 SPELL_EFFECT_TRIGGER_MISSILE
@@ -6995,7 +6995,7 @@ void Spell::EffectBlock(uint32 /*i*/)
unitTarget->ToPlayer()->SetCanBlock(true);
}
void Spell::EffectLeapForward(uint32 i)
void Spell::EffectLeap(uint32 i)
{
if (unitTarget->isInFlight())
return;
@@ -7003,47 +7003,7 @@ void Spell::EffectLeapForward(uint32 i)
if (!m_targets.HasDst())
return;
uint32 mapid = m_caster->GetMapId();
float dist = m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, dist);
float x,y,z;
float destx,desty,destz,ground,floor;
float orientation = unitTarget->GetOrientation(), step = dist/10.0f;
unitTarget->GetPosition(x,y,z);
destx = x + dist * cos(orientation);
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;
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid,x,y,z+0.5f,destx,desty,destz+0.5f,destx,desty,destz,-0.5f);
if (col) // We had a collision!
{
destx -= 0.6 * cos(orientation);
desty -= 0.6 * sin(orientation);
dist = sqrt((x-destx)*(x-destx) + (y-desty)*(y-desty));
step = dist/10.0f;
}
int j = 0;
for (j; j < 10; j++)
{
if (fabs(z - destz) > 6)
{
destx -= step * cos(orientation);
desty -= step * 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;
} else break;
}
if (j < 10)
unitTarget->NearTeleportTo(destx, desty, destz + 0.07531, orientation, unitTarget == m_caster);
unitTarget->NearTeleportTo(m_targets.m_dstPos.GetPositionX(), m_targets.m_dstPos.GetPositionY(), m_targets.m_dstPos.GetPositionZ(), m_targets.m_dstPos.GetOrientation(), unitTarget == m_caster);
}
void Spell::EffectReputation(uint32 i)