Ejemplo n.º 1
0
        // Function from file: atoms.dm
        public override bool add_blood(dynamic M = null)
        {
            int     blood_count         = 0;
            string  index               = null;
            dynamic blood_splatter_icon = null;

            blood_count = (!(this.blood_DNA != null) ? 0 : this.blood_DNA.len);

            if (!base.add_blood((object)(M)))
            {
                return(false);
            }

            if (!(blood_count != 0) && Lang13.Bool(Lang13.Initial(this, "icon")) && Lang13.Bool(Lang13.Initial(this, "icon_state")))
            {
                index = this.blood_splatter_index();
                blood_splatter_icon = GlobalVars.blood_splatter_icons[index];

                if (!Lang13.Bool(blood_splatter_icon))
                {
                    blood_splatter_icon = new Icon(Lang13.Initial(this, "icon"), Lang13.Initial(this, "icon_state"), null, 1);
                    ((Icon)blood_splatter_icon).Blend("#fff", 0);
                    ((Icon)blood_splatter_icon).Blend(new Icon("icons/effects/blood.dmi", "itemblood"), 2);
                    blood_splatter_icon = File13.Cache(blood_splatter_icon);
                    GlobalVars.blood_splatter_icons[index] = blood_splatter_icon;
                }
                this.overlays.Add(blood_splatter_icon);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public File save_map(dynamic t1 = null, dynamic t2 = null, string map_name = null, dynamic flags = null)
        {
            dynamic file_text = null;
            File    saved_map = null;


            if (!(String13.CKeyPreserveCase(map_name) == map_name && Lang13.Bool(String13.CKeyPreserveCase(map_name))))
            {
                Task13.Crash("Invalid text supplied to proc save_map, invalid characters or empty string.");
            }

            if (!(t1 is Tile) || !(t2 is Tile))
            {
                Task13.Crash("Invalid arguments supplied to proc save_map, arguments were not turfs.");
            }
            file_text = this.__CallVerb("write map", t1, t2, flags);

            if (File13.Exists("" + map_name + ".dmm"))
            {
                File13.Delete("" + map_name + ".dmm");
            }
            saved_map = new File("" + map_name + ".dmm");
            saved_map.WriteMsg(file_text);
            return(saved_map);
        }
Ejemplo n.º 3
0
        // Range: -1 Access: 0 Flags: ( 0, 4, 255 )
        public static void save_mode(dynamic the_mode = null)
        {
            File F = null;

            F = new File("data/mode.txt");
            File13.delete(F);
            ((dynamic)F).write(the_mode);
            return;
        }
Ejemplo n.º 4
0
 // Function from file: tooltip.dm
 public Tooltip(Client C = null)
 {
     if (C != null)
     {
         this.owner = C;
         Interface13.Browse(this.owner, File13.Read(this.file), "window=" + this.control);
     }
     // Warning: Super call was HERE! If anything above HERE is needed by the super call, it might break!;
     return;
 }
Ejemplo n.º 5
0
        public Sound(dynamic file = null, bool?repeat = null, bool?wait = null, int?channel = null, int?volume = null)
        {
            volume = volume ?? 100;

            this.file    = File13.Cache(file);
            this.repeat  = repeat;
            this.wait    = wait;
            this.channel = channel;
            this.volume  = volume;
            // Warning: Super call was HERE! If anything above HERE is needed by the super call, it might break!;
            return;
        }
Ejemplo n.º 6
0
		// 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;
		}
Ejemplo n.º 7
0
        // Function from file: tgui.dm
        public Subsystem_Tgui(  )
        {
            this.basehtml = File13.Read("tgui/tgui.html");

            if (GlobalVars.SStgui != this)
            {
                if (GlobalVars.SStgui is Subsystem_Tgui)
                {
                    this.Recover();
                    GlobalFuncs.qdel(GlobalVars.SStgui);
                }
                GlobalVars.SStgui = this;
            }
            return;
        }
Ejemplo n.º 8
0
        // Function from file: personality.dm
        public bool savefile_load(Mob user = null, bool?silent = null)
        {
            silent = silent ?? true;

            string   path    = null;
            SaveFile F       = null;
            bool?    version = null;


            if (GlobalFuncs.IsGuestKey(user.key))
            {
                return(false);
            }
            path = this.savefile_path(user);

            if (!File13.Exists(path))
            {
                return(false);
            }
            F = new SaveFile(path);

            if (!(F != null))
            {
                return(false);
            }
            version = null;
            version = F.ReadItem("version", version);

            if (version == null || version != true)
            {
                File13.Delete(path);

                if (!(silent == true))
                {
                    Interface13.Alert(user, "Your savefile was incompatible with this version and was deleted.");
                }
                return(false);
            }
            this.name        = F.ReadItem("name", this.name);
            this.description = F.ReadItem("description", this.description);
            this.role        = F.ReadItem("role", this.role);
            this.comments    = F.ReadItem("comments", this.comments);
            return(true);
        }
Ejemplo n.º 9
0
        // 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;
        }
