Exemple #1
0
        /// <summary>
        /// Defines how a player's prompt is displayed.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Prompt(CharData ch, string[] str)
        {
            string buf = String.Empty;

            /* Unswitched NPC's get kicked out */
            if (ch.Socket == null)
                return;

            /* Will always have a pc ch after this */
            ch = (ch.Socket.Original != null ? ch.Socket.Original : ch.Socket.Character);

            if (str.Length == 0)
            {
                if (ch.HasActionBit(PC.PLAYER_PROMPT))
                {
                    buf = "-prompt";
                }
                else
                {
                    buf = "+prompt";
                }
                CommandType.Interpret(ch, "toggle " + buf);
                return;
            }

            if (str[0].Equals("raw", StringComparison.CurrentCultureIgnoreCase))
                buf += "&n&+g<%h&n&+g/%H&n&+ghp %mm %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%D&n %B&+g>&n ";
            else if (str[0].Equals("dark", StringComparison.CurrentCultureIgnoreCase))
                buf += "&+L<&n&+m%h&+L/&n&+m%H&+Lhp &n&+m%v&+L/&n&+m%V&+Lmv>\r\n&+L<&n%T&n %E&+L>&n ";
            else if (str[0].Equals("meter", StringComparison.CurrentCultureIgnoreCase))
                if (ch.IsClass(CharClass.Names.psionicist) || ch.IsClass(CharClass.Names.bard))
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp %mm/%MM %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%d&n %b&+g>&n ";
                else
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%d&n %b&+g>&n ";
            else if (str[0].Equals("chains", StringComparison.CurrentCultureIgnoreCase))
                buf += "&+L<&n&+m%h&+L/&n&+m%H&+Lhp &n&+m%v&+L/&n&+m%V&+Lmv>\r\n&+L<&n%t&n %e&+L>&n ";
            else if (str[0].Equals("status", StringComparison.CurrentCultureIgnoreCase))
                buf += "&n&+g<%l&+g:%h&n&+g/%H&n&+ghp %mm %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%D&n %B&+g>&n ";
            else if (str[0].Equals("all", StringComparison.CurrentCultureIgnoreCase))
                if (ch.IsClass(CharClass.Names.psionicist) || ch.IsClass(CharClass.Names.bard))
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp %m/%Mm %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%D&n %B&+g>&n ";
                else
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp %v&n&+g/%V&n&+gmv>\r\n&n&+g<&n%D&n %B&+g>&n ";
            else if (str[0].Equals("fancy", StringComparison.CurrentCultureIgnoreCase))
                if (ch.IsClass(CharClass.Names.psionicist) || ch.IsClass(CharClass.Names.bard))
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp %m/%Mm &+g%v&n&+g/%V&n&+gmv %a>\r\n&n%n&+g< &n%l&n &n%d&n %b&+g>&n ";
                else
                    buf += "&n&+g<%h&n&+g/%H&n&+ghp &+g%v&n&+g/%V&n&+gmv %a>\r\n&n%n&+g< &n%l&n &n%d&n %b&+g>&n";
            else
            {
                string text = String.Join(" ", str);
                if (text.Length > 70)
                    text = text.Substring(0, 70);
                buf = text;
            }

            ((PC)ch).Prompt = buf;
            ch.SendText("&nOk.\r\n");
            return;
        }
Exemple #2
0
        /// <summary>
        /// Fog: Immortal command to turn combat vulnerability on or off.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Fog(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
            {
                return;
            }
            if (!ch.Authorized("fog"))
            {
                return;
            }
            ch.ToggleActionBit(PC.PLAYER_FOG);
            if (ch.HasActionBit(PC.PLAYER_FOG))
            {
                ch.SendText("Fog is now on.\r\n");
            }
            else
            {
                ch.SendText("Fog is now off.\r\n");
            }
            return;
        }
Exemple #3
0
        public static void GodMode(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            if (!ch.Authorized("godmode"))
                return;

            if (ch.HasActionBit(PC.PLAYER_GODMODE))
            {
                ch.RemoveActionBit(PC.PLAYER_GODMODE);
                ch.SendText("God mode off.\r\n");
            }
            else
            {
                ch.SetActionBit(PC.PLAYER_GODMODE);
                ch.SendText("God mode on.\r\n");
            }

            return;
        }
