Пример #1
0
        // Function from file: autolathe.dm
        public string category_win(dynamic user = null, dynamic selected_category = null)
        {
            string  dat            = null;
            dynamic v              = null;
            Design  D              = null;
            int     max_multiplier = 0;

            dat  = new Txt("<A href='?src=").Ref(this).str(";menu=").item(1).str("'>Return to main menu</A>").ToString();
            dat += "<div class='statusDisplay'><h3>Browsing " + selected_category + ":</h3><br>";
            dat += "<b>Total amount:</b> " + this.materials.total_amount + " / " + this.materials.max_amount + " cm<sup>3</sup><br>";
            dat += "<b>Metal amount:</b> " + this.materials.amount("$metal") + " cm<sup>3</sup><br>";
            dat += "<b>Glass amount:</b> " + this.materials.amount("$glass") + " cm<sup>3</sup><br>";

            foreach (dynamic _a in Lang13.Enumerate(this.files.known_designs))
            {
                v = _a;

                D = this.files.known_designs[v];

                if (!D.category.Contains(selected_category))
                {
                    continue;
                }

                if (Lang13.Bool(this.disabled) || !this.can_build(D))
                {
                    dat += "<span class='linkOff'>" + D.name + "</span>";
                }
                else
                {
                    dat += new Txt("<a href='?src=").Ref(this).str(";make=").item(D.id).str(";multiplier=1'>").item(D.name).str("</a>").ToString();
                }

                if (Lang13.Bool(D.build_path.IsSubclassOf(typeof(Obj_Item_Stack))))
                {
                    max_multiplier = Num13.MinInt(D.maxstack, ((int)((Lang13.Bool(D.materials["$metal"]) ? Num13.Floor((this.materials.amount("$metal") ?1:0) / Convert.ToDouble(D.materials["$metal"])) : Double.PositiveInfinity))), ((int)((Lang13.Bool(D.materials["$glass"]) ? Num13.Floor((this.materials.amount("$glass") ?1:0) / Convert.ToDouble(D.materials["$glass"])) : Double.PositiveInfinity))));

                    if (max_multiplier > 10 && !Lang13.Bool(this.disabled))
                    {
                        dat += new Txt(" <a href='?src=").Ref(this).str(";make=").item(D.id).str(";multiplier=10'>x10</a>").ToString();
                    }

                    if (max_multiplier > 25 && !Lang13.Bool(this.disabled))
                    {
                        dat += new Txt(" <a href='?src=").Ref(this).str(";make=").item(D.id).str(";multiplier=25'>x25</a>").ToString();
                    }

                    if (max_multiplier > 0 && !Lang13.Bool(this.disabled))
                    {
                        dat += new Txt(" <a href='?src=").Ref(this).str(";make=").item(D.id).str(";multiplier=").item(max_multiplier).str("'>x").item(max_multiplier).str("</a>").ToString();
                    }
                }
                dat += "" + this.get_design_cost(D) + "<br>";
            }
            dat += "</div>";
            return(dat);
        }
Пример #2
0
        // Function from file: glowshroom.dm
        public void Spread(  )
        {
            int?    i                    = null;
            ByTable possibleLocs         = null;
            bool    spreadsIntoAdjacent  = false;
            Tile_Simulated_Floor earth   = null;
            dynamic newLoc               = null;
            int     shroomCount          = 0;
            int     placeCount           = 0;
            Obj_Effect_Glowshroom shroom = null;
            dynamic wallDir              = null;
            Tile    isWall               = null;
            dynamic child                = null;

            i = null;
            i = 1;

            while ((i ?? 0) <= (this.yield ?? 0))
            {
                if (Rand13.PercentChance(((int)(1 / (this.generation * this.generation) * 100))))
                {
                    possibleLocs        = new ByTable();
                    spreadsIntoAdjacent = false;

                    if (Rand13.PercentChance(this.spreadIntoAdjacentChance))
                    {
                        spreadsIntoAdjacent = true;
                    }

                    foreach (dynamic _a in Lang13.Enumerate(Map13.FetchInView(this, 3), typeof(Tile_Simulated_Floor)))
                    {
                        earth = _a;


                        if (spreadsIntoAdjacent || !Lang13.Bool(Lang13.FindIn(typeof(Obj_Effect_Glowshroom), Map13.FetchInView(earth, 1))))
                        {
                            possibleLocs.Add(earth);
                        }
                    }

                    if (!(possibleLocs.len != 0))
                    {
                        break;
                    }
                    newLoc      = Rand13.PickFromTable(possibleLocs);
                    shroomCount = 0;
                    placeCount  = 1;

                    foreach (dynamic _b in Lang13.Enumerate(newLoc, typeof(Obj_Effect_Glowshroom)))
                    {
                        shroom = _b;

                        shroomCount++;
                    }

                    foreach (dynamic _c in Lang13.Enumerate(GlobalVars.cardinal))
                    {
                        wallDir = _c;

                        isWall = Map13.GetStep(newLoc, Convert.ToInt32(wallDir));

                        if (isWall.density)
                        {
                            placeCount++;
                        }
                    }

                    if (shroomCount >= placeCount)
                    {
                    }
                    else
                    {
                        child            = Lang13.Call(this.type, newLoc);
                        child.potency    = Num13.MaxInt(this.potency + Rand13.Int(-3, 6), 0);
                        child.yield      = Num13.MaxInt((this.yield ?? 0) + Rand13.Int(-1, 2), 0);
                        child.delay      = Num13.MaxInt(this.delay + Rand13.Int(-30, 60), 0);
                        child.endurance  = Num13.MaxInt(((int)(this.endurance + Rand13.Int(-3, 6))), 1);
                        child.generation = this.generation + 1;
                        child.desc       = new Txt("This is a ").st_nd_rd(child.generation).str(" generation ").item(child.name).str("!").ToString();
                    }
                }
                i++;
            }
            return;
        }
Пример #3
0
        // Function from file: datacore.dm
        public void manifest_inject(dynamic H = null)
        {
            dynamic assignment = null;
            string  id         = null;
            Icon    image      = null;
            Obj_Item_Weapon_Photo photo_front = null;
            Obj_Item_Weapon_Photo photo_side  = null;
            Data_Record           G           = null;
            Data_Record           M           = null;
            Data_Record           S           = null;
            Data_Record           L           = null;


            if (Lang13.Bool(H.mind) && H.mind.assigned_role != H.mind.special_role)
            {
                if (Lang13.Bool(H.mind.assigned_role))
                {
                    assignment = H.mind.assigned_role;
                }
                else if (Lang13.Bool(H.job))
                {
                    assignment = H.job;
                }
                else
                {
                    assignment = "Unassigned";
                }
                id          = GlobalFuncs.num2hex(GlobalVars.record_id_num++, 6);
                image       = this.get_id_photo(H);
                photo_front = new Obj_Item_Weapon_Photo();
                photo_side  = new Obj_Item_Weapon_Photo();
                photo_front.photocreate(null, new Icon(image, null, GlobalVars.SOUTH));
                photo_side.photocreate(null, new Icon(image, null, GlobalVars.WEST));
                G = new Data_Record();
                G.fields["id"]   = id;
                G.fields["name"] = H.real_name;
                G.fields["rank"] = assignment;
                G.fields["age"]  = H.age;

                if (GlobalVars.config.mutant_races)
                {
                    G.fields["species"] = H.dna.species.name;
                }
                G.fields["fingerprint"] = Num13.Md5(H.dna.uni_identity);
                G.fields["p_stat"]      = "Active";
                G.fields["m_stat"]      = "Stable";
                G.fields["sex"]         = H.gender;
                G.fields["photo_front"] = photo_front;
                G.fields["photo_side"]  = photo_side;
                this.general.Add(G);
                M = new Data_Record();
                M.fields["id"]         = id;
                M.fields["name"]       = H.real_name;
                M.fields["blood_type"] = H.dna.blood_type;
                M.fields["b_dna"]      = H.dna.unique_enzymes;
                M.fields["mi_dis"]     = "None";
                M.fields["mi_dis_d"]   = "No minor disabilities have been declared.";
                M.fields["ma_dis"]     = "None";
                M.fields["ma_dis_d"]   = "No major disabilities have been diagnosed.";
                M.fields["alg"]        = "None";
                M.fields["alg_d"]      = "No allergies have been detected in this patient.";
                M.fields["cdi"]        = "None";
                M.fields["cdi_d"]      = "No diseases have been diagnosed at the moment.";
                M.fields["notes"]      = "No notes.";
                this.medical.Add(M);
                S = new Data_Record();
                S.fields["id"]       = id;
                S.fields["name"]     = H.real_name;
                S.fields["criminal"] = "None";
                S.fields["mi_crim"]  = new ByTable();
                S.fields["ma_crim"]  = new ByTable();
                S.fields["notes"]    = "No notes.";
                this.security.Add(S);
                L = new Data_Record();
                L.fields["id"]         = Num13.Md5("" + H.real_name + H.mind.assigned_role);
                L.fields["name"]       = H.real_name;
                L.fields["rank"]       = H.mind.assigned_role;
                L.fields["age"]        = H.age;
                L.fields["sex"]        = H.gender;
                L.fields["blood_type"] = H.dna.blood_type;
                L.fields["b_dna"]      = H.dna.unique_enzymes;
                L.fields["enzymes"]    = H.dna.struc_enzymes;
                L.fields["identity"]   = H.dna.uni_identity;
                L.fields["species"]    = H.dna.species.type;
                L.fields["features"]   = H.dna.features;
                L.fields["image"]      = image;
                this.locked.Add(L);
            }
            return;
        }
