// Function from file: musician.dm public void playnote( int note = 0, string acc = null, int oct = 0 ) { dynamic soundfile = null; dynamic source = null; dynamic M = null; if ( acc == "b" && ( note == 3 || note == 6 ) ) { if ( note == 3 ) { oct--; } note--; acc = "n"; } else if ( acc == "#" && ( note == 2 || note == 5 ) ) { if ( note == 2 ) { oct++; } note++; acc = "n"; } else if ( acc == "#" && note == 7 ) { note = 1; acc = "b"; } else if ( acc == "#" ) { acc = "b"; note++; } if ( oct < 1 || ( note == 3 ? oct > 9 : oct > 8 ) ) { return; } soundfile = "sound/" + this.instrumentDir + "/" + String13.GetCharFromCode( note + 64 ) + acc + oct + "." + this.instrumentExt; soundfile = new File( soundfile ); if ( !File13.Exists( soundfile ) ) { return; } source = GlobalFuncs.get_turf( this.instrumentObj ); foreach (dynamic _a in Lang13.Enumerate( GlobalFuncs.get_hearers_in_view( 15, source ) )) { M = _a; if ( !Lang13.Bool( M.client ) || !Lang13.Bool( M.client.prefs.toggles & 128 ) ) { continue; } ((Ent_Static)M).playsound_local( source, soundfile, 100, null, null, 5 ); } return; }
// Function from file: map_template.dm public void preload_size(string path = null) { string quote = null; string map_file = null; int key_len = 0; int mapstart = 0; string content = null; int line_len = 0; quote = String13.GetCharFromCode(34); map_file = File13.Read(path); key_len = Lang13.Length(String13.SubStr(map_file, 2, String13.FindIgnoreCase(map_file, quote, 2, 0))); mapstart = String13.FindIgnoreCase(map_file, "\n(1,1,", 1, 0); content = String13.SubStr(map_file, String13.FindIgnoreCase(map_file, quote + "\n", mapstart, 0) + 2, String13.FindIgnoreCase(map_file, "\n" + quote, mapstart, 0) + 1); line_len = Lang13.Length(String13.SubStr(content, 1, String13.FindIgnoreCase(content, "\n", 2, 0))); this.width = line_len / key_len; this.height = Lang13.Length(content) / (line_len + 1); return; }
public void load_map(string dmm_file = null, bool x_offset = false, bool y_offset = false, int z_offset = 0) { string quote = null; string tfile = null; int tfile_len = 0; int lpos = 0; ByTable grid_models = null; int key_len = 0; string tline = null; string model_key = null; string model_contents = null; int zcrd = 0; double ycrd = 0; int xcrd = 0; int? zpos = null; string zgrid = null; int z_depth = 0; int x_depth = 0; double x_tilecount = 0; double y_depth = 0; int? gpos = null; string grid_line = null; double mpos = 0; string model_key2 = null; if (!(z_offset != 0)) { z_offset = Game13.map_size_z + 1; } if (!x_offset) { x_offset = false; } if (!y_offset) { y_offset = false; } quote = String13.GetCharFromCode(34); tfile = File13.Read(dmm_file); tfile_len = Lang13.Length(tfile); lpos = 1; grid_models = new ByTable(); key_len = Lang13.Length(String13.SubStr(tfile, 2, String13.FindIgnoreCase(tfile, quote, 2, 0))); lpos = 1; while (lpos < tfile_len) { tline = String13.SubStr(tfile, lpos, String13.FindIgnoreCase(tfile, "\n", lpos, 0)); if (String13.SubStr(tline, 1, 2) != quote) { break; } model_key = String13.SubStr(tline, 2, key_len + 2); model_contents = String13.SubStr(tline, String13.FindIgnoreCase(tfile, "=", 1, 0) + 3, Lang13.Length(tline)); grid_models[model_key] = model_contents; Task13.Sleep(-1); lpos = String13.FindIgnoreCase(tfile, "\n", lpos, 0) + 1; } zcrd = -1; ycrd = y_offset ?1:0; xcrd = x_offset ?1:0; zpos = null; zpos = String13.FindIgnoreCase(tfile, "\n(1,1,", lpos, 0); while (zpos != 0) { zcrd++; Game13.map_size_z = Num13.MaxInt(Game13.map_size_z, zcrd + z_offset); zgrid = String13.SubStr(tfile, String13.FindIgnoreCase(tfile, quote + "\n", zpos ?? 0, 0) + 2, String13.FindIgnoreCase(tfile, "\n" + quote, zpos ?? 0, 0) + 1); z_depth = Lang13.Length(zgrid); x_depth = Lang13.Length(String13.SubStr(zgrid, 1, String13.FindIgnoreCase(zgrid, "\n", 2, 0))); x_tilecount = x_depth / key_len; if (Game13.map_size_x < x_tilecount) { Game13.map_size_x = ((int)(x_tilecount)); } y_depth = z_depth / (x_depth + 1); if (Game13.map_size_y < y_depth) { Game13.map_size_y = ((int)(y_depth)); } ycrd = y_depth; gpos = null; gpos = 1; while (gpos != 0) { grid_line = String13.SubStr(zgrid, gpos ?? 0, String13.FindIgnoreCase(zgrid, "\n", gpos ?? 0, 0)); xcrd = 0; foreach (dynamic _a in Lang13.IterateRange(1, x_depth, key_len)) { mpos = _a; xcrd++; model_key2 = String13.SubStr(grid_line, ((int)(mpos)), ((int)(mpos + key_len))); this.parse_grid(grid_models[model_key2], xcrd + (x_offset ?1:0), ycrd + (y_offset ?1:0), zcrd + z_offset); } if ((gpos ?? 0) + x_depth + 1 > z_depth) { break; } ycrd--; Task13.Sleep(-1); gpos = String13.FindIgnoreCase(zgrid, "\n", gpos ?? 0, 0) + 1; } if (String13.FindIgnoreCase(tfile, quote + "}", zpos ?? 0, 0) + 2 == tfile_len) { break; } Task13.Sleep(-1); zpos = String13.FindIgnoreCase(tfile, "\n(1,1,", (zpos ?? 0) + 1, 0); } return; }
// Function from file: other_reagents.dm public override double reaction_mob(dynamic M = null, int?method = null, double?reac_volume = null, bool?show_message = null, dynamic touch_protection = null, Mob_Camera_Blob O = null) { method = method ?? GlobalVars.TOUCH; show_message = show_message ?? true; dynamic N = null; string newcolor = null; int? len = null; int? i = null; int ascii = 0; if (M is Mob_Living_Carbon_Human) { if (method == GlobalVars.PATCH || method == GlobalVars.VAPOR) { N = M; if (N.dna.species.id == "human") { dynamic _a = N.skin_tone; // Was a switch-case, sorry for the mess. if (_a == "african1") { N.skin_tone = "african2"; } else if (_a == "indian") { N.skin_tone = "african1"; } else if (_a == "arab") { N.skin_tone = "indian"; } else if (_a == "asian2") { N.skin_tone = "arab"; } else if (_a == "asian1") { N.skin_tone = "asian2"; } else if (_a == "mediterranean") { N.skin_tone = "african1"; } else if (_a == "latino") { N.skin_tone = "mediterranean"; } else if (_a == "caucasian3") { N.skin_tone = "mediterranean"; } else if (_a == "caucasian2") { N.skin_tone = Rand13.Pick(new object [] { "caucasian3", "latino" }); } else if (_a == "caucasian1") { N.skin_tone = "caucasian2"; } else if (_a == "albino") { N.skin_tone = "caucasian1"; } } if (N.dna.species.specflags.Contains(1)) { newcolor = ""; len = Lang13.Length(N.dna.features["mcolor"]); i = null; i = 1; while ((i ?? 0) <= (len ?? 0)) { ascii = String13.GetCharCode(N.dna.features["mcolor"], i); dynamic _b = ascii; // Was a switch-case, sorry for the mess. if (49 <= _b && _b <= 57) { newcolor += String13.GetCharFromCode(ascii - 1); } else if (98 <= _b && _b <= 102) { newcolor += String13.GetCharFromCode(ascii - 1); } else if (66 <= _b && _b <= 70) { newcolor += String13.GetCharFromCode(ascii + 31); } else if (_b == 48) { newcolor += "0"; } else if (_b == 97) { newcolor += "9"; } else if (_b == 65) { newcolor += "9"; } else { break; } i += 1; } if (Convert.ToDouble(GlobalFuncs.ReadHSV(newcolor)[3]) >= Convert.ToDouble(GlobalFuncs.ReadHSV("#7F7F7F")[3])) { N.dna.features["mcolor"] = newcolor; } } ((Mob)N).regenerate_icons(); } if (method == GlobalVars.INGEST) { if (show_message == true) { M.WriteMsg("<span class='notice'>That tasted horrible.</span>"); } ((Mob)M).AdjustStunned(2); ((Mob)M).AdjustWeakened(2); } } base.reaction_mob((object)(M), method, reac_volume, show_message, (object)(touch_protection), O); return(0); }