当前位置: 首页>>代码示例>>C#>>正文


C# CharData.GetObjHere方法代码示例

本文整理汇总了C#中MUDEngine.CharData.GetObjHere方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.GetObjHere方法的具体用法?C# CharData.GetObjHere怎么用?C# CharData.GetObjHere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MUDEngine.CharData的用法示例。


在下文中一共展示了CharData.GetObjHere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Zap

        /// <summary>
        /// Zap a wand, using its spell power.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Zap(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object wand = null;
            Object obj = null;
            CharData victim;
            int level;

            if (str.Length == 0 && ch.Fighting == null)
            {
                ch.SendText("Zap whom or what?\r\n");
                return;
            }

            if (!String.IsNullOrEmpty(str[0]) && !(wand = ch.GetObjWear(str[0])))
            {
                if (!(wand = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one)))
                {
                    ch.SendText("You hold nothing in your hand.\r\n");
                    return;
                }
            }
            else /* Wand was first argument.. arg is now second argument. */
            if (wand.ItemType != ObjTemplate.ObjectType.wand)
            {
                ch.SendText("You can zap only with a wand.\r\n");
                return;
            }

            level = wand.Level;
            if (String.IsNullOrEmpty(str[0]))
            {
                if (ch.Fighting != null)
                {
                    victim = ch.Fighting;
                }
                else
                {
                    ch.SendText("Zap whom or what?\r\n");
                    return;
                }
            }
            else
            {
                if (((victim = ch.GetCharRoom(str[0])) == null)
                        && (obj = ch.GetObjHere(str[0])) == null)
                {
                    ch.SendText("You can't find your _targetType.\r\n");
                    return;
                }
            }

            if (ch.IsNPC() && !ch.IsFreewilled())
            {
                SocketConnection.Act("You try to zap $p&n, but you have no free will.",
                     ch, wand, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n tries to zap $p&n, but has no free will.",
                     ch, wand, null, SocketConnection.MessageTarget.room);
                return;
            }

            String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(wand.Values[3]);
            if (String.IsNullOrEmpty(spellName))
            {
                ch.SendText("You try to zap, but your wand fizzles.\r\n");
                Log.Error("Zap: Spell number " + wand.Values[3] + " not found in SpellNumberToTextMap for object " + wand.ObjIndexNumber + ".");
                return;
            }

            Spell spell = StringLookup.SpellLookup(spellName);
            if (!spell)
            {
                ch.SendText("You try to zap, but your wand fizzles.\r\n");
                Log.Error("Zap: Spell '" + spellName + "' not found for object " + wand.ObjIndexNumber + ". Check that it exists in the spells file.");
                return;
            }

            ch.PracticeSkill("wands");

            if (wand.Values[2] > 0)
            {
                if (victim != null)
                {
                    if (victim == ch)
                    {
                        SocketConnection.Act("You zap yourself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n zaps $mself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.room);
                    }
                    else
                    {
                        SocketConnection.Act("You zap $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n zaps $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.room);
                    }
                }
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例2: Climb

        /// <summary>
        /// Command to climb something.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Climb(CharData ch, string[] str)
        {
            if( ch == null ) return;

            int chance;

            if (!ch.HasSkill("climb"))
            {
                ch.SendText("You lack the skills to climb anything.\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Climb what?\r\n");
                return;
            }

            Object obj = ch.GetObjHere(str[0]);
            if (!obj)
            {
                ch.SendText("Uhh... what exactly did you want to climb!?\r\n");
                return;
            }

            if (obj.ItemType != ObjTemplate.ObjectType.wall)
            {
                ch.SendText("That wasn't exactly designed for climbing.\r\n");
                return;
            }

            if (ch.IsNPC())
            {
                chance = ch.Level * 3 / 2 + 20;
            }
            else
            {
                chance = ((PC)ch).SkillAptitude["climb"];
            }

            // Agility helps.
            chance += ch.GetCurrAgi() / 10;

            switch (obj.ObjIndexData.IndexNumber)
            {
                case StaticObjects.OBJECT_NUMBER_WALL_STONE:
                    chance += 5;
                    break;
                case StaticObjects.OBJECT_NUMBER_WALL_IRON:
                    chance -= 15;
                    break;
                default:
                    ch.SendText("That wasn't exactly designed for climbing.\r\n");
                    return;
            }

            // Maximum chance of 98%
            if (chance > 98)
            {
                chance = 98;
            }

            if (MUDMath.NumberPercent() >= chance)
            {
                ch.SendText("You try to climb it, but you fall on your ass!\r\n");
                ch.CurrentPosition = Position.sitting;
                ch.WaitState(5);
                return;
            }

            ch.SendText("With great skill, you scale the wall!\r\n");

            // Value 0 of a wall object is the direction that has been walled...
            // This means that they should move in that direction.  We leave it up to
            // move_char to make sure that there is actually an exit in that direction.
            // we use the climbing bit to allow them to pass the walls in move_char.
            ch.SetAffectBit(Affect.AFFECT_CLIMBING);
            ch.Move((Exit.Direction)obj.Values[0]);
            ch.RemoveAffect(Affect.AFFECT_CLIMBING);

            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:87,代码来源:Command.cs

示例3: Unlock

        /// <summary>
        /// Unlock something, like a door or a container.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Unlock(CharData ch, string[] str)
        {
            if( ch == null ) return;
            string arg1 = String.Empty;
            Exit.Direction door;

            if (str.Length == 0)
            {
                ch.SendText("What do you wish to unlock?\r\n");
                return;
            }

            if (!MUDString.StringsNotEqual(str[0], "door") && arg1.Length != 0)
            {
                door = Movement.FindDoor(ch, arg1);
            }
            else
            {
                door = Movement.FindDoor(ch, str[0]);
            }

            if (door >= 0 && !(ch.Level < Limits.LEVEL_AVATAR && ch.InRoom.ExitData[(int)door] && ch.InRoom.ExitData[(int)door].ExitFlags != 0
                && ch.InRoom.ExitData[(int)door].HasFlag(Exit.ExitFlag.secret)))
            {
                /* 'unlock door' */
                Exit reverseExit;
                Room toRoom;

                Exit exit = ch.InRoom.GetExit(door);
                if (!exit.HasFlag(Exit.ExitFlag.closed))
                {
                    ch.SendText("It's not closed.\r\n");
                    return;
                }
                if (exit.Key < 0)
                {
                    ch.SendText("It can't be unlocked.\r\n");
                    return;
                }
                if (!ch.GetKey(exit.Key) && !ch.IsImmortal())
                {
                    ch.SendText("You lack the key.\r\n");
                    return;
                }
                if (!exit.HasFlag(Exit.ExitFlag.locked))
                {
                    ch.SendText("It's already unlocked.\r\n");
                    return;
                }

                exit.RemoveFlag(Exit.ExitFlag.locked);
                ch.SendText("*Click*\r\n");
                SocketConnection.Act("$n&n unlocks the $d.", ch, null, exit.Keyword, SocketConnection.MessageTarget.room);

                if (exit.HasFlag(Exit.ExitFlag.destroys_key))
                {
                    (ch.GetKey(exit.Key)).RemoveFromWorld();
                    SocketConnection.Act("The $d eats the key!", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("The $d eats the key!", ch, null, exit.Keyword, SocketConnection.MessageTarget.room);
                }

                /* unlock the other side */
                if ((toRoom = Room.GetRoom(exit.IndexNumber)) && (reverseExit = toRoom.GetExit(Exit.ReverseDirection(door)))
                    && reverseExit.TargetRoom == ch.InRoom)
                {
                    reverseExit.RemoveFlag(Exit.ExitFlag.locked);
                }

                return;
            }

            Object obj = ch.GetObjHere(str[0]);
            if (obj)
            {
                /* 'unlock portal' */
                if (obj.ItemType == ObjTemplate.ObjectType.portal)
                {
                    if (!Macros.IsSet(obj.Values[1], ObjTemplate.PORTAL_CLOSED))
                    {
                        ch.SendText("It's not closed.\r\n");
                        return;
                    }
                    if (obj.Values[4] < 0)
                    {
                        ch.SendText("It can't be unlocked.\r\n");
                        return;
                    }
                    if (!ch.GetKey(obj.Values[4]))
                    {
                        ch.SendText("You lack the key.\r\n");
                        return;
                    }
                    if (!Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_LOCKED))
                    {
                        ch.SendText("It's already unlocked.\r\n");
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例4: Carve

        /// <summary>
        /// Command for corpse carving.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Carve(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object weap;
            Race.Parts value;

            if (str.Length == 0)
            {
                ch.SendText("What do you want to carve?\r\n");
                return;
            }

            Object corpse = ch.GetObjHere(str[0]);
            if (!corpse)
            {
                ch.SendText("I don't see that around here.\r\n");
                return;
            }

            if (corpse.ItemType != ObjTemplate.ObjectType.pc_corpse)
            {
                ch.SendText("That's not a player corpse!\r\n");
                return;
            }

            if (str.Length < 2)
            {
                ch.SendText("Parts of that corpse that are left:\r\n");
                if (corpse.Values[0] == 0)
                {
                    ch.SendText("None.\r\n");
                }
                else
                {
                    ch.SendText(StringConversion.PartsBitString((Race.Parts)corpse.Values[0]));
                }
                return;
            }

            // 11 is for piercing eapons
            if (!(weap = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one)) || weap.Values[3] != 11)
            {
                ch.SendText("You need some sort of stabbing weapon for carving.\r\n");
                return;
            }

            if (!MUDString.StringsNotEqual(str[1], "head"))
                value = Race.Parts.skull;
            else if (!MUDString.StringsNotEqual(str[1], "arms"))
                value = Race.Parts.arms;
            else if (!MUDString.StringsNotEqual(str[1], "legs"))
                value = Race.Parts.legs;
            else if (!MUDString.StringsNotEqual(str[1], "heart"))
                value = Race.Parts.heart;
            else if (!MUDString.StringsNotEqual(str[1], "brains"))
                value = Race.Parts.brains;
            else if (!MUDString.StringsNotEqual(str[1], "guts"))
                value = Race.Parts.guts;
            else if (!MUDString.StringsNotEqual(str[1], "hands"))
                value = Race.Parts.hands;
            else if (!MUDString.StringsNotEqual(str[1], "feet"))
                value = Race.Parts.feet;
            else if (!MUDString.StringsNotEqual(str[1], "fingers"))
                value = Race.Parts.fingers;
            else if (!MUDString.StringsNotEqual(str[1], "ears"))
                value = Race.Parts.ears;
            else if (!MUDString.StringsNotEqual(str[1], "eyes"))
                value = Race.Parts.eyes;
            else if (!MUDString.StringsNotEqual(str[1], "tongue"))
                value = Race.Parts.tongue;
            else if (!MUDString.StringsNotEqual(str[1], "eyestalks"))
                value = Race.Parts.eyestalks;
            else if (!MUDString.StringsNotEqual(str[1], "tentacles"))
                value = Race.Parts.tentacles;
            else if (!MUDString.StringsNotEqual(str[1], "fins"))
                value = Race.Parts.fins;
            else if (!MUDString.StringsNotEqual(str[1], "wings"))
                value = Race.Parts.wings;
            else if (!MUDString.StringsNotEqual(str[1], "tail"))
                value = Race.Parts.tail;
            else if (!MUDString.StringsNotEqual(str[1], "claws"))
                value = Race.Parts.claws;
            else if (!MUDString.StringsNotEqual(str[1], "fangs"))
                value = Race.Parts.fangs;
            else if (!MUDString.StringsNotEqual(str[1], "scales"))
                value = Race.Parts.scales;
            else if (!MUDString.StringsNotEqual(str[1], "horns"))
                value = Race.Parts.horns;
            else if (!MUDString.StringsNotEqual(str[1], "tusks"))
                value = Race.Parts.tusks;
            else
            {
                ch.SendText("No such part.\r\n");
                return;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例5: Examine

        /// <summary>
        /// Like look, but more detailed.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Examine(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (str.Length == 0)
            {
                ch.SendText("&nWhat do you wish to examine?\r\n");
                return;
            }

            CommandType.Interpret(ch, "look " + str[0]);

            Object obj = ch.GetObjHere(str[0]);
            if (obj)
            {
                // Show material and condition.
                string text = String.Format("It appears to be made of {0}&n and is of {1} craftsmanship.\r\n",
                                            Material.Table[(int)obj.Material].Name, ObjTemplate.CraftsmanshipString(obj.Craftsmanship));
                ch.SendText(text);
                text = String.Format("It is in {0} percent condition.\r\n", obj.Condition);
                ch.SendText(text);
                if (obj.HasFlag(ObjTemplate.ITEM_NOSELL))
                {
                    text = String.Format("It doesn't appear to be worth much.\r\n");
                    ch.SendText(text);
                }
                switch (obj.ItemType)
                {
                    default:
                        break;
                    case ObjTemplate.ObjectType.drink_container:
                    case ObjTemplate.ObjectType.container:
                    case ObjTemplate.ObjectType.quiver:
                    case ObjTemplate.ObjectType.npc_corpse:
                    case ObjTemplate.ObjectType.pc_corpse:
                    case ObjTemplate.ObjectType.storage_chest:
                        ch.SendText("\r\n&nWhen you look inside, you see:\r\n");
                        ch.LookInContainer(str[0], false);
                        break;
                    case ObjTemplate.ObjectType.weapon:
                        text = String.Format("It is a weapon of type {0}.\r\n", ((ObjTemplate.WeaponType)(obj.Values[0])));
                        ch.SendText(text);
                        break;
                    case ObjTemplate.ObjectType.shield:
                        ch.SendText("&nIt is ");
                        if (obj.Values[5] > 0)
                            ch.SendText("\r\n&nIt is &+Lspiked&n.");
                        //buf = String.Format(  "{0}, and {1} in size.&n\r\n",
                        //  shield_thickness_string(obj.value[4]), shield_size_string(obj.value[2]));
                        //ch.SendText( buf );
                        break;
                    case ObjTemplate.ObjectType.armor:
                        text = String.Format("It can be worn on the {0}.", StringConversion.WearString(obj));
                        ch.SendText(text);
                        break;
                }

                // Show item level if eq restrictions are in effect - Xangis.
                if (Macros.IsSet((int)Database.SystemData.ActFlags, (int)Sysdata.MudFlags.levelrestrictedeq))
                {
                    if (obj.Level < 10)
                        ch.SendText("This is a piece of newbie equipment.\r\n");
                    else if (obj.Level < 25)
                        ch.SendText("This is a piece of low-level equipment.\r\n");
                    if (obj.Level < 40)
                        ch.SendText("This is a piece of mid-level equipment.\r\n");
                    else
                        ch.SendText("This is a piece of high-level equipment.\r\n");
                }
            }
            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:77,代码来源:Command.cs

示例6: ProcessSpellTargets


//.........这里部分代码省略.........
                                "self".Equals(argument, StringComparison.CurrentCultureIgnoreCase))
                        {
                            ch.SendText("You cannot cast this spell on another.\r\n");
                            return;
                        }

                        target = new Target(ch);
                        break;

                    case TargetType.objectInInventory:
                        if (String.IsNullOrEmpty(argument))
                        {
                            ch.SendText("What item should the spell be cast upon?\r\n");
                            return;
                        }

                        obj = ch.GetObjCarrying(argument);
                        if (obj == null)
                        {
                            ch.SendText("You are not carrying that.\r\n");
                            return;
                        }

                        target = new Target(obj);
                        break;

                    case TargetType.objectInRoom:
                        if (String.IsNullOrEmpty(argument))
                        {
                            ch.SendText("What should the spell be cast upon?\r\n");
                            return;
                        }

                        obj = ch.GetObjHere(argument);
                        if (obj == null)
                        {
                            ch.SendText("You do not see that here.\r\n");
                            return;
                        }

                        target = new Target(obj);
                        break;

                    case TargetType.objectCorpse:
                        target = new Target(argument);
                        break;
                    case TargetType.objectOrCharacter:
                        if (String.IsNullOrEmpty(argument))
                        {
                            if (ch.Fighting != null)
                                victim = ch.Fighting;
                            else
                            {
                                ch.SendText("Cast upon what?\r\n");
                                return;
                            }
                        }
                        else if (!(victim = ch.GetCharRoom(argument)))
                        {
                            obj = ch.GetObjHere(argument);
                        }

                        if (victim != null)
                        {
                            target = new Target(victim);
                        }
开发者ID:carriercomm,项目名称:ModernMUD,代码行数:67,代码来源:Magic.cs

示例7: Pour

        /// <summary>
        /// Pour a liquid.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Pour(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;
            string arg1 = String.Empty;
            string arg2 = String.Empty;

            if (ch.IsBlind())
                return;

            if (!(obj = ch.GetObjCarrying(arg1)))
            {
                ch.SendText("You do not have that item.\r\n");
                return;
            }

            if (obj.ItemType != ObjTemplate.ObjectType.drink_container)
            {
                ch.SendText("You can't fill that.\r\n");
                return;
            }

            if (!MUDString.StringsNotEqual("out", arg2))
            {
                ch.SendText("You pour it out.\r\n");
                obj.Values[1] = 0;
                return;
            }

            Object otherobj = ch.GetObjHere(arg2);
            if (!otherobj)
            {
                ch.SendText("Pour it where?\r\n");
                return;
            }

            if (otherobj.Values[2] != obj.Values[2] && otherobj.Values[1] != 0)
            {
                ch.SendText("It's got another liquid in it.\r\n");
                return;
            }

            SocketConnection.Act("You fill $p&n.", ch, otherobj, null, SocketConnection.MessageTarget.character);
            otherobj.Values[2] = obj.Values[2];
            otherobj.Values[1] += obj.Values[1];
            obj.Values[1] = 0;
            // Over pour in code => just pour it back in the first container.
            if (otherobj.Values[1] > otherobj.Values[0])
            {
                obj.Values[1] = otherobj.Values[1] - otherobj.Values[0];
                otherobj.Values[1] = otherobj.Values[0];
            }
            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:60,代码来源:Command.cs

示例8: Drag

        /// <summary>
        /// Used for dragging corpses into another room.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Drag(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;
            Object obj2;

            if (ch.IsAffected( Affect.AFFECT_HOLD) ||
                    ch.IsAffected(Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You can't move!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Drag which what where?\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("You need to specify a direction.\r\n");
                return;
            }

            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
            {
                ch.RemoveActionBit(PC.PLAYER_MEMORIZING);
                ch.SendText("You abandon your studies.\r\n");
            }

            if (!(obj = ch.GetObjHere(str[0])))
            {
                ch.SendText("You do not see that here.\r\n");
                return;
            }

            if (obj.ItemType != ObjTemplate.ObjectType.npc_corpse && obj.ItemType != ObjTemplate.ObjectType.pc_corpse)
            {
                ch.SendText("You can only drag corpses.\r\n");
                return;
            }

            if (str.Length > 2 && str[1] == "enter")
            {
                if ((obj2 = ch.GetObjHere(str[3])))
                {
                    switch (obj2.ItemType)
                    {
                        case ObjTemplate.ObjectType.teleport:
                        case ObjTemplate.ObjectType.portal:
                            if (obj2.ItemType == ObjTemplate.ObjectType.teleport && !CommandType.CheckCommandTrigger("enter", obj2.Values[1]))
                            {
                                ch.SendText("Nothing happens.\r\n");
                                return;
                            };
                            Room location;
                            if (Macros.IsSet(obj2.Values[3], ObjTemplate.PORTAL_RANDOM))
                            {
                                location = Movement.GetRandomRoom();
                            }
                            else
                            {
                                location = Room.GetRoom(obj2.Values[0]);
                            }
                            if (!location)
                            {
                                ch.SendText("That portal doesn't seem to go anywhere.\r\n");
                                return;
                            }
                            SocketConnection.Act("You drag the $p&n into $P&n.", ch, obj, obj2, SocketConnection.MessageTarget.character);
                            SocketConnection.Act("$n&n drags the $p&n into $P&n.", ch, obj, obj2, SocketConnection.MessageTarget.room);
                            if (obj2.Values[2] >= 0)
                            {
                                obj2.Values[2] -= 2;
                                if (obj2.Values[2] <= 0)
                                {
                                    SocketConnection.Act("$p&n fades into nothingness.", ch, obj2, null, SocketConnection.MessageTarget.room);
                                    obj2.RemoveFromRoom();
                                }
                            }
                            obj.RemoveFromRoom();
                            ch.RemoveFromRoom();
                            ch.AddToRoom(location);
                            obj.AddToRoom(location);
                            if (obj2.ItemType == ObjTemplate.ObjectType.portal)
                            {
                                SocketConnection.Act("$n&n steps out of $P&n dragging the $p&n.", ch, obj, obj2, SocketConnection.MessageTarget.room);
                            }
                            else
                            {
                                SocketConnection.Act("$n&n appears from elsewhere, dragging the $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                            }
                            CommandType.Interpret(ch, "look auto");
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例9: Open

        /// <summary>
        /// Command to open a door or a container.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Open(CharData ch, string[] str)
        {
            if( ch == null ) return;
            Object obj;
            Exit.Direction door;

            if (str.Length == 0 )
            {
                ch.SendText("What do you wish to open?\r\n");
                return;
            }

            if (!MUDString.StringsNotEqual(str[0], "door") && str.Length > 1 && str[1].Length > 0)
            {
                door = Movement.FindDoor(ch, str[1]);
            }
            else
            {
                door = Movement.FindDoor(ch, str[0]);
            }

            if (door != Exit.Direction.invalid && !(ch.Level < Limits.LEVEL_AVATAR
                && ch.InRoom.ExitData[(int)door] && ch.InRoom.ExitData[(int)door].ExitFlags != 0
                && ch.InRoom.ExitData[(int)door].HasFlag(Exit.ExitFlag.secret)))
            {
                /* 'open door' */
                Exit reverseExit;
                Room toRoom;

                if (ch.FlightLevel > 0)
                {
                    ch.SendText("You see no doors this high up!\r\n");
                    return;
                }
                if (ch.CurrentPosition == Position.fighting)
                {
                    ch.SendText("Stop fighting first!\r\n");
                    return;
                }
                Exit exit = ch.InRoom.GetExit(door);
                if (!exit.HasFlag(Exit.ExitFlag.closed))
                {
                    ch.SendText("It's already open.\r\n");
                    return;
                }
                if (exit.HasFlag(Exit.ExitFlag.locked))
                {
                    ch.SendText("It's locked.\r\n");
                    return;
                }

                exit.RemoveFlag(Exit.ExitFlag.closed);
                SocketConnection.Act("$n&n opens the $d.", ch, null, exit.Keyword, SocketConnection.MessageTarget.room);
                ch.SendText("Done.\r\n");

                /* open the other side */
                if ((toRoom = Room.GetRoom(exit.IndexNumber))
                    && (reverseExit = toRoom.GetExit(Exit.ReverseDirection(door)))
                    && reverseExit.TargetRoom == ch.InRoom)
                {
                    reverseExit.RemoveFlag(Exit.ExitFlag.closed);
                    reverseExit.RemoveFlag(Exit.ExitFlag.secret);
                    foreach (CharData roomChar in ch.InRoom.People)
                    {
                        SocketConnection.Act("The $d opens.", roomChar, null, reverseExit.Keyword, SocketConnection.MessageTarget.character);
                    }
                }

                return;
            }

            if ((obj = ch.GetObjHere(str[0])))
            {
                /* 'open portal' */
                if (obj.ItemType == ObjTemplate.ObjectType.portal)
                {
                    if (!Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_CLOSEABLE))
                    {
                        ch.SendText("You can't do that.\r\n");
                        return;
                    }
                    if (!Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_CLOSED))
                    {
                        ch.SendText("It's already open.\r\n");
                        return;
                    }
                    if (Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_LOCKED))
                    {
                        ch.SendText("It's locked.\r\n");
                        return;
                    }

                    Macros.RemoveBit(ref obj.Values[3], ObjTemplate.PORTAL_CLOSED);
                    ch.SendText("Done.\r\n");
                    SocketConnection.Act("$n&n opens $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例10: Pick

        /// <summary>
        /// Pick a lock.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Pick(CharData ch, string[] str)
        {
            if( ch == null ) return;
            Object obj;
            Exit.Direction door;

            if (str.Length == 0)
            {
                ch.SendText("Pick what, your nose?\r\n");
                return;
            }

            if (ch.Riding)
            {
                ch.SendText("You can't do that while mounted.\r\n");
                return;
            }

            ch.WaitState(Skill.SkillList["pick lock"].Delay);

            // Look for guards or other mobs who could be "in the way".
            foreach (CharData charData in ch.InRoom.People)
            {
                if (charData.IsNPC() && charData.IsAwake() && ch.Level + 5 < charData.Level)
                {
                    SocketConnection.Act("$N&n is standing too close to the lock.", ch, null, charData, SocketConnection.MessageTarget.character);
                    return;
                }
            }

            // Check skill roll for player, make sure mob isn't charmed.
            if ((!ch.IsNPC() && MUDMath.NumberPercent() > ((PC)ch).SkillAptitude["pick lock"])
                    || (ch.IsNPC() && ch.IsAffected( Affect.AFFECT_CHARM)))
            {
                ch.PracticeSkill("pick lock");
                ch.SendText("You failed.\r\n");
                return;
            }

            if ((door = Movement.FindDoor(ch, str[0])) >= 0)
            {
                /* 'pick door' */
                Exit reverseExit;
                Room toRoom;

                Exit exit = ch.InRoom.GetExit(door);
                if (!exit.HasFlag(Exit.ExitFlag.closed))
                {
                    ch.SendText("It's not closed.\r\n");
                    return;
                }
                if (exit.Key < 0)
                {
                    ch.SendText("It can't be picked.\r\n");
                    return;
                }
                if (!exit.HasFlag(Exit.ExitFlag.locked))
                {
                    ch.SendText("It's already unlocked.\r\n");
                    return;
                }
                if (exit.HasFlag(Exit.ExitFlag.pickproof))
                {
                    ch.SendText("You failed.\r\n");
                    return;
                }

                exit.RemoveFlag(Exit.ExitFlag.locked);
                ch.SendText("*Click*\r\n");
                SocketConnection.Act("$n&n picks the $d.", ch, null, exit.Keyword, SocketConnection.MessageTarget.room);

                /* pick the other side */
                if ((toRoom = Room.GetRoom(exit.IndexNumber)) && (reverseExit = toRoom.GetExit(Exit.ReverseDirection(door)))
                        && reverseExit.TargetRoom == ch.InRoom)
                {
                    reverseExit.RemoveFlag(Exit.ExitFlag.locked);
                }

                return;
            }

            if ((obj = ch.GetObjHere(str[0])))
            {
                /* 'pick portal' */
                if (obj.ItemType == ObjTemplate.ObjectType.portal)
                {
                    if (!Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_CLOSED))
                    {
                        ch.SendText("It's not closed.\r\n");
                        return;
                    }
                    if (obj.Values[4] < 0)
                    {
                        ch.SendText("It can't be unlocked.\r\n");
                        return;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例11: LookCommand


//.........这里部分代码省略.........
                    else if (exit.HasFlag(Exit.ExitFlag.blocked))
                        SocketConnection.Act("The $d is blocked.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                }
                else
                {
                    if (exit.HasFlag(Exit.ExitFlag.bashed))
                    {
                        SocketConnection.Act("The door has been bashed from its &n&+whinges&n.",
                             ch, null, null, SocketConnection.MessageTarget.character);
                    }
                    else if (exit.HasFlag(Exit.ExitFlag.closed))
                        SocketConnection.Act("The door is closed.", ch, null, null, SocketConnection.MessageTarget.character);
                    else if (exit.HasFlag(Exit.ExitFlag.is_door))
                        SocketConnection.Act("The door is open.", ch, null, null, SocketConnection.MessageTarget.character);
                    else if (exit.HasFlag(Exit.ExitFlag.secret))
                        SocketConnection.Act("The door is secret.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                    else if (exit.HasFlag(Exit.ExitFlag.blocked))
                        SocketConnection.Act("The $d is blocked.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                }
                // If exit found, don't keep looking.
                return;
            }

            // Look inside something ('look in').
            if (inside)
            {
                // 'look in'
                if (args.Count < 1)
                {
                    ch.SendText("Look in what?\r\n");
                    return;
                }

                obj = ch.GetObjHere(args[0]);
                if (!obj)
                {
                    ch.SendText("You do not see that here.\r\n");
                    return;
                }

                switch (obj.ItemType)
                {
                    default:
                        ch.SendText("That is not a container.\r\n");
                        break;

                    case ObjTemplate.ObjectType.drink_container:
                        if (obj.Values[1] == -1)
                        {
                            ch.SendText("It is full.\r\n");
                            break;
                        }

                        if (obj.Values[1] <= 0)
                        {
                            ch.SendText("It is empty.\r\n");
                            break;
                        }

                        output += "It's ";
                        if (obj.Values[1] < obj.Values[0] / 4)
                            output += "less than half";
                        else if (obj.Values[1] < (3 * obj.Values[0] / 4))
                            output += "about half";
                        else if (obj.Values[1] < obj.Values[0])
                            output += "more than half";
开发者ID:ramseur,项目名称:ModernMUD,代码行数:67,代码来源:Command.cs

示例12: Lock

        /// <summary>
        /// Lock something, like a door or a container.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Lock(CharData ch, string[] str)
        {
            if( ch == null ) return;
            Exit.Direction door;

            if (str.Length == 0)
            {
                ch.SendText("What do you wish to lock?\r\n");
                return;
            }

            if ((door = Movement.FindDoor(ch, str[0])) >= 0)
            {
                /* 'lock door' */
                Exit reverseExit;
                Room toRoom;

                Exit exit = ch.InRoom.GetExit(door);
                if (!exit.HasFlag(Exit.ExitFlag.closed))
                {
                    ch.SendText("It's not closed.\r\n");
                    return;
                }
                if (exit.Key < 0 && !ch.IsImmortal())
                {
                    ch.SendText("It can't be locked.\r\n");
                    return;
                }
                if (!ch.GetKey(exit.Key) && !ch.IsImmortal())
                {
                    ch.SendText("You lack the key.\r\n");
                    return;
                }
                if (exit.HasFlag(Exit.ExitFlag.locked))
                {
                    ch.SendText("It's already locked.\r\n");
                    return;
                }

                exit.AddFlag(Exit.ExitFlag.locked);
                ch.SendText("*Click*\r\n");
                SocketConnection.Act("$n&n locks the $d.", ch, null, exit.Keyword, SocketConnection.MessageTarget.room);

                /* lock the other side */
                if ((toRoom = Room.GetRoom(exit.IndexNumber)) && (reverseExit = toRoom.GetExit(Exit.ReverseDirection(door)))
                        && reverseExit.TargetRoom == ch.InRoom)
                {
                    reverseExit.AddFlag(Exit.ExitFlag.locked);
                }

                return;
            }

            Object obj = ch.GetObjHere(str[0]);
            if (obj)
            {
                /* 'lock portal' */
                if (obj.ItemType == ObjTemplate.ObjectType.portal)
                {
                    if (!Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_CLOSED))
                    {
                        ch.SendText("It's not closed.\r\n");
                        return;
                    }
                    if (obj.Values[4] < 0)
                    {
                        ch.SendText("It can't be locked.\r\n");
                        return;
                    }
                    if (!ch.GetKey(obj.Values[4]))
                    {
                        ch.SendText("You lack the key.\r\n");
                        return;
                    }
                    if (Macros.IsSet(obj.Values[3], ObjTemplate.PORTAL_LOCKED))
                    {
                        ch.SendText("It's already locked.\r\n");
                        return;
                    }

                    Macros.SetBit(ref obj.Values[3], ObjTemplate.PORTAL_LOCKED);
                    ch.SendText("*Click*\r\n");
                    SocketConnection.Act("$n&n locks $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
                    return;
                }

                /* 'lock object' */
                if (obj.ItemType != ObjTemplate.ObjectType.container)
                {
                    ch.SendText("That is not a container.\r\n");
                    return;
                }
                if (!Macros.IsSet(obj.Values[1], ObjTemplate.CONTAINER_CLOSED.Vector))
                {
                    ch.SendText("It's not closed.\r\n");
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例13: GetObjectInWorld

        /// <summary>
        /// Finds an object in the world based on a keyword.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="argument"></param>
        /// <returns></returns>
        public static Object GetObjectInWorld( CharData ch, string argument )
        {
            string arg = String.Empty;

            Object obj = ch.GetObjHere( argument );
            if( obj != null )
            {
                return obj;
            }

            int number = MUDString.NumberArgument( argument, ref arg );
            int count = 0;
            foreach( Object it in Database.ObjectList )
            {
                obj = it;
                if( CharData.CanSeeObj( ch, obj ) && MUDString.NameContainedIn( arg, obj._name ) )
                {
                    if( ++count == number )
                        return obj;
                }
            }

            count = 0;
            foreach( Object it in Database.ObjectList )
            {
                obj = it;
                if( CharData.CanSeeObj( ch, obj ) && MUDString.NameIsPrefixOfContents( arg, obj._name ) )
                {
                    if( ++count == number )
                        return obj;
                }
            }

            return null;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:41,代码来源:Object.cs

示例14: Clone

        /// <summary>
        /// Make a clone of something.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Clone(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string text;
            Object obj;
            CharData mob;

            if (str.Length == 0)
            {
                ch.SendText("Clone what?\r\n");
                return;
            }

            if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "object"))
            {
                mob = null;
                obj = ch.GetObjHere(str[1]);
                if (obj == null)
                {
                    ch.SendText("You don't see that here.\r\n");
                    return;
                }
            }
            else if (str.Length > 1 && !MUDString.IsPrefixOf(str[0], "mobile") || (!MUDString.IsPrefixOf(str[0], "character")))
            {
                obj = null;
                mob = ch.GetCharRoom(str[1]);
                if (mob == null)
                {
                    ch.SendText("You don't see that here.\r\n");
                    return;
                }
            }
            else
            {
                mob = ch.GetCharRoom(str[0]);
                obj = ch.GetObjHere(str[0]);
                if (mob == null && obj == null)
                {
                    ch.SendText("You don't see that here.\r\n");
                    return;
                }
            }

            /* clone object */
            if (obj != null)
            {
                Object clone = Database.CreateObject(obj.ObjIndexData, 0);
                Database.CloneObject(obj, ref clone);
                if (obj.CarriedBy != null)
                {
                    clone.ObjToChar(ch);
                }
                else
                {
                    clone.AddToRoom(ch.InRoom);
                }
                Object.RecursiveClone(ch, obj, clone);

                SocketConnection.Act("$n has created $p.", ch, clone, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("You clone $p.", ch, clone, null, SocketConnection.MessageTarget.character);
                text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription);
                ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text);
                return;
            }
            if (mob != null)
            {
                if (!mob.IsNPC())
                {
                    ch.SendText("You can only clone mobiles.\r\n");
                    return;
                }

                CharData clone = Database.CreateMobile(mob.MobileTemplate);
                Database.CloneMobile(mob, clone);

                foreach (Object obj2 in mob.Carrying)
                {
                    Object newObj = Database.CreateObject(obj2.ObjIndexData, 0);
                    Database.CloneObject(obj2, ref newObj);
                    Object.RecursiveClone(ch, obj2, newObj);
                    newObj.ObjToChar(clone);
                    newObj.WearLocation = obj2.WearLocation;
                }

                clone.AddToRoom(ch.InRoom);
                SocketConnection.Act("$n has created $N.", ch, null, clone, SocketConnection.MessageTarget.room);
                SocketConnection.Act("You clone $N.", ch, null, clone, SocketConnection.MessageTarget.character);
                text = String.Format("{0} clones {1}.", ch.Name, clone.ShortDescription);
                ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_LOAD, ch.GetTrust(), text);
                return;
            }
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:99,代码来源:Command.cs

示例15: Put

        /// <summary>
        /// Put an object into another object.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Put(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;

            if (str.Length < 2)
            {
                ch.SendText("Put what into what?\r\n");
                return;
            }

            if (!MUDString.StringsNotEqual(str[1], "all") || !MUDString.IsPrefixOf("all.", str[1]))
            {
                ch.SendText("You can't do that.\r\n");
                return;
            }

            Object container = ch.GetObjHere(str[1]);
            if (!container)
            {
                SocketConnection.Act("You see no $T&n here.", ch, null, str[1], SocketConnection.MessageTarget.character);
                return;
            }

            /*  Added put <missileweap> <quiver> */
            if (container.ItemType != ObjTemplate.ObjectType.container &&
                    container.ItemType != ObjTemplate.ObjectType.quiver)
            {
                ch.SendText("That's not a container.\r\n");
                return;
            }

            if (Macros.IsSet(container.Values[1], ObjTemplate.CONTAINER_CLOSED.Vector))
            {
                SocketConnection.Act("The $d&n is &n&+ystrapped&n shut.", ch, null, container.Name, SocketConnection.MessageTarget.character);
                return;
            }

            if (str[0] != "all" && MUDString.IsPrefixOf("all.", str[0]))
            {
                /* 'put obj container' */
                obj = ch.GetObjCarrying(str[0]);
                if (!obj)
                {
                    ch.SendText("You do not have that item.\r\n");
                    return;
                }

                if (obj == container)
                {
                    ch.SendText("You can't fold it into itself.\r\n");
                    return;
                }

                if (!ch.CanDropObject(obj))
                {
                    ch.SendText("You can't seem to let go of it.\r\n");
                    return;
                }

                if (obj.GetWeight() + container.GetWeight() - container.Weight > container.Values[0])
                {
                    ch.SendText("It won't fit.\r\n");
                    return;
                }

                /* Added put <missileweap> <quiver> */
                if (container.ItemType == ObjTemplate.ObjectType.quiver
                        && obj.ItemType != ObjTemplate.ObjectType.missile_weapon)
                {
                    SocketConnection.Act("$p&n doesn't belong in $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                    return;
                }

                obj.RemoveFromChar();
                container.AddToObject(obj);
                SocketConnection.Act("You put $p&n in $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n slips $p&n into $P&n.", ch, obj, container, SocketConnection.MessageTarget.room);
                if (obj.Trap != null && obj.Trap.CheckTrigger(Trap.TriggerType.get_put))
                {
                    ch.SetOffTrap(obj);
                }
            }
            else
            {
                /* 'put all container' or 'put all.obj container' */
                bool stuff = false;

                foreach (Object iobj in ch.Carrying)
                {
                    if (iobj.WearLocation != ObjTemplate.WearLocation.none)
                    {
                        continue;
                    }
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs


注:本文中的MUDEngine.CharData.GetObjHere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。