Пример #4
0
        // Function from file: camera_bug.dm
        public string menu(ByTable cameras = null)
        {
            string  html            = null;
            dynamic entry           = null;
            Obj_Machinery_Camera C  = null;
            string functions        = null;
            int    time_diff        = 0;
            Obj_Machinery_Camera C2 = null;
            dynamic outstring       = null;
            int     m = 0;
            dynamic s = null;


            if (!(cameras != null) || !(cameras.len != 0))
            {
                return("No bugged cameras found.");
            }

            switch ((int?)(this.track_mode))
            {
            case 0:
                html = new Txt("<h3>Select a camera:</h3> <a href='?src=").Ref(this).str(";view'>[Cancel camera view]</a><hr><table>").ToString();

                foreach (dynamic _a in Lang13.Enumerate(cameras))
                {
                    entry = _a;

                    C         = cameras[entry];
                    functions = "";

                    if (C.bug == this)
                    {
                        functions = new Txt(" - <a href='?src=").Ref(this).str(";monitor=").Ref(C).str("'>[Monitor]</a> <a href='?src=").Ref(this).str(";emp=").Ref(C).str("'>[Disable]</a>").ToString();
                    }
                    else
                    {
                        functions = new Txt(" - <a href='?src=").Ref(this).str(";monitor=").Ref(C).str("'>[Monitor]</a>").ToString();
                    }
                    html += new Txt("<tr><td><a href='?src=").Ref(this).str(";view=").Ref(C).str("'>").item(entry).str("</a></td><td>").item(functions).str("</td></tr>").ToString();
                }
                break;

            case 1:

                if (Lang13.Bool(this.current))
                {
                    html  = new Txt("Analyzing Camera '").item(this.current.c_tag).str("' <a href='?").Ref(this).str(";mode=0'>[Select Camera]</a><br>").ToString();
                    html += this.camera_report();
                }
                else
                {
                    this.track_mode = 0;
                    return(this.menu(cameras));
                }
                break;

            case 2:

                if (Lang13.Bool(this.tracking))
                {
                    html = new Txt("Tracking '").item(this.tracked_name).str("'  <a href='?").Ref(this).str(";mode=0'>[Cancel Tracking]</a>  <a href='?src=").Ref(this).str(";view'>[Cancel camera view]</a><br>").ToString();

                    if (Lang13.Bool(this.last_found))
                    {
                        time_diff = Num13.Floor((Game13.time - this.last_seen) / 150);
                        C2        = this.bugged_cameras[this.last_found];
                        outstring = null;

                        if (C2 != null)
                        {
                            outstring = new Txt("<a href='?").Ref(this).str(";view=").Ref(C2).str("'>").item(this.last_found).str("</a>").ToString();
                        }
                        else
                        {
                            outstring = this.last_found;
                        }

                        if (!(time_diff != 0))
                        {
                            html += "Last seen near " + outstring + " (now)<br>";
                        }
                        else
                        {
                            m = Num13.Floor(time_diff / 4);
                            s = (time_diff - m * 4) * 15;

                            if (!Lang13.Bool(s))
                            {
                                s = "00";
                            }
                            html += new Txt("Last seen near ").item(outstring).str(" (").item(m).str(":").item(s).str(" minute").s().str(" ago)<br>").ToString();
                        }

                        if (C2 != null && C2.bug == this)
                        {
                            html += new Txt("<a href='?src=").Ref(this).str(";emp=").Ref(C2).str("'>[Disable]</a>").ToString();
                        }
                    }
                    else
                    {
                        html += "Not yet seen.";
                    }
                }
                else
                {
                    this.track_mode = 0;
                    return(this.menu(cameras));
                }
                break;
            }
            return(html);
        }
Пример #5
0
        // Function from file: beam.dm
        public void Draw(  )
        {
            double? Angle      = null;
            Matrix  rot_matrix = null;
            double  DX         = 0;
            double  DY         = 0;
            double  N          = 0;
            double  length     = 0;
            dynamic X          = null;
            Icon    II         = null;
            double? Pixel_x    = null;
            double? Pixel_y    = null;
            int?    a          = null;

            Angle      = Num13.Floor(GlobalFuncs.Get_Angle(this.origin, this.target));
            rot_matrix = Num13.Matrix();
            rot_matrix.Turn(Angle);
            DX     = Convert.ToDouble(this.target.x * 32 + this.target.pixel_x - (this.origin.x * 32 + this.origin.pixel_x));
            DY     = Convert.ToDouble(this.target.y * 32 + this.target.pixel_y - (this.origin.y * 32 + this.origin.pixel_y));
            N      = 0;
            length = Num13.Floor(Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DY, 2)));

            foreach (dynamic _a in Lang13.IterateRange(0, length - 1, 32))
            {
                N = _a;

                X       = Lang13.Call(this.beam_type, this.origin_oldloc);
                X.owner = this;
                this.elements.Or(X);

                if (N + 32 > length)
                {
                    II = new Icon(this.icon, this.icon_state);
                    II.DrawBox(null, 1, length - N, 32, 32);
                    X.icon = II;
                }
                else
                {
                    X.icon = this.base_icon;
                }
                X.transform = rot_matrix;
                Pixel_x     = null;
                Pixel_y     = null;

                if (DX == 0)
                {
                    Pixel_x = 0;
                }
                else
                {
                    Pixel_x = Num13.Floor(Math.Sin(Angle ?? 0) + Math.Sin(Angle ?? 0) * (N + 16) * 32 / 32);
                }

                if (DY == 0)
                {
                    Pixel_y = 0;
                }
                else
                {
                    Pixel_y = Num13.Floor(Math.Cos(Angle ?? 0) + Math.Cos(Angle ?? 0) * (N + 16) * 32 / 32);
                }
                a = null;

                if (Math.Abs(Pixel_x ?? 0) > 32)
                {
                    a        = ((Pixel_x ?? 0) > 0 ? Num13.Floor((Pixel_x ?? 0) / 32) : GlobalFuncs.Ceiling((Pixel_x ?? 0) / 32));
                    X.x     += a;
                    Pixel_x %= 32;
                }

                if (Math.Abs(Pixel_y ?? 0) > 32)
                {
                    a        = ((Pixel_y ?? 0) > 0 ? Num13.Floor((Pixel_y ?? 0) / 32) : GlobalFuncs.Ceiling((Pixel_y ?? 0) / 32));
                    X.y     += a;
                    Pixel_y %= 32;
                }
                X.pixel_x = Pixel_x;
                X.pixel_y = Pixel_y;
            }
            return;
        }
Пример #6
0
        // Function from file: spaceheater.dm
        public override int?ui_act(string action = null, ByTable _params = null, Tgui ui = null, UiState state = null)
        {
            int?_default = null;

            dynamic target = null;
            double? adjust = null;


            if (Lang13.Bool(base.ui_act(action, _params, ui, state)))
            {
                return(_default);
            }

            switch ((string)(action))
            {
            case "power":
                this.on   = !Lang13.Bool(this.on) ?1:0;
                this.mode = "standby";
                Task13.User.visible_message(new Txt().item(Task13.User).str(" switches ").item((Lang13.Bool(this.on) ? "on" : "off")).str(" ").the(this).item().str(".").ToString(), new Txt("<span class='notice'>You switch ").item((Lang13.Bool(this.on) ? "on" : "off")).str(" ").the(this).item().str(".</span>").ToString());
                this.update_icon();
                _default = GlobalVars.TRUE;
                break;

            case "mode":
                this.setMode = _params["mode"];
                _default     = GlobalVars.TRUE;
                break;

            case "target":

                if (!Lang13.Bool(this.panel_open))
                {
                    return(_default);
                }
                target = _params["target"];
                adjust = String13.ParseNumber(_params["adjust"]);

                if (target == "input")
                {
                    target = Interface13.Input("New target temperature:", this.name, Num13.Round(this.targetTemperature - 273.41, 1), null, null, InputType.Num | InputType.Null);

                    if (!(target == null) && !Lang13.Bool(base.ui_act(action, _params, ui, state)))
                    {
                        _default = GlobalVars.TRUE;
                    }
                }
                else if (Lang13.Bool(adjust))
                {
                    target   = this.targetTemperature + (adjust ?? 0);
                    _default = GlobalVars.TRUE;
                }
                else if (String13.ParseNumber(target) != null)
                {
                    target   = (String13.ParseNumber(target) ?? 0) + 273.41;
                    _default = GlobalVars.TRUE;
                }

                if (Lang13.Bool(_default))
                {
                    this.targetTemperature = Num13.MaxInt(Num13.MaxInt(((int)(this.settableTemperatureMedian - this.settableTemperatureRange)), ((int)(2.7))), Num13.MinInt(Num13.Floor(Convert.ToDouble(target)), ((int)(this.settableTemperatureMedian + this.settableTemperatureRange))));
                }
                break;

            case "eject":

                if (Lang13.Bool(this.panel_open) && Lang13.Bool(this.cell))
                {
                    this.cell.loc = GlobalFuncs.get_turf(this);
                    this.cell     = null;
                    _default      = GlobalVars.TRUE;
                }
                break;
            }
            return(_default);
        }
Пример #7
0
        // Function from file: camera.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            string  msg      = null;
            string  msg2     = null;
            dynamic U        = null;
            dynamic X        = null;
            dynamic P        = null;
            string  itemname = null;
            dynamic info     = null;
            dynamic O        = null;
            dynamic AI       = null;
            dynamic L        = null;

            msg  = "<span class='notice'>You attach " + A + " into the assembly's inner circuits.</span>";
            msg2 = "<span class='notice'>" + this + " already has that upgrade!</span>";

            if (A is Obj_Item_Weapon_Screwdriver)
            {
                this.panel_open = !Lang13.Bool(this.panel_open) ?1:0;
                user.WriteMsg("<span class='notice'>You screw the camera's panel " + (Lang13.Bool(this.panel_open) ? "open" : "closed") + ".</span>");
                GlobalFuncs.playsound(this.loc, "sound/items/Screwdriver.ogg", 50, 1);
                return(null);
            }

            if (Lang13.Bool(this.panel_open))
            {
                if (A is Obj_Item_Weapon_Wirecutters)
                {
                    this.toggle_cam(user, true);
                    this.health = Lang13.Initial(this, "health");
                }
                else if (A is Obj_Item_Device_Multitool)
                {
                    this.setViewRange((this.view_range == Lang13.Initial(this, "view_range") ? ((dynamic)(this.short_range)) : Lang13.Initial(this, "view_range")));
                    user.WriteMsg("<span class='notice'>You " + (this.view_range == Lang13.Initial(this, "view_range") ? "restore" : "mess up") + " the camera's focus.</span>");
                }
                else if (A is Obj_Item_Weapon_Weldingtool)
                {
                    if (this.weld(A, user))
                    {
                        this.visible_message("<span class='warning'>" + user + " unwelds " + this + ", leaving it as just a frame screwed to the wall.</span>", "<span class='warning'>You unweld " + this + ", leaving it as just a frame screwed to the wall</span>");

                        if (!(this.assembly != null))
                        {
                            this.assembly = new Obj_Machinery_CameraAssembly();
                        }
                        this.assembly.loc   = this.loc;
                        this.assembly.state = 1;
                        this.assembly.dir   = this.dir;
                        this.assembly       = null;
                        GlobalFuncs.qdel(this);
                        return(null);
                    }
                }
                else if (A is Obj_Item_Device_Analyzer)
                {
                    if (!(this.isXRay() != 0))
                    {
                        this.upgradeXRay();
                        GlobalFuncs.qdel(A);
                        user.WriteMsg("" + msg);
                    }
                    else
                    {
                        user.WriteMsg("" + msg2);
                    }
                }
                else if (A is Obj_Item_Stack_Sheet_Mineral_Plasma)
                {
                    if (!(this.isEmpProof() != 0))
                    {
                        this.upgradeEmpProof();
                        user.WriteMsg("" + msg);
                        GlobalFuncs.qdel(A);
                    }
                    else
                    {
                        user.WriteMsg("" + msg2);
                    }
                }
                else if (A is Obj_Item_Device_Assembly_ProxSensor)
                {
                    if (!(this.isMotion() != 0))
                    {
                        this.upgradeMotion();
                        user.WriteMsg("" + msg);
                        GlobalFuncs.qdel(A);
                    }
                    else
                    {
                        user.WriteMsg("" + msg2);
                    }
                }
            }

            if ((A is Obj_Item_Weapon_Paper || A is Obj_Item_Device_Pda) && user is Mob_Living)
            {
                U        = user;
                X        = null;
                P        = null;
                itemname = "";
                info     = "";

                if (A is Obj_Item_Weapon_Paper)
                {
                    X        = A;
                    itemname = X.name;
                    info     = X.info;
                }
                else
                {
                    P        = A;
                    itemname = P.name;
                    info     = P.notehtml;
                }
                U.WriteMsg(new Txt("<span class='notice'>You hold ").the(itemname).item().str(" up to the camera...</span>").ToString());
                ((Mob)U).changeNext_move(8);

                foreach (dynamic _a in Lang13.Enumerate(GlobalVars.player_list))
                {
                    O = _a;


                    if (O is Mob_Living_Silicon_Ai)
                    {
                        AI = O;

                        if (AI.control_disabled || Convert.ToInt32(AI.stat) == 2)
                        {
                            return(null);
                        }

                        if (U.name == "Unknown")
                        {
                            AI.WriteMsg(new Txt("<b>").item(U).str("</b> holds <a href='?_src_=usr;show_paper=1;'>").a(itemname).item().str("</a> up to one of your cameras ...").ToString());
                        }
                        else
                        {
                            AI.WriteMsg(new Txt("<b><a href='?src=").Ref(AI).str(";track=").item(String13.HtmlEncode(U.name)).str("'>").item(U).str("</a></b> holds <a href='?_src_=usr;show_paper=1;'>").a(itemname).item().str("</a> up to one of your cameras ...").ToString());
                        }
                        AI.last_paper_seen = "<HTML><HEAD><TITLE>" + itemname + "</TITLE></HEAD><BODY><TT>" + info + "</TT></BODY></HTML>";
                    }
                    else if (Lang13.Bool(O.client) && O.client.eye == this)
                    {
                        O.WriteMsg(new Txt().item(U).str(" holds ").a(itemname).item().str(" up to one of the cameras ...").ToString());
                        Interface13.Browse(O, "<HTML><HEAD><TITLE>" + itemname + "</TITLE></HEAD><BODY><TT>" + info + "</TT></BODY></HTML>", "window=" + itemname);
                    }
                }
            }
            else if (A is Obj_Item_Device_CameraBug)
            {
                if (!this.can_use())
                {
                    user.WriteMsg("<span class='notice'>Camera non-functional.</span>");
                    return(null);
                }

                if (this.bug is Obj_Item_Device_CameraBug)
                {
                    user.WriteMsg("<span class='notice'>Camera bug removed.</span>");
                    this.bug.bugged_cameras.Remove(this.c_tag);
                    this.bug = null;
                }
                else
                {
                    user.WriteMsg("<span class='notice'>Camera bugged.</span>");
                    this.bug = A;
                    this.bug.bugged_cameras[this.c_tag] = this;
                }
            }
            else if (A is Obj_Item_Device_LaserPointer)
            {
                L = A;
                ((Obj_Item_Device_LaserPointer)L).laser_act(this, user);
            }
            else if (Convert.ToDouble(A.force) >= 10)
            {
                ((Mob)user).changeNext_move(8);
                this.visible_message("<span class='warning'>" + user + " hits " + this + " with " + A + "!</span>", "<span class='warning'>You hit " + this + " with " + A + "!</span>");
                this.health = Num13.MaxInt(0, Convert.ToInt32(this.health - A.force));
                ((Ent_Dynamic)user).do_attack_animation(this);

                if (!Lang13.Bool(this.health) && this.status)
                {
                    this.triggerCameraAlarm();
                    this.toggle_cam(user, true);
                }
            }
            return(null);
        }
        // Function from file: protolathe.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            Obj_Item_Weapon_ReagentContainers_Glass G = null;
            dynamic stack           = null;
            double? amount          = null;
            double? amount_inserted = null;
            dynamic stack_name      = null;


            if (this.shocked)
            {
                this.shock(user, 50);
            }

            if (this.default_deconstruction_screwdriver(user, "protolathe_t", "protolathe", A))
            {
                if (Lang13.Bool(this.linked_console))
                {
                    this.linked_console.linked_lathe = null;
                    this.linked_console = null;
                }
                return(null);
            }

            if (this.exchange_parts(user, A))
            {
                return(null);
            }

            if (Lang13.Bool(this.panel_open))
            {
                if (A is Obj_Item_Weapon_Crowbar)
                {
                    foreach (dynamic _a in Lang13.Enumerate(this.component_parts, typeof(Obj_Item_Weapon_ReagentContainers_Glass)))
                    {
                        G = _a;

                        this.reagents.trans_to(G, G.reagents.maximum_volume);
                    }
                    this.materials.retrieve_all();
                    this.default_deconstruction_crowbar(A);
                    return(1);
                }
                else
                {
                    user.WriteMsg("<span class='warning'>You can't load the " + this.name + " while it's opened!</span>");
                    return(1);
                }
            }

            if (this.disabled)
            {
                return(null);
            }

            if (!Lang13.Bool(this.linked_console))
            {
                user.WriteMsg("<span class='warning'>The " + this.name + " must be linked to an R&D console first!</span>");
                return(1);
            }

            if (this.busy)
            {
                user.WriteMsg("<span class='warning'>The " + this.name + " is busy! Please wait for completion of previous operation.</span>");
                return(1);
            }

            if (Lang13.Bool(((Ent_Static)A).is_open_container()))
            {
                return(null);
            }

            if (this.stat != 0)
            {
                return(1);
            }

            if (!(A is Obj_Item_Stack_Sheet))
            {
                return(1);
            }

            if (!this.materials.has_space(this.materials.get_item_material_amount(A)))
            {
                user.WriteMsg("<span class='warning'>The " + this.name + "'s material bin is full! Please remove material before adding more.</span>");
                return(1);
            }
            stack  = A;
            amount = Num13.Floor(Convert.ToDouble(Interface13.Input("How many sheets do you want to add?", null, null, null, null, InputType.Num)));

            if (!(Map13.GetDistance(this, stack) <= 1) || !((Ent_Static)user).Adjacent(this))
            {
                return(null);
            }
            amount_inserted = this.materials.insert_stack(A, amount);

            if (!Lang13.Bool(amount_inserted))
            {
                return(1);
            }
            else
            {
                stack_name = stack.name;
                this.busy  = true;
                this.f_use_power(Num13.MaxInt(1000, ((int)((amount_inserted ?? 0) * 2000 / 10))));
                user.WriteMsg("<span class='notice'>You add " + amount_inserted + " sheets to the " + this.name + ".</span>");
                this.overlays.Add("protolathe_" + stack_name);
                Task13.Sleep(10);
                this.overlays.Remove("protolathe_" + stack_name);
                this.busy = false;
            }
            this.updateUsrDialog();
            return(null);
        }
        // Function from file: turbine.dm
        public override int?process(dynamic seconds = null)
        {
            GasMixture environment    = null;
            double     transfer_moles = 0;
            dynamic    removed        = null;


            if (!Lang13.Bool(this.turbine))
            {
                this.stat = 1;
            }

            if ((this.stat & 1) != 0 || Lang13.Bool(this.panel_open))
            {
                return(null);
            }

            if (!this.starter)
            {
                return(null);
            }
            this.overlays.Cut();
            this.rpm       = this.rpm * 081 + Convert.ToDouble(this.rpmtarget * 0.1);
            environment    = this.inturf.return_air();
            transfer_moles = environment.total_moles() / 10;
            removed        = this.inturf.remove_air(transfer_moles);
            this.gas_contained.merge(removed);
            this.rpm = Num13.MaxInt(0, ((int)(this.rpm - this.rpm * this.rpm / (500000 / this.efficiency))));

            if (this.starter && !((this.stat & 2) != 0))
            {
                this.f_use_power(2800);

                if (this.rpm < 1000)
                {
                    this.rpmtarget = 1000;
                }
            }
            else if (this.rpm < 1000)
            {
                this.rpmtarget = 0;
            }

            if (this.rpm > 50000)
            {
                this.overlays.Add(new Image("icons/obj/atmospherics/pipes/simple.dmi", "comp-o4", GlobalVars.FLY_LAYER));
            }
            else if (this.rpm > 10000)
            {
                this.overlays.Add(new Image("icons/obj/atmospherics/pipes/simple.dmi", "comp-o3", GlobalVars.FLY_LAYER));
            }
            else if (this.rpm > 2000)
            {
                this.overlays.Add(new Image("icons/obj/atmospherics/pipes/simple.dmi", "comp-o2", GlobalVars.FLY_LAYER));
            }
            else if (this.rpm > 500)
            {
                this.overlays.Add(new Image("icons/obj/atmospherics/pipes/simple.dmi", "comp-o1", GlobalVars.FLY_LAYER));
            }
            return(null);
        }
        // Function from file: other_tools.dm
        public override string get_equip_info(  )
        {
            string output = null;

            output = base.get_equip_info();

            if (Lang13.Bool(output))
            {
                return(new Txt().item(output).str(" [").item(this.fuel).str(": ").item(Num13.Round((this.fuel.amount ?? 0) * this.fuel.perunit, 0.1)).str(" cm<sup>3</sup>] - <a href='?src=").Ref(this).str(";toggle=1'>").item((this.equip_ready ? "A" : "Dea")).str("ctivate</a>").ToString());
            }
            return(null);
        }
Пример #11
0
        // Function from file: rpgloot.dm
        public override bool start(  )
        {
            ByTable  prefixespositive      = null;
            ByTable  prefixesnegative      = null;
            ByTable  suffixes              = null;
            int      upgrade_scroll_chance = 0;
            Obj_Item I       = null;
            int      quality = 0;
            dynamic  value   = null;
            Obj_Item S       = null;
            Obj_Item_Upgradescroll scroll = null;

            prefixespositive = new ByTable(new object [] { "greater", "major", "blessed", "superior", "enpowered", "honed", "true", "glorious", "robust" });
            prefixesnegative = new ByTable(new object [] { "lesser", "minor", "blighted", "inferior", "enfeebled", "rusted", "unsteady", "tragic", "gimped" });
            suffixes         = new ByTable(new object [] {
                "orc slaying",
                "elf slaying",
                "corgi slaying",
                "strength",
                "dexterity",
                "constitution",
                "intelligence",
                "wisdom",
                "charisma",
                "the forest",
                "the hills",
                "the plains",
                "the sea",
                "the sun",
                "the moon",
                "the void",
                "the world",
                "the fool",
                "many secrets",
                "many tales",
                "many colors",
                "rending",
                "sundering",
                "the night",
                "the day"
            });
            upgrade_scroll_chance = 0;

            foreach (dynamic _b in Lang13.Enumerate(typeof(Game13), typeof(Obj_Item)))
            {
                I = _b;


                if (I is Obj_Item_Organ)
                {
                    continue;
                }
                quality = Convert.ToInt32(Rand13.PickWeighted(new object [] { 1074, 15, 3222, 14, 5370, 13, 7518, 12, 10741, 11, 13964, 10, 17187, 9, 21484, 8, 25781, 7, 30078, 6, 35449, 5, 40820, 4, 46191, 3, 52637, 2, 59083, 1, 65535, 0 }));

                if (Rand13.PercentChance(50))
                {
                    quality = -quality;
                }

                if (quality > 0)
                {
                    I.name = "" + Rand13.PickFromTable(prefixespositive) + " " + I.name + " of " + Rand13.PickFromTable(suffixes) + " +" + quality;
                }
                else if (quality < 0)
                {
                    I.name = "" + Rand13.PickFromTable(prefixesnegative) + " " + I.name + " of " + Rand13.PickFromTable(suffixes) + " " + quality;
                }
                else
                {
                    I.name = "" + I.name + " of " + Rand13.PickFromTable(suffixes);
                }
                I.force      = Num13.MaxInt(0, Convert.ToInt32(I.force + quality));
                I.throwforce = Num13.MaxInt(0, Convert.ToInt32(I.throwforce + quality));

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

                    I.armor[value] += quality;
                }

                if (I is Obj_Item_Weapon_Storage)
                {
                    S = I;

                    if (Rand13.PercentChance(upgrade_scroll_chance) && S.contents.len < Convert.ToDouble(((dynamic)S).storage_slots))
                    {
                        scroll = new Obj_Item_Upgradescroll();
                        ((Obj_Item_Weapon_Storage)S).handle_item_insertion(scroll, true);
                        upgrade_scroll_chance = Num13.MaxInt(0, upgrade_scroll_chance - 100);
                    }
                    upgrade_scroll_chance += 25;
                }
            }
            return(false);
        }
Пример #12
0
        // Function from file: hydroponics.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            double t_growthstate = 0;

            this.overlays.Cut();
            this.UpdateDescription();

            if (this.planted)
            {
                if (this.dead)
                {
                    this.overlays.Add(new Image("icons/obj/hydroponics/growing.dmi", null, "" + this.myseed.species + "-dead"));
                }
                else if (this.harvest)
                {
                    if (Convert.ToInt32(this.myseed.plant_type) == 2)
                    {
                        this.overlays.Add(new Image("icons/obj/hydroponics/growing.dmi", null, "" + this.myseed.species + "-grow" + this.myseed.growthstages));
                    }
                    else
                    {
                        this.overlays.Add(new Image("icons/obj/hydroponics/growing.dmi", null, "" + this.myseed.species + "-harvest"));
                    }
                }
                else if (this.age < Convert.ToDouble(this.myseed.maturation))
                {
                    t_growthstate = this.age / Convert.ToDouble(this.myseed.maturation) * this.myseed.growthstages;
                    this.overlays.Add(new Image("icons/obj/hydroponics/growing.dmi", null, "" + this.myseed.species + "-grow" + Num13.Floor(t_growthstate)));
                    this.lastproduce = this.age;
                }
                else
                {
                    this.overlays.Add(new Image("icons/obj/hydroponics/growing.dmi", null, "" + this.myseed.species + "-grow" + this.myseed.growthstages));
                }
            }

            if (this.myseed is Obj_Item_Seeds_Glowshroom)
            {
                this.SetLuminosity(Num13.Floor(Convert.ToDouble(this.myseed.potency / 10)));
            }
            else
            {
                this.SetLuminosity(0);
            }
            return(false);
        }
