using System.Collections.Generic; using UnityEngine; using System.Linq; using UnityEngine.AI; using System; using Newtonsoft.Json; using Oxide.Core; using Oxide.Core.Libraries; using Facepunch; namespace Oxide.Plugins { [Info("RobSpawn", "Steenamaroo For RobJ", "2.2.5", ResourceId = 0)] [Description("Use only with RobJ maps for npcs")] class RobSpawn : RustPlugin { public static RobSpawn t; const string prefabname = "assets/rust.ai/agents/npcplayer/humannpc/scientist/scientistnpc_roam.prefab"; Dictionary npcs = new Dictionary(); public class Info { public int kit; public Vector3 loc; public string name; public int respawn; public int corpse; public List LootItems = new List(); } public class Kit { public string name; public int health; public int aggrorange = 100; public bool peacekeeper = false; public int roamrange = 50; public int corpse_minutes = 1; public int respawn_minutes = 1; public bool CanHeal = true; public Dictionary belt = new Dictionary(); public Dictionary wear = new Dictionary(); public List LootItems = new List(); } public class LootItem { public string ItemShortname = "wood"; public ulong SkinID = 0; public int Spawn_Percent_Chance = 100; public int Amount = 1; } public List KitList = new List() { new Kit() { name = "Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "smg.mp5", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.lr300", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.m39", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "shotgun.spas12", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "pistol.m92", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Scientist Team Leader", health = 190, aggrorange = 50, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "pistol.m92", 0 }, { "weapon.mod.flashlight", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "smg.mp5", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.lr300", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.m39", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "shotgun.spas12", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist", health = 150, aggrorange = 45, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "pistol.m92", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Arctic Scientist Team Leader", health = 190, aggrorange = 50, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "pistol.m92", 0 }, { "weapon.mod.flashlight", 0 } }, wear = new Dictionary() { { "hazmatsuit_scientist_arctic", 0 } }, CanHeal = true }, new Kit() { name = "Tunnel Dweller", health = 125, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "pistol.m92", 0 } }, wear = new Dictionary() { { "jumpsuit.suit", 0 }, { "shoes.boots", 0 }, { "hat.gas.mask", 0 } }, CanHeal = true }, new Kit() { name = "Tunnel Dweller", health = 125, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.m39", 0 } }, wear = new Dictionary() { { "jumpsuit.suit", 0 }, { "shoes.boots", 0 }, { "hat.gas.mask", 0 } }, CanHeal = true }, new Kit() { name = "Tunnel Dweller Team Leader", health = 170, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "rifle.m39", 0 }, { "weapon.mod.flashlight", 0 }, { "weapon.mod.8x.scope", 0 } }, wear = new Dictionary() { { "jumpsuit.suit", 0 }, { "shoes.boots", 0 }, { "hat.gas.mask", 0 } }, CanHeal = true }, new Kit() { name = "Underwater Dweller", health = 175, aggrorange = 30, peacekeeper = false, roamrange = 1, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "pistol.m92", 0 } }, wear = new Dictionary() { { "jumpsuit.suit.blue", 0 }, { "hat.gas.mask", 0 }, { "shoes.boots", 0 }, { "diving.tank", 0 } }, CanHeal = false }, new Kit() { name = "Underwater Dweller", health = 215, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "smg.mp5", 2887642987 } }, wear = new Dictionary() { { "jumpsuit.suit.blue", 0 }, { "hat.gas.mask", 0 }, { "shoes.boots", 0 }, { "diving.tank", 0 } }, CanHeal = true }, new Kit() { name = "Underwater Dweller Team Leader", health = 390, aggrorange = 32, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "rifle.lr300", 2151920583 }, { "weapon.mod.flashlight", 0 }, { "weapon.mod.holosight", 0 } }, wear = new Dictionary() { { "jumpsuit.suit.blue", 0 }, { "hat.gas.mask", 0 }, { "shoes.boots", 0 }, { "diving.tank", 0 }, {"metal.plate.torso", 797410767 } }, CanHeal = true }, new Kit() { name = "Heavy Scientist", health = 350, aggrorange = 30, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "shotgun.spas12", 0 }, { "weapon.mod.flashlight", 0 }, { "weapon.mod.holosight", 0 } }, wear = new Dictionary() { { "scientistsuit_heavy", 0 } }, CanHeal = true }, new Kit() { name = "Heavy Scientist", health = 300, aggrorange = 30, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 20, belt = new Dictionary() { { "lmg.m249", 0 }, { "weapon.mod.flashlight", 0 }, { "weapon.mod.holosight", 0 } }, wear = new Dictionary() { { "scientistsuit_heavy", 0 } }, CanHeal = true }, new Kit() { name = "Bandit", health = 200, aggrorange = 30, peacekeeper = true, roamrange = 3, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "rifle.semiauto", 0 } }, wear = new Dictionary() { { "attire.banditguard", 0 } }, CanHeal = true }, new Kit() { name = "Desert Rat", health = 135, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "rifle.lr300", 1256863749 } }, wear = new Dictionary() { { "hat.gas.mask", 0 }, { "roadsign.gloves", 2510097681 }, { "hoodie", 2503910428 }, { "pants", 2503903214 }, { "shoes.boots", 2510093391 }, { "metal.plate.torso", 2475407123 } }, CanHeal = true }, new Kit() { name = "Desert Rat", health = 135, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "smg.2", 2530798091 } }, wear = new Dictionary() { { "hat.gas.mask", 0 }, { "roadsign.gloves", 2510097681 }, { "hoodie", 2503910428 }, { "pants", 2503903214 }, { "shoes.boots", 2510093391 }, { "metal.plate.torso", 2475407123 } }, CanHeal = true }, new Kit() { name = "Desert Rat", health = 135, aggrorange = 30, peacekeeper = false, roamrange = 1, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "rifle.l96", 2814893650 }, { "weapon.mod.8x.scope", 0 } }, wear = new Dictionary() { { "hat.gas.mask", 0 }, { "roadsign.gloves", 2510097681 }, { "hoodie", 2503910428 }, { "pants", 2503903214 }, { "shoes.boots", 2510093391 }, { "metal.plate.torso", 2475407123 } }, CanHeal = true }, new Kit() { name = "Desert Rat", health = 135, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "shotgun.pump", 1266271867 } }, wear = new Dictionary() { { "hat.gas.mask", 0 }, { "roadsign.gloves", 2510097681 }, { "hoodie", 2503910428 }, { "pants", 2503903214 }, { "shoes.boots", 2510093391 }, { "metal.plate.torso", 2475407123 } }, CanHeal = true }, new Kit() { name = "Desert Rat Team Leader", health = 170, aggrorange = 35, peacekeeper = false, roamrange = 1, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "hmlmg", 0 } }, wear = new Dictionary() { { "hat.gas.mask", 0 }, { "roadsign.gloves", 2510097681 }, { "hoodie", 2503910428 }, { "pants", 2503903214 }, { "shoes.boots", 2510093391 }, { "metal.plate.torso", 2475407123 } }, CanHeal = true }, new Kit() { name = "Doctor", health = 140, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "pistol.m92", 0 } }, wear = new Dictionary() { { "halloween.surgeonsuit", 0 } }, CanHeal = true }, new Kit() { name = "Lumber Jack", health = 140, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "shotgun.pump", 1932318189 } }, wear = new Dictionary() { { "lumberjack hoodie", 0 }, { "pants", 0 }, { "shoes.boots", 0 }, { "santabeard", 0 }, { "burlap.gloves", 0 }, { "hat.cap", 0 } }, CanHeal = false }, new Kit() { name = "Bad Santa", health = 140, aggrorange = 30, peacekeeper = false, roamrange = 5, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "smg.mp5", 2899340592 } }, wear = new Dictionary() { { "hoodie", 2899736521 }, { "pants", 2899737872 }, { "shoes.boots", 1229544227 }, { "santabeard", 0 }, { "burlap.gloves", 2900409207 }, { "santahat", 0 } }, CanHeal = true }, new Kit() { name = "Mr Spice Factory Worker", health = 130, aggrorange = 30, peacekeeper = false, roamrange = 5, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "shotgun.pump", 1092734120 } }, wear = new Dictionary() { { "hoodie", 2919913723 }, { "pants", 2919917254 }, { "shoes.boots", 2090776132 }, { "hat.cap", 2920518318 } }, CanHeal = false }, new Kit() { name = "Mr Spice Factory Worker", health = 140, aggrorange = 30, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "smg.mp5", 953282188 } }, wear = new Dictionary() { { "hoodie", 2919913723 }, { "pants", 2919917254 }, { "shoes.boots", 2090776132 }, { "hat.cap", 2920518318 } }, CanHeal = false }, new Kit() { name = "Mr Spice Leader", health = 230, aggrorange = 30, peacekeeper = false, roamrange = 6, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.ak", 809212871 } }, wear = new Dictionary() { { "hoodie", 2919913723 }, { "pants", 2919917254 }, { "shoes.boots", 2090776132 }, { "hat.cap", 2920518318 }, { "metal.plate.torso", 797410767 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "rug.bear", SkinID = 2236519739, Spawn_Percent_Chance = 10 } } }, new Kit() { name = "Tuna Factory Worker", health = 130, aggrorange = 30, peacekeeper = false, roamrange = 9, corpse_minutes = 3, respawn_minutes = 10, belt = new Dictionary() { { "pistol.prototype17", 0 } }, wear = new Dictionary() { { "hoodie", 2304560839 }, { "pants", 2304559261 }, { "shoes.boots", 2090776132 } }, CanHeal = false, LootItems = new List() { new LootItem { ItemShortname = "fish.salmon", SkinID = 0, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "can.tuna", SkinID = 0, Spawn_Percent_Chance = 35 }, new LootItem { ItemShortname = "box.wooden.large", SkinID = 2228823369, Spawn_Percent_Chance = 5, } } }, new Kit() { name = "Tuna Factory Worker", health = 150, aggrorange = 30, peacekeeper = false, roamrange = 4, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "smg.thompson", 2115687030 } }, wear = new Dictionary() { { "hoodie", 2304560839 }, { "pants", 2304559261 }, { "shoes.boots", 2090776132 } }, CanHeal = false, LootItems = new List() { new LootItem { ItemShortname = "fish.salmon", SkinID = 0, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "can.tuna", SkinID = 0, Spawn_Percent_Chance = 25 } } }, new Kit() { name = "Tuna Factory Manager", health = 250, aggrorange = 30, peacekeeper = false, roamrange = 4, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.lr300", 2530899430 } }, wear = new Dictionary() { { "hoodie", 2304560839 }, { "pants", 2304559261 }, { "shoes.boots", 2090776132 }, { "metal.plate.torso", 2215911873 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 1615450482, Spawn_Percent_Chance = 5 } } }, new Kit() { name = "NVGM Scientist", health = 320, aggrorange = 30, peacekeeper = false, roamrange = 4, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "shotgun.spas12", 0 }, { "weapon.mod.lasersight", 0 }}, wear = new Dictionary() { { "hazmatsuit_scientist_nvgm", 0 } }, CanHeal = false, LootItems = new List() { new LootItem { ItemShortname = "supply.signal", SkinID = 0, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "techparts", SkinID = 0, Spawn_Percent_Chance = 25, Amount = 2 } } }, new Kit() { name = "NVGM Scientist", health = 390, aggrorange = 30, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.lr300", 2151920583 }, { "weapon.mod.lasersight", 0 }}, wear = new Dictionary() { { "hazmatsuit_scientist_nvgm", 0 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "supply.signal", SkinID = 0, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "techparts", SkinID = 0, Spawn_Percent_Chance = 25, Amount = 4 } } }, new Kit() { name = "NVGM Scientist Team Leader", health = 420, aggrorange = 30, peacekeeper = false, roamrange = 4, corpse_minutes = 3, respawn_minutes = 15, belt = new Dictionary() { { "rifle.lr300", 02151920583 }, { "weapon.mod.holosight", 0 }, { "weapon.mod.lasersight", 0 }}, wear = new Dictionary() { { "hazmatsuit_scientist_nvgm", 0 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "smg.thompson", SkinID = 0, Spawn_Percent_Chance = 1 }, new LootItem { ItemShortname = "supply.signal", SkinID = 0, Spawn_Percent_Chance = 2 }, new LootItem { ItemShortname = "techparts", SkinID = 0, Spawn_Percent_Chance = 12, Amount = 4 }, new LootItem { ItemShortname = "metal.refined", SkinID = 0, Spawn_Percent_Chance = 12, Amount = 15 }, new LootItem { ItemShortname = "syringe.medical", SkinID = 0, Spawn_Percent_Chance = 33, Amount = 1 } } }, new Kit() { name = "Junk Yard Owner", health = 155, aggrorange = 30, peacekeeper = false, roamrange = 20, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "shotgun.waterpipe", 0 } }, wear = new Dictionary() { { "roadsign.jacket", 1852238534 }, { "roadsign.kilt", 1852235315 }, { "coffeecan.helmet", 1852240690 }, { "boots.frog", 0 }, { "burlap.shirt", 719989461 }, { "burlap.trousers", 920139767 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "ammo.handmade.shell", SkinID = 0, Spawn_Percent_Chance = 40, Amount = 11 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1570978071, Spawn_Percent_Chance = 8 }, new LootItem { ItemShortname = "can.beans.empty", SkinID = 0, Spawn_Percent_Chance = 35, Amount = 4 }, new LootItem { ItemShortname = "can.tuna.empty", SkinID = 0, Spawn_Percent_Chance = 30, Amount = 2 }, new LootItem { ItemShortname = "scrap", SkinID = 0, Spawn_Percent_Chance = 15, Amount = 7 }, new LootItem { ItemShortname = "rug", SkinID = 945282460, Spawn_Percent_Chance = 7 }, new LootItem { ItemShortname = "chair", SkinID = 2075743802, Spawn_Percent_Chance = 3 } } }, new Kit() { name = "Railway Maintenance Worker", health = 145, aggrorange = 30, peacekeeper = false, roamrange = 20, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "rifle.semiauto", 2402030924 } }, wear = new Dictionary() { { "hat.miner", 3041020140 }, { "hoodie", 3041021678 }, { "pants", 3041022154 }, { "metal.plate.torso", 2405107952 }, { "shoes.boots", 0 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "door.hinged.toptier", SkinID = 2830678307, Spawn_Percent_Chance = 10, Amount = 1 } } }, new Kit() { name = "Railway Maintenance Worker Boss", health = 240, aggrorange = 32, peacekeeper = false, roamrange = 20, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "rifle.lr300", 2404832446 } }, wear = new Dictionary() { { "hat.miner", 3041020140 }, { "hoodie", 3041021678 }, { "pants", 3041022154 }, { "metal.plate.torso", 2405107952 }, { "shoes.boots", 0 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "door.hinged.toptier", SkinID = 2830678307, Spawn_Percent_Chance = 13, Amount = 1 } } }, new Kit() { name = "Pumpkin Servant", health = 300, aggrorange = 32, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "shotgun.double", 3049787423 } }, wear = new Dictionary() { { "pumpkin", 3041020140 }, { "burlap.shirt", 858256803 }, { "burlap.trousers", 858256643 }, { "burlap.shoes", 858257266 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden.large", SkinID = 1885863219, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "rock", SkinID = 1571052840, Spawn_Percent_Chance = 25 }, } }, new Kit() { name = "Pumpkin Head Servant", health = 400, aggrorange = 32, peacekeeper = false, roamrange = 10, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "rifle.ak", 3048704361 } }, wear = new Dictionary() { { "pumpkin", 3041020140 }, { "burlap.shirt", 858256803 }, { "metal.plate.torso", 1886179838 }, { "burlap.trousers", 858256643 }, { "burlap.shoes", 858257266 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden.large", SkinID = 1885863219, Spawn_Percent_Chance = 37 }, new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 2627987995, Spawn_Percent_Chance = 27 }, new LootItem { ItemShortname = "furnace", SkinID = 3048941724, Spawn_Percent_Chance = 35 }, new LootItem { ItemShortname = "furnace", SkinID = 3049167331, Spawn_Percent_Chance = 35 }, new LootItem { ItemShortname = "rifle.bolt", SkinID = 2630099186, Spawn_Percent_Chance = 2 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 2875905399, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "door.double.hinged.metal", SkinID = 1886090836, Spawn_Percent_Chance = 37 }, new LootItem { ItemShortname = "rug", SkinID = 3048288522, Spawn_Percent_Chance = 24 }, new LootItem { ItemShortname = "rifle.semiauto", SkinID = 1886298134, Spawn_Percent_Chance = 3 }, } }, new Kit() { name = "Electrical Engineer", health = 240, aggrorange = 32, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "smg.2", 3045025929 } }, wear = new Dictionary() { { "hoodie", 1819497052 }, { "pants", 1819498178 }, { "shoes.boots", 919261524 }, { "burlap.gloves", 971733833 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden", SkinID = 1820400113, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 1819106723, Spawn_Percent_Chance = 11 }, new LootItem { ItemShortname = "rug", SkinID = 1839108631, Spawn_Percent_Chance = 22 }, } }, new Kit() { name = "Hydroelectric Plant Technician", health = 280, aggrorange = 32, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "rifle.semiauto", 1637683572 } }, wear = new Dictionary() { { "hoodie", 1819497052 }, { "pants", 1819498178 }, { "shoes.boots", 919261524 }, { "burlap.gloves", 971733833 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden", SkinID = 1820400113, Spawn_Percent_Chance = 19 }, new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 1819106723, Spawn_Percent_Chance = 11 }, new LootItem { ItemShortname = "rug", SkinID = 1839108631, Spawn_Percent_Chance = 35 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1576241040, Spawn_Percent_Chance = 24 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 2082467002, Spawn_Percent_Chance = 17 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 3025309177, Spawn_Percent_Chance = 12 }, } }, new Kit() { name = "Hydroelectric Plant Boss", health = 460, aggrorange = 32, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "rifle.ak", 1127194813 } }, wear = new Dictionary() { { "metal.plate.torso", 1825471202 }, { "hoodie", 1819497052 }, { "pants", 1819498178 }, { "shoes.boots", 919261524 }, { "burlap.gloves", 971733833 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden", SkinID = 1820400113, Spawn_Percent_Chance = 28 }, new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 1819106723, Spawn_Percent_Chance = 27 }, new LootItem { ItemShortname = "rug", SkinID = 1839108631, Spawn_Percent_Chance = 25 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1576241040, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "jackhammer", SkinID = 2374409703, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "explosive.satchel", SkinID = 2943033789, Spawn_Percent_Chance = 12 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 2082467002, Spawn_Percent_Chance = 14 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 3025309177, Spawn_Percent_Chance = 11 }, } }, new Kit() { name = "Research Team Member", health = 160, aggrorange = 12, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "geiger.counter", 0 } }, wear = new Dictionary() { { "hoodie", 3203315840 }, { "hat.gas.mask", 0 }, { "pants", 3203317865 }, { "shoes.boots", 826587881 }, { "diving.tank", 0 }, { "burlap.gloves", 971733833 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 3122757150, Spawn_Percent_Chance = 27 }, new LootItem { ItemShortname = "rug", SkinID = 1316583306, Spawn_Percent_Chance = 25 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1984902763, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "jackhammer", SkinID = 2374409703, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "door.double.hinged.metal", SkinID = 3172403819, Spawn_Percent_Chance = 12 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 2082467002, Spawn_Percent_Chance = 14 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1672890449, Spawn_Percent_Chance = 11 }, } }, new Kit() { name = "Research Team Member", health = 160, aggrorange = 12, peacekeeper = false, roamrange = 3, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "metal.detector", 0 } }, wear = new Dictionary() { { "hoodie", 3203315840 }, { "hat.gas.mask", 0 }, { "pants", 3203317865 }, { "shoes.boots", 826587881 }, { "diving.tank", 0 }, { "burlap.gloves", 971733833 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 3122757150, Spawn_Percent_Chance = 27 }, new LootItem { ItemShortname = "rug", SkinID = 1316583306, Spawn_Percent_Chance = 25 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1984902763, Spawn_Percent_Chance = 15 }, new LootItem { ItemShortname = "jackhammer", SkinID = 2374409703, Spawn_Percent_Chance = 5 }, new LootItem { ItemShortname = "door.double.hinged.metal", SkinID = 3172403819, Spawn_Percent_Chance = 12 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 2082467002, Spawn_Percent_Chance = 14 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 1672890449, Spawn_Percent_Chance = 11 }, } }, new Kit() { name = "Military Remanence", health = 190, aggrorange = 32, peacekeeper = false, roamrange = 2, corpse_minutes = 3, respawn_minutes = 25, belt = new Dictionary() { { "smg.mp5", 3340739449 }, { "weapon.mod.small.scope", 0 }, { "weapon.mod.extendedmags", 0 }, { "weapon.mod.lasersight", 0 }}, wear = new Dictionary() { { "jumpsuit.waterwellnpc", 0 }, { "shoes.boots", 2980941295 }, { "roadsign.gloves", 2401515914 } }, CanHeal = true, LootItems = new List() { new LootItem { ItemShortname = "box.wooden.large", SkinID = 922931250, Spawn_Percent_Chance = 37 }, new LootItem { ItemShortname = "wall.frame.garagedoor", SkinID = 2715059947, Spawn_Percent_Chance = 11 }, new LootItem { ItemShortname = "door.hinged.metal", SkinID = 3269874848, Spawn_Percent_Chance = 14 }, new LootItem { ItemShortname = "rug", SkinID = 2966512879, Spawn_Percent_Chance = 22 }, } }, }; public static System.Random random = new System.Random(); void OnServerInitialized() { CheckVersion(); foreach (var door in BaseNetworkable.serverEntities.OfType().ToList()) { if (door.PrefabName.Contains("hinged.security")) { var rd = (Door)GameManager.server.CreateEntity(door.PrefabName, door.transform.position, door.transform.rotation); rd.Spawn(); door.Kill(); } } t = this; var list = BaseNetworkable.serverEntities.OfType().Where(x => x.PrefabName.Contains("electrical.random.switch.deployed")); PrintWarning($"Welcome, All Map NPC's Have Spawned. Enjoy!"); List found = new List(); List entities = new List(); List switches = new List(); List cells = new List(); List blockers = new List(); foreach (var marker in list) { if (found.Contains(marker.net.ID.Value)) continue; entities.Clear(); Vis.Entities(marker.transform.position, 0.2f, entities); entities = entities.Distinct().ToList(); cells = entities.Where(x => x.PrefabName.Contains("electrical.memorycell.deployed.prefab")).ToList(); if (cells.Count == 0) continue; switches = entities.Where(x => x.PrefabName.Contains("electrical.random.switch.deployed")).ToList(); blockers = entities.Where(x => x.PrefabName.Contains("electrical.blocker.deployed.prefab")).ToList(); if (switches.Count > 1 || cells.Count > 1 || blockers.Count > 0) { foreach (var ent in switches) found.Add(ent.net.ID.Value); SetupNpc(marker.transform.position, switches.Count - 2 + ((cells.Count - 1) * 10) + (blockers.Count * 20)); } } } public class RobNPC : HumanNPC, IAISenses, IAIAttack, IThinker { public string name = ScientistNPC.ScientistName.translated; public override string displayName => name; private ScientistBrain brain { get; set; } public override void ServerInit() { brain = this.GetComponent(); base.ServerInit(); t.NextTick(() => { if (this.Brain != null) { if (this.Brain.Senses != null) { this.Brain.Senses.Init(this, this.Brain, 5f, 50f, 60f, this.Brain.VisionCone, this.Brain.CheckVisionCone, this.Brain.CheckLOS, this.Brain.IgnoreNonVisionSneakers, this.Brain.ListenRange, this.Brain.HostileTargetsOnly, false, true, this.Brain.SenseTypes, this.Brain.RefreshKnownLOS); this.Brain.Senses.ignoreSafeZonePlayers = true; } } }); } } private static RobNPC InstantiateEntityNpc(Vector3 position, Quaternion rotation) { GameObject gameObject = Instantiate.GameObject(GameManager.server.FindPrefab("assets/rust.ai/agents/npcplayer/humannpc/scientist/scientistnpc_full_any.prefab"), position, Quaternion.identity); gameObject.name = "assets/rust.ai/agents/npcplayer/humannpc/scientist/scientistnpc_full_any.prefab"; gameObject.SetActive(false); ScientistNPC scientistNPC = gameObject.GetComponent(); ScientistBrain defaultBrain = gameObject.GetComponent(); defaultBrain._baseEntity = scientistNPC; RobNPC component = gameObject.AddComponent(); defaultBrain.Pet = false; defaultBrain.AllowedToSleep = false; CopyFields(scientistNPC, component); defaultBrain._baseEntity = component; UnityEngine.Object.DestroyImmediate(scientistNPC, true); UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, Rust.Server.EntityScene); UnityEngine.Object.Destroy(gameObject.GetComponent()); return component; } private static void CopyFields(T src, T dst) { var fields = typeof(T).GetFields(); foreach (var field in fields) { if (field.IsStatic) continue; object value = field.GetValue(src); field.SetValue(dst, value); } } void SetupNpc(Vector3 location, int info) { RobNPC npc = InstantiateEntityNpc(location + new Vector3(0, 0.1f, 0), new Quaternion()) as RobNPC; npc.Spawn(); npc.gameObject.SetActive(true); if (npc == null) return; var bData = npc.gameObject.AddComponent(); bData.npc = npc; bData.Kit = info; bData.roamrange = KitList[info].roamrange; var brain = npc.GetComponent(); var nav = npc.GetComponent(); if (nav == null) return; nav.CanUseNavMesh = false; nav.Agent.agentTypeID = -1372625422; nav.DefaultArea = "Walkable"; nav.SetCurrentNavigationType(BaseNavigator.NavigationType.NavMesh); nav.Init(npc, nav.Agent); if (npc != null) { npc.inventory.Strip(); SetInfo(npc, KitList[info], info, location); } else { timer.Once(KitList[info].respawn_minutes * 60, () => { if (!unloading) { SetupNpc(location, info); return; } }); } timer.Once(4f, () => { if (npc?.transform?.position == null || brain?.Senses == null) return; bData.loc = npc.transform.position; brain.UseAIDesign = true; brain.HostileTargetsOnly = KitList[info].peacekeeper; brain.Senses.Init(npc, npc.Brain, 5f, KitList[info].aggrorange, KitList[info].aggrorange + 10, -1f, false, false, true, 50f, KitList[info].peacekeeper, false, false, EntityType.Player, false); brain.Navigator.PlaceOnNavMesh(0f); brain.Events.Memory.Position.Set(bData.loc, 4); var weapon = npc.GetHeldEntity() as AttackEntity; if (weapon != null) weapon.effectiveRange = 100; foreach (var item in npc.inventory.containerBelt.itemList) item?.contents?.Clear(); foreach (var item in npc.inventory.containerBelt.itemList.Where(item => item.GetHeldEntity() is BaseProjectile)) { foreach (var i in npc.inventory.containerBelt.itemList.Where(i => i.GetHeldEntity() is ProjectileWeaponMod).ToList()) i.MoveToContainer(item.contents); break; } if (npc != null && brain?.states != null) { nav.CanUseNavMesh = true; brain.Events.Memory.Position.Set(bData.loc, 4); brain.states[AIState.FollowPath] = new FollowPath(); } }); brain.MemoryDuration = 20f; } public class FollowPath : BaseAIBrain.BaseFollowPathState { public override StateStatus StateThink(float delta, BaseAIBrain brain, BaseEntity entity) { return StateStatus.Finished; } } List BackPacks = new List(); void OnEntitySpawned(NPCPlayerCorpse corpse) { if (corpse != null && corpse.WaterFactor() < 0.1) corpse.GetComponent().mass = 100f; Info info; if (npcs.TryGetValue(corpse.playerSteamID, out info)) { corpse._playerName = npcs[corpse.playerSteamID].name; corpse.lootPanelName = npcs[corpse.playerSteamID].name; corpse.containers[1].SetLocked(true); corpse.containers[2].SetLocked(true); npcs.Remove(corpse.playerSteamID); BackPacks.Add(corpse.playerSteamID); timer.Once(0.1f, () => { if (corpse?.containers != null) { foreach (var item in info.LootItems) { if (item.Spawn_Percent_Chance >= random.Next(1, 101)) { var i = ItemManager.CreateByName(item.ItemShortname, item.Amount, item.SkinID); if (i != null) i.MoveToContainer(corpse.containers[0]); } } } }); timer.Once(info.corpse * 60, () => { if (corpse != null && !corpse.IsDestroyed) corpse?.Kill(); }); var loc = info.loc; var kit = info.kit; timer.Once(info.respawn * 60, () => { if (!unloading) SetupNpc(loc, kit); }); } } void OnEntitySpawned(DroppedItemContainer container) { if (container != null && container.ShortPrefabName.Contains("backpack")) { if (container.WaterFactor() < 0.1) container.GetComponent().mass = 100f; } NextTick(() => { if (container == null || container.IsDestroyed) return; if (container.playerSteamID == 0) return; if (BackPacks.Contains(container.playerSteamID)) { container.Kill(); BackPacks.Remove(container.playerSteamID); } }); } public void SetInfo(RobNPC npc, Kit kit, int info, Vector3 loc) { npc.displayName = kit.name; npc.name = kit.name; npc.inventory.containerWear.Clear(); npc.inventory.containerBelt.Clear(); foreach (var item in kit.belt) { Item newItem = ItemManager.CreateByName(item.Key, 1, item.Value); if (!newItem.MoveToContainer(npc.inventory.containerBelt)) newItem.Remove(); } foreach (var item in kit.wear) { Item newItem = ItemManager.CreateByName(item.Key, 1, item.Value); if (!newItem.MoveToContainer(npc.inventory.containerWear)) newItem.Remove(); } npc._maxHealth = kit.health; npc.startHealth = npc._maxHealth; npc.InitializeHealth(npc._maxHealth, npc._maxHealth); npcs.Add(npc.userID, new Info() { kit = info, loc = loc, name = npc.displayName, corpse = kit.corpse_minutes, respawn = kit.respawn_minutes, LootItems = kit.LootItems }); } public class mono : MonoBehaviour { public RobNPC npc; public BaseAIBrain brain; public Vector3 loc; public bool goingHome = false; public int Kit; public int roamrange; Item syringe; public void Start() { npc.CancelInvoke(npc.EquipTest); npc.EquipTest(); npc.inventory.containerBelt.onlyAllowedItems = null; npc.inventory.containerBelt.onItemAddedRemoved = null; t.timer.Once(2f, () => { syringe = ItemManager.CreateByName("syringe.medical", 1, 0); syringe.MoveToContainer(npc.inventory.containerBelt, -1, false, true); }); brain = npc.GetComponent(); brain.Events.Memory.Position.Set(loc, 4); InvokeRepeating("Roam", 0, 5f); if (t.KitList[Kit].CanHeal) InvokeRepeating("DoHeal", 5, 30); } void DoHeal() => npc.StartCoroutine(Heal()); public class AttackAIEvent : BaseAIEvent { public AttackAIEvent() : base(AIEventType.AttackTick) { } } System.Collections.IEnumerator Heal() { if (npc.health < npc.MaxHealth() / 5 * 4) { for (int i = 0; i < brain.Events.events.Count(); i++) if (brain.Events.events[i].EventType == AIEventType.AttackTick) brain.Events.events[i] = new AttackAIEvent(); brain.sleeping = true; UpdateActiveItem(npc, syringe.GetHeldEntity() as HeldEntity); MedicalTool med = npc.GetActiveItem().GetHeldEntity() as MedicalTool; if (med == null) { brain.SwitchToState(AIState.FollowPath, 0); yield break; } yield return new WaitForSeconds(1f); npc?.SignalBroadcast(BasePlayer.Signal.Attack, "", null); npc?.Heal(40); yield return new WaitForSeconds(2f); UpdateActiveItem(npc, npc.inventory.containerBelt.GetSlot(0).GetHeldEntity() as HeldEntity); syringe.Remove(); ItemManager.DoRemoves(); syringe = ItemManager.CreateByName("syringe.medical", 1, 0); syringe.MoveToContainer(npc.inventory.containerBelt); brain.SwitchToState(AIState.FollowPath, 0); brain.sleeping = false; } } void UpdateActiveItem(RobNPC npc, HeldEntity held) { if (npc == null || held == null) return; var activeItem1 = npc.GetHeldEntity(); npc.svActiveItemID = new ItemId(0); if (activeItem1 != null) activeItem1.SetHeld(false); npc.svActiveItemID = held.GetItem().uid; if (held != null) held.SetHeld(true); npc.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); npc.inventory.UpdatedVisibleHolsteredItems(); } void Roam() { if (Vector3.Distance(npc.transform.position, loc) > roamrange) brain.Navigator.SetDestination(loc, BaseNavigator.NavigationSpeed.Normal, 0f, 0f); else { var newloc = GetPoint(loc, roamrange); brain.Navigator.SetDestination(newloc == Vector3.zero ? loc : newloc, BaseNavigator.NavigationSpeed.Slow, 0f, 0f); } } public void OnDestroy() { CancelInvoke("DoHeal"); CancelInvoke("Roam"); } NavMeshHit navMeshHit; public bool HasNav(Vector3 pos) => NavMesh.SamplePosition(pos, out navMeshHit, 2, 1); public static Vector3 CalculateGroundPos(Vector3 pos) { NavMeshHit navMeshHit; if (!NavMesh.SamplePosition(pos, out navMeshHit, 2, 1)) pos = Vector3.zero; else if (WaterLevel.GetWaterDepth(pos, true, false) > 0) pos = Vector3.zero; else pos = navMeshHit.position; return pos; } Vector3 GetPoint(Vector3 pos, int radius) { int attempts = 0; var spawnPoint = Vector3.zero; Vector2 rand; while (attempts < 50 && spawnPoint == Vector3.zero) { attempts++; rand = UnityEngine.Random.insideUnitCircle * radius; spawnPoint = CalculateGroundPos(pos + new Vector3(rand.x, 0, rand.y)); if (spawnPoint != Vector3.zero) return spawnPoint; } return spawnPoint; } } public bool unloading = false; void Unload() { unloading = true; foreach (var npc in UnityEngine.Object.FindObjectsOfType().ToList()) if (npc?.npc != null && !npc.npc.IsDestroyed) npc.npc.Kill(); } private void CheckVersion() { try { webrequest.Enqueue("https://robjmaps.com/downloads/Plugin_Versions.json", "", (code, response) => { if (code != 200 || response == null) return; var test = JsonConvert.DeserializeObject>(response); if (test != null && test.ContainsKey(this.Name)) { if (test[this.Name] > this.Version) PrintError($"Plugin is out of date. Current version is {test[this.Name]}"); else PrintWarning("Plugin is up to date."); } }, this, RequestMethod.GET, null, 5); } catch (Exception ex) { } } } }