diff --git a/JotunnModStub/Alfar/AlfarDroneAI.cs b/JotunnModStub/Alfar/AlfarDroneAI.cs
index 0d3a83e..b319ceb 100644
--- a/JotunnModStub/Alfar/AlfarDroneAI.cs
+++ b/JotunnModStub/Alfar/AlfarDroneAI.cs
@@ -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
}
}
+ ///
+ /// 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.
+ ///
+ 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())
+ {
+ 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