Exemple #4
0
        /// <summary>
        /// Shows a character's attribute screen.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Attributes(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string buf1 = String.Empty;

            if (ch.IsNPC())
            {
                ch.SendText("&nYour attributes are as would be expected for an NPC.\r\n");
                return;
            }

            if (ch.IsImmortal() && str.Length != 0)
            {
                CharData worldChar = ch.GetCharWorld(str[0]);
                if (!worldChar)
                {
                    ch.SendText("No such person.\r\n");
                    return;
                }
                if (worldChar.IsNPC())
                {
                    ch.SendText("NPCs don't have skills!\r\n");
                    return;
                }
            }

            string buf = String.Format(
                "&+WName: &+G{0}&n    &+WLevel: {1}&n\r\n",
                MUDString.PadStr(ch.Name, 17),
                ch.Level);
            buf1 += buf;

            buf = String.Format(
                      "&+WRace:&n {0}          &+WClass:&n {1}     &n&+WSex:&n {2}\r\n",
                      MUDString.PadStr(Race.RaceList[ch.GetRace()].ColorName, 16),
                      MUDString.PadStr(ch.CharacterClass.WholistName, 16),
                      System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(ch.GetSexString()));
            buf1 += buf;

            // Break a player's size into strings when we get around to it
            // -- Xangis
            if (!ch.IsNPC())
            {
                buf = String.Format(
                          "&+WHeight:&n {0} inches         &+WWeight:&n {1} pounds    &+WSize:&n {2}\r\n",
                          MUDString.PadInt(((PC)ch).Height, 3),
                          MUDString.PadInt(((PC)ch).Weight, 5),
                          Race.SizeString(ch.CurrentSize));
            }
            else
            {
                buf = String.Format("&+WSize:&n  {0}\r\n", ch.CurrentSize);
            }
            buf1 += buf;

            TimeSpan time = TimeSpan.FromTicks(ch.TimePlayed.Ticks) + (DateTime.Now - ch.LogonTime);
            int days = (int)time.TotalHours / 24;
            time = (time - TimeSpan.FromDays(days));
            int hours = (int)time.TotalHours;
            time = (time - TimeSpan.FromHours(hours));
            int minutes = (int)time.TotalMinutes;

            // Age is a hack until we get it coded - Xangis
            buf = String.Format(
                      "\r\n&+BAge:&n {0} years.             &+BPlaying Time:&n {1} days {2} hours {3} minutes.\r\n",
                      MUDString.PadInt(ch.GetAge(), 3), days, hours, minutes);
            buf1 += buf;

            // Need to create a function to display character status strings
            buf = String.Format("&+BStatus:&n  {0}", System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Position.PositionString(ch.CurrentPosition)));
            if (!ch.IsNPC() && ch.IsAffected(Affect.AFFECT_BERZERK))
            {
                buf += ", &+Rberzerk&n";
            }
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
            {
                buf += ", Memorizing";
            }
            if (ch.IsAffected(Affect.AFFECT_CASTING))
            {
                buf += ", Casting";
            }
            if (ch.IsAffected(Affect.AFFECT_SINGING))
            {
                buf += ", Singing";
            }
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEDITATING))
            {
                buf += ", Meditating";
            }
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_CAMPING))
            { /* This is ugly and should be moved to its own function */
                buf += ", Camping";
            }
            buf += ".\r\n\r\n";
            buf1 += buf;

            // We want players to see the same stats for levels 1-50.

            // Should create string converters so that we have no decimals displayed
            // below this point.
            buf = String.Format("     &+cSTR:&n  {0}      &+cArmor Class:&n {1}.\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrStr()), 15), ch.GetAC());
            buf1 += buf;
            buf = String.Format("     &+cAGI:&n  {0}      &+cHitroll:&n     {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrAgi()), 15), StringConversion.BonusString(ch.GetHitroll(ObjTemplate.WearLocation.hand_one)));
            buf1 += buf;
            buf = String.Format("     &+cDEX:&n  {0}      &+cDamroll:&n     {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrDex()), 15), StringConversion.BonusString(ch.GetDamroll(ObjTemplate.WearLocation.hand_one)));
            buf1 += buf;
            buf = String.Format("     &+cCON:&n  {0}      &+cAlignment:&n   {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrCon()), 15), StringConversion.AlignmentString(ch));
            buf1 += buf;
            buf = String.Format("     &n&+cINT:&n  {0}\r\n", MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrInt()), 15));
            buf1 += buf;
            buf = String.Format("     &+cWIS:&n  {0}      &+BSaving Throws&n\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrWis()), 15));
            buf1 += buf;
            buf = String.Format("     &+cPOW:&n  {0}      &+cParalysis:&n {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrPow()), 15), StringConversion.BonusString(-ch.SavingThrows[0]));
            buf1 += buf;
            buf = String.Format("     &+cCHA:&n  {0}      &+cRod:&n       {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrCha()), 15), StringConversion.BonusString(-ch.SavingThrows[1]));
            buf1 += buf;
            buf = String.Format("     &+cLUK:&n  {0}      &+cPetrify:&n   {1}\r\n",
                      MUDString.PadStr(StringConversion.AbilityScoreString(ch.GetCurrLuck()), 15), StringConversion.BonusString(-ch.SavingThrows[2]));
            buf1 += buf;

            buf = String.Format("                                &+cBreath:&n    {0}\r\n",
                      StringConversion.BonusString(-ch.SavingThrows[3]));
            buf1 += buf;

            buf = String.Format("&+BWimpy:        &n{0}               &+cSpell:&n     {1}\r\n",
                      MUDString.PadInt(ch.Wimpy, 4), StringConversion.BonusString(-ch.SavingThrows[4]));
            buf1 += buf;

            buf = String.Format("&+BLoad Carried: &n{0} pounds ({1})\r\n",
                      MUDString.PadInt(ch.CarryWeight, 3), StringConversion.WeightString(ch));
            buf1 += buf;

            ch.SendText(buf1);
            return;
        }
Exemple #5
0
        /// <summary>
        /// Shows available room exits.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Exits(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Exit exit;
            int door;

            bool auto = (str.Length != 0 && !MUDString.StringsNotEqual(str[0], "auto"));

            if (ch.IsBlind() || !ch.InRoom)
            {
                return;
            }

            string text;
            if (!ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED && auto)
            {
                text = "<exits>";
            }
            else
            {
                text = auto ? "&+cExits: &n" : "&+cVisible exits:&n\r\n";
            }

            bool found = false;

            // Show the direction with an asterisk if it
            // has a closed door, and in exits command it shows up as a
            // closed <whatever>.
            for (door = 0; door < Limits.MAX_DIRECTION; ++door)
            {
                exit = ch.InRoom.ExitData[door];
                if (exit && exit.TargetRoom)
                {
                    if (exit.HasFlag(Exit.ExitFlag.secret))
                    {
                        /* Mortals do not see secret exits. */
                        if (ch.Level < Limits.LEVEL_AVATAR)
                            continue;
                        /* Mark secret exits for immortals. */
                        text += "&+LS&n&+c";
                    }
                    if (exit.HasFlag(Exit.ExitFlag.blocked))
                    {
                        /* Mortals do not see secret exits. */
                        if (ch.Level < Limits.LEVEL_AVATAR)
                            continue;
                        /* Mark secret exits for immortals. */
                        text += "&+yB&n&+c";
                    }
                    found = true;
                    if (auto)
                    {
                        if (exit.HasFlag(Exit.ExitFlag.walled) && exit.HasFlag(Exit.ExitFlag.illusion))
                            continue;
                        if (exit.HasFlag(Exit.ExitFlag.closed))
                            text += "&n&+y#&n&+c";
                        // Don't show exits to impassable rooms.
                        // Show a yellow exclamation point to those with holylight on though.
                        if (exit.TargetRoom && exit.TargetRoom.TerrainType == TerrainType.underground_impassable)
                        {
                            if (!ch.HasActionBit(PC.PLAYER_GODMODE))
                            {
                                continue;
                            }
                            text += "&+Y!&n";
                        }
                        text += door.ToString();
                        text += " ";
                    }
                    else
                    {
                        if (exit.HasFlag(Exit.ExitFlag.walled))
                        {
                            text += String.Format("&n{0} - (Walled)&n\r\n",
                                MUDString.PadStr(door.ToString().ToUpper(), 5));
                        }
                        else if (!exit.HasFlag(Exit.ExitFlag.closed))
                        {
                            // gods with holylight on can go to useless exits.
                            if (exit.TargetRoom && exit.TargetRoom.TerrainType == TerrainType.underground_impassable)
                            {
                                if (!ch.HasActionBit(PC.PLAYER_GODMODE))
                                {
                                    continue;
                                }
                                text += "&+Y!&n";
                            }
                            text += String.Format("&n {0} - {1}&n\r\n", MUDString.PadStr(door.ToString().ToUpper(), 5),
                                    (!ch.HasInnate(Race.RACE_ULTRAVISION) && Room.GetRoom(exit.IndexNumber).IsDark())
                                      ? "&nToo dark to tell" : exit.TargetRoom.Title);
                        }
                        else
                        {
                            text += String.Format("&+y#&n{0} - Closed {1}\r\n",
                                MUDString.PadStr(door.ToString().ToUpper(), 5), exit.Keyword);
                        }
                    }
                }
            }

            if (!found)
            {
                text += auto ? " none" : "&nNone.\r\n";
            }

            if (!ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED && auto)
            {
                text += "&n</exits>";
            }
            else if (auto)
            {
                text += "&n\r\n";
            }

            ch.SendText(text);
            return;
        }
Exemple #6
0
        /// <summary>
        /// Command to toggle list combine mode.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Combine(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string buf;

            if (ch.HasActionBit(PC.PLAYER_COMBINE))
                buf = String.Format("-combine");
            else
                buf = String.Format("+combine");

            CommandType.Interpret(ch, "toggle " + buf);

            return;
        }
Exemple #7
0
        public static void Disengage(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (!ch.Fighting)
            {
                ch.SendText("You're not fighting anyone!\r\n");
                if (ch.CurrentPosition == Position.fighting)
                    ch.CurrentPosition = Position.standing;
                return;
            }

            if (ch.Fighting.Fighting && ch.Fighting.Fighting == ch
                    && ch.HasActionBit(PC.PLAYER_VICIOUS))
            {
                ch.SendText("You're a little busy getting beat on at the moment.\r\n");
                return;
            }

            ch.SendText("You disengage from the fight!\r\n");
            ch.WaitState(8);
            Combat.StopFighting(ch, false);

            return;
        }
Exemple #8
0
        public static void Shoot(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object newobj;
            Exit exit;
            Room toRoom;
            string msg;
            string arg1 = String.Empty; // Target.
            string arg2 = String.Empty; // Direction.
            string arg3 = String.Empty; // Distance.
            int range = 3;
            int dir;
            int n;
            bool inBattle = false;

            if (ch.IsNPC() && ch.HasActionBit(MobTemplate.ACT_PET))
                return;

            /* Target specified => arg2 has direction. */
            for (dir = 0; dir < Limits.MAX_DIRECTION; dir++)
            {
                if (dir == Limits.MAX_DIRECTION)
                {
                    ch.SendText("Invalid direction.\r\n");
                    return;
                }
                /* If a _targetType was specified as arg1. */
                if (!MUDString.IsPrefixOf(arg2, dir.ToString()))
                    break;
            }
            if (dir == Limits.MAX_DIRECTION)
                dir = 0;
            /* If arg2 wasn't a direction, then check if arg1 is. */
            if (MUDString.IsPrefixOf(arg2, dir.ToString()))
                for (dir = 0; dir <= Limits.MAX_DIRECTION; dir++)
                {
                    if (dir == Limits.MAX_DIRECTION)
                    {
                        ch.SendText("Invalid direction.\r\n");
                        return;
                    }
                    /* If arg1 is the direction, no _targetType specified. */
                    if (!MUDString.IsPrefixOf(arg1, dir.ToString()))
                    {
                        if (arg2.Length != 0)         // If there is a distance,
                        {
                            arg3 = arg2;     // Copy distance into arg3.
                        }
                        arg2 = arg1;     // Copy direction into arg2.
                        arg1 = String.Empty;     // Set _targetType to null;
                        break;
                    }
                }

            if (String.IsNullOrEmpty(arg2) || dir < 0)
            {
                ch.SendText("&+LSyntax:  &+RShoot &+L<&n&+rDirection&+L> [&n&+rRange&+L]&n\r\n");
                return;
            }

            Object obj = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two);
            if (!obj)
            {
                ch.SendText("You aren't using a missile weapon.\r\n");
                return;
            }

            if (obj.ItemType != ObjTemplate.ObjectType.ranged_weapon || obj.Values[1] < 0 || obj.Values[2] < 0)
            {
                ch.SendText("You can't do that without a ranged weapon.\r\n");
                return;
            }

            if (obj.Values[4] == 0)
            {
                ch.SendText("Its payload is empty.\r\n");
                return;
            }

            if (obj.Values[3] == ObjTemplate.RNG_CATAPULT)
            {
                if (!String.IsNullOrEmpty(arg3))
                    Int32.TryParse(arg3, out range);

                if (range <= 0)
                {
                    ch.SendText("Try shooting it away from you.\r\n");
                    return;
                }

                if (range > obj.Values[0])
                {
                    if (obj.Values[0] > 0)
                        range = obj.Values[0];
                    else
                        range = 1;
                }
            }

            switch (obj.Values[3])
            {
                default:
                    msg = "You pull back the &n&+ystring&n on {0}&n and fire {1}&n!\r\n";
                    break;
                case ObjTemplate.RNG_BOW:
                    msg = "You pull back the &n&+ystring&n on {0}&n and fire {1}&n!\r\n";
                    break;
                case ObjTemplate.RNG_CROSSBOW:
                    msg = "You fire {0}&n bolt {1}&n!\r\n";
                    break;
                case ObjTemplate.RNG_CATAPULT:
                    msg = "You crank back {0}&n, and release it {1}ward!\r\n";
                    break;
            }
            string buf = String.Format(msg, obj.ShortDescription, dir.ToString());
            ch.SendText(buf);

            switch (obj.Values[3])
            {
                default:
                    msg = "{0}&n pulls back the &n&+ystring&n on {1}&n and fire {2}&n!";
                    break;
                case ObjTemplate.RNG_BOW:
                    msg = "{0}&n pulls back the &n&+ystring&n on {1}&n and fires {2}&n!";
                    break;
                case ObjTemplate.RNG_CROSSBOW:
                    msg = "{0}&n fires {1} bolt {2}!";
                    break;
                case ObjTemplate.RNG_CATAPULT:
                    msg = "{0}&n cranks back {1}, and releases it {2}ward!";
                    break;
            }
            buf = String.Format(msg, (ch.IsNPC() ? ch.ShortDescription : ch.Name),
                      obj.ShortDescription, dir.ToString());
            SocketConnection.Act(buf, ch, null, null, SocketConnection.MessageTarget.room);

            ObjTemplate objTemplate = Database.GetObjTemplate(obj.Values[5]);
            if (!objTemplate)
            {
                Log.Error("Ranged weapon (index number {0}) has invalid ammunition.", 0);
                return;
            }

            if (!ch.InRoom.ExitData[dir]
                    || ch.InRoom.ExitData[dir].HasFlag(Exit.ExitFlag.closed))
            {
                newobj = Database.CreateObject(Database.GetObjTemplate(obj.Values[5]), 0);
                if (!newobj)
                    Log.Error("Commandshoot: Missile not created! (1)", 0);
                obj.Values[4]--;

                switch (obj.Values[3])
                {
                    default:
                        msg = "{0}&n impales itself into the &n&+yground&n.";
                        break;
                    case ObjTemplate.RNG_BOW:
                        msg = "{0}&n impales itself into the &n&+yground&n.";
                        break;
                    case ObjTemplate.RNG_CROSSBOW:
                        msg = "{0}&n falls to the &n&+yground&n.";
                        break;
                    case ObjTemplate.RNG_CATAPULT:
                        msg = "{0}&n crashes to the &n&+yground&n.";
                        break;
                }

                buf = String.Format(msg, newobj.ShortDescription);

                SocketConnection.Act(buf.ToUpper(), ch, null, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act(buf.ToUpper(), ch, null, null, SocketConnection.MessageTarget.character);
                newobj.AddToRoom(ch.InRoom);
                return;
            }
            newobj = Database.CreateObject(objTemplate, 0);
            if (!newobj)
                Log.Error("Commandshoot: Missile not created! (2)", 0);
            obj.Values[4]--;

            for (n = 1, exit = ch.InRoom.ExitData[dir]; exit && n <= (range + 1); n++)
            {
                if (exit.HasFlag(Exit.ExitFlag.closed)
                        || exit.HasFlag(Exit.ExitFlag.jammed))
                {
                    switch (obj.Values[3])
                    {
                        default:
                            msg = "{0}&n impales itself into the &n&+yground&n.";
                            break;
                        case ObjTemplate.RNG_BOW:
                            msg = "{0}&n impales itself into the &n&+yground&n.";
                            break;
                        case ObjTemplate.RNG_CROSSBOW:
                            msg = "{0}&n falls to the &n&+yground&n.";
                            break;
                        case ObjTemplate.RNG_CATAPULT:
                            msg = "{0}&n crashes to the &n&+yground&n.";
                            break;
                    }

                    buf = String.Format(msg, newobj.ShortDescription);

                    if (Room.GetRoom(exit.IndexNumber) && Room.GetRoom(exit.IndexNumber).People.Count > 0)
                    {
                        SocketConnection.Act(buf, Room.GetRoom(exit.IndexNumber).People[0], null, null, SocketConnection.MessageTarget.room);
                        SocketConnection.Act(buf, Room.GetRoom(exit.IndexNumber).People[0], null, null, SocketConnection.MessageTarget.character);
                    }

                    newobj.AddToRoom(Room.GetRoom(exit.IndexNumber));
                    SocketConnection.Act(buf, ch, null, null, SocketConnection.MessageTarget.room);
                    continue;
                }

                toRoom = Room.GetRoom(exit.IndexNumber);

                if (toRoom.People.Count > 0)
                {
                    foreach (CharData mob in toRoom.People)
                    {
                        if ((mob.CurrentPosition == Position.standing
                                || mob.CurrentPosition == Position.fighting)
                                && (Combat.CheckDodge(ch, mob) || ch.Level > MUDMath.NumberPercent()))
                        {
                            buf = String.Format("{0}&n streaks into {1}&n from {2}&n!",
                                      newobj.ShortDescription,
                                      (mob.IsNPC() ? mob.ShortDescription : mob.Name),
                                      Exit.ReverseDirectionName[dir]);
                            SocketConnection.Act(buf, mob, null, null, SocketConnection.MessageTarget.room);
                            n = range;

                            buf = String.Format("{0}&n streaks into you from {1}&n!",
                                      newobj.ShortDescription, Exit.ReverseDirectionName[dir]);
                            SocketConnection.Act(buf, mob, null, null, SocketConnection.MessageTarget.character);

                            int dam = MUDMath.NumberRange(obj.Values[1], obj.Values[2]);
                            dam += newobj.Values[1];

                            /*
                            * Weapon Proficiencies.
                            */
                            if (!ch.IsNPC() && ((PC)ch).SkillAptitude["archery"] > 0)
                                dam += dam * ((PC)ch).SkillAptitude["archery"] / 150;

                            if (ch.CurrentPosition == Position.fighting || ch.Fighting)
                                inBattle = true;
                            newobj.RemoveFromWorld();
                            ;
                            Combat.InflictDamage(ch, mob, dam, String.Empty, ObjTemplate.WearLocation.none, AttackType.DamageType.none);
                            if (!inBattle)
                                Combat.StopFighting(mob, true);
                            else
                                Combat.StopFighting(mob, false);

                            if (mob.IsNPC())
                            {
                                Combat.StartGrudge(mob, ch, false);
                            }

                            if (mob.CurrentPosition > Position.stunned
                                    && obj.Values[3] == ObjTemplate.RNG_CATAPULT)
                            {
                                SocketConnection.Act("The impDescriptor._actFlags puts $n&n to sleep!", mob, null, null, SocketConnection.MessageTarget.room);
                                SocketConnection.Act("The impact puts you to sleep... ZzZzZ", mob, null, null, SocketConnection.MessageTarget.character);
                                mob.CurrentPosition = Position.sleeping;
                            }

                            //      continue;
                            return;
                        }
                    }
                }

                if (toRoom.People.Count > 0)
                {
                    if (n <= range)
                    {
                        buf = String.Format("{0}&n streaks through the air and continues {1}&n.",
                                  newobj.ShortDescription, dir.ToString());
                        SocketConnection.Act(buf, toRoom.People[0], null, null, SocketConnection.MessageTarget.room);
                        SocketConnection.Act(buf, toRoom.People[0], null, null, SocketConnection.MessageTarget.character);
                    }
                    else
                    {
                        buf = String.Format("{0}&n zooms in and lands on the &n&+yground&n.",
                                  newobj.ShortDescription);
                        SocketConnection.Act(buf, toRoom.People[0], null, null, SocketConnection.MessageTarget.room);
                        SocketConnection.Act(buf, toRoom.People[0], null, null, SocketConnection.MessageTarget.character);
                        newobj.AddToRoom(toRoom);
                    }
                }

                exit = toRoom.ExitData[dir];
            }

            return;
        }
Exemple #9
0
        /// <summary>
        /// Sing -- using a bard song without an instrument.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Sing(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (!ch.IsClass(CharClass.Names.bard) && !ch.IsImmortal())
            {
                ch.SendText("You don't know how to sing.\r\n");
                return;
            }

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

            if (ch.HasActionBit(Affect.AFFECT_MUTE))
            {
                ch.SendText("You have no voice!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                if (ch.IsAffected(Affect.AFFECT_SINGING))
                {
                    ch.RemoveAffect(Affect.AFFECT_SINGING);
                    ch.SendText("You stop singing.\r\n");
                }
                else
                {
                    ch.SendText("Sing what?\r\n");
                }
                return;
            }

            Magic.Cast(ch, String.Join(" ", str));
        }
Exemple #10
0
        /// <summary>
        /// Reply to the last 'tell' that you received.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Reply(CharData ch, string[] str)
        {
            if( ch == null ) return;
            if (!ch.CanSpeak())
            {
                ch.SendText("Your lips move but no sound comes out.\r\n");
                return;
            }

            CharData victim = ch.ReplyTo;
            if (!victim)
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if ((!ch.IsNPC() && (ch.HasActionBit(PC.PLAYER_SILENCE)
                      || !ch.HasActionBit(PC.PLAYER_TELL) || (!victim.IsNPC() &&
                     !victim.HasActionBit(PC.PLAYER_TELL)))) || victim.InRoom.HasFlag(RoomTemplate.ROOM_SILENT))
            {
                ch.SendText("Your message didn't get through.\r\n");
                return;
            }

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

            if (!victim.Socket)
            {
                SocketConnection.Act("$N is &+Llinkdead&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (!ch.IsImmortal() && !victim.IsAwake())
            {
                SocketConnection.Act("$E can't hear you.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                SocketConnection.Act("$E is ignoring you.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            string text = String.Join(" ", str);
            text = DrunkSpeech.MakeDrunk(text, ch);

            SocketConnection.Act("&+WYou tell $N&+W '$t&+W'&n", ch, text, victim, SocketConnection.MessageTarget.character);
            int position = victim.CurrentPosition;
            victim.CurrentPosition = Position.standing;
            SocketConnection.Act("&+W$n&+W tells you '$t&+W'&n", ch, SocketConnection.TranslateText(text, ch, victim), victim, SocketConnection.MessageTarget.victim);
            victim.CurrentPosition = position;
            victim.ReplyTo = ch;

            if (victim.HasActionBit(PC.PLAYER_AFK))
            {
                SocketConnection.Act("Just so you know, $E is &+RAFK&n.", ch, null, victim, SocketConnection.MessageTarget.character);
            }
            else if (victim.HasActionBit(PC.PLAYER_BOTTING))
            {
                SocketConnection.Act("Just so you know, $E is a &+YBOT&n", ch, null, victim, SocketConnection.MessageTarget.character);
            }

            return;
        }
Exemple #11
0
        /// <summary>
        /// Used to flag a player as running or not running a bot.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Bot(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            if (ch.HasActionBit(PC.PLAYER_BOTTING))
            {
                ch.RemoveActionBit(PC.PLAYER_BOTTING);
                ch.SendText("&nYou are no longer running a bot.\r\n");
                SocketConnection.Act("$n&n's soul has returned to $s body.", ch, null, ch, SocketConnection.MessageTarget.room);
            }
            else
            {
                ch.SetActionBit(PC.PLAYER_BOTTING);
                ch.SendText("&nYou are now running a bot.\r\n");
                SocketConnection.Act("$n&n's soul has left $s body.", ch, null, ch, SocketConnection.MessageTarget.room);
            }

            return;
        }
Exemple #12
0
        /// <summary>
        ///  Weapons #'s:             Ammo #'s:
        /// 0: Range of weapon      0:
        /// 1: Max ammo that can be held    1:
        /// 2: Unused           2:
        /// 3: Type of ammo loadable    3: Type of ammo.
        /// 4: Amount of ammo loaded atm    4:
        /// 5: index number of ammo loaded atm  5:
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Reload(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object quiver;
            Object ammo = null;

            if (ch.IsNPC() && ch.HasActionBit(MobTemplate.ACT_PET))
            {
                return;
            }

            Object weapon = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_two);
            if (!weapon)
            {
                ch.SendText("I don't see that weapon here.\r\n");
                return;
            }

            if (weapon.ItemType != ObjTemplate.ObjectType.ranged_weapon)
            {
                ch.SendText("That is not a missile weapon.\r\n");
                return;
            }

            foreach (Object ammoobj in ch.Carrying)
            {
                if (ammoobj.ObjIndexData.IndexNumber == weapon.Values[5])
                {
                    ammo = ammoobj;
                    break;
                }
                if (weapon.Values[4] == 0
                        && ammoobj.ItemType == ObjTemplate.ObjectType.missile_weapon
                        && ammoobj.Values[3] == weapon.Values[3])
                {
                    ammo = ammoobj;
                    break;
                }
            }

            if (!ammo && (quiver = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.quiver)))
            {
                foreach (Object ammo2 in quiver.Contains)
                {
                    if (ammo2.ObjIndexData.IndexNumber == weapon.Values[5])
                    {
                        ammo = ammo2;
                        break;
                    }
                    if (weapon.Values[4] == 0
                            && ammo2.ItemType == ObjTemplate.ObjectType.missile_weapon
                            && ammo2.Values[3] == weapon.Values[3])
                    {
                        ammo = ammo2;
                        break;
                    }
                }
            }

            if (!ammo)
            {
                if (weapon.Values[4] <= 0)
                    ch.SendText("You do not have ammo for this weapon.\r\n");
                else
                    ch.SendText("You can't load two types of ammo into one weapon.");
                return;
            }

            if (weapon.Values[4] >= weapon.Values[1])
            {
                string buf = String.Format("{0} is already fully loaded.\r\n", weapon.ShortDescription);
                ch.SendText(buf);
                return;
            }

            weapon.Values[5] = ammo.ObjIndexData.IndexNumber;
            weapon.Values[4]++;

            SocketConnection.Act("You get $p&n.", ch, ammo, weapon, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n gets $p&n.", ch, ammo, weapon, SocketConnection.MessageTarget.room);

            SocketConnection.Act("You load $P&n with $p&n.", ch, ammo, weapon, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n loads $P&n with $p&n.", ch, ammo, weapon, SocketConnection.MessageTarget.room);

            ammo.RemoveFromWorld();
            return;
        }
Exemple #13
0
        /// <summary>
        /// Command to recline.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Recline(CharData ch, string[] str)
        {
            if( ch == null ) return;

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

            switch (ch.CurrentPosition)
            {
                case Position.sleeping:
                    ch.SendText("You are sleeping.\r\n");
                    break;

                case Position.reclining:
                    ch.SendText("You are already reclining.\r\n");
                    break;

                case Position.fighting:
                    ch.SendText("Not while you're fighting!\r\n");
                    break;

                case Position.sitting:
                case Position.kneeling:
                case Position.resting:
                case Position.standing:
                    if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
                    {
                        ch.RemoveActionBit(PC.PLAYER_MEMORIZING);
                        ch.SendText("You abandon your studies.\r\n");
                    }
                    ch.SendText("You recline.\r\n");
                    SocketConnection.Act("$n&n reclines.", ch, null, null, SocketConnection.MessageTarget.room);
                    ch.CurrentPosition = Position.reclining;
                    break;
            }

            return;
        }
Exemple #14
0
        // This code is basically a hack, and I'm adding a boatload of log
        // messages until I am satisfied that this code works and is stable.
        // When messing with code like this, it is easy to have players that
        // don't enter or leave the game completely, causing ghost images,
        // player duplicates, weird dangling pointers, etc., so we have to
        // be especially careful.  If anyone happens upon this and has a
        // suggestion for how to handle anything better than I have it will
        // be greatly appreciated.
        public static void Quit(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            // If they're not an immortal, assume they want to rent or camp and be smart
            // enough to try renting first.
            if (!ch.IsImmortal())
            {
                if (ch.InRoom != null && ch.InRoom.HasFlag(RoomTemplate.ROOM_INN))
                {
                    Rent(ch, str);
                    return;
                }
                Camp(ch, str);
                return;
            }

            if (ch.CurrentPosition == Position.fighting || ch.Fighting)
            {
                if (ch.HasActionBit(PC.PLAYER_CAMPING))
                {
                    ch.SendText("You're not gifted enough to make camp and fight at the same time.\r\n");
                    ch.RemoveActionBit(PC.PLAYER_CAMPING);
                    return;
                }
                ch.SendText("No way! You are fighting.\r\n");
                return;
            }

            if (ch.CurrentPosition < Position.stunned)
            {
                if (MUDMath.NumberRange(1, 2) == 1)
                {
                    ch.SendText("You're not &+RD&n&+rE&+RA&n&+rD&n yet.\r\n");
                    return;
                }
                ch.SendText("Just lie still and finish &+RBle&+reding&n!\r\n");
                return;
            }

            SocketConnection.Quit(ch);
        }
Exemple #15
0
        public static void Channels(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (str.Length == 0 || String.IsNullOrEmpty(str[0]))
            {
                if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_SILENCE))
                {
                    ch.SendText("&nYou are silenced, cur.\r\n");
                    return;
                }

                ch.SendText("Channels:");

                ch.SendText(ch.IsListening(TalkChannel.shout)
                              ? " +SHOUT"
                              : " -shout");

                ch.SendText(ch.IsListening(TalkChannel.yell)
                              ? " +YELL"
                              : " -yell");

                if (ch.IsGuild())
                {
                    ch.SendText(ch.IsListening(TalkChannel.guild)
                                  ? " +guild"
                                  : " -guild");
                }

                if (ch.IsHero())
                {
                    ch.SendText(ch.IsListening(TalkChannel.immortal)
                                  ? " +IMMTALK"
                                  : " -immtalk");
                }

                ch.SendText(".\r\n");
            }
            else
            {
                TalkChannel bit;
                bool fClear;

                if (str[0][0] == '+')
                    fClear = true;
                else if (str[0][0] == '-')
                    fClear = false;
                else
                {
                    ch.SendText("&nChannels -channel or +channel?\r\n");
                    return;
                }

                string tmparg = String.Format("{0}", str[0]);
                if (!MUDString.StringsNotEqual(tmparg + 1, "immtalk"))
                    bit = TalkChannel.immortal;
                else if (!MUDString.StringsNotEqual(tmparg + 1, "guild"))
                    bit = TalkChannel.guild;
                else if (!MUDString.StringsNotEqual(tmparg + 1, "shout"))
                    bit = TalkChannel.shout;
                else if (!MUDString.StringsNotEqual(tmparg + 1, "yell"))
                    bit = TalkChannel.yell;
                else
                {
                    ch.SendText("&nSet or clear which channel?\r\n");
                    return;
                }

                if (fClear)
                    ch.SetListening(bit, true);
                else
                    ch.SetListening(bit, false);

                ch.SendText("&nOk.\r\n");
            }

            return;
        }
Exemple #16
0
        /// <summary>
        /// Command to toggle brief mode.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Brief(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string buf;

            if (ch.HasActionBit(PC.PLAYER_BRIEF))
                buf = String.Format("-brief");
            else
                buf = String.Format("+brief");

            CommandType.Interpret(ch, "toggle " + buf);

            return;
        }
Exemple #17
0
        /// <summary>
        /// Lets a player turn ANSI color on and off.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void ColorCommand(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (!ch.HasActionBit(PC.PLAYER_COLOR))
            {
                ch.SetActionBit(PC.PLAYER_COLOR);
                ch.SendText("&+LThe world becomes more &n&+mco&+Ml&+Wor&+Cf&n&+cul&+L.&n\r\n");
            }
            else
            {
                SocketConnection.SendToCharBW("The color drains.\r\n", ch);
                ch.RemoveActionBit(PC.PLAYER_COLOR);
            }
            return;
        }
Exemple #18
0
        /// <summary>
        /// Command to fall asleep.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Sleep(CharData ch, string[] str)
        {
            if( ch == null ) return;
            switch (ch.CurrentPosition)
            {
                case Position.sleeping:
                    ch.SendText("You are already sleeping.\r\n");
                    break;

                case Position.reclining:
                case Position.sitting:
                case Position.kneeling:
                case Position.resting:
                case Position.standing:

                    if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
                    {
                        ch.RemoveActionBit(PC.PLAYER_MEMORIZING);
                        ch.SendText("You abandon your studies.\r\n");
                    }
                    ch.SendText("You sleep.\r\n");
                    SocketConnection.Act("$n&n sleeps.", ch, null, null, SocketConnection.MessageTarget.room);
                    ch.CurrentPosition = Position.sleeping;
                    break;

                case Position.fighting:
                    ch.SendText("Not while you're fighting!\r\n");
                    break;
            }

            return;
        }
Exemple #19
0
        /// <summary>
        /// Consider killing a target.  Lets the actor know whether it would be a good idea or not.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Consider(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string msg;

            if (str.Length == 0)
            {
                ch.SendText("&nConsider killing whom?\r\n");
                return;
            }

            CharData victim = ch.GetCharRoom(str[0]);
            if (!victim)
            {
                ch.SendText("&nThey're not here.\r\n");
                return;
            }

            if (victim == ch)
            {
                ch.SendText("Killing yourself?  Try 'suicide confirm'.\r\n");
                return;
            }

            int diff = victim.Level - ch.Level;

            if (victim.IsAffected( Affect.AFFECT_PROWESS))
                diff += (5 + victim.Level / 5);

            if (victim.IsAffected( Affect.AFFECT_INCOMPETENCE))
                diff -= (5 + victim.Level / 5);

            if (ch.HasActionBit(PC.PLAYER_COLOR_CON))
            {
                if (diff <= -10)
                    msg = "&n&+bToo easy to bother with.&n";
                else if (diff <= -5)
                    msg = "&n&+bYou could do it blindfolded!&n";
                else if (diff <= -2)
                    msg = "&n&+BEasy.&n";
                else if (diff <= -1)
                    msg = "&n&+gFairly easy.&n";
                else if (diff <= 0)
                    msg = "&n&+GAn even fight!&n";
                else if (diff <= 1)
                    msg = "&n&+gYou would need some luck.&n";
                else if (diff <= 2)
                    msg = "&n&+yYou would need a lot of luck!&n";
                else if (diff <= 3)
                    msg = "&n&+YYou would need a lot of luck and great equipment!&n";
                else if (diff <= 5)
                    msg = "&n&+YYou would probably lose that fight.&n";
                else if (diff <= 10)
                    msg = "&n&+RAre you mad!?&n";
                else if (diff <= 15)
                    msg = "&n&+RYou ARE mad!&n";
                else if (diff <= 20)
                    msg = "&n&+rWhy don't you just lie down and pretend you're dead instead?&n";
                else if (diff <= 25)
                    msg = "&n&+rWhat do you want your epitaph to say?!?&n";
                else
                    msg = "&n&+LYou wouldn't last one round of combat!&n";
            }
            else
            {
                if (diff <= -10)
                    msg = "&nToo easy to bother with.&n";
                else if (diff <= -5)
                    msg = "&nYou could do it blindfolded!&n";
                else if (diff <= -2)
                    msg = "&nEasy.&n";
                else if (diff <= -1)
                    msg = "&nFairly easy.&n";
                else if (diff <= 0)
                    msg = "&nAn even fight!&n";
                else if (diff <= 1)
                    msg = "&nYou would need some luck.&n";
                else if (diff <= 2)
                    msg = "&nYou would need a lot of luck!&n";
                else if (diff <= 3)
                    msg = "&nYou would need a lot of luck and great equipment!&n";
                else if (diff <= 5)
                    msg = "&nYou would probably lose that fight.&n";
                else if (diff <= 10)
                    msg = "&nAre you mad!?&n";
                else if (diff <= 15)
                    msg = "&nYou ARE mad!&n";
                else if (diff <= 20)
                    msg = "&nWhy don't you just lie down and pretend you're dead instead?&n";
                else if (diff <= 25)
                    msg = "&nWhat do you want your epitaph to say?!?&n";
                else
                    msg = "&nYou wouldn't last one round of combat!&n";
            }

            SocketConnection.Act(msg, ch, null, victim, SocketConnection.MessageTarget.character);
            SocketConnection.Act("$n&n sizes $N&n up with a quick glance.", ch, null, victim, SocketConnection.MessageTarget.room);
            SocketConnection.Act("$n&n sizes you up with a quick glance.", ch, null, victim, SocketConnection.MessageTarget.victim);
            return;
        }
