Esempio n. 1
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);
        }
Esempio n. 2
0
        // Function from file: heat_exchanger.dm
        public override int?process_atmos(  )
        {
            GasMixture air_contents            = null;
            GasMixture partner_air_contents    = null;
            double     air_heat_capacity       = 0;
            double     other_air_heat_capacity = 0;
            double     combined_heat_capacity  = 0;
            dynamic    old_temperature         = null;
            dynamic    other_old_temperature   = null;
            dynamic    combined_energy         = null;
            dynamic    new_temperature         = null;

            base.process_atmos();

            if (!(this.partner != null))
            {
                return(0);
            }

            if (GlobalVars.SSair.times_fired <= this.update_cycle)
            {
                return(0);
            }
            this.update_cycle         = GlobalVars.SSair.times_fired;
            this.partner.update_cycle = GlobalVars.SSair.times_fired;
            air_contents            = this.airs[1];
            partner_air_contents    = this.partner.airs[1];
            air_heat_capacity       = air_contents.heat_capacity();
            other_air_heat_capacity = partner_air_contents.heat_capacity();
            combined_heat_capacity  = other_air_heat_capacity + air_heat_capacity;
            old_temperature         = air_contents.temperature;
            other_old_temperature   = partner_air_contents.temperature;

            if (combined_heat_capacity > 0)
            {
                combined_energy                  = partner_air_contents.temperature * other_air_heat_capacity + air_heat_capacity * Convert.ToDouble(air_contents.temperature);
                new_temperature                  = combined_energy / combined_heat_capacity;
                air_contents.temperature         = new_temperature;
                partner_air_contents.temperature = new_temperature;
            }

            if (Math.Abs(Convert.ToDouble(old_temperature - air_contents.temperature)) > 1)
            {
                this.update_parents();
            }

            if (Math.Abs(Convert.ToDouble(other_old_temperature - partner_air_contents.temperature)) > 1)
            {
                this.partner.update_parents();
            }
            return(1);
        }
Esempio n. 3
0
        // Function from file: cryo.dm
        public override int?process_atmos(  )
        {
            GasMixture air1            = null;
            dynamic    cold_protection = null;
            dynamic    H = null;
            dynamic    temperature_delta = null;
            double     air_heat_capacity = 0;
            double     heat = 0;

            base.process_atmos();

            if (!Lang13.Bool(this.on))
            {
                return(null);
            }
            air1 = this.airs[1];

            if (!Lang13.Bool(this.nodes[1]) || !Lang13.Bool(this.airs[1]) || Convert.ToDouble(air1.gases["o2"][1]) < 5)
            {
                this.on = GlobalVars.FALSE;
                this.update_icon();
                return(null);
            }

            if (Lang13.Bool(this.occupant))
            {
                cold_protection = 0;
                H = this.occupant;

                if (H is Mob_Living_Carbon_Human)
                {
                    cold_protection = ((Mob_Living_Carbon_Human)H).get_cold_protection(air1.temperature);
                }
                temperature_delta = air1.temperature - this.occupant.bodytemperature;

                if (Math.Abs(Convert.ToDouble(temperature_delta)) > 1)
                {
                    air_heat_capacity = air1.heat_capacity();
                    heat             = ((1 - Convert.ToDouble(cold_protection)) / 10 + Convert.ToDouble(this.conduction_coefficient)) * Convert.ToDouble(temperature_delta) * (air_heat_capacity * Convert.ToDouble(this.heat_capacity) / (air_heat_capacity + Convert.ToDouble(this.heat_capacity)));
                    air1.temperature = Num13.MaxInt(Convert.ToInt32(air1.temperature - heat / air_heat_capacity), ((int)(2.7)));
                    this.occupant.bodytemperature = Num13.MaxInt(Convert.ToInt32(this.occupant.bodytemperature + heat / Convert.ToDouble(this.heat_capacity)), ((int)(2.7)));
                }
                air1.gases["o2"][1] -= 0.5 / Convert.ToDouble(this.efficiency);
            }
            return(null);
        }
Esempio n. 4
0
        // Function from file: he_pipes.dm
        public override int?process_atmos(  )
        {
            dynamic    environment_temperature = null;
            GasMixture pipe_air    = null;
            Ent_Static T           = null;
            GasMixture environment = null;
            double     hc          = 0;
            dynamic    avg_temp    = null;

            environment_temperature = 0;
            pipe_air = this.return_air();
            T        = this.loc;

            if (T is Tile_Simulated)
            {
                if (Lang13.Bool(((dynamic)T).blocks_air))
                {
                    environment_temperature = ((dynamic)T).temperature;
                }
                else
                {
                    environment             = T.return_air();
                    environment_temperature = environment.temperature;
                }
            }
            else
            {
                environment_temperature = ((dynamic)T).temperature;
            }

            if (Math.Abs(Convert.ToDouble(environment_temperature - pipe_air.temperature)) > this.minimum_temperature_difference)
            {
                this.parent.temperature_interact(T, this.volume, this.thermal_conductivity);
            }

            if (Lang13.Bool(this.buckled_mob))
            {
                hc                               = pipe_air.heat_capacity();
                avg_temp                         = (pipe_air.temperature * hc + this.buckled_mob.bodytemperature * 3500) / (hc + 3500);
                pipe_air.temperature             = avg_temp;
                this.buckled_mob.bodytemperature = avg_temp;
            }
            return(null);
        }
Esempio n. 5
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;
        }
Esempio n. 6
0
        // Function from file: thermomachine.dm
        public override int?process_atmos(  )
        {
            GasMixture air_contents           = null;
            double     air_heat_capacity      = 0;
            double     combined_heat_capacity = 0;
            dynamic    old_temperature        = null;
            double     combined_energy        = 0;
            double     temperature_delta      = 0;

            base.process_atmos();

            if (!this.on || !Lang13.Bool(this.nodes[1]))
            {
                return(null);
            }
            air_contents           = this.airs[1];
            air_heat_capacity      = air_contents.heat_capacity();
            combined_heat_capacity = this.heat_capacity + air_heat_capacity;
            old_temperature        = air_contents.temperature;

            if (combined_heat_capacity > 0)
            {
                combined_energy          = this.heat_capacity * this.target_temperature + air_heat_capacity * Convert.ToDouble(air_contents.temperature);
                air_contents.temperature = combined_energy / combined_heat_capacity;
            }
            temperature_delta = Math.Abs(Convert.ToDouble(old_temperature - air_contents.temperature));

            if (temperature_delta > 1)
            {
                this.active_power_usage = this.heat_capacity * temperature_delta / 10 + this.idle_power_usage;
                this.update_parents();
            }
            else
            {
                this.active_power_usage = this.idle_power_usage;
            }
            return(1);
        }
        // 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;
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        // Function from file: spaceheater.dm
        public override int?process(dynamic seconds = null)
        {
            Ent_Static L                = null;
            GasMixture env              = null;
            string     newMode          = null;
            double     heat_capacity    = 0;
            double     requiredPower    = 0;
            double     deltaTemperature = 0;


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

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

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

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

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

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

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

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

                if (deltaTemperature != 0)
                {
                    env.temperature += deltaTemperature;
                    this.air_update_turf();
                }
                this.cell.use(requiredPower / this.efficiency);
            }
            else
            {
                this.on = GlobalVars.FALSE;
                this.update_icon();
            }
            return(null);
        }