// Function from file: transit_tube_pod.dm
        public void mix_air(  )
        {
            GasMixture environment    = null;
            double     env_pressure   = 0;
            double     int_pressure   = 0;
            double     total_pressure = 0;
            int        transfer_in    = 0;
            int        transfer_out   = 0;
            dynamic    from_env       = null;
            GasMixture from_int       = null;

            environment    = this.loc.return_air();
            env_pressure   = environment.return_pressure();
            int_pressure   = this.air_contents.return_pressure();
            total_pressure = env_pressure + int_pressure;

            if (total_pressure == 0)
            {
                return;
            }
            transfer_in  = Num13.MaxInt(((int)(0.1)), ((int)((env_pressure - int_pressure) * 0.5 / total_pressure)));
            transfer_out = Num13.MaxInt(((int)(0.1)), ((int)((int_pressure - env_pressure) * 0.3 / total_pressure)));
            from_env     = this.loc.remove_air(environment.total_moles() * transfer_in);
            from_int     = this.air_contents.remove(this.air_contents.total_moles() * transfer_out);
            this.loc.assume_air(from_int);
            this.air_contents.merge(from_env);
            return;
        }
Exemplo n.º 2
0
        // Function from file: oxygen_generator.dm
        public override int?process_atmos(  )
        {
            GasMixture air_contents          = null;
            double     total_moles           = 0;
            double     current_heat_capacity = 0;
            double     added_oxygen          = 0;

            base.process_atmos();

            if (!this.on)
            {
                return(0);
            }
            air_contents = this.airs[1];
            total_moles  = air_contents.total_moles();

            if (total_moles < this.oxygen_content)
            {
                current_heat_capacity    = air_contents.heat_capacity();
                added_oxygen             = this.oxygen_content - total_moles;
                air_contents.temperature = (current_heat_capacity * Convert.ToDouble(air_contents.temperature) + added_oxygen * 5463) / (current_heat_capacity + added_oxygen * 20);
                air_contents.assert_gas("o2");
                air_contents.gases["o2"][1] += added_oxygen;
                this.update_parents();
            }
            return(1);
        }
Exemplo n.º 3
0
        // Function from file: atmos_control.dm
        public override int?process_atmos(  )
        {
            Signal     signal      = null;
            GasMixture air_sample  = null;
            double     total_moles = 0;
            dynamic    gas_id      = null;
            dynamic    gas_name    = null;


            if (this.on)
            {
                signal     = new Signal();
                air_sample = this.return_air();
                signal.transmission_method = 1;
                signal.data = new ByTable()
                              .Set("sigtype", "status")
                              .Set("id_tag", this.id_tag)
                              .Set("timestamp", Game13.time)
                              .Set("pressure", air_sample.return_pressure())
                              .Set("temperature", air_sample.temperature)
                              .Set("gases", new ByTable())
                ;
                total_moles = air_sample.total_moles();

                foreach (dynamic _a in Lang13.Enumerate(air_sample.gases))
                {
                    gas_id = _a;

                    gas_name = air_sample.gases[gas_id][3][2];
                    signal.data["gases"][gas_name] = air_sample.gases[gas_id][1] / total_moles * 100;
                }
                this.radio_connection.post_signal(this, signal, GlobalVars.RADIO_ATMOSIA);
            }
            return(null);
        }
        // Function from file: jetpack.dm
        public bool allow_thrust(double num = 0, Mob_Living_Carbon_Human user = null)
        {
            GasMixture removed = null;
            dynamic    T       = null;


            if (!Lang13.Bool(this.on))
            {
                return(false);
            }

            if (num < 0.041 || this.air_contents.total_moles() < num)
            {
                this.turn_off();
                return(false);
            }
            removed = this.air_contents.remove(num);

            if (removed.total_moles() < 0.041)
            {
                this.turn_off();
                return(false);
            }
            T = GlobalFuncs.get_turf(user);
            ((Ent_Static)T).assume_air(removed);
            return(true);
        }