Exemple #20
0
        /// <summary>
        /// Command to stand up.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Stand(CharData ch, string[] str)
        {
            if( ch == null ) return;
            if (ch.IsAffected( Affect.AFFECT_HOLD) || ch.IsAffected( Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You're paralyzed!\r\n");
                return;
            }

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

            switch (ch.CurrentPosition)
            {
                case Position.sleeping:
                    if (ch.IsAffected( Affect.AFFECT_SLEEP))
                    {
                        ch.SendText("You can't wake up!\r\n");
                        return;
                    }

                    ch.SendText("You wake and stand up.\r\n");
                    SocketConnection.Act("$n&n wakes and stands up.", ch, null, null, SocketConnection.MessageTarget.room);
                    ch.CurrentPosition = Position.standing;
                    break;

                case Position.sitting:
                case Position.kneeling:
                case Position.reclining:
                case Position.resting:
                    ch.SendText("You stand up.\r\n");
                    SocketConnection.Act("$n&n stands up.", ch, null, null, SocketConnection.MessageTarget.room);
                    if (ch.Fighting)
                    {
                        ch.CurrentPosition = Position.fighting;
                    }
                    else
                    {
                        ch.CurrentPosition = Position.standing;
                    }
                    break;

                case Position.fighting:
                case Position.standing:
                    ch.SendText("You are already standing.\r\n");
                    break;
            }

            return;
        }
Exemple #21
0
        /// <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");
                            return;
                        case ObjTemplate.ObjectType.vehicle:
                        case ObjTemplate.ObjectType.ship:
                            break;
                        case ObjTemplate.ObjectType.other:
                            break;
                        default:
                            ch.SendText("That cannot be entered.\r\n");
                            return;
                    }
                }
            }

            Exit.Direction door = Movement.FindExit(ch, str[1]);

            if (door < 0)
            {
                ch.SendText("You can't drag anything that way.\r\n");
                return;
            }
            if (ch.CurrentMoves < 5 && !ch.IsImmortal())
            {
                ch.SendText("You are too exhausted to drag that anywhere.\r\n");
                return;
            }

            string text = String.Format("You drag $p&n {0}.", door.ToString());
            SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.character);
            text = String.Format("$n&n drags $p&n {0}.", door.ToString());
            SocketConnection.Act(text, ch, obj, null, SocketConnection.MessageTarget.room);

            obj.RemoveFromRoom();
            ch.CurrentMoves -= 5;

            ch.Move(door);
            ch.WaitState(MUDMath.NumberRange(3, 12));

            obj.AddToRoom(ch.InRoom);
            SocketConnection.Act("$n&n drags $p&n along behind $m.", ch, obj, null, SocketConnection.MessageTarget.room);
        }
