public void lowerHealth(ushort originalId, Location location) { WorldObject worldObject = getObject(originalId, location); if (worldObject == null) { addObjectToList(originalId, location); } if (worldObject.getOriginalId() == 733) // Web { if (misc.random(6) == 0) { changeObject(worldObject); } return; } worldObject = getObject(originalId, location); worldObject.setObjectHealth(worldObject.getObjectHealth() - 1); if (worldObject.getObjectHealth() <= 0) { changeObject(worldObject); } }
public void loadSpawnedObjects() { string line = ""; string token = ""; string token2 = ""; string token2_2 = ""; string[] token3 = new string[10]; if(!File.Exists(misc.getServerPath() + @"\data\spawnedObjects.cfg")) { misc.WriteError(@"Missing data\spawnedObjects.cfg"); return; } try { StreamReader sr = File.OpenText(misc.getServerPath() + @"\data\spawnedObjects.cfg"); int amount = 0; while ((line = sr.ReadLine()) != null) { line = line.Trim(); int spot = line.IndexOf("="); if (spot > -1) { token = line.Substring(0, spot); token = token.Trim(); token2 = line.Substring(spot + 1); token2 = token2.Trim(); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token3 = token2_2.Split('\t'); if (token.Equals("object")) { amount++; ushort id = ushort.Parse(token3[0]); Location location = new Location(int.Parse(token3[1]), int.Parse(token3[2]), int.Parse(token3[3])); int face = int.Parse(token3[4]); int type = int.Parse(token3[5]); WorldObject worldObject = new WorldObject(id, location, face, type, true); // these 3 methods are to set variables for spawned rocks, trees etc. worldObject.setRestore(getRestore(id)); worldObject.setObjectHealth(getHealth(id)); worldObject.setSecondaryId(getSecondaryId(id)); objects.Add(worldObject); add(worldObject); // we KNOW this object is legit..since we spawned it. } } else { if (line.Equals("[ENDOFLIST]")) { Console.WriteLine("Loaded " + amount + " custom objects."); } } } } catch (Exception e) { Console.WriteLine("Error loading spawnedObjects.cfg msg=" + e.Message); Console.ReadLine(); } }
public void loadSpawnedObjects() { string line = ""; string token = ""; string token2 = ""; string token2_2 = ""; string[] token3 = new string[10]; if (!File.Exists(misc.getServerPath() + @"\data\spawnedObjects.cfg")) { misc.WriteError(@"Missing data\spawnedObjects.cfg"); return; } try { StreamReader sr = File.OpenText(misc.getServerPath() + @"\data\spawnedObjects.cfg"); int amount = 0; while ((line = sr.ReadLine()) != null) { line = line.Trim(); int spot = line.IndexOf("="); if (spot > -1) { token = line.Substring(0, spot); token = token.Trim(); token2 = line.Substring(spot + 1); token2 = token2.Trim(); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token2_2 = token2.Replace("\t\t", "\t"); token3 = token2_2.Split('\t'); if (token.Equals("object")) { amount++; ushort id = ushort.Parse(token3[0]); Location location = new Location(int.Parse(token3[1]), int.Parse(token3[2]), int.Parse(token3[3])); int face = int.Parse(token3[4]); int type = int.Parse(token3[5]); WorldObject worldObject = new WorldObject(id, location, face, type, true); // these 3 methods are to set variables for spawned rocks, trees etc. worldObject.setRestore(getRestore(id)); worldObject.setObjectHealth(getHealth(id)); worldObject.setSecondaryId(getSecondaryId(id)); objects.Add(worldObject); add(worldObject); // we KNOW this object is legit..since we spawned it. } } else { if (line.Equals("[ENDOFLIST]")) { Console.WriteLine("Loaded " + amount + " custom objects."); } } } } catch (Exception e) { Console.WriteLine("Error loading spawnedObjects.cfg msg=" + e.Message); Console.ReadLine(); } }