aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQAston <none@none>2010-07-21 02:06:51 +0200
committerQAston <none@none>2010-07-21 02:06:51 +0200
commitdd89c54c6ec903f491d7acdec00685b20bcfe1c4 (patch)
treeca88b380d3ddbcf6fd91263fd9d623af0593fcd3
parent1944cd17a1b71a23e6597d28a06de04186184c69 (diff)
*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
-rw-r--r--src/server/game/Entities/Object/Object.cpp50
-rw-r--r--src/server/game/Entities/Object/Object.h6
-rw-r--r--src/server/game/Spells/Spell.cpp6
-rw-r--r--src/server/game/Spells/Spell.h2
-rw-r--r--src/server/game/Spells/SpellEffects.cpp46
5 files changed, 65 insertions, 45 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index fe4b8673b8f..88396fda4c9 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -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;
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index ad7d0c072ab..0129e30b952 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -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);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index d845ee76b22..052c829676b 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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;
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index d7ed3d8eeb6..563572ec1fd 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -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);
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 2a42961df1b..b9c4b6408ac 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -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)