Exemple #1
0
        /// <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:
                    case ObjTemplate.ObjectType.container:
                    case ObjTemplate.ObjectType.drink_container:
                    case ObjTemplate.ObjectType.food:
                        value1 = obj1.Values[0];
                        value2 = obj2.Values[0];
                        break;

                    case ObjTemplate.ObjectType.spellbook:
                    case ObjTemplate.ObjectType.light:
                        value1 = obj1.Values[2];
                        value2 = obj1.Values[2];
                        break;

                    case ObjTemplate.ObjectType.shield:
                        value1 = obj1.Values[3];
                        value2 = obj2.Values[3];
                        break;

                    case ObjTemplate.ObjectType.treasure:
                        value1 = obj1.Cost;
                        value2 = obj2.Cost;
                        break;

                    case ObjTemplate.ObjectType.weapon:
                        value1 = obj1.Values[1] * obj1.Values[2];
                        value2 = obj2.Values[1] * obj2.Values[2];
                        break;
                }
            }

            if (String.IsNullOrEmpty(msg))
            {
                if (obj2.WearLocation != ObjTemplate.WearLocation.none)
                {
                    if (value1 == value2)
                        msg = "$p&n and $P&n (equipped) look about the same.";
                    else if (value1 > value2)
                        msg = "$p&n looks better than $P&n (equipped).";
                    else
                        msg = "$p&n looks worse than $P&n (equipped).";
                }
                else
                {
                    if (value1 == value2)
                        msg = "$p&n and $P&n look about the same.";
                    else if (value1 > value2)
                        msg = "$p&n looks better than $P&n.";
                    else
                        msg = "$p&n looks worse than $P&n.";
                }
            }

            SocketConnection.Act(msg, ch, obj1, obj2, SocketConnection.MessageTarget.character);
            return;
        }
Exemple #2
0
        /// <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);
                    }
                }
                else
                {
                    SocketConnection.Act("You zap $P&n with $p&n.", ch, wand, obj, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$n&n zaps $P&n with $p&n.", ch, wand, obj, SocketConnection.MessageTarget.room);
                }

                if (!ch.IsNPC() && (MUDMath.NumberPercent() > ((PC)ch).SkillAptitude["wands"]))
                {
                    switch (MUDMath.NumberBits(3))
                    {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            SocketConnection.Act("You are unable to invoke the power of $p&n.",
                                 ch, wand, null, SocketConnection.MessageTarget.character);
                            SocketConnection.Act("$n&n is unable to invoke the power of $p&N.",
                                 ch, wand, null, SocketConnection.MessageTarget.room);
                            break;
                        case 4:
                        case 5:
                        case 6:
                            SocketConnection.Act("You summon the power of $p&n, but it fizzles away.",
                                 ch, wand, null, SocketConnection.MessageTarget.character);
                            SocketConnection.Act("$n&n summons the power of $p&n, but it fizzles away.",
                                 ch, wand, null, SocketConnection.MessageTarget.room);
                            break;
                        case 7:
                            SocketConnection.Act("You can't control the power of $p&n, and it &+Rexplodes&n!",
                                 ch, wand, null, SocketConnection.MessageTarget.character);
                            SocketConnection.Act("$p&n &n&+rexplodes&n into fragments!", ch, wand, 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.
                            * I hate sloppy...
                            */
                            wand.RemoveFromWorld();
                            Combat.InflictDamage(ch, ch, level, "wands", ObjTemplate.WearLocation.none, AttackType.DamageType.energy);
                            break;
                    }
                    return;
                }
                Magic.ObjectCastSpell(ch, spell, level, victim, obj);
            }

            if (--(wand.Values[2]) <= 0)
            {
                if (!ch.IsNPC() && MUDMath.NumberPercent() > ((PC)ch).SkillAptitude["wands"])
                {
                    SocketConnection.Act("$p&n &n&+rexplodes&n into fragments.", ch, wand, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$p&n &+Rexplodes&n into fragments.", ch, wand, null, SocketConnection.MessageTarget.room);
                    wand.RemoveFromWorld();
                    Combat.InflictDamage(ch, ch, level, "wands", ObjTemplate.WearLocation.none, AttackType.DamageType.energy);
                }
                else
                {
                    SocketConnection.Act("$p&n blazes bright and is gone.",
                         ch, wand, null, SocketConnection.MessageTarget.character);
                    SocketConnection.Act("$p&n blazes bright and is gone.",
                         ch, wand, null, SocketConnection.MessageTarget.room);
                    wand.RemoveFromWorld();
                }
            }

            return;
        }
Exemple #3
0
        /// <summary>
        /// Use an object. Forwards to the "zap" or "brandish" command for wands
        /// and staves, otherwise does nothing.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Use(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object item;

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

            if (!(item = ch.GetObjWear(str[0])))
            {
                ch.SendText("You can't find it!\r\n");
                return;
            }

            if (item.ItemType == ObjTemplate.ObjectType.wand)
            {
                Zap(ch, str);
                return;
            }
            if (item.ItemType == ObjTemplate.ObjectType.staff)
            {
                Brandish(ch, str);
                return;
            }
            ch.SendText("You can only use staves or wands.\r\n");
            return;
        }