Exemple #22
0
        /// <summary>
        /// The camp function now simply creates a camp event.
        /// The Command.Quit function handles quitters and campers, based
        /// on the camping bit.  The only goofy side effect of this is
        /// that an immortal who is camping can quit and get the
        /// "you roll up in your bedroll" message.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Camp(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            if (ch.CurrentPosition == Position.fighting || ch.Fighting)
            {
                ch.SendText("You're not gifted enough to make camp and fight at the same time.\r\n");
                ch.RemoveActionBit(PC.PLAYER_CAMPING);
                return;
            }

            if (ch.FlightLevel != 0)
            {
                ch.SendText("Perhaps it would be more comfortable on the ground.\r\n");
                return;
            }

            if (ch.HasActionBit(PC.PLAYER_CAMPING))
            {
                ch.SendText("Your preparations are not quite complete.\r\n");
                return;
            }

            if (ch.CurrentPosition < Position.stunned)
            {
                ch.SendText("Just lie still and finish &+RBle&+reding&n!\r\n");
                return;
            }

            SocketConnection.Act("$n&n starts to set up camp.", ch, null, null, SocketConnection.MessageTarget.room);
            ch.SendText("You start to set up camp.\r\n");
            ch.SetActionBit(PC.PLAYER_CAMPING);
            // Pass the character, the room they started camping in, and the
            // number of cycles to camp for
            // Pulse camp is 5 seconds, so make them wait for 1.5 minutes
            Event.CreateEvent(Event.EventType.camp, Event.TICK_CAMP, ch, ch.InRoom, 18);

            return;
        }