Exemplo n.º 5
0
        // Function from file: objs.dm
        public dynamic handle_internal_lifeform(dynamic lifeform_inside_me = null, bool breath_request = false)
        {
            GasMixture environment       = null;
            double     breath_percentage = 0;


            if ((breath_request ?1:0) > 0)
            {
                environment       = this.return_air();
                breath_percentage = 0.5 / environment.return_volume();
                return(this.remove_air(environment.total_moles() * breath_percentage));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        // Function from file: species_types.dm
        public override void spec_life(Mob_Living H = null)
        {
            GasMixture environment = null;
            double     total_moles = 0;
            dynamic    P           = null;

            environment = H.loc.return_air();

            if (!(((dynamic)H).w_uniform is Obj_Item_Clothing_Under_Plasmaman) || !(((dynamic)H).head is Obj_Item_Clothing_Head_Helmet_Space_Plasmaman))
            {
                if (environment != null)
                {
                    total_moles = environment.total_moles();

                    if (total_moles != 0)
                    {
                        if (Lang13.Bool(environment.gases["o2"]) && Convert.ToDouble(environment.gases["o2"][1] / total_moles) >= 0.01)
                        {
                            H.adjust_fire_stacks(0.5);

                            if (!H.on_fire && H.fire_stacks > 0)
                            {
                                H.visible_message("<span class='danger'>" + H + "'s body reacts with the atmosphere and bursts into flames!</span>", "<span class='userdanger'>Your body reacts with the atmosphere and bursts into flame!</span>");
                            }
                            H.IgniteMob();
                        }
                    }
                }
            }
            else if (H.fire_stacks != 0)
            {
                P = ((dynamic)H).w_uniform;

                if (P is Obj_Item_Clothing_Under_Plasmaman)
                {
                    P.Extinguish(H);
                }
            }
            H.update_fire();
            return;
        }
Exemplo n.º 7
0
        // Function from file: unsorted.dm
        public void atmosanalyzer_scan(GasMixture air_contents = null, dynamic user = null, dynamic target = null)
        {
            target = target ?? this;

            dynamic icon              = null;
            double  pressure          = 0;
            double  total_moles       = 0;
            ByTable cached_gases      = null;
            dynamic id                = null;
            double  gas_concentration = 0;

            icon = target;
            ((Ent_Static)user).visible_message(new Txt().item(user).str(" has used the analyzer on ").icon(icon).str(" ").item(target).str(".").ToString(), new Txt("<span class='notice'>You use the analyzer on ").icon(icon).str(" ").item(target).str(".</span>").ToString());
            pressure    = air_contents.return_pressure();
            total_moles = air_contents.total_moles();
            user.WriteMsg(new Txt("<span class='notice'>Results of analysis of ").icon(icon).str(" ").item(target).str(".</span>").ToString());

            if (total_moles > 0)
            {
                user.WriteMsg("<span class='notice'>Pressure: " + Num13.Round(pressure, 0.1) + " kPa</span>");
                cached_gases = air_contents.gases;

                foreach (dynamic _a in Lang13.Enumerate(cached_gases))
                {
                    id = _a;

                    gas_concentration = Convert.ToDouble(cached_gases[id][1] / total_moles);

                    if (Lang13.Bool(((dynamic)(GlobalVars.hardcoded_gases != null || gas_concentration > 0.01)).Contains(id)))
                    {
                        user.WriteMsg("<span class='notice'>" + cached_gases[id][3][2] + ": " + Num13.Floor(gas_concentration * 100) + " %</span>");
                    }
                }
                user.WriteMsg("<span class='notice'>Temperature: " + Num13.Floor(Convert.ToDouble(air_contents.temperature - 273.41)) + " &deg;C</span>");
            }
            else
            {
                user.WriteMsg("<span class='notice'>" + target + " is empty!</span>");
            }
            return;
        }
Exemplo n.º 8
0
        // Function from file: server.dm
        public void produce_heat(double heat_amt = 0)
        {
            Ent_Static L              = null;
            GasMixture env            = null;
            double     transfer_moles = 0;
            GasMixture removed        = null;
            double?    heat_capacity  = null;


            if (!((this.stat & 3) != 0))
            {
                L = this.loc;

                if (L is Tile_Simulated)
                {
                    env = L.return_air();

                    if (Convert.ToDouble(env.temperature) < heat_amt + 273.41)
                    {
                        transfer_moles = env.total_moles() * 0.25;
                        removed        = env.remove(transfer_moles);

                        if (removed != null)
                        {
                            heat_capacity = removed.heat_capacity();

                            if (heat_capacity == 0 || heat_capacity == null)
                            {
                                heat_capacity = 1;
                            }
                            removed.temperature = Num13.MinInt(Convert.ToInt32((removed.temperature * heat_capacity + this.heating_power) / heat_capacity), 1000);
                        }
                        env.merge(removed);
                        this.air_update_turf();
                    }
                }
            }
            return;
        }
Exemplo n.º 9
0
        // Function from file: pump.dm
        public override int?process_atmos(  )
        {
            GasMixture air1 = null;
            dynamic    air2 = null;
            dynamic    output_starting_pressure = null;
            double     pressure_delta           = 0;
            double     transfer_moles           = 0;
            GasMixture removed = null;


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

            if (!Lang13.Bool(this.on))
            {
                return(0);
            }
            air1 = this.airs[1];
            air2 = this.airs[2];
            output_starting_pressure = air2.return_pressure();

            if (this.target_pressure - Convert.ToDouble(output_starting_pressure) < 0.01)
            {
                return(1);
            }

            if (air1.total_moles() > 0 && Convert.ToDouble(air1.temperature) > 0)
            {
                pressure_delta = this.target_pressure - Convert.ToDouble(output_starting_pressure);
                transfer_moles = pressure_delta * Convert.ToDouble(air2.volume) / Convert.ToDouble(air1.temperature * 8.31);
                removed        = air1.remove(transfer_moles);
                air2.merge(removed);
                this.update_parents();
            }
            return(1);
        }
Exemplo n.º 10
0
        // Function from file: passive_gate.dm
        public override int?process_atmos(  )
        {
            GasMixture air1 = null;
            dynamic    air2 = null;
            dynamic    output_starting_pressure = null;
            dynamic    input_starting_pressure  = null;
            int        pressure_delta           = 0;
            double     transfer_moles           = 0;
            GasMixture removed = null;

            base.process_atmos();

            if (!Lang13.Bool(this.on))
            {
                return(0);
            }
            air1 = this.airs[1];
            air2 = this.airs[2];
            output_starting_pressure = air2.return_pressure();
            input_starting_pressure  = air1.return_pressure();

            if (Convert.ToDouble(output_starting_pressure) >= Num13.MinInt(((int)(this.target_pressure)), Convert.ToInt32(input_starting_pressure - 10)))
            {
                return(1);
            }

            if (air1.total_moles() > 0 && Convert.ToDouble(air1.temperature) > 0)
            {
                pressure_delta = Num13.MinInt(((int)(this.target_pressure - Convert.ToDouble(output_starting_pressure))), Convert.ToInt32((input_starting_pressure - output_starting_pressure) / 2));
                transfer_moles = pressure_delta * Convert.ToDouble(air2.volume) / Convert.ToDouble(air1.temperature * 8.31);
                removed        = air1.remove(transfer_moles);
                air2.merge(removed);
                this.update_parents();
            }
            return(null);
        }
Exemplo n.º 11
0
        // Function from file: scanners.dm
        public override dynamic attack_self(dynamic user = null, dynamic flag = null, bool?emp = null)
        {
            Ent_Static location             = null;
            GasMixture environment          = null;
            double     pressure             = 0;
            double     total_moles          = 0;
            ByTable    env_gases            = null;
            dynamic    o2_concentration     = null;
            dynamic    n2_concentration     = null;
            double     co2_concentration    = 0;
            double     plasma_concentration = 0;
            dynamic    id = null;
            dynamic    gas_concentration = null;

            this.add_fingerprint(user);

            if (Lang13.Bool(user.stat) || user.eye_blind != 0)
            {
                return(null);
            }
            location = user.loc;

            if (!(location is Tile))
            {
                return(null);
            }
            environment = location.return_air();
            pressure    = environment.return_pressure();
            total_moles = environment.total_moles();
            user.WriteMsg("<span class='info'><B>Results:</B></span>");

            if (Math.Abs(pressure - 101.32499694824219) < 10)
            {
                user.WriteMsg("<span class='info'>Pressure: " + Num13.Round(pressure, 0.1) + " kPa</span>");
            }
            else
            {
                user.WriteMsg("<span class='alert'>Pressure: " + Num13.Round(pressure, 0.1) + " kPa</span>");
            }

            if (total_moles != 0)
            {
                env_gases = environment.gases;
                GlobalVars.hardcoded_gases.Apply(Lang13.BindFunc(environment, "assert_gases"));
                o2_concentration     = env_gases["o2"][1] / total_moles;
                n2_concentration     = env_gases["n2"][1] / total_moles;
                co2_concentration    = Convert.ToDouble(env_gases["co2"][1] / total_moles);
                plasma_concentration = Convert.ToDouble(env_gases["plasma"][1] / total_moles);
                environment.garbage_collect();

                if (Math.Abs(Convert.ToDouble(n2_concentration - 0.79)) < 20)
                {
                    user.WriteMsg("<span class='info'>Nitrogen: " + Num13.Floor(Convert.ToDouble(n2_concentration * 100)) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='alert'>Nitrogen: " + Num13.Floor(Convert.ToDouble(n2_concentration * 100)) + " %</span>");
                }

                if (Math.Abs(Convert.ToDouble(o2_concentration - 0.01)) < 2)
                {
                    user.WriteMsg("<span class='info'>Oxygen: " + Num13.Floor(Convert.ToDouble(o2_concentration * 100)) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='alert'>Oxygen: " + Num13.Floor(Convert.ToDouble(o2_concentration * 100)) + " %</span>");
                }

                if (co2_concentration > 0.01)
                {
                    user.WriteMsg("<span class='alert'>CO2: " + Num13.Floor(co2_concentration * 100) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='info'>CO2: " + Num13.Floor(co2_concentration * 100) + " %</span>");
                }

                if (plasma_concentration > 0.01)
                {
                    user.WriteMsg("<span class='info'>Plasma: " + Num13.Floor(plasma_concentration * 100) + " %</span>");
                }

                foreach (dynamic _a in Lang13.Enumerate(env_gases))
                {
                    id = _a;


                    if (GlobalVars.hardcoded_gases.Contains(id))
                    {
                        continue;
                    }
                    gas_concentration = env_gases[id][1] / total_moles;
                    user.WriteMsg("<span class='alert'>" + env_gases[id][3][2] + ": " + Num13.Floor(Convert.ToDouble(gas_concentration * 100)) + " %</span>");
                }
                user.WriteMsg("<span class='info'>Temperature: " + Num13.Floor(Convert.ToDouble(environment.temperature - 273.41)) + " &deg;C</span>");
            }
            return(null);
        }
Exemplo n.º 12
0
        // Function from file: supermatter.dm
        public override int?process(dynamic seconds = null)
        {
            Ent_Static L                = null;
            string     stability        = null;
            Mob_Living mob              = null;
            Mob_Living H                = null;
            double     rads             = 0;
            GasMixture env              = null;
            GasMixture removed          = null;
            bool       removed_nitrogen = false;
            int        temp_factor      = 0;
            double     device_energy    = 0;
            Mob_Living_Carbon_Human l   = null;
            Mob_Living l2               = null;
            double     rads2            = 0;

            L = this.loc;

            if (L == null)
            {
                return(26);
            }

            if (!(L is Tile))
            {
                return(null);
            }

            if (L is Tile_Space)
            {
                return(null);
            }

            if (this.damage > this.warning_point)
            {
                if ((Game13.timeofday - this.lastwarning) / 10 >= 30)
                {
                    stability = String13.NumberToString(Num13.Floor(this.damage / this.explosion_point * 100));

                    if (this.damage > this.emergency_point)
                    {
                        this.radio.talk_into(this, "" + this.emergency_alert + " Instability: " + stability + "%");
                        this.lastwarning = Game13.timeofday;

                        if (!this.has_reached_emergency)
                        {
                            this.investigate_log("has reached the emergency point for the first time.", "supermatter");
                            GlobalFuncs.message_admins("" + this + " has reached the emergency point <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=" + this.x + ";Y=" + this.y + ";Z=" + this.z + "'>(JMP)</a>.");
                            this.has_reached_emergency = true;
                        }
                    }
                    else if (this.damage >= this.damage_archived)
                    {
                        this.radio.talk_into(this, "" + this.warning_alert + " Instability: " + stability + "%");
                        this.lastwarning = Game13.timeofday - 150;
                    }
                    else
                    {
                        this.radio.talk_into(this, "" + this.safe_alert);
                        this.lastwarning = Game13.timeofday;
                    }
                }

                if (this.damage > this.explosion_point)
                {
                    foreach (dynamic _a in Lang13.Enumerate(GlobalVars.living_mob_list, typeof(Mob_Living)))
                    {
                        mob = _a;


                        if (mob is Mob_Living_Carbon_Human)
                        {
                            H = mob;
                            H.hallucination += Num13.MaxInt(50, Num13.MinInt(300, ((int)(Math.Sqrt(1 / (Map13.GetDistance(mob, this) + 1)) * 600))));
                        }
                        rads = Math.Sqrt(1 / (Map13.GetDistance(mob, this) + 1)) * 200;
                        mob.rad_act(rads);
                    }
                    this.explode();
                }
            }
            env     = L.return_air();
            removed = env.remove(this.gasefficency * env.total_moles());

            if (!(removed != null) || !(removed.total_moles() != 0))
            {
                this.damage += Num13.MaxInt(((int)((this.power - 1600) / 10)), 0);
                this.power   = Num13.MinInt(((int)(this.power)), 1600);
                return(1);
            }
            this.damage_archived = this.damage;
            this.damage          = Num13.MaxInt(((int)(this.damage + Convert.ToDouble((removed.temperature - 800) / 150))), 0);
            removed_nitrogen     = false;

            if (Lang13.Bool(removed.gases["n2"]))
            {
                removed_nitrogen = Lang13.Bool(removed.gases["n2"][1] * 2);
            }
            removed.assert_gases("o2", "plasma");
            this.oxygen = Num13.MaxInt(Num13.MinInt(Convert.ToInt32((removed.gases["o2"][1] - removed_nitrogen) / 103.98379516601562), 1), 0);
            temp_factor = 50;

            if (this.oxygen > 0.8)
            {
                this.icon_state = "" + this.base_icon_state + "_glow";
            }
            else
            {
                temp_factor     = 30;
                this.icon_state = this.base_icon_state;
            }
            this.power = Num13.MaxInt(Convert.ToInt32(removed.temperature * temp_factor / 273.41 * this.oxygen + this.power), 0);
            this.transfer_energy();
            device_energy               = this.power * 0.55;
            removed.temperature        += device_energy / 5;
            removed.temperature         = Num13.MaxInt(0, Num13.MinInt(Convert.ToInt32(removed.temperature), 2500));
            removed.gases["plasma"][1] += Num13.MaxInt(((int)(device_energy / 750)), 0);
            removed.gases["o2"][1]     += Num13.MaxInt(((int)((device_energy + Convert.ToDouble(removed.temperature) - 273.41) / 325)), 0);
            env.merge(removed);

            foreach (dynamic _b in Lang13.Enumerate(Map13.FetchInView(Num13.MinInt(7, Num13.Floor(Math.Pow(this.power, 0.25))), this), typeof(Mob_Living_Carbon_Human)))
            {
                l = _b;


                if (!(l.glasses is Obj_Item_Clothing_Glasses_Meson))
                {
                    l.hallucination = Num13.MaxInt(0, Num13.MinInt(200, ((int)(l.hallucination + this.power * this.config_hallucination_power * Math.Sqrt(1 / Num13.MaxInt(1, Map13.GetDistance(l, this)))))));
                }
            }

            foreach (dynamic _c in Lang13.Enumerate(Map13.FetchInRange(Num13.Floor(Math.Pow(this.power / 100, 0.25)), this), typeof(Mob_Living)))
            {
                l2 = _c;

                rads2 = this.power / 10 * Math.Sqrt(1 / Num13.MaxInt(Map13.GetDistance(l2, this), 1));
                l2.rad_act(rads2);
            }
            this.power -= Math.Pow(this.power / 500, 3);
            return(1);
        }
Exemplo n.º 13
0
        // Function from file: airalarm.dm
        public override ByTable ui_data(dynamic user = null)
        {
            ByTable    data             = null;
            dynamic    A                = null;
            dynamic    T                = null;
            GasMixture environment      = null;
            Tlv        cur_tlv          = null;
            double     pressure         = 0;
            dynamic    temperature      = null;
            double     total_moles      = 0;
            dynamic    partial_pressure = null;
            dynamic    gas_id           = null;
            dynamic    id_tag           = null;
            dynamic    long_name        = null;
            dynamic    info             = null;
            dynamic    id_tag2          = null;
            dynamic    long_name2       = null;
            dynamic    info2            = null;
            Tlv        selected         = null;
            ByTable    thresholds       = null;
            dynamic    gas_id2          = null;

            data = new ByTable().Set("locked", this.locked).Set("siliconUser", user.has_unlimited_silicon_privilege).Set("emagged", this.emagged).Set("danger_level", this.danger_level);
            A    = GlobalFuncs.get_area(this);
            data["atmos_alarm"] = A.atmosalm;
            data["fire_alarm"]  = A.fire;
            T           = GlobalFuncs.get_turf(this);
            environment = ((Ent_Static)T).return_air();
            data["environment_data"] = new ByTable();
            pressure = environment.return_pressure();
            cur_tlv  = this.TLV["pressure"];
            data["environment_data"] += new ByTable(new object [] { new ByTable().Set("name", "Pressure").Set("value", pressure).Set("unit", "kPa").Set("danger_level", cur_tlv.get_danger_level(pressure)) });
            temperature = environment.temperature;
            cur_tlv     = this.TLV["temperature"];
            data["environment_data"] += new ByTable(new object [] {
                new ByTable()
                .Set("name", "Temperature")
                .Set("value", temperature)
                .Set("unit", "K (" + Num13.Round(Convert.ToDouble(temperature - 273.41), 0.1) + "C)")
                .Set("danger_level", cur_tlv.get_danger_level(temperature))
            });
            total_moles      = environment.total_moles();
            partial_pressure = environment.temperature * 8.31 / environment.volume;

            foreach (dynamic _a in Lang13.Enumerate(environment.gases))
            {
                gas_id = _a;


                if (!this.TLV.Contains(gas_id))
                {
                    continue;
                }
                cur_tlv = this.TLV[gas_id];
                data["environment_data"] += new ByTable(new object [] {
                    new ByTable()
                    .Set("name", environment.gases[gas_id][3][2])
                    .Set("value", environment.gases[gas_id][1] / total_moles * 100)
                    .Set("unit", "%")
                    .Set("danger_level", cur_tlv.get_danger_level(environment.gases[gas_id][1] * partial_pressure))
                });
            }

            if (!this.locked || user.has_unlimited_silicon_privilege)
            {
                data["vents"] = new ByTable();

                foreach (dynamic _b in Lang13.Enumerate(A.air_vent_names))
                {
                    id_tag = _b;

                    long_name = A.air_vent_names[id_tag];
                    info      = A.air_vent_info[id_tag];

                    if (!Lang13.Bool(info) || Convert.ToDouble(info["frequency"]) != this.frequency)
                    {
                        continue;
                    }
                    data["vents"] += new ByTable(new object [] {
                        new ByTable()
                        .Set("id_tag", id_tag)
                        .Set("long_name", GlobalFuncs.sanitize(long_name))
                        .Set("power", info["power"])
                        .Set("checks", info["checks"])
                        .Set("excheck", info["checks"] & 1)
                        .Set("incheck", info["checks"] & 2)
                        .Set("direction", info["direction"])
                        .Set("external", info["external"])
                        .Set("extdefault", Convert.ToDouble(info["external"]) == 101.32499694824219)
                    });
                }
                data["scrubbers"] = new ByTable();

                foreach (dynamic _c in Lang13.Enumerate(A.air_scrub_names))
                {
                    id_tag2 = _c;

                    long_name2 = A.air_scrub_names[id_tag2];
                    info2      = A.air_scrub_info[id_tag2];

                    if (!Lang13.Bool(info2) || Convert.ToDouble(info2["frequency"]) != this.frequency)
                    {
                        continue;
                    }
                    data["scrubbers"] += new ByTable(new object [] {
                        new ByTable()
                        .Set("id_tag", id_tag2)
                        .Set("long_name", GlobalFuncs.sanitize(long_name2))
                        .Set("power", info2["power"])
                        .Set("scrubbing", info2["scrubbing"])
                        .Set("widenet", info2["widenet"])
                        .Set("filter_co2", info2["filter_co2"])
                        .Set("filter_toxins", info2["filter_toxins"])
                        .Set("filter_n2o", info2["filter_n2o"])
                    });
                }
                data["mode"]   = this.mode;
                data["modes"]  = new ByTable();
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Filtering - Scrubs out contaminants").Set("mode", 1).Set("selected", this.mode == 1).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Contaminated - Scrubs out ALL contaminants quickly").Set("mode", 8).Set("selected", this.mode == 8).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Draught - Siphons out air while replacing").Set("mode", 2).Set("selected", this.mode == 2).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Refill - Triple vent output").Set("mode", 9).Set("selected", this.mode == 9).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Cycle - Siphons air before replacing").Set("mode", 4).Set("selected", this.mode == 4).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Siphon - Siphons air out of the room").Set("mode", 7).Set("selected", this.mode == 7).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Panic Siphon - Siphons air out of the room quickly").Set("mode", 3).Set("selected", this.mode == 3).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Off - Shuts off vents and scrubbers").Set("mode", 5).Set("selected", this.mode == 5).Set("danger", 0) });

                if (Lang13.Bool(this.emagged))
                {
                    data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Flood - Shuts off scrubbers and opens vents").Set("mode", 6).Set("selected", this.mode == 6).Set("danger", 1) });
                }
                selected   = null;
                thresholds = new ByTable();
                selected   = this.TLV["pressure"];
                thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", "Pressure").Set("settings", new ByTable()) }));
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "min2").Set("selected", selected.min2) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "min1").Set("selected", selected.min1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "max1").Set("selected", selected.max1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "max2").Set("selected", selected.max2) });
                selected = this.TLV["temperature"];
                thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", "Temperature").Set("settings", new ByTable()) }));
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "min2").Set("selected", selected.min2) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "min1").Set("selected", selected.min1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "max1").Set("selected", selected.max1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "max2").Set("selected", selected.max2) });

                foreach (dynamic _d in Lang13.Enumerate(GlobalVars.meta_gas_info))
                {
                    gas_id2 = _d;


                    if (!this.TLV.Contains(gas_id2))
                    {
                        continue;
                    }
                    selected = this.TLV[gas_id2];
                    thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", GlobalVars.meta_gas_info[gas_id2][2]).Set("settings", new ByTable()) }));
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "min2").Set("selected", selected.min2) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "min1").Set("selected", selected.min1) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "max1").Set("selected", selected.max1) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "max2").Set("selected", selected.max2) });
                }
                data["thresholds"] = thresholds;
            }
            return(data);
        }
        // Function from file: experimentor.dm
        public void experiment(double?exp = null, dynamic exp_on = null)
        {
            dynamic    chosenchem       = null;
            dynamic    criticalReaction = null;
            Mob_Living m        = null;
            dynamic    target   = null;
            dynamic    throwing = null;
            dynamic    T        = null;
            Obj_Effect_Decal_Cleanable_Greenglow reagentdecal = null;
            string   savedName = null;
            dynamic  newPath   = null;
            dynamic  CG        = null;
            Reagents R         = null;
            EffectSystem_SmokeSpread_Chem smoke = null;
            Reagents R2 = null;
            EffectSystem_SmokeSpread_Chem smoke2 = null;
            Obj_Item_Weapon_ReagentContainers_Food_Drinks_Coffee C = null;
            dynamic start = null;
            dynamic M     = null;
            dynamic MT    = null;
            Obj_Item_Projectile_Magic_Fireball FB = null;
            GasMixture env                  = null;
            double     transfer_moles       = 0;
            GasMixture removed              = null;
            double?    heat_capacity        = null;
            Mob_Living m2                   = null;
            Obj_Machinery_Vending_Coffee C2 = null;
            Reagents R3 = null;
            EffectSystem_SmokeSpread_Chem smoke3 = null;
            GasMixture env2                 = null;
            double     transfer_moles2      = 0;
            GasMixture removed2             = null;
            double?    heat_capacity2       = null;
            EffectSystem_SmokeSpread smoke4 = null;
            dynamic     material            = null;
            Ent_Dynamic AM         = null;
            ByTable     throwAt    = null;
            Ent_Dynamic AM2        = null;
            int?        counter    = null;
            Ent_Dynamic cast       = null;
            dynamic     a          = null;
            dynamic     b          = null;
            dynamic     R4         = null;
            int         globalMalf = 0;
            Mob_Living  m3         = null;
            ByTable     reqs       = null;
            dynamic     T2         = null;

            this.recentlyExperimented = true;
            this.icon_state           = "h_lathe_wloop";
            criticalReaction          = Lang13.FindIn(exp_on, (this.critical_items != null ? GlobalVars.TRUE : GlobalVars.FALSE));

            if (exp == 1)
            {
                this.visible_message("" + this + " prods at " + exp_on + " with mechanical arms.");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("" + exp_on + " is gripped in just the right way, enhancing its focus.");
                    this.badThingCoeff++;
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " malfunctions and destroys " + exp_on + ", lashing its arms out at nearby people!</span>");

                    foreach (dynamic _a in Lang13.Enumerate(Map13.FetchInViewExcludeThis(this, 1), typeof(Mob_Living)))
                    {
                        m = _a;

                        m.apply_damage(15, "brute", Rand13.Pick(new object [] { "head", "chest", "groin" }));
                        this.investigate_log("Experimentor dealt minor brute to " + m + ".", "experimentor");
                    }
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions!</span>");
                    exp = 6;
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " malfunctions, throwing the " + exp_on + "!</span>");
                    target = Lang13.FindIn(typeof(Mob_Living), Map13.FetchInViewExcludeThis(this, 7));

                    if (Lang13.Bool(target))
                    {
                        throwing = this.loaded_item;
                        this.investigate_log("Experimentor has thrown " + this.loaded_item + " at " + target, "experimentor");
                        this.ejectItem();

                        if (Lang13.Bool(throwing))
                        {
                            ((Ent_Dynamic)throwing).throw_at(target, 10, 1);
                        }
                    }
                }
            }

            if (exp == 2)
            {
                this.visible_message("<span class='danger'>" + this + " reflects radioactive rays at " + exp_on + "!</span>");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("" + exp_on + " has activated an unknown subroutine!");
                    this.cloneMode  = GlobalVars.TRUE;
                    this.cloneCount = this.badThingCoeff;
                    this.investigate_log("Experimentor has made a clone of " + exp_on, "experimentor");
                    this.ejectItem();
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " malfunctions, melting " + exp_on + " and leaking radiation!</span>");
                    GlobalFuncs.radiation_pulse(GlobalFuncs.get_turf(this), 1, 1, 25, true);
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions, spewing toxic waste!</span>");

                    foreach (dynamic _b in Lang13.Enumerate(Map13.FetchInViewExcludeThis(this, 1)))
                    {
                        T = _b;


                        if (!T.density)
                        {
                            if (Rand13.PercentChance(95))
                            {
                                reagentdecal = new Obj_Effect_Decal_Cleanable_Greenglow(T);
                                reagentdecal.reagents.add_reagent("radium", 7);
                            }
                        }
                    }
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    savedName = "" + exp_on;
                    this.ejectItem(GlobalVars.TRUE);
                    newPath          = this.pickWeighted(this.valid_items);
                    this.loaded_item = Lang13.Call(newPath, this);
                    this.visible_message("<span class='warning'>" + this + " malfunctions, transforming " + savedName + " into " + this.loaded_item + "!</span>");
                    this.investigate_log("Experimentor has transformed " + savedName + " into " + this.loaded_item, "experimentor");

                    if (this.loaded_item is Obj_Item_Weapon_Grenade_ChemGrenade)
                    {
                        CG = this.loaded_item;
                        ((Obj_Item_Weapon_Grenade)CG).prime();
                    }
                    this.ejectItem();
                }
            }

            if (exp == 3)
            {
                this.visible_message("<span class='warning'>" + this + " fills its chamber with gas, " + exp_on + " included.</span>");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("" + exp_on + " achieves the perfect mix!");
                    new Obj_Item_Stack_Sheet_Mineral_Plasma(GlobalFuncs.get_turf(Rand13.PickFromTable(Map13.FetchInViewExcludeThis(this, 1))));
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " destroys " + exp_on + ", leaking dangerous gas!</span>");
                    chosenchem = Rand13.Pick(new object [] { "carbon", "radium", "toxin", "condensedcapsaicin", "mushroomhallucinogen", "space_drugs", "ethanol", "beepskysmash" });
                    R          = new Reagents(50);
                    R.my_atom  = this;
                    R.add_reagent(chosenchem, 50);
                    this.investigate_log("Experimentor has released " + chosenchem + " smoke.", "experimentor");
                    smoke = new EffectSystem_SmokeSpread_Chem();
                    smoke.set_up(R, 0, this);
                    GlobalFuncs.playsound(this.loc, "sound/effects/smoke.ogg", 50, 1, -3);
                    smoke.start();
                    GlobalFuncs.qdel(R);
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + "'s chemical chamber has sprung a leak!</span>");
                    chosenchem = Rand13.Pick(new object [] { "mutationtoxin", "nanomachines", "sacid" });
                    R2         = new Reagents(50);
                    R2.my_atom = this;
                    R2.add_reagent(chosenchem, 50);
                    smoke2 = new EffectSystem_SmokeSpread_Chem();
                    smoke2.set_up(R2, 0, this);
                    GlobalFuncs.playsound(this.loc, "sound/effects/smoke.ogg", 50, 1, -3);
                    smoke2.start();
                    GlobalFuncs.qdel(R2);
                    this.ejectItem(GlobalVars.TRUE);
                    this.warn_admins(Task13.User, "" + chosenchem + " smoke");
                    this.investigate_log("Experimentor has released <font color='red'>" + chosenchem + "</font> smoke!", "experimentor");
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("" + this + " malfunctions, spewing harmless gas.");
                    this.throwSmoke(this.loc);
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " melts " + exp_on + ", ionizing the air around it!</span>");
                    GlobalFuncs.empulse(this.loc, 4, 6);
                    this.investigate_log("Experimentor has generated an Electromagnetic Pulse.", "experimentor");
                    this.ejectItem(GlobalVars.TRUE);
                }
            }

            if (exp == 4)
            {
                this.visible_message("" + this + " raises " + exp_on + "'s temperature.");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("<span class='warning'>" + this + "'s emergency coolant system gives off a small ding!</span>");
                    GlobalFuncs.playsound(this.loc, "sound/machines/ding.ogg", 50, 1);
                    C          = new Obj_Item_Weapon_ReagentContainers_Food_Drinks_Coffee(GlobalFuncs.get_turf(Rand13.PickFromTable(Map13.FetchInViewExcludeThis(this, 1))));
                    chosenchem = Rand13.Pick(new object [] { "plasma", "capsaicin", "ethanol" });
                    C.reagents.remove_any(25);
                    C.reagents.add_reagent(chosenchem, 50);
                    C.name = "Cup of Suspicious Liquid";
                    C.desc = "It has a large hazard symbol printed on the side in fading ink.";
                    this.investigate_log("Experimentor has made a cup of " + chosenchem + " coffee.", "experimentor");
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    start = GlobalFuncs.get_turf(this);
                    M     = Lang13.FindIn(typeof(Mob_Living), Map13.FetchInView(3, this));
                    MT    = GlobalFuncs.get_turf(M);

                    if (Lang13.Bool(MT))
                    {
                        this.visible_message("<span class='danger'>" + this + " dangerously overheats, launching a flaming fuel orb!</span>");
                        this.investigate_log("Experimentor has launched a <font color='red'>fireball</font> at " + M + "!", "experimentor");
                        FB          = new Obj_Item_Projectile_Magic_Fireball(start);
                        FB.original = MT;
                        FB.current  = start;
                        FB.yo       = Convert.ToDouble(MT.y - start.y);
                        FB.xo       = Convert.ToDouble(MT.x - start.x);
                        FB.fire();
                    }
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " malfunctions, melting " + exp_on + " and releasing a burst of flame!</span>");
                    GlobalFuncs.explosion(this.loc, -1, 0, 0, 0, 0, null, 2);
                    this.investigate_log("Experimentor started a fire.", "experimentor");
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions, melting " + exp_on + " and leaking hot air!</span>");
                    env            = this.loc.return_air();
                    transfer_moles = env.total_moles() * 0.25;
                    removed        = env.remove(transfer_moles);

                    if (removed != null)
                    {
                        heat_capacity = removed.heat_capacity();

                        if (heat_capacity == 0 || heat_capacity == null)
                        {
                            heat_capacity = 1;
                        }
                        removed.temperature = Num13.MinInt(Convert.ToInt32((removed.temperature * heat_capacity + 100000) / heat_capacity), 1000);
                    }
                    env.merge(removed);
                    this.air_update_turf();
                    this.investigate_log("Experimentor has released hot air.", "experimentor");
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions, activating its emergency coolant systems!</span>");
                    this.throwSmoke(this.loc);

                    foreach (dynamic _c in Lang13.Enumerate(Map13.FetchInViewExcludeThis(this, 1), typeof(Mob_Living)))
                    {
                        m2 = _c;

                        m2.apply_damage(5, "burn", Rand13.Pick(new object [] { "head", "chest", "groin" }));
                        this.investigate_log("Experimentor has dealt minor burn damage to " + m2, "experimentor");
                    }
                    this.ejectItem();
                }
            }

            if (exp == 5)
            {
                this.visible_message("" + this + " lowers " + exp_on + "'s temperature.");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("<span class='warning'>" + this + "'s emergency coolant system gives off a small ding!</span>");
                    C2 = new Obj_Machinery_Vending_Coffee(GlobalFuncs.get_turf(Rand13.PickFromTable(Map13.FetchInViewExcludeThis(this, 1))));
                    GlobalFuncs.playsound(this.loc, "sound/machines/ding.ogg", 50, 1);
                    chosenchem = Rand13.Pick(new object [] { "uranium", "frostoil", "ephedrine" });
                    C2.reagents.remove_any(25);
                    C2.reagents.add_reagent(chosenchem, 50);
                    C2.name = "Cup of Suspicious Liquid";
                    C2.desc = "It has a large hazard symbol printed on the side in fading ink.";
                    this.investigate_log("Experimentor has made a cup of " + chosenchem + " coffee.", "experimentor");
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + " malfunctions, shattering " + exp_on + " and releasing a dangerous cloud of coolant!</span>");
                    R3         = new Reagents(50);
                    R3.my_atom = this;
                    R3.add_reagent("frostoil", 50);
                    this.investigate_log("Experimentor has released frostoil gas.", "experimentor");
                    smoke3 = new EffectSystem_SmokeSpread_Chem();
                    smoke3.set_up(R3, 0, this);
                    GlobalFuncs.playsound(this.loc, "sound/effects/smoke.ogg", 50, 1, -3);
                    smoke3.start();
                    GlobalFuncs.qdel(R3);
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions, shattering " + exp_on + " and leaking cold air!</span>");
                    env2            = this.loc.return_air();
                    transfer_moles2 = env2.total_moles() * 0.25;
                    removed2        = env2.remove(transfer_moles2);

                    if (removed2 != null)
                    {
                        heat_capacity2 = removed2.heat_capacity();

                        if (heat_capacity2 == 0 || heat_capacity2 == null)
                        {
                            heat_capacity2 = 1;
                        }
                        removed2.temperature = (removed2.temperature * heat_capacity2 - 75000) / heat_capacity2;
                    }
                    env2.merge(removed2);
                    this.air_update_turf();
                    this.investigate_log("Experimentor has released cold air.", "experimentor");
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (Rand13.PercentChance(((int)(50 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='warning'>" + this + " malfunctions, releasing a flurry of chilly air as " + exp_on + " pops out!</span>");
                    smoke4 = new EffectSystem_SmokeSpread();
                    smoke4.set_up(0, this.loc);
                    smoke4.start();
                    this.ejectItem();
                }
            }

            if (exp == 6)
            {
                this.visible_message("<span class='warning'>" + exp_on + " activates the crushing mechanism, " + exp_on + " is destroyed!</span>");

                if (Rand13.PercentChance(35) && Lang13.Bool(criticalReaction))
                {
                    this.visible_message("<span class='warning'>" + this + "'s crushing mechanism slowly and smoothly descends, flattening the " + exp_on + "!</span>");
                    new Obj_Item_Stack_Sheet_Plasteel(GlobalFuncs.get_turf(Rand13.PickFromTable(Map13.FetchInViewExcludeThis(this, 1))));
                }

                if (this.linked_console.linked_lathe != null)
                {
                    foreach (dynamic _d in Lang13.Enumerate(exp_on.materials))
                    {
                        material = _d;

                        ((MaterialContainer)((dynamic)this.linked_console.linked_lathe).materials).insert_amount(Num13.MinInt(Convert.ToInt32(((dynamic)this.linked_console.linked_lathe).materials.max_amount - ((dynamic)this.linked_console.linked_lathe).materials.total_amount), Convert.ToInt32(exp_on.materials[material])), material);
                    }
                }

                if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + "'s crusher goes way too many levels too high, crushing right through space-time!</span>");
                    GlobalFuncs.playsound(this.loc, "sound/effects/supermatter.ogg", 50, 1, -3);
                    this.investigate_log("Experimentor has triggered the 'throw things' reaction.", "experimentor");

                    foreach (dynamic _e in Lang13.Enumerate(Map13.FetchInViewExcludeThis(this, 7), typeof(Ent_Dynamic)))
                    {
                        AM = _e;


                        if (!Lang13.Bool(AM.anchored))
                        {
                            AM.throw_at_fast(this, 10, 1);
                        }
                    }
                }

                if (Rand13.PercentChance(((int)(35 - this.badThingCoeff))))
                {
                    this.visible_message("<span class='danger'>" + this + "'s crusher goes one level too high, crushing right into space-time!</span>");
                    GlobalFuncs.playsound(this.loc, "sound/effects/supermatter.ogg", 50, 1, -3);
                    this.investigate_log("Experimentor has triggered the 'minor throw things' reaction.", "experimentor");
                    throwAt = new ByTable();

                    foreach (dynamic _f in Lang13.Enumerate(Map13.FetchInViewExcludeThis(this, 7), typeof(Ent_Dynamic)))
                    {
                        AM2 = _f;


                        if (!Lang13.Bool(AM2.anchored))
                        {
                            throwAt.Add(AM2);
                        }
                    }
                    counter = null;
                    counter = 1;

                    while ((counter ?? 0) < throwAt.len)
                    {
                        cast = throwAt[counter];
                        cast.throw_at_fast(Rand13.PickFromTable(throwAt), 10, 1);
                        counter++;
                    }
                }
                this.ejectItem(GlobalVars.TRUE);
            }

            if (exp == 8)
            {
                a = Rand13.Pick(new object [] { "rumbles", "shakes", "vibrates", "shudders" });
                b = Rand13.Pick(new object [] { "crushes", "spins", "viscerates", "smashes", "insults" });
                this.visible_message("<span class='warning'>" + exp_on + " " + a + ", and " + b + ", the experiment was a failure.</span>");
            }

            if (exp == 7)
            {
                this.visible_message("" + this + " scans the " + exp_on + ", revealing its true nature!");
                GlobalFuncs.playsound(this.loc, "sound/effects/supermatter.ogg", 50, 3, -1);
                R4 = this.loaded_item;
                R4.reveal();
                this.investigate_log("Experimentor has revealed a relic with <span class='danger'>" + R4.realProc + "</span> effect.", "experimentor");
                this.ejectItem();
            }

            if (Rand13.PercentChance(((int)(20 - this.badThingCoeff))))
            {
                globalMalf = Rand13.Int(1, 100);

                if (globalMalf < 15)
                {
                    this.visible_message("<span class='warning'>" + this + "'s onboard detection system has malfunctioned!</span>");
                    this.item_reactions["" + exp_on.type] = Rand13.Pick(new object [] { 1, 2, 3, 4, 5, 6 });
                    this.ejectItem();
                }

                if (globalMalf > 16 && globalMalf < 35)
                {
                    this.visible_message("<span class='warning'>" + this + " melts " + exp_on + ", ian-izing the air around it!</span>");
                    this.throwSmoke(this.loc);

                    if (Lang13.Bool(this.trackedIan))
                    {
                        this.throwSmoke(this.trackedIan.loc);
                        this.trackedIan.loc = this.loc;
                        this.investigate_log("Experimentor has stolen Ian!", "experimentor");
                    }
                    else
                    {
                        new Mob_Living_SimpleAnimal_Pet_Dog_Corgi(this.loc);
                        this.investigate_log("Experimentor has spawned a new corgi.", "experimentor");
                    }
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (globalMalf > 36 && globalMalf < 50)
                {
                    this.visible_message("<span class='warning'>" + this + " improves " + exp_on + ", drawing the life essence of those nearby!</span>");

                    foreach (dynamic _g in Lang13.Enumerate(Map13.FetchInView(this, 4), typeof(Mob_Living)))
                    {
                        m3 = _g;

                        m3.WriteMsg("<span class='danger'>You feel your flesh being torn from you, mists of blood drifting to " + this + "!</span>");
                        m3.apply_damage(50, "brute", "chest");
                        this.investigate_log("Experimentor has taken 50 brute a blood sacrifice from " + m3, "experimentor");
                    }
                    reqs = this.ConvertReqString2List(exp_on.origin_tech);

                    foreach (dynamic _h in Lang13.Enumerate(reqs))
                    {
                        T2 = _h;

                        reqs[T2] = reqs[T2] + 1;
                    }
                    exp_on.origin_tech = String13.MakeUrlParams(reqs);
                    this.investigate_log("Experimentor has set the origin tech of " + exp_on + " to " + exp_on.origin_tech, "experimentor");
                }

                if (globalMalf > 51 && globalMalf < 75)
                {
                    this.visible_message("<span class='warning'>" + this + " encounters a run-time error!</span>");
                    this.throwSmoke(this.loc);

                    if (Lang13.Bool(this.trackedRuntime))
                    {
                        this.throwSmoke(this.trackedRuntime.loc);
                        this.trackedRuntime.loc = this.loc;
                        this.investigate_log("Experimentor has stolen Runtime!", "experimentor");
                    }
                    else
                    {
                        new Mob_Living_SimpleAnimal_Pet_Cat(this.loc);
                        this.investigate_log("Experimentor failed to steal runtime, and instead spawned a new cat.", "experimentor");
                    }
                    this.ejectItem(GlobalVars.TRUE);
                }

                if (globalMalf > 76)
                {
                    this.visible_message("<span class='warning'>" + this + " begins to smoke and hiss, shaking violently!</span>");
                    this.f_use_power(500000);
                    this.investigate_log("Experimentor has drained power from its APC", "experimentor");
                }
            }
            Task13.Schedule(((int)(this.resetTime)), (Task13.Closure)(() => {
                this.icon_state           = "h_lathe";
                this.recentlyExperimented = false;
                return;
            }));
            return;
        }
