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


C# CharData.GetObjCarrying方法代码示例

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


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

示例1: Fill

        public static void Fill(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object fountain = null;

            if (ch.IsBlind())
            {
                ch.SendText("You can't see what you're trying to fill.\r\n");
                return;
            }

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

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

            bool found = false;
            foreach (Object fount in ch.InRoom.Contents)
            {
                if (fount.FlyLevel != ch.FlightLevel)
                    continue;
                if (fount.ItemType == ObjTemplate.ObjectType.drink_container)
                {
                    fountain = fount;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                ch.SendText("There is nothing to fill from here!\r\n");
                return;
            }

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

            if (obj.Values[1] != 0 && obj.Values[2] != fountain.Values[2])
            {
                ch.SendText("There is already another liquid in it.\r\n");
                return;
            }

            if (obj.Values[1] >= obj.Values[0])
            {
                ch.SendText("Your container is full.\r\n");
                return;
            }

            SocketConnection.Act("You fill $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
            obj.Values[2] = fountain.Values[2];
            obj.Values[1] = obj.Values[0];
            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:67,代码来源:Command.cs

示例2: Drop


//.........这里部分代码省略.........
                else
                {
                    ch.SendText("They haven't minted that type of &+Lcoin&n yet.\r\n");
                    return;
                }

                /* Disabled merging of coin types.  This should eventually be re-enabled
                for ( obj = ch.in_room.contents; obj; obj = obj_next )
                {
                obj_next = obj.next_content;

                switch ( obj.pIndexData.vnum )
                {
                case StaticObjects.OBJECT_NUMBER_MONEY_ONE:
                amount += 1;
                obj.ExtractFromWorld();;
                break;

                case StaticObjects.OBJECT_NUMBER_MONEY_SOME:
                amount += obj.value[0];
                obj.ExtractFromWorld();;
                break;
                }
                }
                */
                ch.SendText("Done.\r\n");
                SocketConnection.Act("$n&n drops some &n&+wcoins&n.", ch, null, null, SocketConnection.MessageTarget.room);
                return;
            }

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

                if (!ch.CanDropObject(iobj))
                {
                    ch.SendText("You can't release your grip on it.\r\n");
                    return;
                }

                iobj.RemoveFromChar();
                iobj.AddToRoom(ch.InRoom);

                // Prevent item duping - Xangis
                CharData.SavePlayer(ch);

                iobj.FlyLevel = ch.FlightLevel;
                SocketConnection.Act("You drop $p&n.", ch, iobj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n discards $p&n.", ch, iobj, null, SocketConnection.MessageTarget.room);
                if (iobj.HasFlag(ObjTemplate.ITEM_TRANSIENT))
                {
                    SocketConnection.Act("$p&n crumbles to dust.", ch, iobj, null, SocketConnection.MessageTarget.all);
                    iobj.RemoveFromWorld();
                }
                else if (ch.InRoom.TerrainType == TerrainType.lava && !iobj.HasFlag(ObjTemplate.ITEM_NOBURN))
                {
                    SocketConnection.Act("$p&n melts as it sinks into the &+RLava&n.", ch, iobj, null, SocketConnection.MessageTarget.all);
                    if (!ch.IsNPC())
                    {
                        ((PC)ch).Destroyed.AddItem(iobj);
开发者ID:ramseur,项目名称:ModernMUD,代码行数:67,代码来源:Command.cs

示例3: Eat

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

            Object obj;

            if (ch.IsBlind())
                return;

            if (ch.Fighting || ch.CurrentPosition == Position.fighting)
            {
                ch.SendText("You can't eat while you're fighting!\r\n");
                return;
            }

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

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

            if (!ch.IsImmortal())
            {
                if (obj.ItemType != ObjTemplate.ObjectType.food && obj.ItemType != ObjTemplate.ObjectType.pill)
                {
                    ch.SendText("That's not edible.\r\n");
                    return;
                }

                if (!ch.IsNPC() && ((PC)ch).Hunger > 40)
                {
                    ch.SendText("You are too full to eat more.\r\n");
                    return;
                }
            }

            SocketConnection.Act("You consume $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n inhales $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);

            switch (obj.ItemType)
            {

                case ObjTemplate.ObjectType.food:
                    if (!ch.IsNPC())
                    {
                        int condition = ((PC)ch).Hunger;
                        if (!ch.IsUndead())
                        {
                            ch.AdjustHunger(obj.Values[0]);
                        }
                        if (((PC)ch).Hunger > 40)
                        {
                            ch.SendText("You are full.\r\n");
                        }
                        else if (condition == 0 && ((PC)ch).Hunger > 0)
                        {
                            ch.SendText("You are no longer hungry.\r\n");
                        }
                    }

                    if (obj.Values[3] != 0 && !CharData.CheckImmune(ch, Race.DamageType.poison))
                    {
                        /* The shit was poisoned! */
                        Affect af = new Affect();

                        SocketConnection.Act("$n chokes and gags.", ch, null, null, SocketConnection.MessageTarget.room);
                        ch.SendText("You choke and gag.\r\n");

                        af.Type = Affect.AffectType.spell;
                        af.Value = "poison";
                        af.Duration = 2 * obj.Values[0];
                        af.AddModifier(Affect.Apply.strength, -(obj.Level / 7 + 2));
                        af.SetBitvector(Affect.AFFECT_POISON);
                        ch.CombineAffect(af);
                    }
                    break;

                case ObjTemplate.ObjectType.pill:
                    {
                        for (int i = 1; i <= 4; i++)
                        {
                            String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(obj.Values[i]);
                            if (String.IsNullOrEmpty(spellName))
                            {
                                Log.Error("Eat: Spell number " + obj.Values[i] + " not found for pill object " + obj.ObjIndexNumber + ". Make sure it's in the SpellNumberToTextMap.");
                            }
                            Spell spell = StringLookup.SpellLookup(spellName);
                            if (!spell)
                            {
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例4: Wield

        /// <summary>
        /// Equip a weapon.  Now calls equip_hand to resolve the actual equipping 
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Wield(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;

            if (ch.IsAffected(Affect.AFFECT_HOLD) || ch.IsAffected( Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("Your body refuses the call to movement.\r\n");
                return;
            }

            if (!ch.IsNPC() && ch.IsAffected( Affect.AFFECT_WRAITHFORM))
            {
                ch.SendText("You try, but your &n&+wghoul&n form resists your  attempts.\r\n");
                return;
            }

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

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

            if (!obj.HasWearFlag(ObjTemplate.WEARABLE_WIELD))
            {
                if (obj.ItemType == ObjTemplate.ObjectType.weapon)
                {
                    ch.SendText("That object is not usable as a weapon.\r\n");
                    return;
                }
                if (obj.ItemType == ObjTemplate.ObjectType.ranged_weapon && !obj.HasWearFlag(ObjTemplate.WEARABLE_HOLD))
                {
                    ch.SendText("That object is not usable as a missile weapon.\r\n");
                    return;
                }
                if (obj.ItemType == ObjTemplate.ObjectType.ranged_weapon)
                {
                    // Ranged weapons flagged wither wield or hold are fine to use -- Xangis
                }
                else
                {
                    ch.SendText("That object is not a weapon.\r\n");
                    return;
                }
            }

            if (!ch.HasInnate(Race.RACE_WEAPON_WIELD))
            {
                ch.SendText("You are not able to wield a weapon.\r\n");
                return;
            }

            if (!obj.IsWearableBy(ch))
                return;

            Object.EquipInHand(ch, obj, Object.EQUIP_WIELD);

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

示例5: Compare

        /// <summary>
        /// Compares two objects to see which one is better.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Compare(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj2 = null;

            if (ch.IsNPC())
                return;

            if (str.Length < 1 || String.IsNullOrEmpty(str[0]))
            {
                ch.SendText("&nCompare what to what?\r\n");
                return;
            }

            Object obj1 = ch.GetObjCarrying(str[0]);
            if (!obj1)
            {
                ch.SendText("&nYou do not have that item.\r\n");
                return;
            }

            if (str.Length < 2 || String.IsNullOrEmpty(str[1]))
            {
                foreach (Object obj3 in ch.Carrying)
                {
                    if (obj3.WearLocation != ObjTemplate.WearLocation.none
                            && CharData.CanSeeObj(ch, obj3)
                            && obj1.ItemType == obj3.ItemType
                            && (obj1.WearFlags[0] & obj3.WearFlags[0] & ~ObjTemplate.WEARABLE_CARRY.Vector) != 0)
                    {
                        obj2 = obj3;
                        break;
                    }
                }

                if (!obj2)
                {
                    ch.SendText("&nYou aren't wearing anything comparable.\r\n");
                    return;
                }
            }
            else
            {
                obj2 = ch.GetObjCarrying(str[1]);
                if (!obj2)
                {
                    /*  Strip off number argument, subtrDescriptor._actFlags one, paste it together */
                    int number = MUDString.NumberArgument(str[1], ref str[1]);
                    if (number > 1)
                        number--;
                    string newArg2 = String.Format("{0}.{1}", number, str[1]);

                    obj2 = ch.GetObjWear(newArg2);
                    if (!obj2)
                    {
                        ch.SendText("&nYou do not have that item.\r\n");
                        return;
                    }

                    if ((obj1.WearFlags[0] & obj2.WearFlags[0] & ~ObjTemplate.WEARABLE_CARRY.Vector) == 0)
                    {
                        ch.SendText("&nThey are not comparable items.\r\n");
                        return;
                    }

                }
            }

            string msg = null;
            int value1 = 0;
            int value2 = 0;

            if (obj1 == obj2)
            {
                msg = "You compare $p&n to itself.  It looks about the same.";
            }
            else if (obj1.ItemType != obj2.ItemType)
            {
                msg = "$p&n and $P&n are not the same type of item.";
            }
            else
            {
                switch (obj1.ItemType)
                {
                    default:
                        msg = "You can't compare $p&n and $P&n.";
                        break;

                    case ObjTemplate.ObjectType.trash:
                        msg = "They're both junk.";
                        break;

                    case ObjTemplate.ObjectType.armor:
                    case ObjTemplate.ObjectType.clothing:
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例6: LookCommand


//.........这里部分代码省略.........
                            ch.SendText("It is closed.\r\n");
                            break;
                        }

                        SocketConnection.Act("$p&n contains:", ch, obj, null, SocketConnection.MessageTarget.character, true);
                        Look.ShowListToCharacter(obj.Contains, ch, true, true);
                        break;
                    case ObjTemplate.ObjectType.portal:
                        SocketConnection.Act("A $p&n leads to:", ch, obj, null, SocketConnection.MessageTarget.character);
                        output += Room.GetRoom(obj.Values[0]).Title + "\r\n";
                        output += Room.GetRoom(obj.Values[0]).Description;
                        output += "\r\n";
                        ch.SendText(output);
                        break;
                }
                return;
            }

            // Look at another char.
            if (args.Count > 0)
            {
                CharData victim = ch.GetCharRoom(args[0]);
                if (victim != null)
                {
                    Look.ShowCharacterToCharacterFull(victim, ch);
                    return;
                }
            }

            // Look at an object.
            if (args.Count > 0)
            {
                // Check inventory.
                obj = ch.GetObjCarrying(args[0]);
                // If not in inventory, check eq.
                if (obj == null)
                    obj = ch.GetObjWear(args[0]);
                // If not on character, check room.
                if (obj == null)
                    obj = Object.GetObjFromList(ch.InRoom.Contents, ch, args[0]);
                // If object found, show it to the char.
                if (obj != null)
                {
                    pdesc = (Database.GetExtraDescription(args[0], obj.ExtraDescription));
                    if (pdesc.Length != 0)
                    {
                        ch.SendText(pdesc);
                    }
                    else if ((pdesc = (Database.GetExtraDescription(args[0], obj.ObjIndexData.ExtraDescriptions))).Length > 0)
                    {
                        ch.SendText(pdesc);
                    }
                    else if (obj.FullDescription.Length > 0)
                    {
                        ch.SendText(obj.FullDescription);
                        ch.SendText("\r\n");
                    }
                    if (obj.HasAffect(Affect.AffectType.skill, "poison weapon"))
                    {
                        if (ch.IsClass(CharClass.Names.thief) || ch.IsClass(CharClass.Names.assassin)
                                || MUDMath.NumberPercent() < ch.GetCurrInt() / 2)
                            ch.SendText("It has a &+Gsickly &+Lcolored&n hue.\r\n");
                    }
                    return;
                }
            }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:67,代码来源:Command.cs

示例7: Wear

        /// <summary>
        /// Put on a piece of equipment.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Wear(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;

            if (ch.IsAffected(Affect.AFFECT_HOLD) || ch.IsAffected(Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("Your body refuses the call to movement.\r\n");
                return;
            }

            if (!ch.IsNPC() && ch.IsAffected( Affect.AFFECT_WRAITHFORM))
            {
                ch.SendText("You try, but your &n&+wghoul&n form resists your attempts.\r\n");
                return;
            }

            if (ch.Fighting || ch.CurrentPosition == Position.fighting)
            {
                ch.SendText("You can't wear stuff while you're fighting!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Wear, wield, or hold what?\r\n");
                return;
            }

            if (str[0] == "all")
            {
                foreach (Object iobj in ch.Carrying)
                {
                    if (iobj.WearLocation != ObjTemplate.WearLocation.none || !CharData.CanSeeObj(ch, iobj))
                    {
                        continue;
                    }

                    if (iobj.HasWearFlag(ObjTemplate.WEARABLE_WIELD)
                            && !ch.HasInnate(Race.RACE_WEAPON_WIELD))
                    {
                        continue;
                    }

                    Object.WearObject(ch, iobj, false);
                    if (iobj.Trap != null && iobj.Trap.CheckTrigger( Trap.TriggerType.wear))
                    {
                        ch.SetOffTrap(iobj);
                        if (ch.CurrentPosition == Position.dead)
                        {
                            return;
                        }
                    }
                }
                return;
            }
            if (!(obj = ch.GetObjCarrying(str[0])))
            {
                ch.SendText("You do not have that item.\r\n");
                return;
            }

            if (obj.HasWearFlag(ObjTemplate.WEARABLE_WIELD)
                && !ch.HasInnate(Race.RACE_WEAPON_WIELD))
            {
                ch.SendText("You are not able to wield a weapon.\r\n");
                return;
            }

            Object.WearObject(ch, obj, true);
            if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.wear))
            {
                ch.SetOffTrap(obj);
                if (ch.CurrentPosition == Position.dead)
                {
                    return;
                }
            }

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

示例8: Sell

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

            Object obj;
            CharData keeper;
            string arg2 = String.Empty;
            int cost;

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

            if (!(keeper = ch.FindShopkeeper(arg2)))
            {
                return;
            }

            if (!ch.IsNPC())
            {
                // Won't buy from bottom 25% of faction range.
                if (((PC)ch).GetFaction(keeper) < (Limits.MIN_FACTION / 2))
                {
                    SocketConnection.Act("$n&+W tells you 'I won't do business with scum like you.'&n", keeper, null, ch, SocketConnection.MessageTarget.victim);
                    ch.ReplyTo = keeper;
                    return;
                }
            }

            if (!(obj = ch.GetObjCarrying(str[0])))
            {
                SocketConnection.Act("$n&+W tells you 'You don't have that item.'&n",
                     keeper, null, ch, SocketConnection.MessageTarget.victim);
                ch.ReplyTo = keeper;
                return;
            }

            if (!ch.CanDropObject(obj))
            {
                ch.SendText("You couldn't possibly part with that.\r\n");
                return;
            }

            if (!CharData.CanSeeObj(keeper, obj))
            {
                SocketConnection.Act("$n&+W tells you 'I can't see that item.'&n",
                     keeper, null, ch, SocketConnection.MessageTarget.victim);
                ch.ReplyTo = keeper;
                return;
            }

            if ((cost = Object.GetCost(ch, keeper, obj, false)) <= 0 || obj.HasFlag(ObjTemplate.ITEM_NOSELL))
            {
                SocketConnection.Act("$n&n looks uninterested in $p&n.", keeper, obj, ch, SocketConnection.MessageTarget.victim);
                return;
            }

            if (cost > obj.Cost)
            {
                Log.Error("Shopkeeper with index number {0} buys for more than 100 percent of value.\r\n",
                     keeper.MobileTemplate.IndexNumber);
                cost = obj.Cost;
            }

            if (cost < 1)
                cost = 1;

            if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
            {
                SocketConnection.Act("$n&+W tells you 'I won't buy that!  It's poisoned!'&n",
                     keeper, null, ch, SocketConnection.MessageTarget.victim);
                ch.ReplyTo = keeper;
                return;
            }

            string buf = String.Format("You sell $p&n for {0}.", StringConversion.CoinString(cost));
            SocketConnection.Act(buf, ch, obj, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n sells $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
            ch.ReceiveCash(cost);

            if (obj.ItemType == ObjTemplate.ObjectType.trash)
            {
                obj.RemoveFromWorld();
            }
            else
            {
                obj.RemoveFromChar();
                obj.ObjToChar(keeper);
                // Selling an object decreases its scarcity.
                --obj.ObjIndexData.Scarcity;
            }

            return;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例9: Smoke

        /// <summary>
        /// Smoke - consume a magical herb.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Smoke(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object herb;
            Object pipe;
            string arg1 = String.Empty;
            string arg2 = String.Empty;

            if (String.IsNullOrEmpty(arg1))
            {
                SocketConnection.Act("You whip out a cigarette and puff away.", ch, null, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n lights up a cigarette and inhales deeply.", ch, null, null, SocketConnection.MessageTarget.room);
                return;
            }

            if (String.IsNullOrEmpty(arg2))
            {
                ch.SendText("What do you want to smoke through?\r\n");
                return;
            }

            if (!(herb = ch.GetObjCarrying(arg1)))
            {
                ch.SendText("You do not have $p&n.\r\n");
                return;
            }

            if (herb.ItemType != ObjTemplate.ObjectType.herb)
            {
                ch.SendText("Its unsafe to smoke anything but &n&+gherbs&n.\r\n");
                return;
            }

            if (!(pipe = ch.GetObjCarrying(arg2)))
            {
                ch.SendText("You do not have $P&n.\r\n");
                return;
            }

            if (pipe.ItemType != ObjTemplate.ObjectType.pipe)
            {
                ch.SendText("You need a &+Lpipe&n of some sort, $P just won't do.\r\n");
                return;
            }

            if ((Database.SystemData.WeatherData.Sky == Sysdata.SkyType.rain) && ((ch.InRoom.TerrainType != TerrainType.inside)
                    || (ch.InRoom.TerrainType == TerrainType.swamp) || (ch.InRoom.TerrainType == TerrainType.forest)))
            {
                ch.SendText("There is no way you can smoke in these wet conditions.\r\n");
                return;
            }

            if (ch.InRoom.IsWater())
            {
                ch.SendText("The &n&+cwa&+Ct&n&+ce&+Cr&m makes that an impossiblity.\r\n");
                return;
            }

            SocketConnection.Act("You pack $p&n into your $P.", ch, herb, pipe, SocketConnection.MessageTarget.character);
            SocketConnection.Act("You &n&+rlight&n $P&n and inhale deep $p&+W smoke&n.", ch, pipe, herb, SocketConnection.MessageTarget.character);
            SocketConnection.Act("You finish smoking $p&n.", ch, herb, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n smokes $p&n through $s $P&n.", ch, herb, pipe, SocketConnection.MessageTarget.room);

            // herb.Values[0] is not used for Herbs.
            for (int i = 1; i <= 4; i++)
            {
                String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(herb.Values[i]);
                if (String.IsNullOrEmpty(spellName))
                {
                    Log.Error("Smoke: Spell number " + herb.Values[i] + " not found for object " + herb.ObjIndexNumber + ". Make sure it's in the SpellNumberToTextMap.");
                }
                Spell spell = StringLookup.SpellLookup(spellName);
                if (!spell)
                {
                    Log.Error("Smoke: Spell '" + spellName + "' not found for object " + herb.ObjIndexNumber + ". Make sure it's in the spells file.");
                }
                else
                {
                    spell.Invoke(ch, herb.Level, ch);
                }
            }

            // pipe.value[1] would be refering to de percent chance burnout of
            // pipe value set when creating item.
            int pipebreak = MUDMath.NumberRange(1, 100);

            if (pipebreak <= pipe.Values[1])
            {
                SocketConnection.Act("Your $p&n cracks and becomes useless from too much &n&+rheat&n.", ch, pipe, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("You toss $p&n violently into the distance.", ch, pipe, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n throws away $p, as cracks have made it useless.", ch, pipe, null, SocketConnection.MessageTarget.room);
                pipe.RemoveFromWorld();
                ;
            }
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例10: Quaff

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

            Object obj;

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

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

            if (obj.ItemType != ObjTemplate.ObjectType.potion)
            {
                ch.SendText("You can quaff only potions.\r\n");
                return;
            }

            SocketConnection.Act("You quaff $p&n.", ch, obj, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n drains $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);

            ch.WaitState(3);

            if (obj.ObjIndexData.IndexNumber == StaticObjects.OBJECT_NUMBER_51_POTION)
            {
                obj.RemoveFromWorld();
                ;
                if (ch.Level != 50 || ch.ExperiencePoints < ExperienceTable.Table[ch.Level].LevelExperience)
                {
                    ch.SendText("Nothing happens.\r\n");
                    return;
                }
                ch.AdvanceLevel(true);
            }
            if (obj.ObjIndexData.IndexNumber == StaticObjects.OBJECT_NUMBER_52_POTION)
            {
                obj.RemoveFromWorld();
                if (ch.Level != 51 || ch.ExperiencePoints < ExperienceTable.Table[ch.Level].LevelExperience)
                {
                    ch.SendText("Nothing happens.\r\n");
                    return;
                }
                ch.AdvanceLevel(true);
            }
            if (obj.ObjIndexData.IndexNumber == StaticObjects.OBJECT_NUMBER_53_POTION)
            {
                obj.RemoveFromWorld();
                if (ch.Level != 52 || ch.ExperiencePoints < ExperienceTable.Table[ch.Level].LevelExperience)
                {
                    ch.SendText("Nothing happens.\r\n");
                    return;
                }
                ch.AdvanceLevel(true);
            }
            if (obj.ObjIndexData.IndexNumber == StaticObjects.OBJECT_NUMBER_54_POTION)
            {
                obj.RemoveFromWorld();
                if (ch.Level != 53 || ch.ExperiencePoints < ExperienceTable.Table[ch.Level].LevelExperience)
                {
                    ch.SendText("Nothing happens.\r\n");
                    return;
                }
                ch.AdvanceLevel(true);
            }
            if (obj.ObjIndexData.IndexNumber == StaticObjects.OBJECT_NUMBER_55_POTION)
            {
                obj.RemoveFromWorld();
                if (ch.Level != 54 || ch.ExperiencePoints < ExperienceTable.Table[ch.Level].LevelExperience)
                {
                    ch.SendText("Nothing happens.\r\n");
                    return;
                }
                ch.AdvanceLevel(true);
            }

            // obj.Values[0] is not used for potions.
            for (int i = 1; i <= 4; i++)
            {
                String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(obj.Values[i]);
                if (String.IsNullOrEmpty(spellName))
                {
                    Log.Error("Quaff: Spell number " + obj.Values[i] + " not found for object " + obj.ObjIndexNumber + ". Make sure it's in the SpellNumberToTextMap.");
                }
                Spell spell = StringLookup.SpellLookup(spellName);
                if (!spell)
                {
                    Log.Error("Quaff: Spell '" + spellName + "' not found for object " + obj.ObjIndexNumber + ". Make sure it's in the spells file.");
                }
                else
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例11: Recite

        /// <summary>
        /// Use a scroll to invoke its magical spells.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Recite(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object scroll;
            Object obj = null;
            CharData victim;
            string arg1 = String.Empty;
            string arg2 = String.Empty;

            if (!(scroll = ch.GetObjCarrying(arg1)))
            {
                ch.SendText("You do not have that &+Wscroll&n.\r\n");
                return;
            }

            if (scroll.ItemType != ObjTemplate.ObjectType.scroll)
            {
                ch.SendText("You can recite only &+Wscrolls&n.\r\n");
                return;
            }

            if (String.IsNullOrEmpty(arg2))
            {
                victim = ch;
                if (ch.Fighting != null)
                {
                    victim = ch.Fighting;
                }
            }
            else
            {
                if (((victim = ch.GetCharRoom(arg2)) == null) && !(obj = ch.GetObjHere(arg2)))
                {
                    ch.SendText("You can't find it.\r\n");
                    return;
                }
            }

            if (!ch.CanSpeak())
            {
                ch.SendText("Your lips move but no sound comes out.\r\n");
                return;
            }

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

            ch.WaitState(2 * Event.TICK_COMBAT);

            SocketConnection.Act("You recite $p&n.", ch, scroll, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n recites $p&n.", ch, scroll, null, SocketConnection.MessageTarget.room);

            if (ch.CheckSkill("scrolls"))
            {
                switch (MUDMath.NumberBits(3))
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        SocketConnection.Act("You can't understand $p&n at all.",
                             ch, scroll, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$n&n can't understand $p&n at all.",
                             ch, scroll, null, SocketConnection.MessageTarget.room);
                        return;
                    case 4:
                    case 5:
                    case 6:
                        ch.SendText("You must have said something incorrectly.\r\n");
                        SocketConnection.Act("$n&n must have said something incorrectly.", ch, null, null, SocketConnection.MessageTarget.room);
                        SocketConnection.Act("$p&n blazes brightly, then is gone.",
                             ch, scroll, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$p&n blazes brightly and disappears.",
                             ch, scroll, null, SocketConnection.MessageTarget.room);
                        scroll.RemoveFromWorld();
                        ;
                        return;
                    case 7:
                        SocketConnection.Act(
                            "You completely botch the recitation, and $p&n bursts into &+Rflames&n!!",
                            ch, scroll, null, SocketConnection.MessageTarget.character);
                        SocketConnection.Act("$p&n &+rglows&n and then bursts into &+Rflame&n!",
                             ch, scroll, null, SocketConnection.MessageTarget.room);
                        /*
                        * Command.damage( ) call after Object.extract_obj in case the damage would
                        * have extracted ch.  This is okay because we merely mark
                        * obj.deleted; it still retains all values until list_update.
                        * Sloppy?  Okay, create another integer variable.
                        */
                        scroll.RemoveFromWorld();
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例12: 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

示例13: 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

示例14: PoisonWeapon

        /// <summary>
        /// Apply poison to a weapon.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void PoisonWeapon(CharData ch, string[] str)
        {
            if (ch == null)
            {
                return;
            }

            Object obj;
            Object pobj = null;
            Affect af = new Affect();

            /* Don't allow mobs or unskilled pcs to do this */
            if (ch.IsNPC() || (!ch.IsNPC() && !ch.HasSkill("poison weapon")))
            {
                ch.SendText("What do you think you are, a thief?\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("What are you trying to poison?\r\n");
                return;
            }
            if (ch.Fighting != null)
            {
                ch.SendText("While you're fighting?  Nice try.\r\n");
                return;
            }
            if (!(obj = ch.GetObjCarrying(str[0])))
            {
                ch.SendText("You do not have that weapon.\r\n");
                return;
            }
            if (obj.ItemType != ObjTemplate.ObjectType.weapon)
            {
                ch.SendText("That item is not a weapon.\r\n");
                return;
            }
            if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
            {
                ch.SendText("That weapon is already poisoned.\r\n");
                return;
            }
            if (obj.Values[0] != 2)
            {
                ch.SendText("You don't have enough poison to cover that!\r\n");
                return;
            }

            /* Now we have a valid weapon...check to see if we have the poison. */
            foreach (Object iobj in ch.Carrying)
            {
                // here is where we should check to see if they have poison
                if (iobj.ItemType == ObjTemplate.ObjectType.drink_container
                        && iobj.Values[2] == 27)
                {
                    pobj = iobj;
                    break;
                }
            }
            if (!pobj)
            {
                ch.SendText("You do not have any poison.\r\n");
                return;
            }

            if (pobj.Values[1] <= 0 && pobj.Values[1] != -1)
            {
                SocketConnection.Act("Sorry, $p&n seems to be empty.", ch, pobj, null, SocketConnection.MessageTarget.character);
                return;
            }

            ch.WaitState(Skill.SkillList["poison weapon"].Delay);

            /* Check the skill percentage */
            if (!ch.CheckSkill("poison weapon"))
            {
                ch.SendText("You failed and spill some on yourself.  &+ROuch!&n\r\n");
                Combat.InflictDamage(ch, ch, ch.Level, "poison weapon", ObjTemplate.WearLocation.none, AttackType.DamageType.poison);
                SocketConnection.Act("$n spills the &+Gpoison&n all over!", ch, null, null, SocketConnection.MessageTarget.room);
                pobj.Values[1] -= 2;
                return;
            }

            /* Can't have people smearing gunk on artifacts */
            if (obj.InsultArtifact(ch))
            {
                pobj.Values[1]--;
                return;
            }

            SocketConnection.Act("You apply the &+Gpoison&n to $p&n, which glistens wickedly!",
                 ch, obj, null, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n pours the &+Gli&n&+gq&+Gu&n&+gid&n over $p&n, which glistens wickedly!",
                 ch, obj, null, SocketConnection.MessageTarget.room);
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例15: Give


//.........这里部分代码省略.........
                        victim.ReceiveGold(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "platinum"))
                {
                    if (ch.GetPlatinum() < amount)
                    {
                        ch.SendText("You haven't got that many &+Wplatinum&n coins.\r\n");
                        return;
                    }
                    ch.SpendPlatinum(amount);
                    SocketConnection.Act("You give $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+Wplatinum&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+Wplatinum&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount* 1000 );
                    if (!ch.CheckQuest(victim, null, (amount * 1000)))
                    {
                        victim.ReceivePlatinum(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                ch.SendText("You don't have any of _that_ type of coin yet.\r\n");
                return;
            }

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

            if (obj.WearLocation != ObjTemplate.WearLocation.none)
            {
                ch.SendText("You must remove it first.\r\n");
                return;
            }

            victim = ch.GetCharRoom(arg2);
            if (victim == null)
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if (!ch.CanDropObject(obj))
            {
                ch.SendText("You couldn't possibly part with it.\r\n");
                return;
            }

            /*
            * How silly of shopkeepers to refuse blessed items... previously vampires would
            * refuse blessed items... now all undead types refuse blessed items.
            */
            if (obj.HasFlag(ObjTemplate.ITEM_BLESS) && victim.IsUndead())
            {
                SocketConnection.Act("$N&n refuses to touch the blessed $p&n.", ch, obj, victim, SocketConnection.MessageTarget.character);
开发者ID:ramseur,项目名称:ModernMUD,代码行数:67,代码来源:Command.cs


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