Exemple #4
0
        /// <summary>
        /// Remove a piece of equipment.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Remove(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object obj;

            if (ch.IsAffected(Affect.AFFECT_HOLD) || ch.IsAffected(Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You no longer have control of your body!\r\n");
                return;
            }

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

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

                if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
                {
                    ch.SendText("You have your hands full.\r\n");
                    return;
                }

                ch.RemoveObject(obj.WearLocation, true);
                if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.unequip))
                {
                    ch.SetOffTrap(obj);
                    if (ch.CurrentPosition == Position.dead)
                        return;
                }
            }
            else
            {
                /* 'remove all' or 'remove all.obj' */
                bool found = false;
                foreach (Object iobj in ch.Carrying)
                {
                    if (str.Length < 2 || (MUDString.NameContainedIn(str[0].Substring(4), iobj.Name)
                            && iobj.WearLocation != ObjTemplate.WearLocation.none))
                    {
                        found = true;
                        if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
                        {
                            ch.SendText("You have your hands full.\r\n");
                            return;
                        }
                        ch.RemoveObject(iobj.WearLocation, true);
                        if (iobj.Trap != null && iobj.Trap.CheckTrigger(Trap.TriggerType.unequip))
                        {
                            ch.SetOffTrap(iobj);
                            if (ch.CurrentPosition == Position.dead)
                            {
                                return;
                            }
                        }
                    }
                }

                if (!found)
                {
                    if (str.Length == 0 || str[0].Length < 4)
                    {
                        ch.SendText("You can't find anything to remove.\r\n");
                    }
                    else
                    {
                        SocketConnection.Act("You can't find any $T&n to remove.",
                             ch, null, str[0].Substring(4), SocketConnection.MessageTarget.character);
                    }
                }
            }

            return;
        }