Exemplo n.º 15
0
        // Function from file: overview.dm
        public void drawmap(Mob user = null)
        {
            int        icx         = 0;
            int        icy         = 0;
            int        xoff        = 0;
            int        yoff        = 0;
            int?       icount      = null;
            ByTable    imap        = null;
            int?       i           = null;
            int?       wx          = null;
            int?       wy          = null;
            Tile       T           = null;
            string     colour      = null;
            bool       sense       = false;
            GasMixture environment = null;
            double     turf_total  = 0;
            double     t1          = 0;
            Ent_Static AM          = null;
            Ent_Static A           = null;
            int        red         = 0;
            int        green       = 0;
            int        blue        = 0;
            int        ix          = 0;
            int        iy          = 0;
            double?    rx          = null;
            double?    ry          = null;
            Icon       I           = null;
            int?       i2          = null;
            Obj_Screen H           = null;
            dynamic    I2          = null;

            icx    = Num13.Floor(Game13.map_size_x / 16) + 1;
            icy    = Num13.Floor(Game13.map_size_y / 16) + 1;
            xoff   = Num13.Floor(icx * 16 - Game13.map_size_x - 2);
            yoff   = Num13.Floor(icy * 16 - Game13.map_size_y - 2);
            icount = icx * icy;
            imap   = new ByTable();
            i      = null;
            i      = 0;

            while ((i ?? 0) < (icount ?? 0))
            {
                imap.Add(new Icon("icons/misc/imap.dmi", "blank"));
                i++;
            }
            wx = null;
            wx = 1;

            while ((wx ?? 0) <= Game13.map_size_x)
            {
                wy = null;
                wy = 1;

                while ((wy ?? 0) <= Game13.map_size_y)
                {
                    T      = Map13.GetTile(wx ?? 0, wy ?? 0, this.z);
                    colour = null;

                    if (!(T != null))
                    {
                        colour = "#000000";
                    }
                    else
                    {
                        sense = true;

                        switch ((string)("" + T.type))
                        {
                        case "/turf/space":
                            colour = "#0a0a0a";
                            sense  = false;
                            break;

                        case "/turf/simulated/floor":
                        case "/turf/simulated/floor/engine":
                            environment = T.return_air();
                            turf_total  = environment.total_moles();
                            t1          = turf_total / 103.98379516601562 * 175;

                            if (t1 <= 100)
                            {
                                colour = String13.ColorCode(0, 0, ((int)(t1 * 2.41)));
                            }
                            else
                            {
                                t1     = Num13.MinInt(100, ((int)(t1 - 100)));
                                colour = String13.ColorCode(((int)(t1 * 2.41)), ((int)(t1 * 2.41)), 255);
                            }
                            break;

                        case "/turf/simulated/wall":
                            colour = "#606060";
                            break;

                        case "/turf/simulated/wall/r_wall":
                            colour = "#806060";
                            break;

                        default:
                            colour = "#002800";
                            break;
                        }

                        if (sense)
                        {
                            foreach (dynamic _b in Lang13.Enumerate(T.contents, typeof(Ent_Static)))
                            {
                                AM = _b;


                                if (AM is Obj_Machinery_Door && !(AM is Obj_Machinery_Door_Window))
                                {
                                    if (AM.density)
                                    {
                                        colour = "#0060c0";
                                    }
                                    else
                                    {
                                        colour = "#60c080";
                                    }
                                }

                                if (AM is Obj_Machinery_Airalarm)
                                {
                                    colour = "#00ff00";

                                    if (AM.icon_state == "alarm:1")
                                    {
                                        colour = "#ffff00";
                                    }
                                }

                                if (AM is Mob)
                                {
                                    if (Lang13.Bool(((dynamic)AM).client))
                                    {
                                        colour = "#ff0000";
                                    }
                                    else
                                    {
                                        colour = "#ff8080";
                                    }
                                }
                            }
                        }
                        A = T.loc;

                        if (Lang13.Bool(((dynamic)A).fire))
                        {
                            red    = GlobalFuncs.getr(colour);
                            green  = GlobalFuncs.getg(colour);
                            blue   = GlobalFuncs.getb(colour);
                            green  = Num13.MinInt(255, green + 40);
                            blue   = Num13.MinInt(255, blue + 40);
                            colour = String13.ColorCode(red, green, blue);
                        }
                    }
                    ix = Num13.Floor(((wx ?? 0) * 2 + xoff) / 32);
                    iy = Num13.Floor(((wy ?? 0) * 2 + yoff) / 32);
                    rx = ((wx ?? 0) * 2 + xoff) % 32 + 1;
                    ry = ((wy ?? 0) * 2 + yoff) % 32 + 1;
                    I  = imap[ix + icx * iy + 1];
                    I.DrawBox(colour, rx, ry, rx, ry);
                    wy++;
                }
                wx++;
            }
            user.clearmap();
            user.mapobjs = new ByTable();
            i2           = null;
            i2           = 0;

            while ((i2 ?? 0) < (icount ?? 0))
            {
                H            = new Obj_Screen();
                H.screen_loc = "" + ((i2 ?? 0) % icx + 5) + "," + (Num13.Floor((i2 ?? 0) / icx) + 6);
                H.name       = (i2 == 0 ? "maprefresh" : "map");
                I2           = imap[(i2 ?? 0) + 1];
                H.icon       = I2;
                GlobalFuncs.qdel(I2);
                H.layer = 25;
                Task13.User.mapobjs.Add(H);
                i2++;
            }
            user.client.screen.Add(user.mapobjs);
            this.close(user);
            return;
        }
