Ejemplo n.º 1
0
        // Function from file: magazines.dm
        public override int ammo_count(bool?countempties = null)
        {
            countempties = countempties ?? true;

            int boolets = 0;
            Obj_Item_AmmoCasing bullet = null;


            if (!(countempties == true))
            {
                boolets = 0;

                foreach (dynamic _a in Lang13.Enumerate(this.stored_ammo, typeof(Obj_Item_AmmoCasing)))
                {
                    bullet = _a;


                    if (Lang13.Bool(bullet.BB))
                    {
                        boolets++;
                    }
                }
                return(boolets);
            }
            else
            {
                return(base.ammo_count(countempties));
            }
        }
Ejemplo n.º 2
0
        // Function from file: magazines.dm
        public override bool give_round(dynamic R = null, bool?replace_spent = null)
        {
            replace_spent = replace_spent ?? false;

            double i = 0;
            Obj_Item_AmmoCasing bullet = null;


            if (!Lang13.Bool(R) || Lang13.Bool(this.caliber) && R.caliber != this.caliber || !Lang13.Bool(this.caliber) && R.type != this.ammo_type)
            {
                return(false);
            }

            foreach (dynamic _a in Lang13.IterateRange(1, this.stored_ammo.len))
            {
                i = _a;

                bullet = this.stored_ammo[i];

                if (!(bullet != null) || !Lang13.Bool(bullet.BB))
                {
                    this.stored_ammo[i] = R;
                    R.loc = this;

                    if (bullet != null)
                    {
                        bullet.loc = GlobalFuncs.get_turf(this.loc);
                    }
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        // Function from file: ammunition.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            silent        = silent ?? false;
            replace_spent = replace_spent ?? false;

            int                 num_loaded = 0;
            dynamic             AM         = null;
            Obj_Item_AmmoCasing AC         = null;
            bool                did_load   = false;
            dynamic             AC2        = null;

            num_loaded = 0;

            if (A is Obj_Item_AmmoBox)
            {
                AM = A;

                foreach (dynamic _a in Lang13.Enumerate(AM.stored_ammo, typeof(Obj_Item_AmmoCasing)))
                {
                    AC = _a;

                    did_load = this.give_round(AC, replace_spent);

                    if (did_load)
                    {
                        AM.stored_ammo.Remove(AC);
                        num_loaded++;
                    }

                    if (!did_load || !this.multiload)
                    {
                        break;
                    }
                }
            }

            if (A is Obj_Item_AmmoCasing)
            {
                AC2 = A;

                if (this.give_round(AC2, replace_spent))
                {
                    user.drop_item();
                    AC2.loc = this;
                    num_loaded++;
                }
            }

            if (num_loaded != 0)
            {
                if (!(silent == true))
                {
                    user.WriteMsg(new Txt("<span class='notice'>You load ").item(num_loaded).str(" shell").s().str(" into ").the(this).item().str("!</span>").ToString());
                }
                A.update_icon();
                this.update_icon();
            }
            return(num_loaded);
        }
Ejemplo n.º 4
0
        // Function from file: ammunition.dm
        public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null)
        {
            dynamic             box     = null;
            int                 boolets = 0;
            Obj_Item_AmmoCasing bullet  = null;


            if (A is Obj_Item_AmmoBox)
            {
                box = A;

                if (this.loc is Tile)
                {
                    boolets = 0;

                    foreach (dynamic _a in Lang13.Enumerate(this.loc, typeof(Obj_Item_AmmoCasing)))
                    {
                        bullet = _a;


                        if (box.stored_ammo.len >= (box.max_ammo ?? 0))
                        {
                            break;
                        }

                        if (Lang13.Bool(bullet.BB))
                        {
                            if (((Obj_Item_AmmoBox)box).give_round(bullet, false))
                            {
                                boolets++;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (boolets > 0)
                    {
                        box.update_icon();
                        user.WriteMsg(new Txt("<span class='notice'>You collect ").item(boolets).str(" shell").s().str(". ").item(box).str(" now contains ").item(box.stored_ammo.len).str(" shell").s().str(".</span>").ToString());
                    }
                    else
                    {
                        user.WriteMsg("<span class='warning'>You fail to collect anything!</span>");
                    }
                }
            }
            else
            {
                base.attackby((object)(A), (object)(user), _params, silent, replace_spent);
            }
            return(null);
        }
        // Function from file: shotgun.dm
        public virtual bool blow_up(dynamic user = null)
        {
            bool _default = false;

            Obj_Item_AmmoCasing AC = null;

            _default = false;

            foreach (dynamic _a in Lang13.Enumerate(this.magazine.stored_ammo, typeof(Obj_Item_AmmoCasing)))
            {
                AC = _a;


                if (Lang13.Bool(AC.BB))
                {
                    this.process_fire(user, user, false);
                    _default = true;
                }
            }
            return(_default);
        }
Ejemplo n.º 6
0
        // Function from file: ammunition.dm
        public virtual bool give_round(dynamic R = null, bool?replace_spent = null)
        {
            replace_spent = replace_spent ?? false;

            Obj_Item_AmmoCasing AC = null;


            if (!Lang13.Bool(R) || Lang13.Bool(this.caliber) && R.caliber != this.caliber || !Lang13.Bool(this.caliber) && R.type != this.ammo_type)
            {
                return(false);
            }

            if (this.stored_ammo.len < (this.max_ammo ?? 0))
            {
                this.stored_ammo.Add(R);
                R.loc = this;
                return(true);
            }
            else if (replace_spent == true)
            {
                foreach (dynamic _a in Lang13.Enumerate(this.stored_ammo, typeof(Obj_Item_AmmoCasing)))
                {
                    AC = _a;


                    if (!Lang13.Bool(AC.BB))
                    {
                        this.stored_ammo.Remove(AC);
                        AC.loc = GlobalFuncs.get_turf(this.loc);
                        this.stored_ammo.Add(R);
                        R.loc = this;
                        return(true);
                    }
                }
            }
            return(false);
        }