aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-04-01 18:27:29 +0200
committerTreeston <treeston.mmoc@gmail.com>2018-04-01 18:27:29 +0200
commitebc96af6bb784819ba8824ac390864ae9ba12351 (patch)
treea312819a680ad33ee84c7c5732e46a3af53649d2
parent69143b949e89612bbdd3abbc5308175a19ff76f9 (diff)
Core/Object: Bump hover delta handling on nearpoints downstack into GetNearPoint2D (from movement generators); functionality should be unchanged
-rw-r--r--src/server/game/Entities/Object/Object.cpp38
-rw-r--r--src/server/game/Entities/Object/Object.h4
-rw-r--r--src/server/game/Movement/MotionMaster.cpp4
-rw-r--r--src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp13
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp2
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp4
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp6
-rw-r--r--src/server/scripts/Northrend/zone_icecrown.cpp2
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_supremus.cpp2
9 files changed, 43 insertions, 32 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 632e9d0050b..e2f19a2ac9f 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -3119,18 +3119,38 @@ void WorldObject::GetPlayerListInGrid(Container& playerContainer, float maxSearc
Cell::VisitWorldObjects(this, searcher, maxSearchRange);
}
-void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle) const
+void WorldObject::GetNearPoint2D(WorldObject const* searcher, float &x, float &y, float distance2d, float absAngle) const
{
- x = GetPositionX() + (GetCombatReach() + distance2d) * std::cos(absAngle);
- y = GetPositionY() + (GetCombatReach() + distance2d) * std::sin(absAngle);
+ float effectiveReach = GetCombatReach();
+
+ if (searcher)
+ {
+ effectiveReach += searcher->GetCombatReach();
+
+ if (this != searcher)
+ {
+ float myHover = 0.0f, searcherHover = 0.0f;
+ if (Unit const* unit = ToUnit())
+ myHover = unit->GetHoverOffset();
+ if (Unit const* searchUnit = searcher->ToUnit())
+ searcherHover = searchUnit->GetHoverOffset();
+
+ float hoverDelta = myHover - searcherHover;
+ if (hoverDelta != 0.0f)
+ effectiveReach = std::sqrt(effectiveReach * effectiveReach - hoverDelta * hoverDelta);
+ }
+ }
+
+ x = GetPositionX() + (effectiveReach + distance2d) * std::cos(absAngle);
+ y = GetPositionY() + (effectiveReach + distance2d) * std::sin(absAngle);
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
}
-void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
+void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float distance2d, float absAngle) const
{
- GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
+ GetNearPoint2D(searcher, x, y, distance2d, absAngle);
z = GetPositionZ();
(searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
@@ -3151,7 +3171,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
// loop in a circle to look for a point in LoS using small steps
for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8)
{
- GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle);
+ GetNearPoint2D(searcher, x, y, distance2d, absAngle + angle);
z = GetPositionZ();
(searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
if (IsWithinLOS(x, y, z))
@@ -3164,10 +3184,10 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y,
z = first_z;
}
-void WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d /*= 0*/, float angle /*= 0*/) const
+void WorldObject::GetClosePoint(float &x, float &y, float &z, float size, float distance2d /*= 0*/, float relAngle /*= 0*/) const
{
// angle calculated from current orientation
- GetNearPoint(nullptr, x, y, z, size, distance2d, GetOrientation() + angle);
+ GetNearPoint(nullptr, x, y, z, distance2d+size, GetOrientation() + relAngle);
}
Position WorldObject::GetNearPosition(float dist, float angle)
@@ -3194,7 +3214,7 @@ Position WorldObject::GetRandomNearPosition(float radius)
void WorldObject::GetContactPoint(WorldObject const* obj, float& x, float& y, float& z, float distance2d /*= CONTACT_DISTANCE*/) const
{
// angle to face `obj` to `this` using distance includes size of `obj`
- GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2d, GetAbsoluteAngle(obj));
+ GetNearPoint(obj, x, y, z, distance2d, GetAbsoluteAngle(obj));
}
void WorldObject::MovePosition(Position &pos, float dist, float angle)
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 2c5bdd19dbd..2cb0583cf38 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -273,8 +273,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void AddToWorld() override;
void RemoveFromWorld() override;
- void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const;
- void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const;
+ void GetNearPoint2D(WorldObject const* searcher, float &x, float &y, float distance, float absAngle) const;
+ void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float distance2d, float absAngle) const;
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float relAngle = 0) const;
void MovePosition(Position &pos, float dist, float angle);
Position GetNearPosition(float dist, float angle);
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index 92ac7b11fc1..cb00f455959 100644
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -436,7 +436,7 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa
float dist = 2 * moveTimeHalf * speedXY;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
- _owner->GetNearPoint(_owner, x, y, z, _owner->GetCombatReach(), dist, _owner->GetAbsoluteAngle(srcX, srcY) + float(M_PI));
+ _owner->GetNearPoint(_owner, x, y, z, dist, _owner->GetAbsoluteAngle(srcX, srcY) + float(M_PI));
Movement::MoveSplineInit init(_owner);
init.MoveTo(x, y, z);
@@ -457,7 +457,7 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ)
float moveTimeHalf = speedZ / Movement::gravity;
float dist = 2 * moveTimeHalf * speedXY;
- _owner->GetNearPoint2D(x, y, dist, _owner->GetOrientation() + angle);
+ _owner->GetNearPoint2D(nullptr, x, y, dist, _owner->GetOrientation() + angle);
z = _owner->GetPositionZ();
_owner->UpdateAllowedPositionZ(x, y, z);
MoveJump(x, y, z, 0.0f, speedXY, speedZ);
diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
index 09b187dc976..ad702575726 100644
--- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp
@@ -125,34 +125,25 @@ void TargetedMovementGenerator<T, D>::SetTargetLocation(T* owner, bool updateDes
float x, y, z;
if (updateDestination || !_path)
{
- float size = owner->GetCombatReach();
float hoverDiff = std::abs(owner->GetHoverOffset() - GetTarget()->GetHoverOffset());
if (!_offset)
{
if (GetTarget()->IsWithinDistInMap(owner, CONTACT_DISTANCE))
return;
- if (hoverDiff)
- size = size > hoverDiff ? std::sqrt(size * size - hoverDiff * hoverDiff) : 0.0f;
-
- GetTarget()->GetNearPoint(owner, x, y, z, size, CONTACT_DISTANCE, GetTarget()->GetAbsoluteAngle(owner));
+ GetTarget()->GetNearPoint(owner, x, y, z, CONTACT_DISTANCE, GetTarget()->GetAbsoluteAngle(owner));
}
else
{
float distance = _offset + 1.0f;
if (owner->IsPet() && GetTarget()->GetTypeId() == TYPEID_PLAYER)
- {
distance = 1.0f;
- size = 1.0f;
- }
- else if (hoverDiff)
- size = size > hoverDiff ? std::sqrt(size * size - hoverDiff * hoverDiff) : 0.0f;
if (GetTarget()->IsWithinDistInMap(owner, distance))
return;
- GetTarget()->GetClosePoint(x, y, z, size, _offset, _angle);
+ GetTarget()->GetClosePoint(x, y, z, _offset, _angle);
}
if (owner->IsHovering())
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
index 1b022b2c6f3..3f9f9b715ff 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp
@@ -972,7 +972,7 @@ void hyjalAI::WaypointReached(uint32 waypointId, uint32 /*pathId*/)
(*itr)->GetMotionMaster()->Initialize();
float range = 10;
if (me->GetEntry() == THRALL)range = 20;
- me->GetNearPoint(me, x, y, z, range, 0, me->GetAbsoluteAngle((*itr)));
+ me->GetNearPoint(nullptr, x, y, z, range, me->GetAbsoluteAngle((*itr)));
(*itr)->GetMotionMaster()->MovePoint(0, x+irand(-5, 5), y+irand(-5, 5), me->GetPositionZ());
}
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
index 7830e96c29b..97f2079cbec 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
@@ -381,7 +381,7 @@ class npc_coldflame : public CreatureScript
{
float ang = pos.GetAbsoluteAngle(me);
me->SetOrientation(ang);
- owner->GetNearPoint2D(pos.m_positionX, pos.m_positionY, 5.0f - owner->GetCombatReach(), ang);
+ owner->GetNearPoint2D(nullptr, pos.m_positionX, pos.m_positionY, 5.0f - owner->GetCombatReach(), ang);
}
else
{
@@ -394,7 +394,7 @@ class npc_coldflame : public CreatureScript
float ang = pos.GetAbsoluteAngle(target);
me->SetOrientation(ang);
- owner->GetNearPoint2D(pos.m_positionX, pos.m_positionY, 15.0f - owner->GetCombatReach(), ang);
+ owner->GetNearPoint2D(nullptr, pos.m_positionX, pos.m_positionY, 15.0f - owner->GetCombatReach(), ang);
}
me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), me->GetPositionZ(), me->GetOrientation());
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index 72acb22914a..61faa846a85 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -464,7 +464,7 @@ public:
{
Position pos;
pos.m_positionZ = alexstraszaBunny->GetPositionZ();
- alexstraszaBunny->GetNearPoint2D(pos.m_positionX, pos.m_positionY, 30.0f, alexstraszaBunny->GetAbsoluteAngle(me));
+ alexstraszaBunny->GetNearPoint2D(nullptr, pos.m_positionX, pos.m_positionY, 30.0f, alexstraszaBunny->GetAbsoluteAngle(me));
me->GetMotionMaster()->MoveLand(POINT_LAND_P_ONE, pos);
me->SetImmuneToAll(false);
me->SetReactState(REACT_AGGRESSIVE);
@@ -847,7 +847,7 @@ public:
Position randomPosOnRadius;
// Hardcodded retail value, reason is Z getters can fail... (TO DO: Change to getter when height calculation works on 100%!)
randomPosOnRadius.m_positionZ = 283.0521f;
- alexstraszaBunny->GetNearPoint2D(randomPosOnRadius.m_positionX, randomPosOnRadius.m_positionY, 120.0f, alexstraszaBunny->GetAbsoluteAngle(me));
+ alexstraszaBunny->GetNearPoint2D(nullptr, randomPosOnRadius.m_positionX, randomPosOnRadius.m_positionY, 120.0f, alexstraszaBunny->GetAbsoluteAngle(me));
me->GetMotionMaster()->MovePoint(POINT_FLY_OUT_OF_PLATFORM_P_TWO, randomPosOnRadius);
_flyingOutOfPlatform = true;
}
@@ -1673,7 +1673,7 @@ class spell_malygos_random_portal : public SpellScriptLoader
{
Position pos;
pos.m_positionZ = target->GetPositionZ();
- target->GetNearPoint2D(pos.m_positionX, pos.m_positionY, frand(29.1f, 30.0f), target->GetAbsoluteAngle(malygos));
+ target->GetNearPoint2D(nullptr, pos.m_positionX, pos.m_positionY, frand(29.1f, 30.0f), target->GetAbsoluteAngle(malygos));
malygos->GetMotionMaster()->MovePoint(POINT_NEAR_RANDOM_PORTAL_P_NONE, pos);
}
}
diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp
index 32ace5b6b0e..cbce40f67f6 100644
--- a/src/server/scripts/Northrend/zone_icecrown.cpp
+++ b/src/server/scripts/Northrend/zone_icecrown.cpp
@@ -751,7 +751,7 @@ class npc_frostbrood_skytalon : public CreatureScript
{
Position randomPosOnRadius;
randomPosOnRadius.m_positionZ = (me->GetPositionZ() + 40.0f);
- me->GetNearPoint2D(randomPosOnRadius.m_positionX, randomPosOnRadius.m_positionY, 40.0f, me->GetAbsoluteAngle(me));
+ me->GetNearPoint2D(nullptr, randomPosOnRadius.m_positionX, randomPosOnRadius.m_positionY, 40.0f, me->GetAbsoluteAngle(me));
me->GetMotionMaster()->MovePoint(POINT_FLY_AWAY, randomPosOnRadius);
}
}
diff --git a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
index b7a0acdc892..bdb4ac7415b 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_supremus.cpp
@@ -183,7 +183,7 @@ struct npc_molten_flame : public NullCreatureAI
void InitializeAI() override
{
float x, y, z;
- me->GetNearPoint(me, x, y, z, 1, 100.0f, frand(0.f, 2.f * float(M_PI)));
+ me->GetNearPoint(me, x, y, z, 100.0f, frand(0.f, 2.f * float(M_PI)));
me->GetMotionMaster()->MovePoint(0, x, y, z);
DoCastSelf(SPELL_MOLTEN_FLAME, true);
}