Exemplo n.º 16
0
        // Function from file: gas_mixture.dm
        public dynamic share(GasMixture sharer = null, int?atmos_adjacent_turfs = null)
        {
            atmos_adjacent_turfs = atmos_adjacent_turfs ?? 4;

            ByTable cached_gases                 = null;
            ByTable sharer_gases                 = null;
            dynamic temperature_delta            = null;
            double  abs_temperature_delta        = 0;
            double  old_self_heat_capacity       = 0;
            double  old_sharer_heat_capacity     = 0;
            double  heat_capacity_self_to_sharer = 0;
            double  heat_capacity_sharer_to_self = 0;
            double  moved_moles     = 0;
            double  abs_moved_moles = 0;
            dynamic id                       = null;
            dynamic id2                      = null;
            dynamic gas                      = null;
            dynamic sharergas                = null;
            double  delta                    = 0;
            double  gas_heat_capacity        = 0;
            double  new_self_heat_capacity   = 0;
            double  new_sharer_heat_capacity = 0;
            ByTable unique_gases             = null;
            dynamic delta_pressure           = null;


            if (!(sharer != null))
            {
                return(0);
            }
            cached_gases             = this.gases;
            sharer_gases             = sharer.gases;
            temperature_delta        = this.temperature_archived - sharer.temperature_archived;
            abs_temperature_delta    = Math.Abs(Convert.ToDouble(temperature_delta));
            old_self_heat_capacity   = 0;
            old_sharer_heat_capacity = 0;

            if (abs_temperature_delta > 0.5)
            {
                old_self_heat_capacity   = this.heat_capacity();
                old_sharer_heat_capacity = sharer.heat_capacity();
            }
            heat_capacity_self_to_sharer = 0;
            heat_capacity_sharer_to_self = 0;
            moved_moles     = 0;
            abs_moved_moles = 0;

            foreach (dynamic _a in Lang13.Enumerate(sharer_gases - cached_gases))
            {
                id = _a;

                this.add_gas(id);
            }

            foreach (dynamic _b in Lang13.Enumerate(cached_gases))
            {
                id2 = _b;


                if (!Lang13.Bool(sharer_gases[id2]))
                {
                    sharer.add_gas(id2);
                }
                gas       = cached_gases[id2];
                sharergas = sharer_gases[id2];
                delta     = Num13.Round(Convert.ToDouble(gas[2] - sharergas[2]), 1.0000000116860974e-7) / ((atmos_adjacent_turfs ?? 0) + 1);

                if (delta != 0 && abs_temperature_delta > 0.5)
                {
                    gas_heat_capacity = delta * Convert.ToDouble(gas[3][1]);

                    if (delta > 0)
                    {
                        heat_capacity_self_to_sharer += gas_heat_capacity;
                    }
                    else
                    {
                        heat_capacity_sharer_to_self -= gas_heat_capacity;
                    }
                }
                gas[1]          -= delta;
                sharergas[1]    += delta;
                moved_moles     += delta;
                abs_moved_moles += Math.Abs(delta);
            }
            this.last_share = abs_moved_moles;

            if (abs_temperature_delta > 0.5)
            {
                new_self_heat_capacity   = old_self_heat_capacity + heat_capacity_sharer_to_self - heat_capacity_self_to_sharer;
                new_sharer_heat_capacity = old_sharer_heat_capacity + heat_capacity_self_to_sharer - heat_capacity_sharer_to_self;

                if (new_self_heat_capacity > 0.0003)
                {
                    this.temperature = (old_self_heat_capacity * Convert.ToDouble(this.temperature) - heat_capacity_self_to_sharer * Convert.ToDouble(this.temperature_archived) + heat_capacity_sharer_to_self * Convert.ToDouble(sharer.temperature_archived)) / new_self_heat_capacity;
                }

                if (new_sharer_heat_capacity > 0.0003)
                {
                    sharer.temperature = (old_sharer_heat_capacity * Convert.ToDouble(sharer.temperature) - heat_capacity_sharer_to_self * Convert.ToDouble(sharer.temperature_archived) + heat_capacity_self_to_sharer * Convert.ToDouble(this.temperature_archived)) / new_sharer_heat_capacity;

                    if (Math.Abs(old_sharer_heat_capacity) > 0.0003)
                    {
                        if (Math.Abs(new_sharer_heat_capacity / old_sharer_heat_capacity - 1) < 0.1)
                        {
                            this.temperature_share(sharer, 0.4);
                        }
                    }
                }
            }
            unique_gases = cached_gases ^ sharer_gases;

            if (unique_gases.len != 0)
            {
                this.garbage_collect(cached_gases - sharer_gases);
                sharer.garbage_collect(sharer_gases - cached_gases);
            }

            if (Convert.ToDouble(temperature_delta) > 393.41 || Math.Abs(moved_moles) > 0.5199189782142639)
            {
                delta_pressure = this.temperature_archived * (this.total_moles() + moved_moles) - sharer.temperature_archived * (sharer.total_moles() - moved_moles);
                return(delta_pressure * 8.31 / this.volume);
            }
            return(null);
        }
        // Function from file: mixer.dm
        public override int?process_atmos(  )
        {
            GasMixture air1 = null;
            GasMixture air2 = null;
            dynamic    air3 = null;
            dynamic    output_starting_pressure = null;
            double     pressure_delta           = 0;
            double     transfer_moles1          = 0;
            double     transfer_moles2          = 0;
            double     air1_moles = 0;
            double     air2_moles = 0;
            double     ratio      = 0;
            GasMixture removed1   = null;
            GasMixture removed2   = null;
            dynamic    parent1    = null;
            dynamic    parent2    = null;
            dynamic    parent3    = null;

            base.process_atmos();

            if (!this.on)
            {
                return(0);
            }

            if (!(Lang13.Bool(this.nodes[1]) && Lang13.Bool(this.nodes[2]) && Lang13.Bool(this.nodes[3])))
            {
                return(0);
            }
            air1 = this.airs[1];
            air2 = this.airs[2];
            air3 = this.airs[3];
            output_starting_pressure = air3.return_pressure();

            if (Convert.ToDouble(output_starting_pressure) >= this.target_pressure)
            {
                return(1);
            }
            pressure_delta  = this.target_pressure - Convert.ToDouble(output_starting_pressure);
            transfer_moles1 = 0;
            transfer_moles2 = 0;

            if (Convert.ToDouble(air1.temperature) > 0)
            {
                transfer_moles1 = this.node1_concentration * pressure_delta * Convert.ToDouble(air3.volume) / Convert.ToDouble(air1.temperature * 8.31);
            }

            if (Convert.ToDouble(air2.temperature) > 0)
            {
                transfer_moles2 = this.node2_concentration * pressure_delta * Convert.ToDouble(air3.volume) / Convert.ToDouble(air2.temperature * 8.31);
            }
            air1_moles = air1.total_moles();
            air2_moles = air2.total_moles();

            if (air1_moles < transfer_moles1 || air2_moles < transfer_moles2)
            {
                ratio = 0;

                if (transfer_moles1 > 0 && transfer_moles2 > 0)
                {
                    ratio = Num13.MinInt(((int)(air1_moles / transfer_moles1)), ((int)(air2_moles / transfer_moles2)));
                }

                if (transfer_moles2 == 0 && transfer_moles1 > 0)
                {
                    ratio = air1_moles / transfer_moles1;
                }

                if (transfer_moles1 == 0 && transfer_moles2 > 0)
                {
                    ratio = air2_moles / transfer_moles2;
                }
                transfer_moles1 *= ratio;
                transfer_moles2 *= ratio;
            }

            if (transfer_moles1 > 0)
            {
                removed1 = air1.remove(transfer_moles1);
                air3.merge(removed1);
            }

            if (transfer_moles2 > 0)
            {
                removed2 = air2.remove(transfer_moles2);
                air3.merge(removed2);
            }

            if (transfer_moles1 != 0)
            {
                parent1        = this.parents[1];
                parent1.update = GlobalVars.TRUE;
            }

            if (transfer_moles2 != 0)
            {
                parent2        = this.parents[2];
                parent2.update = GlobalVars.TRUE;
            }
            parent3        = this.parents[3];
            parent3.update = GlobalVars.TRUE;
            return(GlobalVars.TRUE);
        }
        // Function from file: vent_scrubber.dm
        public bool scrub(Ent_Static tile = null)
        {
            GasMixture environment     = null;
            dynamic    air_contents    = null;
            ByTable    env_gases       = null;
            int?       should_we_scrub = null;
            dynamic    id              = null;
            double     transfer_moles  = 0;
            dynamic    removed         = null;
            ByTable    removed_gases   = null;
            GasMixture filtered_out    = null;
            ByTable    filtered_gases  = null;
            double     transfer_moles2 = 0;
            dynamic    removed2        = null;


            if (!(tile is Tile_Simulated))
            {
                return(false);
            }
            environment  = tile.return_air();
            air_contents = this.airs[1];
            env_gases    = environment.gases;

            if ((((int)(this.scrubbing ?? 0)) & 1) != 0)
            {
                should_we_scrub = GlobalVars.FALSE;

                foreach (dynamic _a in Lang13.Enumerate(env_gases))
                {
                    id = _a;


                    if (id == "n2" || id == "o2")
                    {
                        continue;
                    }

                    if (Lang13.Bool(env_gases[id][1]))
                    {
                        should_we_scrub = GlobalVars.TRUE;
                        break;
                    }
                }

                if (Lang13.Bool(should_we_scrub))
                {
                    transfer_moles = Num13.MinInt(1, ((int)(this.volume_rate / (environment.volume ?? 0)))) * environment.total_moles();
                    removed        = tile.remove_air(transfer_moles);
                    removed_gases  = removed.gases;

                    if (removed == null)
                    {
                        return(false);
                    }
                    filtered_out             = new GasMixture();
                    filtered_gases           = filtered_out.gases;
                    filtered_out.temperature = removed.temperature;

                    if (Lang13.Bool(this.scrub_Toxins) && Lang13.Bool(removed_gases["plasma"]))
                    {
                        filtered_out.assert_gas("plasma");
                        filtered_gases["plasma"][1] = removed_gases["plasma"][1];
                        removed.gases["plasma"][1]  = 0;
                    }

                    if (Lang13.Bool(this.scrub_CO2) && Lang13.Bool(removed_gases["co2"]))
                    {
                        filtered_out.assert_gas("co2");
                        filtered_out.gases["co2"][1] = removed_gases["co2"][1];
                        removed.gases["co2"][1]      = 0;
                    }

                    if (Lang13.Bool(removed_gases["agent_b"]))
                    {
                        filtered_out.assert_gas("agent_b");
                        filtered_out.gases["agent_b"][1] = removed_gases["agent_b"][1];
                        removed.gases["agent_b"][1]      = 0;
                    }

                    if (Lang13.Bool(this.scrub_N2O) && Lang13.Bool(removed_gases["n2o"]))
                    {
                        filtered_out.assert_gas("n2o");
                        filtered_out.gases["n2o"][1] = removed_gases["n2o"][1];
                        removed.gases["n2o"][1]      = 0;
                    }
                    removed.garbage_collect();
                    air_contents.merge(filtered_out);
                    tile.assume_air(removed);
                    ((Tile)tile).air_update_turf();
                }
            }
            else
            {
                if (Convert.ToDouble(air_contents.return_pressure()) >= 5066.25)
                {
                    return(false);
                }
                transfer_moles2 = environment.total_moles() * (this.volume_rate / (environment.volume ?? 0));
                removed2        = tile.remove_air(transfer_moles2);
                air_contents.merge(removed2);
                ((Tile)tile).air_update_turf();
            }
            this.update_parents();
            return(true);
        }
Exemplo n.º 19
0
        // Function from file: scrubber.dm
        public void scrub(GasMixture mixture = null)
        {
            double     transfer_moles = 0;
            GasMixture filtering      = null;
            GasMixture filtered       = null;
            dynamic    gas            = null;

            transfer_moles = Num13.MinInt(1, ((int)(this.volume_rate / (mixture.volume ?? 0)))) * mixture.total_moles();
            filtering      = mixture.remove(transfer_moles);
            filtered       = new GasMixture();

            if (!(filtering != null))
            {
                return;
            }
            filtered.temperature = filtering.temperature;

            foreach (dynamic _a in Lang13.Enumerate(filtering.gases & this.scrubbing))
            {
                gas = _a;

                filtered.add_gas(gas);
                filtered.gases[gas][1]  = filtering.gases[gas][1];
                filtering.gases[gas][1] = 0;
            }
            filtering.garbage_collect();
            this.air_contents.merge(filtered);
            mixture.merge(filtering);

            if (!Lang13.Bool(this.holding))
            {
                this.air_update_turf();
            }
            return;
        }
        // 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);
        }