public static void load() { if (!File.Exists(Misc.getServerPath() + @"\data\npcDrops.xml")) { Console.WriteLine(@"Missing data\npcDrops.xml"); return; } try { //Deserialize text file to a new object. StreamReader objStreamReader = new StreamReader(Misc.getServerPath() + @"\data\npcDrops.xml"); XmlSerializer serializer = new XmlSerializer(typeof(List <NpcDrop>)); List <NpcDrop> list = (List <NpcDrop>)serializer.Deserialize(objStreamReader); int p = 0; foreach (NpcDrop drop in list) { for (int i = 0; i < drop.npcs.Length; i++) { NpcData.forId(drop.npcs[i]).setDrop(drop); } p++; } Console.WriteLine("Loaded " + p + " npc drops."); } catch (Exception e) { Misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString())); } }
public Npc(int id) { this.id = id; npcDef = NpcData.forId(id); skills = new NpcSkills(this); skills.setMaxLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints()); //this must be first. skills.setCurLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints()); this.setWalkType(WalkType.RANGE); this.faceDirection = FaceDirection.NORTH; this.updateFlags = new AppearanceUpdateFlags(this); }
public static NpcData forId(int id) { NpcData d; if (!definitions.TryGetValue(id, out d)) { d = new NpcData(); d.id = id; d.name = "NPC #" + d.id; d.examine = "It's an NPC."; definitions.Add(id, d); } return d; }
public static NpcData forId(int id) { NpcData d; if (!definitions.TryGetValue(id, out d)) { d = new NpcData(); d.id = id; d.name = "NPC #" + d.id; d.examine = "It's an NPC."; definitions.Add(id, d); } return(d); }