I tried to add some AIMovePoint for Monuments. I think AIInformationZone controls this function. Here is my code.
I use Scientistnpc_roam entity for test. These code works fine for Monuments that originally spawned with npc like GIANT EXCAVATOR.
But when I run code in No NPC monument like ABANDONED CABINS, Scientistnpc_roam stay where they spawn and would not roam.
I know plugins like Botrespawn and BetterNPC can add custom NPC. But I still curious about how this AIInformationZone work.
Thanks for help.
[ChatCommand("zoneAddNew")]
private void zoneAddNew(BasePlayer player, string command, string[] args)
{
AIInformationZone zone = AIInformationZone.GetForPoint(player.transform.position, false);
if (zone == null)
{
var zoneObject = new GameObject("AIInformationZone");
zoneObject.transform.position = player.transform.position;
zone = zoneObject.AddComponent<AIInformationZone>();
zone.bounds = new Bounds(Vector3.zero, new Vector3(100, 100, 100));
zone.name = "MCZoneTest";
zone.ShouldSleepAI = true;
zone.Start();
}
GameObject pointObj = new GameObject();
pointObj.transform.position = player.transform.position;
pointObj.transform.SetParent(zone.transform, true);
pointObj.SetActive(true);
AIMovePoint movePoint = pointObj.AddComponent<AIMovePoint>();
movePoint.radius = 1;
AIMovePoint[] movePointary = new AIMovePoint[] { movePoint };
zone.AddDynamicAIPoints(movePointary, null);
}