fix: drones fly beside a station instead of into it
A flyer's goal is lifted to m_flyAltitudeMin over the ground under the point, and under a charcoal kiln's origin that is inside the dome. The drone never came within reach, timed out on the collect job and put the kiln in the penalty box, so no wood was loaded for three minutes at a time (snakey's second log: penalty True, 'Could not reach collect'). Station jobs now aim a metre past the station's colliders on the side the drone comes from. Loading and the drop sweep still use the station's own position.
This commit is contained in:
parent
85c7af6d05
commit
038d827991
1 changed files with 36 additions and 4 deletions
|
|
@ -617,7 +617,7 @@ namespace RacesOfValheim
|
|||
Kind = "collect",
|
||||
Target = best.Id,
|
||||
Claim = best.Id,
|
||||
Point = best.Position,
|
||||
Point = ApproachPoint(best),
|
||||
Hurry = true,
|
||||
Label = "Saving the food",
|
||||
};
|
||||
|
|
@ -648,7 +648,7 @@ namespace RacesOfValheim
|
|||
Kind = "collect",
|
||||
Target = best.Id,
|
||||
Claim = best.Id,
|
||||
Point = best.Position,
|
||||
Point = ApproachPoint(best),
|
||||
Label = "Collecting",
|
||||
};
|
||||
}
|
||||
|
|
@ -788,7 +788,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
Kind = "deposit_station",
|
||||
Target = target,
|
||||
Point = station.Position,
|
||||
Point = ApproachPoint(station),
|
||||
Label = "Loading " + Describe(),
|
||||
};
|
||||
}
|
||||
|
|
@ -841,7 +841,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
Kind = "deposit_station",
|
||||
Target = consumer.Id,
|
||||
Point = consumer.Position,
|
||||
Point = ApproachPoint(consumer),
|
||||
Label = "Loading " + Describe(),
|
||||
};
|
||||
}
|
||||
|
|
@ -1798,6 +1798,38 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where the drone flies to serve a station: beside it, a metre past its colliders on the side
|
||||
/// the drone comes from. Vanilla lifts a flyer's goal to m_flyAltitudeMin over the ground under
|
||||
/// it (BaseAI.MoveTo, IL), and under a charcoal kiln's origin that is inside the dome: the drone
|
||||
/// pressed against the stone, never came within ArriveDistance, and the kiln went into the
|
||||
/// penalty box (snakey's log, "Could not reach collect target"). Beside it is open air, and it
|
||||
/// stays under a roof indoors, where aiming over the top would not. The loading and the sweep
|
||||
/// still work from the station's own position.
|
||||
/// </summary>
|
||||
private Vector3 ApproachPoint(ButlerStation station)
|
||||
{
|
||||
Vector3 centre = station.Position;
|
||||
bool any = false;
|
||||
Bounds bounds = new Bounds(centre, Vector3.zero);
|
||||
foreach (Collider collider in station.Behaviour.GetComponentsInChildren<Collider>())
|
||||
{
|
||||
if (collider == null || !collider.enabled || collider.isTrigger) continue;
|
||||
if (any) bounds.Encapsulate(collider.bounds);
|
||||
else { bounds = collider.bounds; any = true; }
|
||||
}
|
||||
if (!any) return centre;
|
||||
|
||||
Vector3 away = transform.position - bounds.center;
|
||||
away.y = 0f;
|
||||
if (away.sqrMagnitude < 0.01f) away = station.Transform.forward;
|
||||
float reach = Mathf.Max(bounds.extents.x, bounds.extents.z) + 1f;
|
||||
|
||||
Vector3 point = bounds.center + away.normalized * reach;
|
||||
point.y = centre.y;
|
||||
return point;
|
||||
}
|
||||
|
||||
private bool MoveToPoint(float dt, Vector3 point, float distance, bool run)
|
||||
{
|
||||
if (m_ai == null || MoveToMethod == null) return true; // cannot walk: act in place
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue