Ejemplo n.º 1
0
        // Function from file: advance.dm
        public void AssignProperties(ByTable properties = null)
        {
            properties = properties ?? new ByTable();


            if (properties != null && properties.len != 0)
            {
                dynamic _a = properties["stealth"];                 // Was a switch-case, sorry for the mess.
                if (2 <= _a && _a <= 3)
                {
                    this.visibility_flags = 1;
                }
                else if (3 <= _a && _a <= Double.PositiveInfinity)
                {
                    this.visibility_flags = 3;
                }
                this.SetSpread(Num13.MaxInt(4, Num13.MinInt(((int)(Math.Pow(2, Convert.ToDouble(properties["transmittable"] - this.symptoms.len)))), 64)));
                this.permeability_mod = Num13.MaxInt(GlobalFuncs.Ceiling(properties["transmittable"] * 0.4), 1);
                this.cure_chance      = 15 - Num13.MaxInt(-5, Num13.MinInt(Convert.ToInt32(properties["resistance"]), 5));
                this.stage_prob       = Num13.MaxInt(Convert.ToInt32(properties["stage_rate"]), 2);
                this.SetSeverity(properties["severity"]);
                this.GenerateCure(properties);
            }
            else
            {
                Task13.Crash("Our properties were empty or null!");
            }
            return;
        }
Ejemplo n.º 2
0
        // Function from file: window.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            double ratio = 0;

            Task13.Schedule(2, (Task13.Closure)(() => {
                if (!(this != null))
                {
                    return;
                }

                if (!this.fulltile)
                {
                    return;
                }
                ratio = this.health / this.maxhealth;
                ratio = GlobalFuncs.Ceiling(ratio * 4) * 25;

                if (this.smooth != 0)
                {
                    GlobalFuncs.smooth_icon(this);
                }
                this.overlays.Remove(this.crack_overlay);

                if (ratio > 75)
                {
                    return;
                }
                this.crack_overlay = new Image("icons/obj/structures.dmi", "damage" + ratio, -(this.layer + 0.1));
                this.overlays.Add(this.crack_overlay);
                return;
            }));
            return(false);
        }
        // Function from file: defib.dm
        public void update_charge(  )
        {
            int ratio = 0;


            if (this.powered)
            {
                if (Lang13.Bool(this.bcell))
                {
                    ratio = Convert.ToInt32(this.bcell.charge / this.bcell.maxcharge);
                    ratio = GlobalFuncs.Ceiling(ratio * 4) * 25;
                    this.overlays.Add("" + Lang13.Initial(this, "icon_state") + "-charge" + ratio);
                }
            }
            return;
        }
Ejemplo n.º 4
0
        // Function from file: chrono_eraser.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            double ttk_frame = 0;

            ttk_frame = 1 - this.tickstokill / Convert.ToDouble(Lang13.Initial(this, "tickstokill"));
            ttk_frame = Num13.MaxInt(1, Num13.MinInt(GlobalFuncs.Ceiling(ttk_frame * 22), 22));

            if (ttk_frame != this.RPpos)
            {
                this.RPpos = ttk_frame;
                this.mob_underlay.icon_state = "frame" + this.RPpos;
                this.underlays = new ByTable();
                this.underlays.Add(this.mob_underlay);
            }
            return(false);
        }
Ejemplo n.º 5
0
 // Function from file: wand.dm
 public Obj_Item_Weapon_Gun_Magic_Wand(dynamic loc = null) : base((object)(loc))
 {
     if (Rand13.PercentChance(75) && this.variable_charges)
     {
         if (Rand13.PercentChance(33))
         {
             this.max_charges = GlobalFuncs.Ceiling(this.max_charges / 3);
         }
         else
         {
             this.max_charges = GlobalFuncs.Ceiling(this.max_charges / 2);
         }
     }
     // 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: tools.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            double ratio = 0;


            if (this.change_icons)
            {
                ratio = (this.get_fuel() ?1:0) / (this.max_fuel ?? 0);
                ratio = GlobalFuncs.Ceiling(ratio * 4) * 25;

                if (ratio == 100)
                {
                    this.icon_state = Lang13.Initial(this, "icon_state");
                }
                else
                {
                    this.icon_state = "" + Lang13.Initial(this, "icon_state") + ratio;
                }
            }
            this.update_torch();
            return(false);
        }
Ejemplo n.º 7
0
 // Function from file: saw.dm
 public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
 {
     this.icon_state = "l6" + (this.cover_open ? "open" : "closed") + (Lang13.Bool(this.magazine) ? ((dynamic)(GlobalFuncs.Ceiling(this.get_ammo(false) / 12.5) * 25)) : ((dynamic)("-empty"))) + (Lang13.Bool(this.suppressed) ? "-suppressed" : "");
     this.item_state = "l6" + (this.cover_open ? "openmag" : "closedmag");
     return(false);
 }
Ejemplo n.º 8
0
        // Function from file: robot.dm
        public void update_robot_modules_display(  )
        {
            Mob         r            = null;
            int         display_rows = 0;
            int         x            = 0;
            int         y            = 0;
            Ent_Dynamic A            = null;
            Ent_Static  A2           = null;


            if (!(this.mymob is Mob_Living_Silicon_Robot))
            {
                return;
            }
            r = this.mymob;

            if (!(r.client != null))
            {
                return;
            }

            if (!Lang13.Bool(((dynamic)r).module))
            {
                return;
            }

            if (Lang13.Bool(((dynamic)r).shown_robot_modules) && this.hud_shown)
            {
                r.client.screen.Add(this.module_store_icon);

                if (!Lang13.Bool(((dynamic)r).module.modules))
                {
                    Task13.User.WriteMsg("<span class='danger'>Selected module has no modules to select</span>");
                    return;
                }

                if (!Lang13.Bool(((dynamic)r).robot_modules_background))
                {
                    return;
                }
                display_rows = GlobalFuncs.Ceiling(Lang13.Length(((Obj_Item_Weapon_RobotModule)((dynamic)r).module).get_inactive_modules()) / 8);
                ((dynamic)r).robot_modules_background.screen_loc = "CENTER-4:16,SOUTH+1:7 to CENTER+3:16,SOUTH+" + display_rows + ":7";
                r.client.screen.Add(((dynamic)r).robot_modules_background);
                x = -4;
                y = 1;

                foreach (dynamic _a in Lang13.Enumerate(((Obj_Item_Weapon_RobotModule)((dynamic)r).module).get_inactive_modules(), typeof(Ent_Dynamic)))
                {
                    A = _a;

                    r.client.screen.Add(A);

                    if (x < 0)
                    {
                        A.screen_loc = "CENTER" + x + ":16,SOUTH+" + y + ":7";
                    }
                    else
                    {
                        A.screen_loc = "CENTER+" + x + ":16,SOUTH+" + y + ":7";
                    }
                    A.layer = 20;
                    x++;

                    if (x == 4)
                    {
                        x = -4;
                        y++;
                    }
                }
            }
            else
            {
                r.client.screen.Remove(this.module_store_icon);

                foreach (dynamic _b in Lang13.Enumerate(((Obj_Item_Weapon_RobotModule)((dynamic)r).module).get_inactive_modules(), typeof(Ent_Static)))
                {
                    A2 = _b;

                    r.client.screen.Remove(A2);
                }
                ((dynamic)r).shown_robot_modules = 0;
                r.client.screen.Remove(((dynamic)r).robot_modules_background);
            }
            return;
        }
Ejemplo n.º 9
0
 // Function from file: automatic.dm
 public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
 {
     base.update_icon((object)(new_state), (object)(new_icon), new_px, new_py);
     this.icon_state = "wt550" + (Lang13.Bool(this.magazine) ? "-" + GlobalFuncs.Ceiling(this.get_ammo(false) / 4) * 4 : "");
     return(false);
 }
Ejemplo n.º 10
0
        // Function from file: energy.dm
        public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
        {
            int ratio = 0;
            Obj_Item_AmmoCasing_Energy shot = null;
            string iconState = null;
            string itemState = null;
            int?   i         = null;
            string iconF     = null;

            this.overlays.Cut();
            ratio     = GlobalFuncs.Ceiling(this.power_supply.charge / this.power_supply.maxcharge * 4);
            shot      = this.ammo_type[this.select];
            iconState = "" + this.icon_state + "_charge";
            itemState = null;

            if (!Lang13.Bool(Lang13.Initial(this, "item_state")))
            {
                itemState = this.icon_state;
            }

            if (this.modifystate != 0)
            {
                this.overlays.Add("" + this.icon_state + "_" + shot.select_name);
                iconState += "_" + shot.select_name;

                if (Lang13.Bool(itemState))
                {
                    itemState += "" + shot.select_name;
                }
            }

            if (Convert.ToDouble(this.power_supply.charge) < (shot.e_cost ?? 0))
            {
                this.overlays.Add("" + this.icon_state + "_empty");
            }
            else if (!this.shaded_charge)
            {
                i = null;
                i = ratio;

                while ((i ?? 0) >= 1)
                {
                    this.overlays.Add(new Image(this.icon, null, iconState, null, null, this.ammo_x_offset * ((i ?? 0) - 1)));
                    i--;
                }
            }
            else
            {
                this.overlays.Add(new Image(this.icon, null, "" + this.icon_state + "_charge" + ratio));
            }

            if (Lang13.Bool(this.F))
            {
                iconF = "flight";

                if (Lang13.Bool(this.F.on))
                {
                    iconF = "flight_on";
                }
                this.overlays.Add(new Image(this.icon, null, iconF, null, null, this.flight_x_offset, this.flight_y_offset));
            }

            if (Lang13.Bool(itemState))
            {
                itemState      += "" + ratio;
                this.item_state = itemState;
            }
            return(false);
        }
Ejemplo n.º 11
0
        // Function from file: pizzabox.dm
        public override dynamic attack_hand(dynamic a = null, bool?b = null, bool?c = null)
        {
            dynamic topbox = null;


            if (((Mob)a).get_inactive_hand() != this)
            {
                base.attack_hand((object)(a), b, c);
                return(null);
            }

            if (this.open)
            {
                if (Lang13.Bool(this.pizza))
                {
                    ((Mob)a).put_in_hands(this.pizza);
                    a.WriteMsg("<span class='notice'>You take " + this.pizza + " out of " + this + ".</span>");
                    this.pizza = null;
                    this.update_icon();
                    return(null);
                }
                else if (Lang13.Bool(this.bomb))
                {
                    if (Lang13.Bool(((Wires)this.wires).is_all_cut()) && Lang13.Bool(this.bomb_defused))
                    {
                        ((Mob)a).put_in_hands(this.bomb);
                        a.WriteMsg("<span class='notice'>You carefully remove the " + this.bomb + " from " + this + ".</span>");
                        this.bomb = null;
                        this.update_icon();
                        return(null);
                    }
                    else
                    {
                        this.bomb_timer   = Interface13.Input(a, "Set the " + this.bomb + " timer from " + GlobalVars.BOMB_TIMER_MIN + " to " + GlobalVars.BOMB_TIMER_MAX + ".", this.bomb, this.bomb_timer, null, InputType.Num);
                        this.bomb_timer   = Num13.MaxInt(GlobalVars.BOMB_TIMER_MIN ?1:0, Num13.MinInt(GlobalFuncs.Ceiling(this.bomb_timer / 2), GlobalVars.BOMB_TIMER_MAX));
                        this.bomb_defused = GlobalVars.FALSE;
                        GlobalFuncs.message_admins(new Txt().item(GlobalFuncs.key_name_admin(a)).str("<A HREF='?_src_=holder;adminmoreinfo=").Ref(a).str("'>?</A> (<A HREF='?_src_=holder;adminplayerobservefollow=").Ref(a).str("'>FLW</A>) has trapped a ").item(this).str(" with ").item(this.bomb).str(" set to ").item(this.bomb_timer * 2).str(" seconds.").ToString());
                        GlobalFuncs.log_game("" + GlobalFuncs.key_name(a) + " has trapped a " + this + " with " + this.bomb + " set to " + this.bomb_timer * 2 + " seconds.");
                        this.bomb.adminlog = "The " + this.bomb.name + " in " + this.name + " that " + GlobalFuncs.key_name(a) + " activated has detonated!";
                        a.WriteMsg("<span class='warning'>You trap " + this + " with " + this.bomb + ".</span>");
                        this.update_icon();
                    }
                    return(null);
                }
            }
            else if (this.boxes.len != 0)
            {
                topbox = this.boxes[this.boxes.len];
                this.boxes.Remove(topbox);
                ((Mob)a).put_in_hands(topbox);
                a.WriteMsg("<span class='notice'>You remove the topmost " + this.name + " from the stack.</span>");
                topbox.update_icon();
                this.update_icon();
                return(null);
            }
            base.attack_hand((object)(a), b, c);
            return(null);
        }