Пример #13
0
        // Function from file: autolathe.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            dynamic D = null;
            double? material_amount = null;
            double? inserted        = null;


            if (this.busy)
            {
                user.WriteMsg("<span class=\"alert\">The autolathe is busy. Please wait for completion of previous operation.</span>");
                return(1);
            }

            if (this.default_deconstruction_screwdriver(user, "autolathe_t", "autolathe", A))
            {
                this.updateUsrDialog();
                return(null);
            }

            if (this.exchange_parts(user, A))
            {
                return(null);
            }

            if (Lang13.Bool(this.panel_open))
            {
                if (A is Obj_Item_Weapon_Crowbar)
                {
                    this.materials.retrieve_all();
                    this.default_deconstruction_crowbar(A);
                    return(1);
                }
                else if (Lang13.Bool(GlobalFuncs.is_wire_tool(A)))
                {
                    this.wires.interact(user);
                    return(1);
                }
            }

            if (this.stat != 0)
            {
                return(1);
            }

            if (A is Obj_Item_Weapon_Disk_DesignDisk)
            {
                ((Ent_Static)user).visible_message(new Txt().item(user).str(" begins to load ").the(A).item().str(" in ").the(this).item().str("...").ToString(), new Txt("You begin to load a design from ").the(A).item().str("...").ToString(), "You hear the chatter of a floppy drive.");
                this.busy = true;
                D         = A;

                if (GlobalFuncs.do_after(user, 1431, null, this))
                {
                    this.files.AddDesign2Known(D.blueprint);
                }
                this.busy = false;
                return(null);
            }
            material_amount = this.materials.get_item_material_amount(A);

            if (!Lang13.Bool(material_amount))
            {
                user.WriteMsg("<span class='warning'>This object does not contain sufficient amounts of metal or glass to be accepted by the autolathe.</span>");
                return(1);
            }

            if (!this.materials.has_space(material_amount))
            {
                user.WriteMsg("<span class='warning'>The autolathe is full. Please remove metal or glass from the autolathe in order to insert more.</span>");
                return(1);
            }

            if (!((Mob)user).unEquip(A))
            {
                user.WriteMsg(new Txt("<span class='warning'>").The(A).item().str(" is stuck to you and cannot be placed into the autolathe.</span>").ToString());
                return(1);
            }
            this.busy = true;
            inserted  = this.materials.insert_item(A);

            if (Lang13.Bool(inserted))
            {
                if (A is Obj_Item_Stack)
                {
                    if (Lang13.Bool(A.materials["$metal"]))
                    {
                        Icon13.Flick("autolathe_o", this);
                    }

                    if (Lang13.Bool(A.materials["$glass"]))
                    {
                        Icon13.Flick("autolathe_r", this);
                    }
                    user.WriteMsg("<span class='notice'>You insert " + inserted + " sheet" + ((inserted ?? 0) > 1 ? "s" : "") + " to the autolathe.</span>");
                    this.f_use_power((inserted ?? 0) * 100);
                }
                else
                {
                    user.WriteMsg("<span class='notice'>You insert a material total of " + inserted + " to the autolathe.</span>");
                    this.f_use_power(Num13.MaxInt(500, ((int)((inserted ?? 0) / 10))));
                    GlobalFuncs.qdel(A);
                }
            }
            this.busy = false;
            this.updateUsrDialog();
            return(null);
        }
Пример #14
0
        // Function from file: autolathe.dm
        public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null)
        {
            Ent_Static     T               = null;
            double?        multiplier      = null;
            int            max_multiplier  = 0;
            dynamic        is_stack        = null;
            double         coeff           = 0;
            dynamic        metal_cost      = null;
            dynamic        glass_cost      = null;
            double         power           = 0;
            ByTable        materials_used  = null;
            dynamic        N               = null;
            Obj_Item_Stack S               = null;
            ByTable        materials_used2 = null;
            dynamic        new_item        = null;
            dynamic        v               = null;
            dynamic        D               = null;


            if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc))))
            {
                return(null);
            }

            if (!this.busy)
            {
                if (Lang13.Bool(href_list["menu"]))
                {
                    this.screen = String13.ParseNumber(href_list["menu"]);
                }

                if (Lang13.Bool(href_list["category"]))
                {
                    this.selected_category = href_list["category"];
                }

                if (Lang13.Bool(href_list["make"]))
                {
                    T = this.loc;
                    this.being_built = this.files.FindDesignByID(href_list["make"]);

                    if (!(this.being_built != null))
                    {
                        return(null);
                    }
                    multiplier     = String13.ParseNumber(href_list["multiplier"]);
                    max_multiplier = Num13.MinInt(this.being_built.maxstack, ((int)((Lang13.Bool(this.being_built.materials["$metal"]) ? Num13.Floor((this.materials.amount("$metal") ?1:0) / Convert.ToDouble(this.being_built.materials["$metal"])) : Double.PositiveInfinity))), ((int)((Lang13.Bool(this.being_built.materials["$glass"]) ? Num13.Floor((this.materials.amount("$glass") ?1:0) / Convert.ToDouble(this.being_built.materials["$glass"])) : Double.PositiveInfinity))));
                    is_stack       = this.being_built.build_path.IsSubclassOf(typeof(Obj_Item_Stack));

                    if (!Lang13.Bool(is_stack) && (multiplier ?? 0) > 1)
                    {
                        return(null);
                    }

                    if (!new ByTable(new object [] { 1, 10, 25, max_multiplier }).Contains(multiplier))
                    {
                        return(null);
                    }
                    coeff      = (Lang13.Bool(is_stack) ? 1 : Math.Pow(2, this.prod_coeff));
                    metal_cost = this.being_built.materials["$metal"];
                    glass_cost = this.being_built.materials["$glass"];
                    power      = Num13.MaxInt(2000, Convert.ToInt32((metal_cost + glass_cost) * multiplier / 5));

                    if ((this.materials.amount("$metal") ?1:0) >= Convert.ToDouble(metal_cost * multiplier / coeff) && (this.materials.amount("$glass") ?1:0) >= Convert.ToDouble(glass_cost * multiplier / coeff))
                    {
                        this.busy = true;
                        this.f_use_power(power);
                        this.icon_state = "autolathe";
                        Icon13.Flick("autolathe_n", this);
                        Task13.Schedule(((int)(32 / coeff)), (Task13.Closure)(() => {
                            this.f_use_power(power);

                            if (Lang13.Bool(is_stack))
                            {
                                materials_used = new ByTable().Set("$metal", metal_cost * multiplier).Set("$glass", glass_cost * multiplier);
                                this.materials.use_amount(materials_used);
                                N = Lang13.Call(this.being_built.build_path, T, multiplier);
                                N.update_icon();
                                ((Obj_Item)N).autolathe_crafted(this);

                                foreach (dynamic _a in Lang13.Enumerate(T.contents - N, typeof(Obj_Item_Stack)))
                                {
                                    S = _a;


                                    if (Lang13.Bool(((dynamic)N.merge_type).IsInstanceOfType(S)))
                                    {
                                        N.merge(S);
                                    }
                                }
                            }
                            else
                            {
                                materials_used2 = new ByTable().Set("$metal", metal_cost / coeff).Set("$glass", glass_cost / coeff);
                                this.materials.use_amount(materials_used2);
                                new_item           = Lang13.Call(this.being_built.build_path, T);
                                new_item.materials = materials_used2.Copy();
                                ((Obj_Item)new_item).autolathe_crafted(this);
                            }
                            this.busy = false;
                            this.updateUsrDialog();
                            return;
                        }));
                    }
                }

                if (Lang13.Bool(href_list["search"]))
                {
                    this.matching_designs.Cut();

                    foreach (dynamic _b in Lang13.Enumerate(this.files.known_designs))
                    {
                        v = _b;

                        D = this.files.known_designs[v];

                        if (String13.FindIgnoreCase(D.name, href_list["to_search"], 1, 0) != 0)
                        {
                            this.matching_designs.Add(D);
                        }
                    }
                }
            }
            else
            {
                Task13.User.WriteMsg("<span class=\"alert\">The autolathe is busy. Please wait for completion of previous operation.</span>");
            }
            this.updateUsrDialog();
            return(null);
        }
