minor bugfix and pad support

This commit is contained in:
Ferdinando 2026-09-12 10:42:01 +02:00
commit 6e87be3c77
21 changed files with 574 additions and 85 deletions

View file

@ -98,6 +98,15 @@ namespace RacesOfValheim
BaseAI ai = prefab.GetComponent<BaseAI>();
if (ai != null) ai.m_randomMoveRange = SvermConfig.TroopLeashRange;
// The hive's own bounds for a fight - see SvermConfig.TroopAlertRange. Without these the
// troops kept the vanilla prefab's numbers and chased whatever they could see.
MonsterAI monster = prefab.GetComponent<MonsterAI>();
if (monster != null)
{
monster.m_alertRange = SvermConfig.TroopAlertRange;
monster.m_maxChaseDistance = SvermConfig.TroopAlertRange;
}
foreach (CharacterDrop drops in prefab.GetComponentsInChildren<CharacterDrop>(true))
{
if (drops != null) Object.DestroyImmediate(drops);
@ -191,7 +200,10 @@ namespace RacesOfValheim
/// creature on the TERRAIN height there, so a nest on a slope does not bury anyone either.
/// The per-kind height goes on top, which is what keeps the Gjall in the air.
/// </summary>
private static Vector3 SpawnSpot(SvermHiveBehaviour hive, Kind kind)
private static Vector3 SpawnSpot(SvermHiveBehaviour hive, Kind kind) => SpawnSpot(hive, kind.SpawnHeight);
/// <summary>The same ring, for anything else the nest puts on the ground - the workers.</summary>
internal static Vector3 SpawnSpot(SvermHiveBehaviour hive, float height)
{
Vector3 centre = hive.transform.position;
float radius = RingRadius(hive);
@ -206,14 +218,14 @@ namespace RacesOfValheim
if (Physics.CheckSphere(candidate + Vector3.up * 1.5f, 1f, obstacleMask)) continue;
return candidate + Vector3.up * kind.SpawnHeight;
return candidate + Vector3.up * height;
}
// Twelve tries and everything is built up: due south on the ring anyway. Still outside
// the nest, which is the thing this is here to guarantee.
Vector3 fallback = centre + new Vector3(0f, 0f, -radius);
if (ZoneSystem.instance != null) fallback.y = ZoneSystem.instance.GetGroundHeight(fallback);
return fallback + Vector3.up * kind.SpawnHeight;
return fallback + Vector3.up * height;
}
/// <summary>
@ -224,7 +236,7 @@ namespace RacesOfValheim
/// small one hatches troops inside the big one. Only solid meshes are measured; the hive's
/// particle effects have bounds of their own and would report a ring the size of a field.
/// </summary>
private static float RingRadius(SvermHiveBehaviour hive)
internal static float RingRadius(SvermHiveBehaviour hive)
{
Vector3 centre = hive.transform.position;
float widest = 0f;