コード例 #1
0
        // Function from file: summonitem.dm
        public override bool cast(dynamic targets = null, dynamic thearea = null, dynamic user = null)
        {
            thearea = thearea ?? Task13.User;

            Mob_Living L                  = null;
            ByTable    hand_items         = null;
            bool       butterfingers      = false;
            string     message            = null;
            Obj        item               = null;
            Ent_Static item_to_retrive    = null;
            int        infinite_recursion = 0;
            Ent_Static organ              = null;
            Ent_Static M                  = null;
            Ent_Static C                  = null;
            Ent_Static P                  = null;


            foreach (dynamic _b in Lang13.Enumerate(targets, typeof(Mob_Living)))
            {
                L = _b;

                hand_items    = new ByTable(new object [] { L.get_active_hand(), L.get_inactive_hand() });
                butterfingers = false;
                message       = null;

                if (!(this.marked_item != null))
                {
                    message = "<span class='notice'>";

                    foreach (dynamic _a in Lang13.Enumerate(hand_items, typeof(Obj)))
                    {
                        item = _a;


                        if (Lang13.Bool(item.flags.Contains(128)))
                        {
                            continue;
                        }

                        if (Lang13.Bool(item.flags.Contains(2)))
                        {
                            message += "Though it feels redundant, ";
                        }
                        this.marked_item = item;
                        message         += "You mark " + item + " for recall.</span>";
                        this.name        = "Recall " + item;
                        break;
                    }

                    if (!(this.marked_item != null))
                    {
                        if (hand_items != null)
                        {
                            message = "<span class='caution'>You aren't holding anything that can be marked for recall.</span>";
                        }
                        else
                        {
                            message = "<span class='notice'>You must hold the desired item in your hands to mark it for recall.</span>";
                        }
                    }
                }
                else if (hand_items.Contains(this.marked_item != null && this.marked_item != null))
                {
                    message          = "<span class='notice'>You remove the mark on " + this.marked_item + " to use elsewhere.</span>";
                    this.name        = "Instant Summons";
                    this.marked_item = null;
                }
                else if (this.marked_item != null && Lang13.Bool(this.marked_item.gc_destroyed))
                {
                    message          = "<span class='warning'>You sense your marked item has been destroyed!</span>";
                    this.name        = "Instant Summons";
                    this.marked_item = null;
                }
                else
                {
                    item_to_retrive    = this.marked_item;
                    infinite_recursion = 0;

                    if (!(item_to_retrive.loc != null))
                    {
                        if (GlobalFuncs.isorgan(item_to_retrive))
                        {
                            organ = item_to_retrive;

                            if (Lang13.Bool(((dynamic)organ).owner))
                            {
                                GlobalFuncs.add_logs(L, ((dynamic)organ).owner, "magically removed " + organ.name + " from", null, "INTENT: " + String13.ToUpper(L.a_intent));
                                ((dynamic)organ).Remove(((dynamic)organ).owner);
                            }
                        }
                    }
                    else
                    {
                        while (!(item_to_retrive.loc is Tile) && infinite_recursion < 10)
                        {
                            if (item_to_retrive.loc is Mob)
                            {
                                M = item_to_retrive.loc;

                                if (M is Mob_Living_Silicon)
                                {
                                    M.loc.visible_message("<span class='warning'>" + M + " suddenly disappears!</span>");
                                    M.loc = L.loc;
                                    M.loc.visible_message("<span class='caution'>" + M + " suddenly appears!</span>");
                                    item_to_retrive = null;
                                    break;
                                }
                                ((Mob)M).unEquip(item_to_retrive);

                                if (M is Mob_Living_Carbon)
                                {
                                    C = M;

                                    if (Lang13.Bool(((dynamic)C).stomach_contents.Contains(Lang13.Bool(((dynamic)C).stomach_contents) && item_to_retrive != null)))
                                    {
                                        ((dynamic)C).stomach_contents -= item_to_retrive;
                                    }
                                }
                            }
                            else
                            {
                                if (item_to_retrive.loc is Obj_Machinery_PortableAtmospherics)
                                {
                                    P = item_to_retrive.loc;
                                    ((dynamic)P).disconnect();
                                    ((dynamic)P).update_icon();
                                }
                                item_to_retrive = item_to_retrive.loc;
                            }
                            infinite_recursion += 1;
                        }
                    }

                    if (!(item_to_retrive != null))
                    {
                        return(false);
                    }

                    if (item_to_retrive.loc != null)
                    {
                        item_to_retrive.loc.visible_message("<span class='warning'>The " + item_to_retrive.name + " suddenly disappears!</span>");
                    }

                    if (L.hand)
                    {
                        if (!L.equip_to_slot_if_possible(item_to_retrive, 4, false, true, true))
                        {
                            if (!L.equip_to_slot_if_possible(item_to_retrive, 5, false, true, true))
                            {
                                butterfingers = true;
                            }
                        }
                    }
                    else if (!L.equip_to_slot_if_possible(item_to_retrive, 5, false, true, true))
                    {
                        if (!L.equip_to_slot_if_possible(item_to_retrive, 4, false, true, true))
                        {
                            butterfingers = true;
                        }
                    }

                    if (butterfingers)
                    {
                        item_to_retrive.loc = L.loc;
                        item_to_retrive.loc.visible_message("<span class='caution'>The " + item_to_retrive.name + " suddenly appears!</span>");
                        GlobalFuncs.playsound(GlobalFuncs.get_turf(L), "sound/magic/SummonItems_generic.ogg", 50, 1);
                    }
                    else
                    {
                        item_to_retrive.loc.visible_message("<span class='caution'>The " + item_to_retrive.name + " suddenly appears in " + L + "'s hand!</span>");
                        GlobalFuncs.playsound(GlobalFuncs.get_turf(L), "sound/magic/SummonItems_generic.ogg", 50, 1);
                    }
                }

                if (Lang13.Bool(message))
                {
                    L.WriteMsg(message);
                }
            }
            return(false);
        }