// Function from file: interactive.dm
        public override bool Life(  )
        {
            Obj_Item_Weapon_Grab G = null;
            dynamic Proc           = null;
            dynamic D   = null;
            Tile    T   = null;
            dynamic W   = null;
            dynamic C   = null;
            dynamic I   = null;
            dynamic STR = null;
            dynamic W2  = null;

            base.Life();

            if (this.isnotfunc())
            {
                Map13.Walk(this, 0, 0);
                return(false);
            }

            if (this.a_intent != "disarm")
            {
                this.a_intent = "disarm";
            }

            if (this.interest < 0 || this.inactivity_period < 0)
            {
                if (this.interest < 0)
                {
                    this.interest = 0;
                }

                if (this.inactivity_period < 0)
                {
                    this.inactivity_period = 0;
                }
            }

            if (this.interest > 100)
            {
                this.interest = 100;
            }
            this.nearby = new ByTable();

            if (!Lang13.Bool(this.l_hand) || !Lang13.Bool(this.r_hand))
            {
                this.update_hands = true;
            }

            if (this.update_hands)
            {
                if (Lang13.Bool(this.l_hand) || Lang13.Bool(this.r_hand))
                {
                    if (Lang13.Bool(this.l_hand))
                    {
                        this.hand      = true;
                        this.main_hand = this.l_hand;

                        if (Lang13.Bool(this.r_hand))
                        {
                            this.other_hand = this.r_hand;
                        }
                    }
                    else if (Lang13.Bool(this.r_hand))
                    {
                        this.hand      = false;
                        this.main_hand = this.r_hand;

                        if (Lang13.Bool(this.l_hand))
                        {
                            this.other_hand = this.l_hand;
                        }
                    }
                    this.update_icons();
                }
                this.update_hands = false;
            }

            if (this.grabbed_by.len > 0)
            {
                foreach (dynamic _a in Lang13.Enumerate(this.grabbed_by, typeof(Obj_Item_Weapon_Grab)))
                {
                    G = _a;


                    if (this.Adjacent(G))
                    {
                        this.a_intent = "disarm";
                        ((Ent_Static)G.assailant).attack_hand(this);
                        this.inactivity_period = 10;
                    }
                }
            }

            foreach (dynamic _b in Lang13.Enumerate(this.functions))
            {
                Proc = _b;


                if (!this.isnotfunc())
                {
                    this.callfunction(Proc);
                }
            }

            if (Lang13.Bool(this.TARGET) && Map13.FetchInView(null, 1).Contains(this.TARGET) || this.timeout >= 2)
            {
                if (Map13.FetchInView(this, 1).Contains(this.TARGET))
                {
                    this.doing |= 2;

                    if (this.TARGET is Obj_Machinery_Door)
                    {
                        D = this.TARGET;

                        if (((Obj)D).check_access(this.MYID) && !(D is Obj_Machinery_Door_Poddoor))
                        {
                            D.open();
                            Task13.Sleep(15);
                            T = Map13.GetStep(Map13.GetStep(D.loc, this.dir), this.dir);
                            this.tryWalk(T);
                        }
                    }

                    if (Rand13.PercentChance(this.slyness))
                    {
                        if (this.TARGET is Obj_Item_Weapon)
                        {
                            W = this.TARGET;

                            if (Convert.ToDouble(W.force) >= Convert.ToDouble(this.best_force) || Rand13.PercentChance(((int)(67.5))))
                            {
                                if (!Lang13.Bool(this.l_hand) || !Lang13.Bool(this.r_hand))
                                {
                                    this.take_to_slot(W);
                                }
                                else
                                {
                                    this.insert_into_backpack();
                                }
                            }
                        }

                        if (this.TARGET is Obj_Item_Clothing)
                        {
                            if (Rand13.PercentChance(((int)(67.5))))
                            {
                                if (!Lang13.Bool(this.l_hand) || !Lang13.Bool(this.r_hand))
                                {
                                    C = this.TARGET;
                                    this.take_to_slot(C);

                                    if (!this.equip_to_appropriate_slot(C))
                                    {
                                        I = this.get_item_by_slot(C);
                                        this.unEquip(I);
                                        this.equip_to_appropriate_slot(C);
                                    }
                                    this.update_hands = true;
                                    this.drop_item();

                                    if (Lang13.Bool(((dynamic)this.loc).Contains(((dynamic)(this.loc != null || this.MYID != null)).Contains(this.MYPDA))))
                                    {
                                        if (Lang13.Bool(((dynamic)this.loc).Contains(this.MYPDA)))
                                        {
                                            this.equip_to_appropriate_slot(this.MYPDA);
                                        }

                                        if (Lang13.Bool(((dynamic)this.loc).Contains(this.MYID)))
                                        {
                                            this.equip_to_appropriate_slot(this.MYID);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (this.TARGET is Obj_Structure)
                    {
                        STR = this.TARGET;

                        if (Lang13.Bool(this.main_hand))
                        {
                            W2 = this.main_hand;
                            ((Ent_Static)STR).attackby(W2, this);
                        }
                        else
                        {
                            ((Ent_Static)STR).attack_hand(this);
                        }
                    }
                }
                this.interest = this.interest + 25;
                this.doing    = this.doing & 65533;
                this.timeout  = 0;
                this.TARGET   = null;
            }
            else
            {
                this.tryWalk(this.TARGET);
                this.timeout++;
            }

            if (!(this.doing != 0))
            {
                this.interest--;
            }
            else
            {
                this.interest++;
            }

            if (this.inactivity_period > 0)
            {
                this.inactivity_period--;
            }

            if (!(this.doing != 0) && !this.isnotfunc() && !Lang13.Bool(this.TARGET))
            {
                this.doing |= 4;

                if (this.nearby.len > 4)
                {
                    this.TARGET = Rand13.PickFromTable(this.target_filter(GlobalFuncs.ultra_range(32, this, true)));
                }
                else if (Rand13.PercentChance(((int)(67.5))))
                {
                    this.TARGET = Lang13.FindIn(typeof(Obj_Item), GlobalFuncs.ultra_range(16, this, true));
                }
                else if (Rand13.PercentChance(((int)(67.5))))
                {
                    this.TARGET = Lang13.FindIn(typeof(Obj_Machinery_Door), GlobalFuncs.ultra_range(16, this, true));
                }
                else if (Rand13.PercentChance(((int)(67.5))))
                {
                    this.TARGET = Rand13.PickFromTable(this.target_filter(GlobalFuncs.ultra_range(16, this, true)));
                }
                else
                {
                    this.TARGET = GlobalFuncs.safepick(GlobalFuncs.get_area_turfs(this.job2area(this.myjob)));
                }
                this.tryWalk(this.TARGET);
            }
            this.LAST_TARGET = this.TARGET;
            return(false);
        }
Пример #2
0
        // Function from file: mob_grab.dm
        public override int?process(dynamic seconds = null)
        {
            dynamic G  = null;
            dynamic G2 = null;
            bool    h  = false;
            Obj_Item_Weapon_Grab G3 = null;
            Mob_Living           L  = null;


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

            if (Lang13.Bool(this.assailant.client))
            {
                this.assailant.client.screen -= this.hud;
                this.assailant.client.screen += this.hud;
            }

            if (this.assailant.pulling == this.affecting)
            {
                this.assailant.__CallVerb("Stop Pulling");
            }

            if (this.state <= 2)
            {
                this.allow_upgrade = true;

                if (Lang13.Bool(this.assailant.l_hand) && this.assailant.l_hand != this && this.assailant.l_hand is Obj_Item_Weapon_Grab)
                {
                    G = this.assailant.l_hand;

                    if (G.affecting != this.affecting)
                    {
                        this.allow_upgrade = false;
                    }
                }

                if (Lang13.Bool(this.assailant.r_hand) && this.assailant.r_hand != this && this.assailant.r_hand is Obj_Item_Weapon_Grab)
                {
                    G2 = this.assailant.r_hand;

                    if (G2.affecting != this.affecting)
                    {
                        this.allow_upgrade = false;
                    }
                }

                if (this.state == 2)
                {
                    h = this.affecting.hand;
                    this.affecting.hand = false;
                    this.affecting.drop_item();
                    this.affecting.hand = true;
                    this.affecting.drop_item();
                    this.affecting.hand = h;

                    foreach (dynamic _a in Lang13.Enumerate(this.affecting.grabbed_by, typeof(Obj_Item_Weapon_Grab)))
                    {
                        G3 = _a;


                        if (G3 == this)
                        {
                            continue;
                        }

                        if (G3.state == 2)
                        {
                            this.allow_upgrade = false;
                        }
                    }
                }

                if (this.allow_upgrade)
                {
                    this.hud.icon_state = "reinforce";
                }
                else
                {
                    this.hud.icon_state = "!reinforce";
                }
            }
            else if (!(this.affecting.buckled != null))
            {
                this.affecting.loc = this.assailant.loc;
            }

            if (this.state >= 3)
            {
                this.affecting.Stun(5);

                if (this.affecting is Mob_Living)
                {
                    L = this.affecting;
                    L.adjustOxyLoss(1);
                }
            }

            if (this.state >= 5)
            {
                this.affecting.Weaken(5);
                this.affecting.losebreath = Num13.MinInt(this.affecting.losebreath + 2, 3);
            }
            return(null);
        }