Ejemplo n.º 10
0
        // Function from file: swapmaps.dm
        public bool Save(  )
        {
            SaveFile S = null;


            if (this.id == this)
            {
                return(false);
            }
            S = (this.mode ? new SaveFile() : new SaveFile("map_" + this.id + ".sav"));
            ((dynamic)S).WriteMsg(this);

            while (this.locked)
            {
                Task13.Sleep(1);
            }

            if (this.mode)
            {
                File13.Delete("map_" + this.id + ".txt");
                S.ExportText("/", "map_" + this.id + ".txt");
            }
            return(true);
        }
Ejemplo n.º 11
0
        // Function from file: minimap.dm
        public void generate(dynamic z = null, int?x1 = null, int?y1 = null, int?x2 = null, int?y2 = null)
        {
            z  = z ?? 1;
            x1 = x1 ?? 1;
            y1 = y1 ?? 1;
            x2 = x2 ?? Game13.map_size_x;
            y2 = y2 ?? Game13.map_size_y;

            Icon    minimap   = null;
            ByTable obj_icons = null;
            int     counter   = 0;
            dynamic T         = null;
            dynamic tile      = null;
            Icon    tile_icon = null;
            dynamic obj       = null;
            dynamic I         = null;
            dynamic obj_icon  = null;
            Icon    flatten   = null;
            Icon    final     = null;

            minimap = new Icon("icons/minimap.dmi");
            minimap.Scale(GlobalVars.MINIMAP_SIZE, GlobalVars.MINIMAP_SIZE);
            obj_icons = new ByTable();
            counter   = 128;

            foreach (dynamic _b in Lang13.Enumerate(Map13.FetchInBlock(Map13.GetTile(x1 ?? 0, y1 ?? 0, Convert.ToInt32(z)), Map13.GetTile(x2 ?? 0, y2 ?? 0, Convert.ToInt32(z)))))
            {
                T = _b;

                tile      = T;
                tile_icon = null;
                obj       = null;

                if (tile is Tile_Space)
                {
                    obj = Lang13.FindIn(typeof(Obj_Structure_Lattice_Catwalk), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/smooth_structures/catwalk.dmi", "catwalk", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Lattice), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/smooth_structures/lattice.dmi", "lattice", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Grille), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/structures.dmi", "grille", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_TransitTube), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/atmospherics/pipes/transit_tube.dmi", obj.icon_state, Lang13.DoubleNullable(obj.dir));
                    }
                }
                else
                {
                    tile_icon = new Icon(tile.icon, tile.icon_state, Lang13.DoubleNullable(tile.dir));
                    obj_icons.Cut();
                    obj = Lang13.FindIn(typeof(Obj_Structure), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(GlobalFuncs.getFlatIcon(obj));
                    }
                    obj = Lang13.FindIn(typeof(Obj_Machinery), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(new Icon(obj.icon, obj.icon_state, Lang13.DoubleNullable(obj.dir), 1, false));
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Window), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(new Icon("icons/obj/smooth_structures/window.dmi", "window", GlobalVars.SOUTH));
                    }

                    foreach (dynamic _a in Lang13.Enumerate(obj_icons))
                    {
                        I = _a;

                        obj_icon = I;
                        tile_icon.Blend(obj_icon, 3);
                    }
                }

                if (tile_icon != null)
                {
                    tile_icon.Scale(GlobalVars.TILE_SIZE, GlobalVars.TILE_SIZE);
                    minimap.Blend(tile_icon, 3, Lang13.DoubleNullable((tile.x - 1) * 8), Lang13.DoubleNullable((tile.y - 1) * 8));
                    Lang13.Delete(tile_icon);
                    tile_icon = null;
                }
                counter--;

                if (counter <= 0)
                {
                    counter = 128;
                    flatten = new Icon();
                    flatten.Insert(minimap, "", GlobalVars.SOUTH, 1, false);
                    Lang13.Delete(minimap);
                    minimap = null;
                    minimap = flatten;
                    Task13.Sleep(-1);
                }
            }
            final = new Icon();
            final.Insert(minimap, "", GlobalVars.SOUTH, 1, false);
            File13.Copy(final, this.map_path(z));
            return;
        }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
 // Range: -1 Access: 0 Flags: ( 0, 4, 255 )
 public static void load_motd(  )
 {
     GlobalVars.join_motd = File13.read("config/motd.txt");
     return;
 }