Пример #15
0
        // Function from file: spaceheater.dm
        public override void RefreshParts(  )
        {
            double laser = 0;
            double cap   = 0;
            Obj_Item_Weapon_StockParts_MicroLaser M  = null;
            Obj_Item_Weapon_StockParts_Capacitor  M2 = null;

            laser = 0;
            cap   = 0;

            foreach (dynamic _a in Lang13.Enumerate(this.component_parts, typeof(Obj_Item_Weapon_StockParts_MicroLaser)))
            {
                M = _a;

                laser += Convert.ToDouble(M.rating);
            }

            foreach (dynamic _b in Lang13.Enumerate(this.component_parts, typeof(Obj_Item_Weapon_StockParts_Capacitor)))
            {
                M2 = _b;

                cap += Convert.ToDouble(M2.rating);
            }
            this.heatingPower             = laser * 40000;
            this.settableTemperatureRange = cap * 30;
            this.efficiency        = (cap + 1) * 10000;
            this.targetTemperature = Num13.MaxInt(Num13.MaxInt(((int)(this.settableTemperatureMedian - this.settableTemperatureRange)), ((int)(2.7))), Num13.MinInt(((int)(this.targetTemperature)), ((int)(this.settableTemperatureMedian + this.settableTemperatureRange))));
            return;
        }
        // Function from file: collector.dm
        public override dynamic attack_hand(dynamic a = null, bool?b = null, bool?c = null)
        {
            if (Lang13.Bool(base.attack_hand((object)(a), b, c)))
            {
                return(null);
            }

            if (Lang13.Bool(this.anchored))
            {
                if (!this.locked)
                {
                    this.toggle_power();
                    ((Ent_Static)a).visible_message("" + a.name + " turns the " + this.name + " " + (this.active ? "on" : "off") + ".", "<span class='notice'>You turn the " + this.name + " " + (this.active ? "on" : "off") + ".</span>");
                    this.investigate_log("turned " + (this.active ? "<font color='green'>on</font>" : "<font color='red'>off</font>") + " by " + a.key + ". " + (Lang13.Bool(this.P) ? "Fuel: " + Num13.Floor(Convert.ToDouble(this.P.air_contents.gases["plasma"][1] / 0.81)) + "%" : "<font color='red'>It is empty</font>") + ".", "singulo");
                    return(null);
                }
                else
                {
                    a.WriteMsg("<span class='warning'>The controls are locked!</span>");
                    return(null);
                }
            }
            return(null);
        }
Пример #17
0
        // Function from file: spaceheater.dm
        public override int?process(dynamic seconds = null)
        {
            Ent_Static L                = null;
            GasMixture env              = null;
            string     newMode          = null;
            double     heat_capacity    = 0;
            double     requiredPower    = 0;
            double     deltaTemperature = 0;


            if (!Lang13.Bool(this.on) || !this.is_operational())
            {
                return(null);
            }

            if (Lang13.Bool(this.cell) && Convert.ToDouble(this.cell.charge) > 0)
            {
                L = this.loc;

                if (!(L is Tile_Simulated))
                {
                    if (this.mode != "standby")
                    {
                        this.mode = "standby";
                        this.update_icon();
                    }
                    return(null);
                }
                env     = L.return_air();
                newMode = "standby";

                if (this.setMode != "cool" && Convert.ToDouble(env.temperature) < this.targetTemperature - (this.temperatureTolerance ?1:0))
                {
                    newMode = "heat";
                }
                else if (this.setMode != "heat" && Convert.ToDouble(env.temperature) > this.targetTemperature + (this.temperatureTolerance ?1:0))
                {
                    newMode = "cool";
                }

                if (this.mode != newMode)
                {
                    this.mode = newMode;
                    this.update_icon();
                }

                if (this.mode == "standby")
                {
                    return(null);
                }
                heat_capacity = env.heat_capacity();
                requiredPower = Math.Abs(Convert.ToDouble(env.temperature - this.targetTemperature)) * heat_capacity;
                requiredPower = Num13.MinInt(((int)(requiredPower)), ((int)(this.heatingPower)));

                if (requiredPower < 1)
                {
                    return(null);
                }
                deltaTemperature = requiredPower / heat_capacity;

                if (this.mode == "cool")
                {
                    deltaTemperature *= -1;
                }

                if (deltaTemperature != 0)
                {
                    env.temperature += deltaTemperature;
                    this.air_update_turf();
                }
                this.cell.use(requiredPower / this.efficiency);
            }
            else
            {
                this.on = GlobalVars.FALSE;
                this.update_icon();
            }
            return(null);
        }
        // Function from file: glass.dm
        public override bool attack(dynamic M = null, dynamic user = null, bool?def_zone = null)
        {
            dynamic R        = null;
            Reagent A        = null;
            double? fraction = null;


            if (!this.canconsume(M, user))
            {
                return(false);
            }

            if (!this.spillable)
            {
                return(false);
            }

            if (!(this.reagents != null) || !Lang13.Bool(this.reagents.total_volume))
            {
                user.WriteMsg("<span class='warning'>" + this + " is empty!</span>");
                return(false);
            }

            if (M is Mob)
            {
                if (user.a_intent == "harm")
                {
                    ((Ent_Static)M).visible_message("<span class='danger'>" + user + " splashes the contents of " + this + " onto " + M + "!</span>", "<span class='userdanger'>" + user + " splashes the contents of " + this + " onto " + M + "!</span>");

                    if (this.reagents != null)
                    {
                        foreach (dynamic _a in Lang13.Enumerate(this.reagents.reagent_list, typeof(Reagent)))
                        {
                            A = _a;

                            R += A.id + " (";
                            R += String13.NumberToString(A.volume) + "),";
                        }
                    }
                    this.reagents.reaction(M, GlobalVars.TOUCH);
                    GlobalFuncs.add_logs(user, M, "splashed", R);
                    this.reagents.clear_reagents();
                }
                else
                {
                    if (M != user)
                    {
                        ((Ent_Static)M).visible_message("<span class='danger'>" + user + " attempts to feed something to " + M + ".</span>", "<span class='userdanger'>" + user + " attempts to feed something to you.</span>");

                        if (!GlobalFuncs.do_mob(user, M))
                        {
                            return(false);
                        }

                        if (!(this.reagents != null) || !Lang13.Bool(this.reagents.total_volume))
                        {
                            return(false);
                        }
                        ((Ent_Static)M).visible_message("<span class='danger'>" + user + " feeds something to " + M + ".</span>", "<span class='userdanger'>" + user + " feeds something to you.</span>");
                        GlobalFuncs.add_logs(user, M, "fed", this.reagentlist(this));
                    }
                    else
                    {
                        user.WriteMsg("<span class='notice'>You swallow a gulp of " + this + ".</span>");
                    }
                    fraction = Num13.MinInt(((int)(5 / (this.reagents.total_volume ?? 0))), 1);
                    this.reagents.reaction(M, GlobalVars.INGEST, fraction);
                    Task13.Schedule(5, (Task13.Closure)(() => {
                        this.reagents.trans_to(M, 5);
                        return;
                    }));
                    GlobalFuncs.playsound(M.loc, "sound/items/drink.ogg", Rand13.Int(10, 50), 1);
                }
            }
            return(false);
        }
Пример #19
0
 // Function from file: mutations.dm
 public override void on_life(Mob_Living owner = null)
 {
     owner.alpha = Num13.MaxInt(0, owner.alpha - 25);
     return;
 }
Пример #20
0
        // Function from file: air.dm
        public void setup_allturfs(double?z_level = null)
        {
            double?        z_start       = null;
            double?        z_finish      = null;
            ByTable        turfs_to_init = null;
            Tile_Simulated T             = null;
            dynamic        tile          = null;
            dynamic        enemy_tile    = null;
            GasMixture     enemy_air     = null;
            dynamic        is_active     = null;
            Tile_Simulated T2            = null;

            z_start  = 1;
            z_finish = Game13.map_size_z;

            if (1 <= (z_level ?? 0) && (z_level ?? 0) <= Game13.map_size_z)
            {
                z_level  = Num13.Floor(z_level ?? 0);
                z_start  = z_level;
                z_finish = z_level;
            }
            turfs_to_init = Map13.FetchInBlock(Map13.GetTile(1, 1, ((int)(z_start ?? 0))), Map13.GetTile(Game13.map_size_x, Game13.map_size_y, ((int)(z_finish ?? 0))));

            foreach (dynamic _b in Lang13.Enumerate(turfs_to_init, typeof(Tile_Simulated)))
            {
                T = _b;

                T.CalculateAdjacentTurfs();
                T.excited = false;
                this.active_turfs.Remove(T);

                if (T.blocks_air)
                {
                    continue;
                }
                T.update_visuals();

                foreach (dynamic _a in Lang13.Enumerate(T.atmos_adjacent_turfs))
                {
                    tile = _a;

                    enemy_tile = tile;
                    enemy_air  = ((Ent_Static)enemy_tile).return_air();
                    is_active  = T.air.compare(enemy_air);

                    if (Lang13.Bool(is_active))
                    {
                        GlobalFuncs.testing("Active turf found. Return value of compare(): " + is_active);
                        T.excited = true;
                        this.active_turfs.Or(T);
                        break;
                    }
                }
            }

            if (this.active_turfs.len != 0)
            {
                GlobalFuncs.warning("There are " + this.active_turfs.len + " active turfs at roundstart, this is a mapping error caused by a difference of the air between the adjacent turfs. You can see its coordinates using \"Mapping -> Show roundstart AT list\" verb (debug verbs required)");

                foreach (dynamic _c in Lang13.Enumerate(this.active_turfs, typeof(Tile_Simulated)))
                {
                    T2 = _c;

                    GlobalVars.active_turfs_startlist.Add("" + T2.x + ", " + T2.y + ", " + T2.z + "\n");
                }
            }
            return;
        }