Exemple #5
0
        /// <summary>
        /// Looks at an object, mobile, or room.
        /// </summary>
        /// <param name="ch">The acting character.</param>
        /// <param name="str">Command arguments.</param>
        public static void LookCommand(CharData ch, string[] str)
        {
            if( ch == null ) return;

            // Build argument list, stripping articles.
            bool inside = false;
            List<String> args = new List<string>(str);
            for (int i = (args.Count - 1); i >= 0; i-- )
            {
                if (args[i].Equals("in", StringComparison.CurrentCultureIgnoreCase) || args[i].Equals("i", StringComparison.CurrentCultureIgnoreCase))
                {
                    args.RemoveAt(i);
                    inside = true;
                }
                else if (args[i].Equals("at", StringComparison.CurrentCultureIgnoreCase))
                {
                    args.RemoveAt(i);
                }
            }

            // If it's a mob that isn't switched, bail.
            if (ch.Socket == null)
                return;

            if (ch.CurrentPosition < Position.sleeping)
            {
                ch.SendText("&nYou can't see anything but &+Ystars&n!  See how pretty!\r\n");
                return;
            }

            if (ch.CurrentPosition == Position.sleeping)
            {
                ch.SendText("&nYou can't see anything, you're &+Lsleeping&n!  Zzz.\r\n");
                return;
            }

            if (ch.IsBlind())
                return;

            // Look panel for ships.
            if ( args.Count > 0 && args[0].Equals("panel", StringComparison.CurrentCultureIgnoreCase))
            {
                CommandType.Interpret(ch, "Lookpanel");
                return;
            }
            // Look out for ships.
            if (args.Count > 0 && args[0].Equals("out", StringComparison.CurrentCultureIgnoreCase))
            {
                CommandType.Interpret(ch, "Lookout");
                return;
            }

            Object obj;
            Exit exit;
            string pdesc;
            int number = 0;
            string output = String.Empty;

            // 'look' or 'look auto' or 'look room'
            if (args.Count == 0 || args[0].Equals( "auto", StringComparison.CurrentCultureIgnoreCase) ||
                args[0].Equals("room", StringComparison.CurrentCultureIgnoreCase))
            {
                if (ch.InRoom == null)
                {
                    ch.SendText("You are not in a room.  You are just floating in empty space.  This should never happen.  You should <petition> someone for help.\r\n");
                    Log.Error("Character executing Commandlook command from null room: " + ch.Name);
                    return;
                }
                if (ch.FlightLevel > 0)
                {
                    switch (ch.FlightLevel)
                    {
                        case CharData.FlyLevel.low:
                            ch.SendText("Hovering above ");
                            break;
                        case CharData.FlyLevel.medium:
                            ch.SendText("Flying above ");
                            break;
                        case CharData.FlyLevel.high:
                            ch.SendText("Flying high above ");
                            break;
                    }
                }
                if (!ch.HasActionBit(PC.PLAYER_GODMODE) && ch.InRoom.IsDark()
                        && !ch.HasInnate(Race.RACE_ULTRAVISION)
                        && !ch.IsAffected( Affect.AFFECT_ULTRAVISION))
                {
                    ch.SendText("&+lSomewhere\r\n");
                }
                else if (!ch.HasActionBit(PC.PLAYER_GODMODE))
                {
                    String roomOpen = String.Empty;
                    String roomClose = String.Empty;
                    if (!ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED)
                    {
                        roomOpen = "<zone>" + ch.InRoom.Area.Name + "</zone><roomTitle>";
                        roomClose = "</roomTitle>";
                    }
                    else
                    {
                        roomClose = "&n\r\n";
                    }
                    // Added support for both manual and automatic descriptions on the worldmap.
                    if (!ch.InRoom.Area.HasFlag(Area.AREA_WORLDMAP) || ch.InRoom.Title.Length > 1)
                    {
                        output += roomOpen + ch.InRoom.Title + roomClose;
                    }
                    else
                    {
                        output += roomOpen + "No room title." + roomClose;
                    }
                }
                else
                {
                    if (!ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED)
                    {
                        ch.SendText("<zone>" + ch.InRoom.Area.Name + "</zone>");
                    }
                    Look.ShowRoomInfo(ch, ch.InRoom);
                }

                if (!ch.IsNPC() && !ch.HasActionBit(PC.PLAYER_GODMODE) && ch.InRoom.IsDark()
                    && !ch.HasInnate(Race.RACE_ULTRAVISION) && !ch.IsAffected( Affect.AFFECT_ULTRAVISION))
                {
                    ch.SendText("&+LIt is pitch black...&n \r\n");
                    Look.ShowCharacterToCharacter(ch.InRoom.People, ch);
                    return;
                }

                if (!ch.IsNPC() && (args.Count > 0 && (args[0].Equals("room", StringComparison.CurrentCultureIgnoreCase) ||
                    args[0].Equals("auto", StringComparison.CurrentCultureIgnoreCase))))
                {
                    String roomDescOpen = String.Empty;
                    String roomDescClose = String.Empty;
                    String mapSpace = String.Empty;

                    if (!ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED)
                    {
                        roomDescOpen = "<roomDescription>";
                        roomDescClose = "</roomDescription>";
                    }
                    else
                    {
                        roomDescClose = "&n\r\n";
                        mapSpace = "    ";
                    }
                    if( !ch.HasActionBit(PC.PLAYER_BRIEF) && !ch.InRoom.Area.HasFlag(Area.AREA_WORLDMAP))
                    {
                        // Added support for both manual and automatic descriptions on the worldmap.
                        if (ch.InRoom.Description.Length > 0)
                        {
                            output += roomDescOpen + "    " + (ch.InRoom.Description.Trim()) + roomDescClose;
                        }
                        //else if (ch._inRoom.WorldmapTerrainType < Database.SystemData.MapInfo.Length)
                        //    output += roomDescOpen + mapSpace + Database.SystemData.MapInfo[ch._inRoom.WorldmapTerrainType].RoomDescription + roomDescClose;
                        else
                        {
                            output += roomDescOpen + "    No room description." + roomDescClose;
                        }
                    }
                }
                if (!String.IsNullOrEmpty(output))
                {
                    ch.SendText(output);
                }

                if (ch.InRoom.Area.HasFlag(Area.AREA_WORLDMAP))
                {
                    if (ch.HasActionBit(PC.PLAYER_MAP))
                    {
                        Command.Worldmap(ch, null);
                    }
                    else if (!ch.IsNPC() && ch.Socket.Terminal != SocketConnection.TerminalType.TERMINAL_ENHANCED)
                    {
                        ch.SendText("\r\n");
                    }
                }

                if (ch.InRoom.HasFlag(RoomTemplate.ROOM_SILENT))
                {
                    ch.SendText("&nIt seems preternaturally quiet.\r\n");
                }

                CommandType.Interpret(ch, "exits auto");

                Look.ShowRoomAffects(ch, ch.InRoom);

                Look.ShowListToCharacter(ch.InRoom.Contents, ch, false, false);
                Look.ShowCharacterToCharacter(ch.InRoom.People, ch);
                return;
            }

            // 'look direction'
            int door = -1;
            if (args.Count > 0)
            {
                if ("north".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 0;
                else if ("east".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 1;
                else if ("south".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 2;
                else if ("west".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 3;
                else if ("up".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 4;
                else if ("down".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 5;
                else if ("northwest".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 6;
                else if ("southwest".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 7;
                else if ("northeast".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 8;
                else if ("southeast".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 9;
                else if ("nw".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 6;
                else if ("sw".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 7;
                else if ("ne".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 8;
                else if ("se".StartsWith(args[0], StringComparison.CurrentCultureIgnoreCase))
                    door = 9;
            }
            if (door != -1)
            {
                // If no exit data, then return.
                exit = ch.InRoom.ExitData[door];
                if (!exit)
                {
                    ch.SendText("There's nothing to see in that direction.\r\n");
                    return;
                }

                if (exit.HasFlag(Exit.ExitFlag.walled))
                {
                    ch.SendText("There's a wall in the way.\r\n");
                    return;
                }

                // Check for farsee
                if ((ch.IsAffected( Affect.AFFECT_FARSEE) || ch.HasActionBit(PC.PLAYER_GODMODE))
                        && !exit.HasFlag(Exit.ExitFlag.closed))
                {
                    if (exit.TargetRoom)
                    {
                        Room room = ch.InRoom;
                        ch.RemoveFromRoom();
                        ch.AddToRoom(Room.GetRoom(exit.IndexNumber));
                        CommandType.Interpret(ch, "look");
                        ch.RemoveFromRoom();
                        ch.AddToRoom(room);
                        return;
                    }
                    ch.SendText("Nothing special there.\r\n");
                }

                if (exit.Description.Length != 0)
                {
                    ch.SendText(exit.Description);
                }
                else
                {
                    ch.SendText("Nothing special there.\r\n");
                }

                if (exit.Keyword.Length != 0)
                {
                    if (exit.HasFlag(Exit.ExitFlag.bashed))
                        SocketConnection.Act("The $d has been bashed from its &n&+whinges&n.",
                             ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                    else if (exit.HasFlag(Exit.ExitFlag.closed))
                        SocketConnection.Act("The $d is closed.", ch, null, exit.Keyword, SocketConnection.MessageTarget.character);
                    else if (exit.HasFlag(Exit.ExitFlag.secret))
                        SocketConnection.Act("The $d 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);
                }
                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";
                        else
                            output += "completely";
                        output += " full of a " + Liquid.Table[obj.Values[2]].Color + "liquid.\r\n";

                        ch.SendText(output);
                        break;

                    case ObjTemplate.ObjectType.quiver:
                    case ObjTemplate.ObjectType.container:
                    case ObjTemplate.ObjectType.npc_corpse:
                    case ObjTemplate.ObjectType.pc_corpse:
                        if (Macros.IsSet(obj.Values[1], ObjTemplate.CONTAINER_CLOSED.Vector))
                        {
                            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;
                }
            }

            // Look at an object in the room
            if (args.Count > 0)
            {
                int count = 0;
                foreach (Object iobj in ch.InRoom.Contents)
                {
                    if (CharData.CanSeeObj(ch, iobj))
                    {
                        pdesc = (Database.GetExtraDescription(args[0], iobj.ExtraDescription));
                        if (pdesc.Length != 0)
                        {
                            if (++count == number)
                            {
                                ch.SendText(pdesc);
                                return;
                            }
                            continue;
                        }
                        pdesc = (Database.GetExtraDescription(args[0], iobj.ObjIndexData.ExtraDescriptions));
                        if (pdesc.Length != 0)
                        {
                            if (++count == number)
                            {
                                ch.SendText(pdesc);
                                return;
                            }
                            continue;
                        }
                        if (MUDString.NameContainedIn(args[0], iobj.Name))
                        {
                            if (++count == number)
                            {
                                ch.SendText(iobj.FullDescription);
                                ch.SendText("\r\n");
                                return;
                            }
                            continue;
                        }
                    }
                }
            }

            // Check for room extra descriptions
            if (args.Count > 0)
            {
                pdesc = (Database.GetExtraDescription(args[0], ch.InRoom.ExtraDescriptions));
                if (!String.IsNullOrEmpty(pdesc))
                {
                    ch.SendText(pdesc);
                    return;
                }
            }

            ch.SendText("You do not see that here.\r\n");
            return;
        }
Exemple #6
0
        public static void Invoke(CharData ch, string[] str)
        {
            if( ch == null ) return;

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

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

            Object.Invoke(ch, obj);
            return;
        }