using UnityEngine; namespace Oxide.Plugins { [Info("NPCErrorFix", "MikeHawke", "0.0.1")] [Description("Moves NPCs to terrain height when they spawn underground.")] public class NPCErrorFix : RustPlugin { private void OnEntitySpawned(BaseAnimalNPC animal) { NextTick(() => { if (animal != null) CheckUnderground(animal); }); } private void OnEntitySpawned(NPCPlayerApex npc) { NextTick(() => { if (npc != null) CheckUnderground(npc); }); } private void CheckUnderground(BaseCombatEntity entity) { float ground = TerrainMeta.HeightMap.GetHeight(entity.transform.position); float entlevel = entity.transform.position.y; if (ground != entlevel) entity.transform.position = new Vector3(entity.transform.position.x, TerrainMeta.HeightMap.GetHeight(entity.transform.position), entity.transform.position.z); } } }