Пример #1
0
        // Function from file: slotmachine.dm
        public override double emp_act(int severity = 0)
        {
            int severity_ascending = 0;


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

            if (Rand13.PercentChance(severity * 15))
            {
                return(0);
            }

            if (Rand13.PercentChance(1))
            {
                this.emagged = 1;
            }
            severity_ascending = 4 - severity;
            this.money         = Num13.MaxInt(Rand13.Int(this.money - severity_ascending * 200, this.money + severity_ascending * 200), 0);
            this.balance       = Num13.MaxInt(Rand13.Int(((int)(this.balance - severity_ascending * 50)), ((int)(this.balance + severity_ascending * 50))), 0);
            this.money        -= Num13.MaxInt(0, Convert.ToInt32(this.give_coins(Num13.Min(Rand13.Int(-50, severity_ascending * 100)))));
            this.spin();
            return(0);
        }
Пример #2
0
        // Function from file: holder.dm
        public bool handle_reactions(  )
        {
            bool    reaction_occured = false;
            dynamic reagent          = null;
            dynamic R        = null;
            dynamic reaction = null;
            dynamic C        = null;
            int     total_required_reagents  = 0;
            int     total_matching_reagents  = 0;
            int     total_required_catalysts = 0;
            int     total_matching_catalysts = 0;
            bool    matching_container       = false;
            bool    matching_other           = false;
            ByTable multipliers    = null;
            dynamic required_temp  = null;
            dynamic B              = null;
            dynamic B2             = null;
            dynamic M              = null;
            dynamic multiplier     = null;
            dynamic B3             = null;
            double? created_volume = null;
            ByTable seen           = null;
            dynamic M2             = null;
            dynamic ME2            = null;
            dynamic M3             = null;


            if (Lang13.Bool(this.my_atom.flags & 16384))
            {
                return(false);
            }
            reaction_occured = false;

            do
            {
                reaction_occured = false;

                foreach (dynamic _g in Lang13.Enumerate(this.reagent_list))
                {
                    reagent = _g;

                    R = reagent;

                    foreach (dynamic _f in Lang13.Enumerate(GlobalVars.chemical_reactions_list[R.id]))
                    {
                        reaction = _f;


                        if (!Lang13.Bool(reaction))
                        {
                            continue;
                        }
                        C = reaction;
                        total_required_reagents  = C.required_reagents.len;
                        total_matching_reagents  = 0;
                        total_required_catalysts = C.required_catalysts.len;
                        total_matching_catalysts = 0;
                        matching_container       = false;
                        matching_other           = false;
                        multipliers   = new ByTable();
                        required_temp = C.required_temp;

                        foreach (dynamic _a in Lang13.Enumerate(C.required_reagents))
                        {
                            B = _a;


                            if (!Lang13.Bool(this.has_reagent(B, Lang13.DoubleNullable(C.required_reagents[B]))))
                            {
                                break;
                            }
                            total_matching_reagents++;
                            multipliers.Add(Num13.Floor((this.get_reagent_amount(B) ?1:0) / Convert.ToDouble(C.required_reagents[B])));
                        }

                        foreach (dynamic _b in Lang13.Enumerate(C.required_catalysts))
                        {
                            B2 = _b;


                            if (!Lang13.Bool(this.has_reagent(B2, Lang13.DoubleNullable(C.required_catalysts[B2]))))
                            {
                                break;
                            }
                            total_matching_catalysts++;
                        }

                        if (!(C.required_container != null))
                        {
                            matching_container = true;
                        }
                        else if (this.my_atom.type == C.required_container)
                        {
                            matching_container = true;
                        }

                        if (this.my_atom is Mob_Living)
                        {
                            if (C.mob_react)
                            {
                                return(false);
                            }
                        }

                        if (!C.required_other)
                        {
                            matching_other = true;
                        }
                        else if (this.my_atom is Obj_Item_SlimeExtract)
                        {
                            M = this.my_atom;

                            if (M.Uses > 0)
                            {
                                matching_other = true;
                            }
                        }

                        if (required_temp == 0)
                        {
                            required_temp = this.chem_temp;
                        }

                        if (total_matching_reagents == total_required_reagents && total_matching_catalysts == total_required_catalysts && matching_container && matching_other && Convert.ToDouble(this.chem_temp) >= Convert.ToDouble(required_temp))
                        {
                            multiplier = Num13.Min(multipliers);

                            foreach (dynamic _c in Lang13.Enumerate(C.required_reagents))
                            {
                                B3 = _c;

                                this.remove_reagent(B3, multiplier * C.required_reagents[B3], true);
                            }
                            created_volume = C.result_amount * Convert.ToDouble(multiplier);

                            if (Lang13.Bool(C.result))
                            {
                                GlobalFuncs.feedback_add_details("chemical_reaction", "" + C.result + "|" + C.result_amount * Convert.ToDouble(multiplier));
                                multiplier = Num13.MaxInt(Convert.ToInt32(multiplier), 1);
                                this.add_reagent(C.result, C.result_amount * Convert.ToDouble(multiplier), null, this.chem_temp);
                            }
                            seen = Map13.FetchViewers(GlobalFuncs.get_turf(this.my_atom), 4);

                            if (!(this.my_atom is Mob))
                            {
                                GlobalFuncs.playsound(GlobalFuncs.get_turf(this.my_atom), "sound/effects/bubbles.ogg", 80, 1);

                                foreach (dynamic _d in Lang13.Enumerate(seen))
                                {
                                    M2 = _d;

                                    M2.WriteMsg(new Txt("<span class='notice'>").icon(this.my_atom).str(" ").item(C.mix_message).str("</span>").ToString());
                                }
                            }

                            if (this.my_atom is Obj_Item_SlimeExtract)
                            {
                                ME2 = this.my_atom;
                                ME2.Uses--;

                                if (ME2.Uses <= 0)
                                {
                                    foreach (dynamic _e in Lang13.Enumerate(seen))
                                    {
                                        M3 = _e;

                                        M3.WriteMsg(new Txt("<span class='notice'>").icon(this.my_atom).str(" ").The(this.my_atom).item().str("'s power is consumed in the reaction.</span>").ToString());
                                        ME2.name = "used slime extract";
                                        ME2.desc = "This extract has been used up.";
                                    }
                                }
                            }
                            ((ChemicalReaction)C).on_reaction(this, created_volume);
                            reaction_occured = true;
                            break;
                        }
                    }
                }
            } while (reaction_occured);
            this.update_total();
            return(false);
        }