Пример #21
0
        // Function from file: camera_bug.dm
        public string camera_report(  )
        {
            string          dat   = null;
            ByTable         seen  = null;
            ByTable         names = null;
            Obj_Singularity S     = null;
            int             stage = 0;
            Obj_Mecha       M     = null;
            Mob_Living      M2    = null;

            dat = "";

            if (Lang13.Bool(this.current) && ((Obj_Machinery_Camera)this.current).can_use())
            {
                seen  = ((Obj_Machinery_Camera)this.current).can_see();
                names = new ByTable();

                foreach (dynamic _a in Lang13.Enumerate(seen, typeof(Obj_Singularity)))
                {
                    S = _a;


                    if (names.Contains(S.name))
                    {
                        names[S.name]++;
                        dat += "" + S.name + " (" + names[S.name] + ")";
                    }
                    else
                    {
                        names[S.name] = 1;
                        dat          += "" + S.name;
                    }
                    stage = Num13.Floor((S.current_size ?? 0) / 2) + 1;
                    dat  += " (Stage " + stage + ")";
                    dat  += new Txt(" <a href='?").Ref(this).str(";track=").Ref(S).str("'>[Track]</a><br>").ToString();
                }

                foreach (dynamic _b in Lang13.Enumerate(seen, typeof(Obj_Mecha)))
                {
                    M = _b;


                    if (names.Contains(M.name))
                    {
                        names[M.name]++;
                        dat += "" + M.name + " (" + names[M.name] + ")";
                    }
                    else
                    {
                        names[M.name] = 1;
                        dat          += "" + M.name;
                    }
                    dat += new Txt(" <a href='?").Ref(this).str(";track=").Ref(M).str("'>[Track]</a><br>").ToString();
                }

                foreach (dynamic _c in Lang13.Enumerate(seen, typeof(Mob_Living)))
                {
                    M2 = _c;


                    if (names.Contains(M2.name))
                    {
                        names[M2.name]++;
                        dat += "" + M2.name + " (" + names[M2.name] + ")";
                    }
                    else
                    {
                        names[M2.name] = 1;
                        dat           += "" + M2.name;
                    }

                    if (M2.buckled != null && !Lang13.Bool(M2.lying))
                    {
                        dat += " (Sitting)";
                    }

                    if (Lang13.Bool(M2.lying))
                    {
                        dat += " (Laying down)";
                    }
                    dat += new Txt(" <a href='?").Ref(this).str(";track=").Ref(M2).str("'>[Track]</a><br>").ToString();
                }

                if (Lang13.Length(dat) == 0)
                {
                    dat += "No motion detected.";
                }
                return(dat);
            }
            else
            {
                return("Camera Offline<br>");
            }
        }
Пример #22
0
 // Function from file: events.dm
 public void reschedule(  )
 {
     this.scheduled = Game13.time + Rand13.Int(Convert.ToInt32(this.frequency_lower), Num13.MaxInt(Convert.ToInt32(this.frequency_lower), Convert.ToInt32(this.frequency_upper)));
     return;
 }
Пример #23
0
 // Function from file: simple_animal.dm
 public override void updatehealth(  )
 {
     base.updatehealth();
     this.health = Num13.MaxInt(0, Num13.MinInt(Convert.ToInt32(this.health), Convert.ToInt32(this.maxHealth)));
     return;
 }
        // Function from file: structures.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            dynamic M      = null;
            int     spend  = 0;
            dynamic G      = null;
            int     spend2 = 0;
            dynamic LG     = null;
            int     spend3 = 0;
            dynamic GG     = null;
            int     spend4 = 0;


            if (!Lang13.Bool(A) || !Lang13.Bool(user))
            {
                return(0);
            }

            if (A is Obj_Item_Stack_Sheet_Metal)
            {
                M = A;

                if (Lang13.Bool(this.metal_cost))
                {
                    spend = Num13.MinInt(Convert.ToInt32(this.metal_cost), Convert.ToInt32(M.amount));
                    user.WriteMsg(new Txt("<span class='notice'>You add ").item(spend).str(" metal to ").the(this).item().str(".").ToString());
                    this.metal_cost = Num13.MaxInt(0, Convert.ToInt32(this.metal_cost - spend));
                    M.use(spend);
                    this.check_completion();
                }
                else
                {
                    user.WriteMsg(new Txt("<span class='notice'>").The(this).item().str(" does not require any more metal!").ToString());
                }
                return(null);
            }

            if (A is Obj_Item_Stack_Sheet_Glass)
            {
                G = A;

                if (Lang13.Bool(this.glass_cost))
                {
                    spend2 = Num13.MinInt(Convert.ToInt32(this.glass_cost), Convert.ToInt32(G.amount));
                    user.WriteMsg(new Txt("<span class='notice'>You add ").item(spend2).str(" glass to ").the(this).item().str(".").ToString());
                    this.glass_cost = Num13.MaxInt(0, Convert.ToInt32(this.glass_cost - spend2));
                    G.use(spend2);
                    this.check_completion();
                }
                else
                {
                    user.WriteMsg(new Txt("<span class='notice'>").The(this).item().str(" does not require any more glass!").ToString());
                }
                return(null);
            }

            if (A is Obj_Item_Stack_Sheet_Lessergem)
            {
                LG = A;

                if (Lang13.Bool(this.lesser_gem_cost))
                {
                    spend3 = Num13.MinInt(Convert.ToInt32(this.lesser_gem_cost), Convert.ToInt32(LG.amount));
                    user.WriteMsg(new Txt("<span class='notice'>You add ").item(spend3).str(" lesser gems to ").the(this).item().str(".").ToString());
                    this.lesser_gem_cost = Num13.MaxInt(0, Convert.ToInt32(this.lesser_gem_cost - spend3));
                    LG.use(spend3);
                    this.check_completion();
                }
                else
                {
                    user.WriteMsg(new Txt("<span class='notice'>").The(this).item().str(" does not require any more lesser gems!").ToString());
                }
                return(null);
            }

            if (A is Obj_Item_Stack_Sheet_Greatergem)
            {
                GG = A;

                if (Lang13.Bool(this.greater_gem_cost))
                {
                    spend4 = Num13.MinInt(Convert.ToInt32(this.greater_gem_cost), Convert.ToInt32(GG.amount));
                    user.WriteMsg(new Txt("<span class='notice'>You add ").item(spend4).str(" greater gems to ").the(this).item().str(".").ToString());
                    this.greater_gem_cost = Num13.MaxInt(0, Convert.ToInt32(this.greater_gem_cost - spend4));
                    GG.use(spend4);
                    this.check_completion();
                }
                else
                {
                    user.WriteMsg(new Txt("<span class='notice'>").The(this).item().str(" does not require any more greater gems!").ToString());
                }
                return(null);
            }
            base.attackby((object)(A), (object)(user), _params, silent, replace_spent);
            return(null);
        }
Пример #25
0
        // Function from file: spellbook.dm
        public virtual bool Buy(Mob user = null, Obj_Item_Weapon_Spellbook book = null)
        {
            Obj_Effect_ProcHolder_Spell aspell = null;


            if (!Lang13.Bool(this.S) || Lang13.Bool(GlobalFuncs.qdeleted(this.S)))
            {
                this.S = Lang13.Call(this.spell_type);
            }

            foreach (dynamic _b in Lang13.Enumerate(user.mind.spell_list, typeof(Obj_Effect_ProcHolder_Spell)))
            {
                aspell = _b;


                if (Lang13.Initial(this.S, "name") == Lang13.Initial(aspell, "name"))
                {
                    if (aspell.spell_level >= aspell.level_max)
                    {
                        user.WriteMsg("<span class='warning'>This spell cannot be improved further.</span>");
                        return(false);
                    }
                    else
                    {
                        aspell.name = Lang13.Initial(aspell, "name");
                        aspell.spell_level++;
                        aspell.charge_max = Num13.Floor(Convert.ToDouble(Lang13.Initial(aspell, "charge_max") - aspell.spell_level * Convert.ToDouble(Lang13.Initial(aspell, "charge_max") - aspell.cooldown_min) / aspell.level_max));

                        if (aspell.charge_max < aspell.charge_counter)
                        {
                            aspell.charge_counter = aspell.charge_max;
                        }

                        switch ((int)(aspell.spell_level))
                        {
                        case 1:
                            user.WriteMsg("<span class='notice'>You have improved " + aspell.name + " into Efficient " + aspell.name + ".</span>");
                            aspell.name = "Efficient " + aspell.name;
                            break;

                        case 2:
                            user.WriteMsg("<span class='notice'>You have further improved " + aspell.name + " into Quickened " + aspell.name + ".</span>");
                            aspell.name = "Quickened " + aspell.name;
                            break;

                        case 3:
                            user.WriteMsg("<span class='notice'>You have further improved " + aspell.name + " into Free " + aspell.name + ".</span>");
                            aspell.name = "Free " + aspell.name;
                            break;

                        case 4:
                            user.WriteMsg("<span class='notice'>You have further improved " + aspell.name + " into Instant " + aspell.name + ".</span>");
                            aspell.name = "Instant " + aspell.name;
                            break;
                        }

                        if (aspell.spell_level >= aspell.level_max)
                        {
                            user.WriteMsg("<span class='notice'>This spell cannot be strengthened any further.</span>");
                        }
                        return(true);
                    }
                }
            }
            GlobalFuncs.feedback_add_details("wizard_spell_learned", this.log_name);
            user.mind.AddSpell(this.S);
            user.WriteMsg("<span class='notice'>You have learned " + this.S.name + ".</span>");
            return(true);
        }