Ejemplo n.º 14
0
        public void LoadMap(string dmm_file, int x_offset, int y_offset, int z_offset)
        {
            string tfile     = File13.Read(dmm_file);
            int    tfile_len = tfile.Length;

            string[] tfile_lines = tfile.Split('\n');

            int key_len = Lang13.Length(String13.SubStr(tfile, 2, String13.Find(tfile, quote, 2, 0)));

            var grid_models = new ByTable();

            Logger.Announce("Parsing map file...");
            var timer = new System.Diagnostics.Stopwatch();

            timer.Start();

            int line_i = 0;

            string default_key = null;

            while (true)
            {
                string tline = tfile_lines[line_i];

                // Bail out if not a model.
                if (tline.Length == 0)
                {
                    break;
                }

                string model_key      = tline.Substring(1, key_len);
                string model_contents = tline.Substring(key_len + 6, tline.Length - (key_len + 7));

                grid_models[model_key] = model_contents;

                if (default_key == null)
                {
                    default_key = model_key;
                }

                line_i++;
            }
            Logger.Announce("Done parsing map file in " + timer.Elapsed + "s.");

            string zgrid = null;

            int x_depth = 0;
            int y_depth = 0;
            int z_depth = 0;

            double x_tilecount = 0;

            int?   gpos      = null;
            string grid_line = null;


            int xcrd = x_offset;
            int ycrd = y_offset;
            int zcrd = -1;

            int tpos = String13.Find(tfile, "\n(1,1,");

            while (tpos != 0)
            {
                zcrd++;
                Game13.map_size_z = Num13.MaxInt(Game13.map_size_z, zcrd + z_offset);
                zgrid             = String13.SubStr(tfile, String13.Find(tfile, quote + "\n", tpos, 0) + 2, String13.Find(tfile, "\n" + quote, tpos, 0) + 1);
                z_depth           = Lang13.Length(zgrid);
                x_depth           = Lang13.Length(String13.SubStr(zgrid, 1, String13.Find(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.Find(zgrid, "\n", gpos ?? 0, 0));
                    xcrd      = 0;

                    foreach (double mpos in Lang13.IterateRange(1, x_depth, key_len))
                    {
                        xcrd++;
                        string model_key = String13.SubStr(grid_line, (int)mpos, (int)mpos + key_len);
                        if (model_key != default_key)
                        {
                            this.parse_grid(grid_models[model_key], xcrd + x_offset, ycrd + y_offset, zcrd + z_offset);
                        }
                    }
                    if ((gpos ?? 0) + x_depth + 1 > z_depth)
                    {
                        break;
                    }
                    ycrd--;

                    gpos = String13.Find(zgrid, "\n", gpos ?? 0, 0) + 1;
                }
                if (String13.Find(tfile, quote + "}", tpos, 0) + 2 == tfile_len)
                {
                    break;
                }

                tpos = String13.Find(tfile, "\n(1,1,", tpos + 1, 0);
            }
            Logger.Announce("Done loading map in " + timer.Elapsed + "s.");
            return;
        }
Ejemplo n.º 15
0
        // Function from file: html_interface.dm
        public void show(dynamic hclient = null)
        {
            hclient = this.getClient(hclient, GlobalVars.TRUE);

            if (hclient is HtmlInterfaceClient)
            {
                if (GlobalVars.asset_list.Contains(this.type) && GlobalVars.asset_list[this.type] is ByTable)
                {
                    GlobalFuncs.send_asset_list(hclient.client, GlobalVars.asset_list[this.type], GlobalVars.TRUE);
                }

                if (!Interface13.WindowExists(hclient.client, new Txt("browser_").Ref(this).ToString()))
                {
                    this.createWindow(hclient);
                }
                hclient.is_loaded = GlobalVars.FALSE;
                Interface13.Output(hclient.client, GlobalFuncs.replacetextEx(GlobalFuncs.replacetextEx(File13.Read("html_interface.html"), "[hsrc]", new Txt().Ref(this).ToString()), "</head>", "" + this.head + "</head>"), new Txt("browser_").Ref(this).str(".browser").ToString());
                Interface13.WindowShow(hclient.client, new Txt("browser_").Ref(this).ToString(), GlobalVars.TRUE);

                while (Lang13.Bool(hclient.client) && Lang13.Bool(hclient.active) && !Lang13.Bool(hclient.is_loaded))
                {
                    Task13.Sleep(2);
                }
            }
            return;
        }
Ejemplo n.º 16
0
 public dynamic RscFile(  )
 {
     return(File13.Cache(this.icon));
 }