Core/Object: Bump hover delta handling on nearpoints downstack into GetNearPoint2D (from movement generators); functionality should be unchanged

(cherry picked from commit ebc96af6bb784819ba8824ac390864ae9ba12351)
This commit is contained in:
Treeston
2021-09-23 22:28:06 +02:00
committed by Shauren
parent b0e064ff89
commit f69d12504c
10 changed files with 45 additions and 34 deletions
+30 -10
View File
@@ -2972,20 +2972,40 @@ 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);
// if detection disabled, return first point
@@ -3004,7 +3024,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))
@@ -3017,10 +3037,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)
@@ -3047,7 +3067,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)