Exemple #23
0
        /// <summary>
        /// Emote - act like you've just performed an action.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Emote(CharData ch, string[] str)
        {
            if( ch == null ) return;
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_NO_EMOTE))
            {
                ch.SendText("You are unable to emote.\r\n");
                return;
            }

            if (ch.CurrentPosition == Position.fighting || ch.Fighting)
            {
                ch.SendText("You can't emote in combat.\r\n");
                return;
            }

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

            string text = String.Join(" ", str );
            if (text[(text.Length - 1)] != '.')
            {
                text += ".";
            }

            foreach (CharData roomChar in ch.InRoom.People)
            {
                if (roomChar == ch)
                    continue;

                SocketConnection.Act("$n $t", ch, SocketConnection.TranslateText(text, ch, roomChar), roomChar, SocketConnection.MessageTarget.victim);
            }
            //    MOBtrigger = false;
            SocketConnection.Act("$n $T", ch, null, text, SocketConnection.MessageTarget.character);
            return;
        }
Exemple #24
0
        /// <summary>
        /// Direct telepathy-like communication with another individual.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Tell(CharData ch, string[] str)
        {
            if( ch == null ) return;

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

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

            /*
            * PCs can receive a tell anywhere, but NPCs only can only hear them in the same room.
            *
            * get PC target first, if fails then get NPC
            */

            CharData victim = ch.GetCharWorld(str[0]);
            if (!victim || (victim.IsNPC() && victim.InRoom != ch.InRoom))
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if (victim == ch)
            {
                ch.SendText("You listen to your own thoughts. *cricket* *cricket*\r\n");
                return;
            }

            if ((ch.IsRacewar(victim)) && (!ch.IsImmortal() && !victim.IsImmortal())
                    && (ch.InRoom != victim.InRoom))
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            /* Can tell to other side of racewar iff the opponent is in the same
            room or one of the people are Immortals. */
            if ((!ch.IsImmortal() && !victim.IsImmortal()) && (ch.IsRacewar(victim))
                    && (victim.InRoom != ch.InRoom))
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if ((!ch.IsNPC() && (ch.HasActionBit(PC.PLAYER_SILENCE) || !ch.HasActionBit(PC.PLAYER_TELL)
                || (!victim.IsNPC() && !victim.HasActionBit(PC.PLAYER_TELL))))
                    || victim.InRoom.HasFlag(RoomTemplate.ROOM_SILENT))
            {
                ch.SendText("They can't hear you.\r\n");
                return;
            }

            if (!victim.Socket && !victim.IsNPC())
            {
                SocketConnection.Act("$N&n is &+Llinkdead&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (!ch.IsImmortal() && !victim.IsAwake())
            {
                SocketConnection.Act("$E isn't paying attention.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                SocketConnection.Act("$E is ignoring you.", ch, null, victim, SocketConnection.MessageTarget.character);
                return;
            }

            string text = String.Join(" ", str, 1, (str.Length - 1));
            text = DrunkSpeech.MakeDrunk(text, ch);

            int position = victim.CurrentPosition;
            victim.CurrentPosition = Position.standing;
            Race.Language lang = ch.IsNPC() ? Race.RaceList[ch.GetOrigRace()].PrimaryLanguage :
                                                                                       ((PC)ch).Speaking;
            if (lang == Race.Language.god || lang == Race.Language.unknown)
            {
                text = String.Format("&+WYou tell $N&+W '$t&+W'&n");
            }
            else
            {
                text = String.Format("&+WYou tell $N&+W in {0} '$t&+W'&n", Race.LanguageTable[(int)lang]);
            }

            SocketConnection.Act(text, ch, text, victim, SocketConnection.MessageTarget.character);
            if (lang == Race.Language.god || lang == Race.Language.unknown)
            {
                text = String.Format("&+W$n&+W tells you '$t&+W'&n");
            }
            else
            {
                text = String.Format("&+W$n&+W tells you in {0} '$t&+W'&n", Race.LanguageTable[(int)lang]);
            }
            SocketConnection.Act(text, ch, SocketConnection.TranslateText(text, ch, victim), victim, SocketConnection.MessageTarget.victim);
            victim.CurrentPosition = position;
            victim.ReplyTo = ch;

            if (victim.HasActionBit(PC.PLAYER_AFK))
            {
                SocketConnection.Act("Just so you know, $E is &+RAFK&n.", ch, null, victim, SocketConnection.MessageTarget.character);
            }
            else if (victim.HasActionBit(PC.PLAYER_BOTTING))
            {
                SocketConnection.Act("Just so you know, $E is a &+YBOT&n", ch, null, victim, SocketConnection.MessageTarget.character);
            }

            // players can't have talk files -- go home!  Quest stuff.
            if (!victim.IsNPC())
            {
                return;
            }

            bool questfound = false;
            foreach (QuestTemplate it in QuestTemplate.QuestList)
            {
                bool isquest = (ch.IsImmortal() && !MUDString.StringsNotEqual(text, "quest")) ? true : false;

                if (it.Messages == null || (it.IndexNumber != victim.MobileTemplate.IndexNumber))
                    continue;
                foreach (TalkData message in it.Messages)
                {
                    if (MUDString.NameContainedIn(text, message.Keywords) || isquest)
                    {
                        ch.SendText("\r\n");
                        ch.SendText(message.Message);
                        questfound = true;
                    }
                }
            }
            // Chatterbot code.  Bots won't check if a quest matched (prevents multiple statements).
            if (!questfound && victim.ChatBot != null)
            {
                victim.ChatBot.CheckConversation(victim, ch, text);
            }

            return;
        }
Exemple #25
0
        /// <summary>
        /// Flee: Attempt to run away from combat.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Flee(CharData ch, string[] str)
        {
            if( ch == null ) return;

            int attempt;
            int chances;

            if (ch.CurrentPosition < Position.reclining || ch.Wait > 0)
            {
                return;
            }

            // Remove memorization and meditation bits - Xangis
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEDITATING))
            {
                SocketConnection.Act("$N&n is disrupted from meditation.", ch, null, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("Your meditation is disrupted.", ch, null, null, SocketConnection.MessageTarget.character);
                ch.RemoveActionBit(PC.PLAYER_MEDITATING);
            }
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_MEMORIZING))
            {
                SocketConnection.Act("$N&n abandons $S studies.", ch, null, null, SocketConnection.MessageTarget.room);
                SocketConnection.Act("You abandon your studies.", ch, null, null, SocketConnection.MessageTarget.character);
                ch.RemoveActionBit(PC.PLAYER_MEMORIZING);
            }

            if (ch.CurrentPosition < Position.fighting)
            {
                ch.SendText("You scramble madly to your feet!\r\n");
                SocketConnection.Act("$n&n scrambles madly to $s feet!",
                     ch, null, null, SocketConnection.MessageTarget.room);
                ch.CurrentPosition = Position.standing;
                return;
            }

            if (!ch.InRoom)
            {
                ch.SendText("You give up when you realize there's nowhere to flee to.\r\n");
            }

            // Panicked people can flee when not fighting.
            CharData victim = ch.Fighting;
            if (!victim)
            {
                if (ch.CurrentPosition == Position.fighting)
                {
                    ch.CurrentPosition = Position.standing;
                }
            }

            if (ch.IsAffected(Affect.AFFECT_BERZERK))
            {
                ch.SendText("You can't flee, you're in a &+RBl&n&+ro&+Ro&n&+rd&+L Rage&n!!\r\n");
                return;
            }

            if (ch.IsAffected( Affect.AFFECT_BOUND))
            {
                ch.SendText("You are bound!  You can't move!\r\n");
                SocketConnection.Act("$n&n tries to flee, but is tied up!",
                     ch, null, null, SocketConnection.MessageTarget.room);
                return;
            }

            if (ch.IsAffected( Affect.AFFECT_HOLD) ||
                    ch.IsAffected( Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You can't move!\r\n");
                SocketConnection.Act("$n&n tries to flee, but $e can't move!",
                     ch, null, null, SocketConnection.MessageTarget.room);
                return;
            }

            // You should almost always be able to flee when not fighting.
            if (ch.CurrentPosition == Position.standing)
            {
                chances = 30;
            }
            else
            {
                chances = 6;
            }

            Room wasIn = ch.InRoom;
            for (attempt = 0; attempt < chances; attempt++)
            {
                Exit exit;

                Exit.Direction door = Database.RandomDoor();
                if ((exit = wasIn.GetExit(door)) == null || !exit.TargetRoom
                        || exit.TargetRoom == wasIn || exit.HasFlag(Exit.ExitFlag.closed)
                        || (ch.IsNPC() && (Room.GetRoom(exit.IndexNumber).HasFlag(RoomTemplate.ROOM_NO_MOB)
                        || (ch.HasActionBit(MobTemplate.ACT_STAY_AREA) && exit.TargetRoom.Area != ch.InRoom.Area))))
                {
                    continue;
                }

                if (ch.Riding && ch.Riding.Fighting)
                {
                    Combat.StopFighting(ch.Riding, true);
                }

                // Just to keep the damned messages from being wacky...
                ch.SetAffectBit(Affect.AFFECT_IS_FLEEING);
                ch.Move(door);
                ch.RemoveAffect(Affect.AFFECT_IS_FLEEING);
                if (ch.InRoom == wasIn)
                {
                    break;
                }
                Room nowIn = ch.InRoom;
                ch.InRoom = wasIn;

                SocketConnection.Act("$n&n panics and attempts to flee...", ch, null, null, SocketConnection.MessageTarget.room, true);
                string text;
                if (ch.CheckSneak())
                {
                    SocketConnection.Act("$n&n has fled!", ch, null, null, SocketConnection.MessageTarget.room);
                }
                else
                {
                    text = String.Format("$n&n flees {0}ward.", door.ToString());
                    SocketConnection.Act(text, ch, null, null, SocketConnection.MessageTarget.room, true);
                }
                ch.InRoom = nowIn;

                text = String.Format("You flee {0}ward!\r\n", door.ToString());
                ch.SendText(text);

                Combat.StopFighting(ch, true);
                return;
            }

            SocketConnection.Act("$n&n tries to flee but can't make it out of here!", ch, null, null, SocketConnection.MessageTarget.room, true);
            ch.SendText("&+WYour escape is blocked!\r\n");
            return;
        }
Exemple #26
0
        /// <summary>
        /// Sets and gets player configuration options.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="argument"></param>
        public static void Toggle(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            if (str.Length == 0)
            {
                ch.SendText("&+L+------------+------------------------------------------------------------+&n\r\n");
                ch.SendText("&+L|&n&+m  Option&+L    |&n&+r Description&n                                                &+L|&n\r\n");
                ch.SendText("&+L+------------+------------------------------------------------------------+&n\r\n");
                ch.SendText(ch.HasActionBit(PC.PLAYER_AUTOWRAP)
                               ? "&+L[&+WX&+L]&n Autowrap &+L|&n &+cThe MUD automatically wraps long lines of text.            &+L|&n\r\n"
                               : "&+L[ ]&n Autowrap &+L|&n &+cThe MUD does not automatically wrap long text.             &+L|&n\r\n"
                               );
                ch.SendText(ch.HasActionBit(PC.PLAYER_BLANK)
                               ? "&+L[&+WX&+L]&n Blank    &+L|&n &+cYou have a blank line before your prompt.                  &+L|&n\r\n"
                               : "&+L[ ]&n Blank    &+L|&n &+cYou have no blank line before your prompt.                 &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_BRIEF)
                               ? "&+L[&+WX&+L]&n Brief    &+L|&n &+cYou see brief descriptions.                                &+L|&n\r\n"
                               : "&+L[ ]&n Brief    &+L|&n &+cYou see long descriptions.                                 &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_CAST_TICK)
                               ? "&+L[&+WX&+L]&n Casttick &+L|&n &+cYou see your casting ticks.                                &+L|&n\r\n"
                               : "&+L[ ]&n Casttick &+L|&n &+cFor spam's sake, no casting ticks!                         &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_COMBINE)
                               ? "&+L[&+WX&+L]&n Combine  &+L|&n &+cYou see object lists in combined format.                   &+L|&n\r\n"
                               : "&+L[ ]&n Combine  &+L|&n &+cYou see object lists in single format.                     &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_COLOR)
                               ? "&+L[&+WX&+L]&n Color    &+L|&n &+cYou see ANSI colors.                                       &+L|&n\r\n"
                               : "&+L[ ]&n Color    &+L|&n &+cYou don't see ANSI colors.                                 &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_COLOR_CON)
                               ? "&+L[&+WX&+L]&n Colorcon &+L|&n &+cYou see ANSI colors in consider messages.                  &+L|&n\r\n"
                               : "&+L[ ]&n Colorcon &+L|&n &+cYou don't see ANSI colors in consider messages.            &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_MSP)
                               ? "&+L[&+WX&+L]&n MSP      &+L|&n &+cMUD Sound Protocol (MSP) support is on.                    &+L|&n\r\n"
                               : "&+L[ ]&n MSP      &+L|&n &+cMUD Sound Protocol (MSP) support is off.                   &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_PAGER)
                               ? "&+L[&+WX&+L]&n Pager    &+L|&n &+cText is shown in separate pages.                           &+L|&n\r\n"
                               : "&+L[ ]&n Pager    &+L|&n &+cText is shown all-at-once with no paging.                  &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_PROMPT)
                               ? "&+L[&+WX&+L]&n Prompt   &+L|&n &+cYou have a prompt.                                         &+L|&n\r\n"
                               : "&+L[ ]&n Prompt   &+L|&n &+cYou don't have a prompt.                                   &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_SHOUT)
                               ? "&+L[&+WX&+L]&n Shout    &+L|&n &+cYou can hear shouts.                                       &+L|&n\r\n"
                               : "&+L[ ]&n Shout    &+L|&n &+cYou cover your ears when someone is yelling.               &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_TELNET_GA)
                               ? "&+L[&+WX&+L]&n TelnetGA &+L|&n &+cYou receive a telnet go-ahead sequence.                    &+L|&n\r\n"
                               : "&+L[ ]&n TelnetGA &+L|&n &+cYou don't receive a telnet GA sequence.                    &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_TELL)
                               ? "&+L[&+WX&+L]&n Tell     &+L|&n &+cYou can hear tells.                                        &+L|&n\r\n"
                               : "&+L[ ]&n Tell     &+L|&n &+cYou are ignoring tells.                                    &+L|&n\r\n"
                                );
                ch.SendText(ch.HasActionBit(PC.PLAYER_VICIOUS)
                               ? "&+L[&+WX&+L]&n Vicious  &+L|&n &+cYou are vicious and will kill mortally wounded foes.       &+L|&n\r\n"
                               : "&+L[ ]&n Vicious  &+L|&n &+cYou aren't vicious and will spare a mortally wounded foe.  &+L|&n\r\n");
                ch.SendText(ch.HasActionBit(PC.PLAYER_MAP)
                               ? "&+L[&+WX&+L]&n Map      &+L|&n &+cYou see the maps.                                          &+L|&n\r\n"
                               : "&+L[ ]&n Map      &+L|&n &+cYou do not see maps.                                       &+L|&n\r\n");

                if (ch.HasActionBit(PC.PLAYER_SILENCE))
                {
                    ch.SendText( "&+L[&+WX&+L]&n Silence  &+L|&n &+cYou are silenced.                                       &+L|&n\r\n");
                }

                ch.SendText(!ch.HasActionBit(PC.PLAYER_NO_EMOTE)
                              ? "&n"
                              : "&+L[ ]&n emote    | &+cYou can't emote.                                                 &+L|&n\r\n");

                ch.SendText("&+L+------------+------------------------------------------------------------+&n\r\n");
                string termStr = "&+L|&n &+cYour terminal type is " + ch.Socket.Terminal + " and MCCP is " +
                    ch.Socket.MCCPEnabled + ".";
                while (termStr.Length < 82)
                    termStr += " ";
                termStr += "&+L|&n\r\n";
                ch.SendText(termStr);
                ch.SendText("&+L+-------------------------------------------------------------------------+&n\r\n");
            }
            else
            {
                string word;
                Bitvector bit;
                int fSet;

                if (str[0][0] == '-')
                {
                    fSet = 0;
                    word = str[0].Substring(1);
                }
                else if (str[0][0] == '+')
                {
                    fSet = 1;
                    word = str[0].Substring(1);
                }
                else
                {
                    fSet = 2;
                    word = str[0];
                }

                if (("blank".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_BLANK;
                else if (("autowrap".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_AUTOWRAP;
                else if (("brief".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_BRIEF;
                else if (("casttick".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_CAST_TICK;
                else if (("combine".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_COMBINE;
                else if (("color".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                {
                    if (ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED)
                    {
                        ch.SendText("You cannot turn color off when using the enhanced client.\r\n");
                        return;
                    }
                    bit = PC.PLAYER_COLOR;
                }
                else if (("colorcon".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_COLOR_CON;
                else if (("msp".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_MSP;
                else if (("pager".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_PAGER;
                else if (("shout".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_SHOUT;
                else if (("prompt".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_PROMPT;
                else if (("telnetga".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_TELNET_GA;
                else if (("tell".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_TELL;
                else if (("vicious".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_VICIOUS;
                else if (("map".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_MAP;
                else if (("vicious".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_VICIOUS;
                else if (("compact".StartsWith(word, StringComparison.CurrentCultureIgnoreCase)))
                    bit = PC.PLAYER_BLANK;
                else if (word.Contains("wimpy"))
                {
                    CommandType.Interpret(ch, "wimpy " + word.Substring((word.IndexOf("wimpy") + 5)));
                    return;
                }
                else if ("mccp".StartsWith(word, StringComparison.CurrentCultureIgnoreCase))
                {
                    ch.Socket.MCCPEnabled = !ch.Socket.MCCPEnabled;
                    if (ch.Socket.MCCPEnabled)
                    {
                        ch.SendText("MCCP is now enabled.");
                    }
                    else
                    {
                        ch.SendText("MCCP is now disabled.");
                    }
                    return;
                }
                else
                {
                    ch.SendText("&nConfig which option?\r\n");
                    return;
                }

                if (ch.IsClass(CharClass.Names.paladin) && bit == PC.PLAYER_VICIOUS)
                {
                    ch.SendText("Paladins may not toggle vicious.\r\n");
                    /* Just to make sure they don't have it toggled on. */
                    ch.RemoveActionBit(bit);
                    return;
                }

                if (fSet == 1)
                {
                    if (bit != PC.PLAYER_NONE)
                    {
                        ch.SetActionBit(bit);
                    }
                    ch.SendText( (String.Format("&n{0} is now ON.\r\n", word.ToUpper())));
                }
                else if (fSet == 0)
                {
                    if (bit != PC.PLAYER_NONE)
                    {
                        ch.RemoveActionBit(bit);
                    }
                    ch.SendText((String.Format("&n{0} is now OFF.\r\n", word.ToUpper())));
                }
                else if (fSet == 2)
                {
                    if (bit != PC.PLAYER_NONE)
                    {
                        ch.ToggleActionBit(bit);
                    }
                    if (ch.HasActionBit(bit))
                        ch.SendText((String.Format("&n{0} is now ON.\r\n", word.ToUpper())));
                    else
                        ch.SendText((String.Format("&n{0} is now OFF.\r\n", word.ToUpper())));
                }
            }

            return;
        }
Exemple #27
0
        /// <summary>
        /// Immortal command to paralyze a player.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Freeze(CharData ch, string[] str)
        {
            if( ch == null ) return;

            CharData victim;
            CharData realChar = ch.GetChar();

            if (!realChar.Authorized("freeze"))
            {
                return;
            }

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

            if (!(victim = ch.GetCharWorld(str[0])))
            {
                ch.SendText("They aren't here.\r\n");
                return;
            }

            if (ch == victim && ch.HasActionBit(PC.PLAYER_FREEZE))
            {
                ch.RemoveActionBit(PC.PLAYER_FREEZE);
            }

            if (victim.IsNPC())
            {
                ch.SendText("Not on NPC's.\r\n");
                return;
            }

            if (victim.GetTrust() >= ch.GetTrust())
            {
                ch.SendText("You failed.\r\n");
                return;
            }

            if (victim.HasActionBit(PC.PLAYER_FREEZE))
            {
                victim.RemoveActionBit(PC.PLAYER_FREEZE);
                ch.SendText("FREEZE bit removed.\r\n");
                victim.SendText("You can play again.\r\n");
            }
            else
            {
                victim.SetActionBit(PC.PLAYER_FREEZE);
                ch.SendText("FREEZE bit set.\r\n");
                victim.SendText("You can't do anything!\r\n");
            }

            CharData.SavePlayer(victim);

            return;
        }
Exemple #28
0
        /// <summary>
        /// Shows the world map.  Can be called from the look command or called directly.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Worldmap(CharData ch, string[] str)
        {
            int x;
            Room room;

            if (ch.InRoom == null)
            {
                return;
            }

            if (!ch.InRoom.Area.HasFlag(Area.AREA_WORLDMAP))
            {
                return;
            }

            // TODO: Use Map.GetUnderdarkVisibilityModifier(racewarside) and Map.GetDaytimeVisibilityModifier(racewarside)
            int visibility = 5 + (int)ch.FlightLevel;

            // Godmode will make you see farther on the map.
            if (!ch.IsNPC() && ch.HasActionBit(PC.PLAYER_GODMODE))
            {
                visibility += 5;
            }

            int indexNumber = ch.InRoom.IndexNumber;
            int startIndexNumber = ch.InRoom.Area.LowRoomIndexNumber;

            int column = (indexNumber - startIndexNumber) % ch.InRoom.Area.Width;
            int row = (indexNumber - startIndexNumber) / ch.InRoom.Area.Width;
            if (visibility <= 0 && !ch.IsAffected(Affect.AFFECT_BLIND))
            {
                visibility = 1;
            }

            if (visibility > Limits.MAX_MAP_VISIBILITY)
            {
                visibility = Limits.MAX_MAP_VISIBILITY;
            }

            string mapSpaces = String.Empty;
            string lineEnding = ":";
            string mapClose = "</map>";
            string text = "<map>";
            string boundchar = " ";
            bool graphicalClient = !ch.IsNPC() && ch.Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED;
            if (!graphicalClient)
            {
                boundchar = "&-L &n";
                mapSpaces = "     ";
                lineEnding = "\r\n";
                mapClose = "\r\n";
                text = "\r\n";
            }
            for (x = (0 - Limits.MAX_MAP_VISIBILITY); x <= Limits.MAX_MAP_VISIBILITY; x++)
            {
                if (graphicalClient)
                {
                    text += (x + Limits.MAX_MAP_VISIBILITY).ToString() + "|";
                }
                else if (x < (0 - visibility) || x > (visibility))
                {
                    continue;
                }
                text += mapSpaces;
                int y;
                for (y = (0 - Limits.MAX_MAP_VISIBILITY); y <= Limits.MAX_MAP_VISIBILITY; y++)
                {
                    if(x < (0 - visibility) || x > (visibility))
                    {
                        if (graphicalClient)
                        {
                            text += boundchar;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    bool hasM = false;
                    bool hasP = false;
                    room = Room.GetRoom((indexNumber + ((x * ch.InRoom.Area.Width) + y)));
                    if (room && room.People.Count > 0)
                    {
                        foreach (CharData roomChar in room.People)
                        {
                            if ((roomChar.FlightLevel == ch.FlightLevel || ch.FlightLevel == roomChar.FlightLevel + 1) && CharData.CanSee(ch, roomChar))
                            {
                                if (roomChar.IsNPC())
                                {
                                    if (roomChar.FlightLevel == ch.FlightLevel)
                                    {
                                        hasM = true;
                                    }
                                    else
                                    {
                                        hasM = false;
                                    }
                                }
                                else
                                {
                                    if (roomChar.FlightLevel == ch.FlightLevel)
                                    {
                                        hasP = true;
                                    }
                                    else
                                    {
                                        hasP = false;
                                    }
                                }
                            }
                        }
                    }
                    if (x == 0 && y == 0)
                    {
                        if (graphicalClient)
                        {
                            String chars = Map.GetMapCharacters(room, graphicalClient);
                            // Pick a diff character based on player's size.
                            text += chars[0];
                            int offset = 64;
                            if (ch.CurrentSize >= Race.Size.large && ch.CurrentSize <= Race.Size.gargantuan)
                            {
                                text += (char)(24 + offset); // Large humanoid
                            }
                            else if( ch.CurrentSize <= Race.Size.small && ch.CurrentSize >= Race.Size.tiny )
                            {
                                text += (char)(28 + offset); // Small humanoid
                            }
                            else
                            {
                                text += (char)(26 + offset); // Medium humanoid
                            }
                        }
                        else
                        {
                            text += "&+W@&n";
                        }
                    }
                    else if ((column + y) < 0 || (column + y) >= ch.InRoom.Area.Width ||
                             (row + x) < 0 || (row + x) >= ch.InRoom.Area.Height)
                    {
                        text += boundchar;
                    }
                    else if (!(room = Room.GetRoom((indexNumber + ((x * ch.InRoom.Area.Width) + y)))))
                    {
                        if (graphicalClient)
                        {
                            text += boundchar;
                        }
                        else
                        {
                            text += "&+L-&n";
                        }
                    }
                    else if (hasM)
                    {
                        if (graphicalClient)
                        {
                            text += "*";
                        }
                        else
                        {
                            text += Color.MOD_BLINK + "&+BM&n" + Color.MOD_CLEAR;
                        }
                    }
                    else if (hasP)
                    {
                        if (graphicalClient)
                        {
                            text += "!";
                        }
                        else
                        {
                            text += Color.MOD_BLINK + "&+WP&n" + Color.MOD_CLEAR;
                        }
                    }
                    else
                    {
                        text += Map.GetMapCharacters(room, graphicalClient);
                    }
                }
                text += lineEnding;
                /* Added these two lines to make it smaller string size in send_to_chr,
                * so that the pager isnt needed when large maps fill the screen
                */
                ch.SendText(text);
                text = String.Empty;
            }
            text += mapClose;

            ch.SendText(text);

            return;
        }
Exemple #29
0
        /// <summary>
        /// Teleport to another location.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Goto(CharData ch, string[] str)
        {
            if( ch == null ) return;

            CharData realChar = ch.GetChar();

            if (!realChar.Authorized("goto") || !ch.IsImmortal())
            {
                return;
            }

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

            Room location = Room.FindLocation(ch, str[0]);
            if (!location)
            {
                ch.SendText("No such location.\r\n");
                return;
            }

            if (location.IsPrivate())
            {
                ch.SendText("That room is private right now.\r\n");
                return;
            }

            if (ch.Fighting)
            {
                Combat.StopFighting(ch, true);
            }
            if (!ch.HasActionBit(PC.PLAYER_WIZINVIS))
            {
                if (!ch.IsNPC() && ((PC)ch).ImmortalData.DisappearMessage.Length > 0)
                {
                    SocketConnection.Act("$T", ch, null, ((PC)ch).ImmortalData.DisappearMessage, SocketConnection.MessageTarget.room);
                }
                else
                {
                    SocketConnection.Act("$n disappears in a puff of smoke.", ch, null, null, SocketConnection.MessageTarget.room);
                }
            }

            ch.RemoveFromRoom();
            ch.AddToRoom(location);

            if (!ch.HasActionBit(PC.PLAYER_WIZINVIS))
            {
                if (!ch.IsNPC() && ((PC)ch).ImmortalData.AppearMessage.Length > 0)
                {
                    SocketConnection.Act("$T", ch, null, ((PC)ch).ImmortalData.AppearMessage, SocketConnection.MessageTarget.room);
                }
                else
                {
                    SocketConnection.Act("$n appears in a swirling mist", ch, null, null, SocketConnection.MessageTarget.room);
                }
            }

            CommandType.Interpret(ch, "look auto");
            return;
        }
Exemple #30
0
        /// <summary>
        /// Command to set yourself as being away from keyboard.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void AFK(CharData ch, string[] str)
        {
            if( ch == null ) return;

            if (ch.IsNPC())
                return;

            if (ch.HasActionBit(PC.PLAYER_AFK))
            {
                ch.RemoveActionBit(PC.PLAYER_AFK);
                ch.SendText("&nYou are back at your keyboard.\r\n");
                SocketConnection.Act("$n&n has returned to $s keyboard.", ch, null, ch, SocketConnection.MessageTarget.room);
            }
            else
            {
                ch.SetActionBit(PC.PLAYER_AFK);
                ch.SendText("&nYou are away from keyboard.\r\n");
                SocketConnection.Act("$n&n has left $s keyboard.", ch, null, ch, SocketConnection.MessageTarget.room);
            }

            return;
        }