Ejemplo n.º 12
0
        // Function from file: vending.dm
        public int refill_inventory(dynamic refill = null, ByTable machine = null, dynamic charge_type = null)
        {
            charge_type = charge_type ?? 1;

            int total      = 0;
            int to_restock = 0;
            Data_VendingProduct machine_content  = null;
            Data_VendingProduct machine_content2 = null;
            dynamic             tmp_charges      = null;
            Data_VendingProduct machine_content3 = null;
            int restock = 0;

            total      = 0;
            to_restock = 0;

            foreach (dynamic _a in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
            {
                machine_content = _a;


                if (machine_content.amount == 0 && Convert.ToDouble(refill.charges[charge_type]) > 0)
                {
                    machine_content.amount++;
                    refill.charges[charge_type]--;
                    total++;
                }
                to_restock += (machine_content.max_amount == true ?1:0) - (machine_content.amount ?? 0);
            }

            if (to_restock <= Convert.ToDouble(refill.charges[charge_type]))
            {
                foreach (dynamic _b in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
                {
                    machine_content2 = _b;

                    machine_content2.amount = Lang13.IntNullable(machine_content2.max_amount);
                }
                refill.charges[charge_type] -= to_restock;
                total += to_restock;
            }
            else
            {
                tmp_charges = refill.charges[charge_type];

                foreach (dynamic _c in Lang13.Enumerate(machine, typeof(Data_VendingProduct)))
                {
                    machine_content3 = _c;


                    if (Lang13.Bool(refill.charges[charge_type]) == false)
                    {
                        break;
                    }
                    restock = GlobalFuncs.Ceiling(((machine_content3.max_amount == true ?1:0) - (machine_content3.amount ?? 0)) / to_restock * Convert.ToDouble(tmp_charges));

                    if (restock > Convert.ToDouble(refill.charges[charge_type]))
                    {
                        restock = Convert.ToInt32(refill.charges[charge_type]);
                    }
                    machine_content3.amount     += restock;
                    refill.charges[charge_type] -= restock;
                    total += restock;
                }
            }
            return(total);
        }
Ejemplo n.º 13
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;
        }
Ejemplo n.º 14
0
 // Function from file: magazines.dm
 public override bool update_icon(dynamic new_state = null, dynamic new_icon = null, int?new_px = null, int?new_py = null)
 {
     base.update_icon((object)(new_state), (object)(new_icon), new_px, new_py);
     this.icon_state = "" + Lang13.Initial(this, "icon_state") + "-" + GlobalFuncs.Ceiling(this.ammo_count(false) / 8) * 8;
     return(false);
 }