I want to change default horde spawn interval with harmony patch.
Default spawn is 12-24h, and i want: 8-16.
Here is my code:
No errors, game accept all lines of this code.. but.... this dosen't change horde spawn frequency
Help pls with hint, what to change.
Default spawn is 12-24h, and i want: 8-16.
Here is my code:
using System;using HarmonyLib;using UnityEngine;namespace ng_HordesSpawn{ public class ModApi : IModApi { public void InitMod(Mod modInstance) { var harmony = new Harmony("ng.hordes.spawn"); harmony.PatchAll(); } } [HarmonyPatch(typeof(AIWanderingHordeSpawner), "UpdateSpawn")] public static class Patch_WanderingHorde_UpdateSpawn { private static int lastDayBonusApplied = -1; // protection against repeated bonuses static void Postfix(AIWanderingHordeSpawner __instance, World _world, float _deltaTime) { if (__instance == null || __instance.spawner == null) return; // === BASIC SETTINGS === if (__instance.spawner.numToSpawn > 0) { __instance.spawner.numToSpawn += 2; // always +2 zombies } // frequency: 8–16 h instead of 12–24 //float minDelay = 8f * 60f * 60f; // 8 h in seconds //float maxDelay = 16f * 60f * 60f; // 16 h in seconds float minDelay = 60f; // 1 m while test float maxDelay = 120f; // 2 m while test __instance.spawnDelay = UnityEngine.Random.Range(minDelay, maxDelay); // === BONUS EVERY 50 DAYS === int day = GameUtils.WorldTimeToDays(_world.worldTime); if (day <= 0) return; int currentInterval = day / 50; int lastInterval = lastDayBonusApplied / 50; if (currentInterval > lastInterval) // new interval → apply bonus { lastDayBonusApplied = day; __instance.spawner.numToSpawn += 1; // +1 zombie __instance.spawnDelay = Math.Max(0f, __instance.spawnDelay - 1200f); // -20 min (1200 sec) } } }}No errors, game accept all lines of this code.. but.... this dosen't change horde spawn frequency
Help pls with hint, what to change.