Пример #26
0
        // Function from file: particle_control.dm
        public bool part_scan(  )
        {
            Obj_Structure_ParticleAccelerator_FuelChamber F = null;
            int        tally = 0;
            int        ldir  = 0;
            int        rdir  = 0;
            int        odir  = 0;
            Ent_Static T     = null;


            foreach (dynamic _a in Lang13.Enumerate(Map13.FetchInRangeExcludeThis(this, 1), typeof(Obj_Structure_ParticleAccelerator_FuelChamber)))
            {
                F = _a;

                this.dir = F.dir;
            }
            this.connected_parts = new ByTable();
            tally = 0;
            ldir  = Num13.Rotate(this.dir, -90);
            rdir  = Num13.Rotate(this.dir, 90);
            odir  = Num13.Rotate(this.dir, 180);
            T     = this.loc;
            T     = Map13.GetStep(T, rdir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_FuelChamber)))
            {
                tally++;
            }
            T = Map13.GetStep(T, odir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_EndCap)))
            {
                tally++;
            }
            T = Map13.GetStep(T, this.dir);
            T = Map13.GetStep(T, this.dir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_PowerBox)))
            {
                tally++;
            }
            T = Map13.GetStep(T, this.dir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_ParticleEmitter_Center)))
            {
                tally++;
            }
            T = Map13.GetStep(T, ldir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_ParticleEmitter_Left)))
            {
                tally++;
            }
            T = Map13.GetStep(T, rdir);
            T = Map13.GetStep(T, rdir);

            if (this.check_part(T, typeof(Obj_Structure_ParticleAccelerator_ParticleEmitter_Right)))
            {
                tally++;
            }

            if (tally >= 6)
            {
                this.assembled = true;
                return(true);
            }
            else
            {
                this.assembled = false;
                return(false);
            }
        }
Пример #27
0
        // Function from file: cards.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            Playingcard P      = null;
            Image       I      = null;
            int         origin = 0;
            int         offset = 0;
            int         i      = 0;
            Image       I2     = null;
            Playingcard P2     = null;
            string      html   = null;
            Playingcard card   = null;


            if (!(this.cards.len != 0))
            {
                GlobalFuncs.qdel(this);
            }
            else
            {
                if (this.cards.len > 1)
                {
                    this.name = "hand of cards";
                    this.desc = "Some playing cards.";
                }
                else
                {
                    this.name = "a playing card";
                    this.desc = "A playing card.";
                }
                this.overlays.len = 0;

                if (this.cards.len == 1)
                {
                    P         = this.cards[1];
                    I         = new Image(this.icon, (this.concealed ? "card_back" : "" + P.card_icon));
                    I.pixel_x = I.pixel_x + Rand13.Int(10) + -5;
                    I.pixel_y = I.pixel_y + Rand13.Int(10) + -5;
                    this.overlays.Add(I);
                }
                else
                {
                    origin = -12;
                    offset = Num13.Floor(32 / this.cards.len);
                    i      = 0;

                    foreach (dynamic _a in Lang13.Enumerate(this.cards, typeof(Playingcard)))
                    {
                        P2 = _a;

                        I2         = new Image(this.icon, (this.concealed ? "card_back" : "" + P2.card_icon));
                        I2.pixel_x = origin + offset * i;
                        this.overlays.Add(I2);
                        i = i + 1;
                    }
                }
                html = "";

                foreach (dynamic _b in Lang13.Enumerate(this.cards, typeof(Playingcard)))
                {
                    card = _b;

                    html = html + new Txt("<a href=\"byond://?src=").Ref(this.hi).str("&action=play_card&card=").Ref(card).str("\" class=\"card ").item(card.suit).str(" ").item(card.number).str("\"></a>").ToString();
                }
                this.hi.updateContent("hand", html);
            }
            return(false);
        }
Пример #28
0
        // Function from file: telecomunications.dm
        public int?relay_information(Signal signal = null, dynamic filter = null, bool?copysig = null, int?amount = null)
        {
            amount = amount ?? 20;

            int?send_count = null;
            int netlag     = 0;
            Obj_Machinery_Telecomms machine = null;
            Signal copy = null;


            if (!this.on)
            {
                return(null);
            }
            send_count = 0;
            netlag     = Num13.Floor(this.traffic / 50);

            if (netlag > Convert.ToDouble(signal.data["slow"]))
            {
                signal.data["slow"] = netlag;
            }

            foreach (dynamic _a in Lang13.Enumerate(this.links, typeof(Obj_Machinery_Telecomms)))
            {
                machine = _a;


                if (Lang13.Bool(filter) && !Lang13.Bool(((dynamic)Lang13.FindClass(filter)).IsInstanceOfType(machine)))
                {
                    continue;
                }

                if (!machine.on)
                {
                    continue;
                }

                if (Lang13.Bool(amount) && (send_count ?? 0) >= (amount ?? 0))
                {
                    break;
                }

                if (machine.loc.z != this.listening_level)
                {
                    if (!this.long_range_link && !machine.long_range_link)
                    {
                        continue;
                    }
                }
                copy = new Signal();

                if (copysig == true)
                {
                    copy.transmission_method = 2;
                    copy.frequency           = signal.frequency;
                    copy.data = new ByTable()
                                .Set("mob", signal.data["mob"])
                                .Set("mobtype", signal.data["mobtype"])
                                .Set("realname", signal.data["realname"])
                                .Set("name", signal.data["name"])
                                .Set("job", signal.data["job"])
                                .Set("key", signal.data["key"])
                                .Set("vmask", signal.data["vmask"])
                                .Set("compression", signal.data["compression"])
                                .Set("message", signal.data["message"])
                                .Set("radio", signal.data["radio"])
                                .Set("slow", signal.data["slow"])
                                .Set("traffic", signal.data["traffic"])
                                .Set("type", signal.data["type"])
                                .Set("server", signal.data["server"])
                                .Set("reject", signal.data["reject"])
                                .Set("level", signal.data["level"])
                                .Set("spans", signal.data["spans"])
                                .Set("verb_say", signal.data["verb_say"])
                                .Set("verb_ask", signal.data["verb_ask"])
                                .Set("verb_exclaim", signal.data["verb_exclaim"])
                                .Set("verb_yell", signal.data["verb_yell"])
                    ;

                    if (!Lang13.Bool(signal.data["original"]))
                    {
                        copy.data["original"] = signal;
                    }
                    else
                    {
                        copy.data["original"] = signal.data["original"];
                    }
                }
                else
                {
                    copy = null;
                }
                send_count++;

                if (machine.is_freq_listening(signal))
                {
                    machine.traffic++;
                }

                if (copysig == true && copy != null)
                {
                    machine.receive_information(copy, this);
                }
                else
                {
                    machine.receive_information(signal, this);
                }
            }

            if ((send_count ?? 0) > 0 && this.is_freq_listening(signal))
            {
                this.traffic++;
            }
            return(send_count);
        }
Пример #29
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;
        }
Пример #30
0
        // Function from file: ninjaDrainAct.dm
        public override dynamic ninjadrain_act(Obj_Item_Clothing_Suit_Space_SpaceNinja S = null, Ent_Static H = null, Obj_Item_Clothing_Gloves_SpaceNinja G = null)
        {
            dynamic _default = null;

            bool     maxcapacity            = false;
            int      drain                  = 0;
            Powernet PN                     = null;
            int      drained                = 0;
            Obj_Machinery_Power_Terminal T  = null;
            Obj_Machinery_Power          AP = null;


            if (!(S != null) || !(H != null) || !(G != null))
            {
                return("INVALID");
            }
            maxcapacity = false;
            drain       = 0;
            _default    = 0;
            PN          = this.powernet;

            while (G.candrain && !maxcapacity && this != null)
            {
                drain   = Num13.Floor(Rand13.Int(G.mindrain, G.maxdrain) / 2);
                drained = 0;

                if (PN != null && GlobalFuncs.do_after(H, 10, null, this))
                {
                    drained  = Num13.MinInt(drain, ((int)(PN.avail)));
                    PN.load += drained;

                    if (drained < drain)
                    {
                        foreach (dynamic _a in Lang13.Enumerate(PN.nodes, typeof(Obj_Machinery_Power_Terminal)))
                        {
                            T = _a;


                            if (T.master is Obj_Machinery_Power_Apc)
                            {
                                AP = T.master;

                                if (Lang13.Bool(((dynamic)AP).operating) && Lang13.Bool(((dynamic)AP).cell) && Convert.ToDouble(((dynamic)AP).cell.charge) > 0)
                                {
                                    ((dynamic)AP).cell.charge = Num13.MaxInt(0, Convert.ToInt32(((dynamic)AP).cell.charge - 5));
                                    drained += 5;
                                }
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
                S.cell.charge += drained;

                if (Convert.ToDouble(S.cell.charge) > (S.cell.maxcharge ?? 0))
                {
                    _default     += drained - Convert.ToDouble(S.cell.charge - S.cell.maxcharge);
                    S.cell.charge = S.cell.maxcharge;
                    maxcapacity   = true;
                }
                else
                {
                    _default += drained;
                }
                S.spark_system.start();
            }
            return(_default);
        }