protected virtual NPCInst SpawnNPC(NPCClass classDef, Vec3f pos, Angles ang, float posOffset = 100, int teamID = 1, bool giveAI = true) { NPCInst npc = CreateNPC(classDef, teamID); Vec3f spawnPos = posOffset > 0 ? Randomizer.GetVec3fRad(pos, posOffset) : pos; npc.BaseInst.SetNeedsClientGuide(giveAI); npc.Spawn(World, spawnPos, ang); return(npc); }
protected NPCInst SpawnNPC(NPCClass classDef, Vec3f pos, float posOffset = 100, int teamID = 1, bool giveAI = true) { return(SpawnNPC(classDef, pos, Randomizer.GetYaw(), posOffset, teamID, giveAI)); }
protected NPCInst CreateNPC(NPCClass def, int teamID, CharCreationInfo cInfo = null) { if (def == null) { return(null); } NPCInst npc; if (def.Definition == null) { if (cInfo == null) { npc = new NPCInst(NPCDef.Get("maleplayer")); npc.RandomizeCustomVisuals(def.Name, true); } else { npc = new NPCInst(NPCDef.Get(cInfo.BodyMesh == HumBodyMeshs.HUM_BODY_NAKED0 ? "maleplayer" : "femaleplayer")) { UseCustoms = true, CustomBodyTex = cInfo.BodyTex, CustomHeadMesh = cInfo.HeadMesh, CustomHeadTex = cInfo.HeadTex, CustomVoice = cInfo.Voice, CustomFatness = cInfo.Fatness, CustomScale = new Vec3f(cInfo.BodyWidth, 1.0f, cInfo.BodyWidth), CustomName = cInfo.Name }; } } else { npc = new NPCInst(NPCDef.Get(def.Definition)); } // add inventory items if (def.ItemDefs != null) { foreach (var invItem in def.ItemDefs) { var item = new ItemInst(ItemDef.Get(invItem.DefName)); item.SetAmount(invItem.Amount); npc.Inventory.AddItem(item); npc.EffectHandler.TryEquipItem(item); } } // add overlays if (def.Overlays != null) { foreach (var overlay in def.Overlays) { if (npc.ModelDef.TryGetOverlay(overlay, out ScriptOverlay ov)) { npc.ModelInst.ApplyOverlay(ov); } } } npc.TeamID = teamID; npc.Protection = def.Protection; npc.Damage = def.Damage; npc.SetHealth(def.HP, def.HP); npc.Guild = def.Guild; return(npc); }