diff --git a/JotunnModStub/Alfar/AlfarDroneAI.cs b/JotunnModStub/Alfar/AlfarDroneAI.cs index 4cb5f86..40bf69b 100644 --- a/JotunnModStub/Alfar/AlfarDroneAI.cs +++ b/JotunnModStub/Alfar/AlfarDroneAI.cs @@ -1664,10 +1664,22 @@ namespace RacesOfValheim lines.Add($"[RoV drone] {distance:0}m: '{drone.Status}' job {(drone.m_job != null ? drone.m_job.Kind : "none")} " + $"carry {drone.PayloadCount()} fight {drone.m_fighting} vanilla target {targetText} " + $"alerted {drone.m_ai.IsAlerted()} flying {drone.m_character.IsFlying()} owner {drone.m_nview.IsOwner()}"); + + // The other half of what holds a fight: the 12 m sweep, and how long the linger has left. + Character near = BaseAI.FindClosestEnemy(drone.m_character, drone.transform.position, FightRange); + string nearText = near != null + ? $"{Utils.GetPrefabName(near.gameObject)} {Vector3.Distance(near.transform.position, drone.transform.position):0}m" + : "none"; + lines.Add($"[RoV drone] fight left {Mathf.Max(0f, drone.m_fightUntil - Time.time):0.0}s, " + + $"closest enemy {nearText}, in reach {(target != null && drone.InFightReach(target))}"); } if (nearest == null) lines.Add("[RoV drone] no worker drone within 60m"); - else lines.AddRange(nearest.SortReport()); + else + { + lines.AddRange(nearest.SortReport()); + lines.AddRange(nearest.StationReport()); + } foreach (string line in lines) { @@ -1676,6 +1688,59 @@ namespace RacesOfValheim } } + /// Why a station is (or is not) fed: what the last scan saw, the wood chest, and every + /// smelter, hearth or fermenter within the radius - and the ones just past it, by how much. + private IEnumerable StationReport() + { + Vector3? anchor = Anchor; + if (anchor == null) { yield return "[RoV station] no anchor"; yield break; } + + float radius = AlfarNexusConfig.NexusRadius.Value + m_radiusBonus; + yield return $"[RoV station] anchor {Vector3.Distance(transform.position, anchor.Value):0}m from drone, " + + $"radius {radius:0}, scanned {Time.time - m_scannedAt:0}s ago, {m_stations.Count} stations, {m_chests.Count} chests"; + + if (m_wood == null) yield return "[RoV station] no Eldividarkista in range (or it is open, or holds the sigil)"; + else + { + var wood = new List(); + Inventory inventory = m_wood.GetInventory(); + if (inventory != null) + { + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + wood.Add(item.m_dropPrefab != null ? $"{item.m_dropPrefab.name}x{item.m_stack}" : $"{item.m_shared.m_name}(no prefab)"); + } + } + yield return $"[RoV station] Eldividarkista {Vector3.Distance(m_wood.transform.position, anchor.Value):0}m from anchor, " + + $"open {m_wood.IsInUse()}, penalty {IsPenalised(ZdoOf(m_wood))}, holds [{string.Join(", ", wood.ToArray())}]"; + } + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive) { yield return "[RoV station] (a station that is gone)"; continue; } + + Container chest; + string material = FindMaterialFor(station, out chest); + string from = material == null ? "nothing" : $"{material} from {(chest == m_wood ? "Eldividarkista" : "entry")}"; + yield return $"[RoV station] {Utils.GetPrefabName(station.Behaviour.gameObject)} " + + $"{Vector3.Distance(station.Position, anchor.Value):0}m: operable {station.Operable} free {station.FreeSlots} " + + $"work {station.HasWork} wood {station.Accepts("Wood")} penalty {IsPenalised(station.Id)} " + + $"claimed {ClaimedByOther(station.Id)} fuel {station.FuelPrefab ?? "-"}/{station.FuelWanted} | load: {from}"; + } + + // A station the scan cannot see because it stands past the edge. + List pieces = AllPiecesField != null ? AllPiecesField.GetValue(null) as List : null; + if (pieces == null) yield break; + foreach (Piece piece in pieces) + { + if (piece == null) continue; + float distance = Vector3.Distance(piece.transform.position, anchor.Value); + if (distance <= radius || distance > radius + 15f) continue; + if (ButlerStation.From(piece.gameObject) == null) continue; + yield return $"[RoV station] {Utils.GetPrefabName(piece.gameObject)} {distance:0}m: OUTSIDE the radius by {distance - radius:0.0}m"; + } + } + private IEnumerable SortReport() { if (m_entry == null) { yield return "[RoV sort] no entry chest in range"; yield break; }