Ejemplo n.º 1
0
        public static void reset_colors(PlayerInstance ch)
        {
            var path = SystemConstants.GetSystemDirectory(SystemDirectoryTypes.Color) + "default";

            using (var proxy = new TextReaderProxy(new StreamReader(path)))
            {
                IEnumerable <string> lines = proxy.ReadIntoList();
                foreach (var line in lines.Where(l => !l.EqualsIgnoreCase("#colortheme") &&
                                                 !l.StartsWithIgnoreCase("name") &&
                                                 !l.EqualsIgnoreCase("maxcolors")))
                {
                    var tuple = line.FirstArgument();
                    switch (tuple.Item1.ToLower())
                    {
                    case "colors":
                        var colors = tuple.Item2.Split(' ');
                        for (var i = 0; i < colors.Length; i++)
                        {
                            ch.Colors[EnumerationExtensions.GetEnum <ATTypes>(i)] = (char)colors[i].ToInt32();
                        }
                        break;

                    case "end":
                        return;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void ProcessChannelStatus(PlayerInstance ch, string argument,
                                                 Action <CharacterInstance, ChannelTypes> clearAction, Action <CharacterInstance, ChannelTypes> verifyAction)
        {
            if (argument.EqualsIgnoreCase("all"))
            {
                foreach (var chType in ClearAllList)
                {
                    clearAction.Invoke(ch, chType);
                }
                return;
            }

            var channelType = EnumerationExtensions.GetEnumByName <ChannelTypes>(argument);

            var attrib = channelType.GetAttribute <ChannelAttribute>();

            if (attrib == null)
            {
                throw new InvalidOperationException();
            }

            var minTrust    = 0;
            var trustAttrib = channelType.GetAttribute <RequireTrustChannelAttribute>();

            if (trustAttrib != null)
            {
                minTrust = GameConstants.GetConstant <int>(trustAttrib.TrustType);
            }

            if (attrib.Verify(channelType, ch, minTrust))
            {
                verifyAction.Invoke(ch, channelType);
            }
        }
Ejemplo n.º 3
0
        private static void SetCharacterColorByItemType(CharacterInstance ch, IList <int> pitShow, int i)
        {
            var itemType = EnumerationExtensions.GetEnum <ItemTypes>(pitShow[i]);
            var attrib   = itemType.GetAttribute <CharacterColorAttribute>();

            ch.SetColor(attrib?.ATType ?? ATTypes.AT_OBJECT);
        }
Ejemplo n.º 4
0
        private static WearLocations GetRandomWearLocation()
        {
            var min = WearLocations.About.GetMinimum();
            var max = WearLocations.WieldMissile.GetMaximum();
            var loc =
                EnumerationExtensions.GetEnum <WearLocations>(SmaugRandom.Between(min, max));

            return(loc == WearLocations.None ? GetRandomWearLocation() : loc);
        }
Ejemplo n.º 5
0
        public static string color_str(ATTypes attype, CharacterInstance ch)
        {
            if (ch.IsNpc() || ch.Act.IsSet((int)PlayerFlags.Ansi))
            {
                return(string.Empty);
            }

            var code = EnumerationExtensions.GetEnum <AnsiCodes>((int)attype);

            return(code.GetName());
        }
Ejemplo n.º 6
0
        public static void show_colors(CharacterInstance ch)
        {
            ch.SendToPager("&BSyntax: color [color type] [color] | default\r\n");
            ch.SendToPager("&BSyntax: color _reset_ (Resets all colors to default set)\r\n");
            ch.SendToPager("&BSyntax: color _all_ [color] (Sets all color types to [color])\r\n\r\n");
            ch.SendToPager("&BSyntax: color theme [name] (Sets all color types to a defined theme)\r\n\r\n");

            ch.SendToPager("&W********************************[ COLORS ]*********************************\r\n");

            for (var count = 0; count < 16; ++count)
            {
                if (count % 8 == 0 && count != 0)
                {
                    ch.SendToPager("\r\n");
                }

                var atType = EnumerationExtensions.GetEnum <ATTypes>(count);
                ch.PagerPrintf("%s%-10s", color_str(atType, ch), LookupConstants.pc_displays[count]);
            }

            ch.SendToPager("\r\n\r\n&W******************************[ COLOR TYPES ]******************************\r\n");

            // todo foreach through colors instead of using MAX_COLORS
            //for (var count = 32; count < (int)ATTypes.MAX_COLORS; ++count)
            //{
            //    if ((count % 8) == 0 && count != 32)
            //        ch.SendToPager("\r\n");

            //    var atType = EnumerationExtensions.GetEnum<ATTypes>(count);
            //    ch.PagerPrintf("%s%-10s%s", color_str(atType, ch), LookupConstants.pc_displays[count], AnsiCodes.Reset);
            //}

            ch.SendToPager("\r\n\r\n");
            ch.SendToPager("&YAvailable colors are:\r\n");

            var numColors = 0;

            foreach (var color in LookupManager.Instance.GetLookups("ValidColors"))
            {
                if (numColors % 8 == 0 && numColors != 0)
                {
                    ch.SendToPager("\r\n");
                }

                ch.PagerPrintf("%s%-10s", color_str(ATTypes.AT_PLAIN, ch), color);
                numColors++;
            }

            ch.SendToPager("\r\n");
            show_colorthemes(ch);
        }
Ejemplo n.º 7
0
        public static string random_ansi(int type)
        {
            switch (type)
            {
            default:
                return(EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(1, 15)).GetName());

            case 2:
                var code = EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(1, 15));
                return(code.MakeBlink());

            case 3:
                return(EnumerationExtensions.GetEnum <AnsiCodes>(SmaugRandom.Between(16, 31)).GetName());
            }
        }
Ejemplo n.º 8
0
        private static void ListChannels(PlayerInstance ch, string argument)
        {
            if (string.IsNullOrEmpty(argument) && ch.Act.IsSet((int)PlayerFlags.Silence))
            {
                ch.SetColor(ATTypes.AT_GREEN);
                ch.SendTo("You are silenced.");
                return;
            }

            ch.SendTo(" %gChannels  %G:\r\n  ");

            foreach (var channelType in EnumerationExtensions.GetValues <ChannelTypes>())
            {
                var msg = GetChannelText(channelType, ch);
                if (!string.IsNullOrEmpty(msg))
                {
                    ch.PrintfColor(msg);
                }
            }
        }
Ejemplo n.º 9
0
        /*public static void delete_room(RoomTemplate room)
         * {
         *  RoomTemplate limbo = RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Get(VnumConstants.ROOM_VNUM_LIMBO);
         *
         *  CharacterInstance ch;
         *  while ((ch = room.Persons.FirstOrDefault()) != null)
         *  {
         *      if (!ch.IsNpc())
         *      {
         *          room.RemoveFrom(ch);
         *          limbo.AddTo(ch);
         *      }
         *      else
         *          CharacterInstanceExtensions.Extract(ch, true);
         *  }
         *
         *  foreach (CharacterInstance och in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values)
         *  {
         *      if (och.PreviousRoom == room)
         *          och.PreviousRoom = och.CurrentRoom;
         *      if (och.SubState == CharacterSubStates.RoomDescription
         *          && och.DestinationBuffer == room)
         *      {
         *          ch.SetColor("The room is no more.\r\n", och);
         *          build.stop_editing(och);
         *          och.SubState = CharacterSubStates.None;
         *          och.DestinationBuffer = null;
         *      }
         *      else if (och.SubState == CharacterSubStates.RoomExtra
         *               && och.DestinationBuffer != null)
         *      {
         *          if (room.ExtraDescriptions.Any(e => e == och.DestinationBuffer))
         *          {
         *              ch.SetColor("The room is no more.\r\n", och);
         *              build.stop_editing(och);
         *              och.SubState = CharacterSubStates.None;
         *              och.DestinationBuffer = null;
         *          }
         *      }
         *  }
         *
         *  room.Contents.ForEach(handler.extract_obj);
         *  reset.wipe_resets(room);
         *  room.ExtraDescriptions.Clear();
         *  room.Affects.Clear();
         *  room.PermanentAffects.Clear();
         *  room.Exits.ForEach(x => handler.extract_exit(room, x));
         *  room.MudProgActs.Clear();
         *  room.MudProgs.Clear();
         *  RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Delete(room.Vnum);
         *
         *  // TODO: Room hash stuff here, but can be removed?
         * }
         *
         * public static void delete_obj(ObjectTemplate obj)
         * {
         *  RepositoryManager.Instance.OBJECTS.CastAs<Repository<long, ObjectInstance>>().Values.Where(x => x.ObjectIndex == obj).ToList().ForEach(handler.extract_obj);
         *  obj.ExtraDescriptions.Clear();
         *  obj.Affects.Clear();
         *  obj.MudProgs.Clear();
         *  RepositoryManager.Instance.OBJECT_INDEXES.CastAs<Repository<long, ObjectTemplate>>().Delete(obj.Vnum);
         *
         *  // TODO Object hash stuff here, but can be removed?
         * }
         *
         * public static void delete_mob(MobTemplate mob)
         * {
         *  foreach (CharacterInstance ch in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values)
         *  {
         *      if (ch.MobIndex == mob)
         *          CharacterInstanceExtensions.Extract(ch, true);
         *      else if (ch.SubState == CharacterSubStates.MProgEditing
         *               && ch.DestinationBuffer != null)
         *      {
         *          if (mob.MudProgs.Any(mp => mp == ch.DestinationBuffer))
         *          {
         *              ch.SetColor("Your victim has departed.\r\n", ch);
         *              build.stop_editing(ch);
         *              ch.DestinationBuffer = null;
         *              ch.SubState = CharacterSubStates.MProgEditing;
         *          }
         *      }
         *  }
         *
         *  mob.MudProgs.Clear();
         *  if (mob.Shop != null)
         *      SHOP.Remove(mob.Shop);
         *  if (mob.RepairShop != null)
         *      REPAIR.Remove(mob.RepairShop);
         *  RepositoryManager.Instance.MOBILE_INDEXES.CastAs<Repository<long, MobTemplate>>().Delete(mob.Vnum);
         *
         *  // TODO Mob hash stuff here, but can be removed?
         * }*/

        public static ExitData make_exit(RoomTemplate room, RoomTemplate to_room, int door)
        {
            var newExit = new ExitData(door, "An exit")
            {
                Direction   = EnumerationExtensions.GetEnum <DirectionTypes>(door),
                Room_vnum   = room.ID,
                Destination = to_room.ID,
                Distance    = 1,
                Key         = -1
            };

            var reverseExit = to_room.GetExitTo(LookupConstants.rev_dir[door], room.ID);

            if (reverseExit != null)
            {
                reverseExit.Reverse = newExit.ID;
                newExit.Reverse     = reverseExit.ID;
            }

            var broke = room.Exits.Any(exit => door < (int)exit.Direction);

            if (room.Exits == null)
            {
                room.Exits.Add(newExit);
            }
            else
            {
                if (broke && reverseExit != null)
                {
                    room.Exits.ToList().Insert(room.Exits.First() == reverseExit ? 0 : 1, newExit);
                    return(newExit);
                }
            }

            return(newExit);
        }
Ejemplo n.º 10
0
        public static void do_shove(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Deadly),
                                           "Only deadly characters can shove."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't shove a player right now."))
            {
                return;
            }

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Shove whom?"))
            {
                return;
            }

            var victim = ch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You shove yourself around, to no avail."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() || !((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.Deadly),
                                           "You can only shove deadly characters."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.Level.GetAbsoluteDifference(victim.Level) > 5,
                                           "There is too great an experience difference for you to even bother."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNullObject(ch, victim.HasTimer(TimerTypes.PKilled),
                                                 "You can't shove that player right now."))
            {
                return;
            }

            if (victim.CurrentPosition != PositionTypes.Standing)
            {
                comm.act(ATTypes.AT_PLAIN, "$N isn't standing up.", ch, null, victim, ToTypes.Character);
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Shove them in which direction?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag),
                                           "That character cannot be shoved right now."))
            {
                return;
            }

            victim.CurrentPosition = PositionTypes.Shove;

            var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg);
            var exit    = ch.CurrentRoom.GetExit(exitDir);

            if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           exit.Flags.IsSet(ExitFlags.Closed) &&
                                           (!victim.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor)),
                                           "There's no exit in that direction."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            var toRoom = exit.GetDestination();

            if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death,
                                          "You cannot shove someone into a death trap."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim),
                                           "That character cannot enter that area."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            var chance = GetChanceByCharacterClass(ch);

            chance += (ch.GetCurrentStrength() - 15) * 3;
            chance += ch.Level - victim.Level;
            chance += GetBonusByCharacterRace(ch);

            if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            comm.act(ATTypes.AT_ACTION, "You shove $M.", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, "$n shoves you.", ch, null, victim, ToTypes.Victim);
            Move.move_char(victim, exit, 0);

            if (!victim.CharDied())
            {
                victim.CurrentPosition = PositionTypes.Standing;
            }

            Macros.WAIT_STATE(ch, 12);

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag))
            {
                ch.AddTimer(TimerTypes.ShoveDrag, 10);
            }
        }
Ejemplo n.º 11
0
        public static string affect_loc_name(int location)
        {
            var type = EnumerationExtensions.GetEnum <ApplyTypes>(location);

            return(type.GetName());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Process the spell's required components, if any
        /// </summary>
        /// <remarks>
        /// T###		check for item of type ###
        /// V#####	check for item of vnum #####
        /// Kword	check for item with keyword 'word'
        /// G#####	check if player has ##### amount of gold
        /// H####	check if player has #### amount of hitpoints
        ///
        /// Special operators:
        /// ! spell fails if player has this
        /// + don't consume this component
        /// @ decrease component's value[0], and extract if it reaches 0
        /// # decrease component's value[1], and extract if it reaches 0
        /// $ decrease component's value[2], and extract if it reaches 0
        /// % decrease component's value[3], and extract if it reaches 0
        /// ^ decrease component's value[4], and extract if it reaches 0
        /// & decrease component's value[5], and extract if it reaches 0
        /// </remarks>
        public static bool process_spell_components(CharacterInstance ch, int sn)
        {
            var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn);

            if (skill == null || skill.Components.Count == 0)
            {
                return(true);
            }

            ObjectInstance obj = null;
            var            val = -1;

            foreach (var component in skill.Components)
            {
                var found   = false;
                var fail    = false;
                var consume = true;

                switch (component.OperatorType)
                {
                case ComponentOperatorTypes.FailIfPresent:
                    fail = true;
                    break;

                case ComponentOperatorTypes.DoNotConsume:
                    consume = false;
                    break;

                case ComponentOperatorTypes.DecreaseValue0:
                    val = 0;
                    break;

                case ComponentOperatorTypes.DecreaseValue1:
                    val = 1;
                    break;

                case ComponentOperatorTypes.DecreaseValue2:
                    val = 2;
                    break;

                case ComponentOperatorTypes.DecreaseValue3:
                    val = 3;
                    break;

                case ComponentOperatorTypes.DecreaseValue4:
                    val = 4;
                    break;

                case ComponentOperatorTypes.DecreaseValue5:
                    val = 5;
                    break;
                }

                switch (component.RequiredType)
                {
                case ComponentRequiredTypes.ItemType:
                    foreach (var vobj in ch.Carrying)
                    {
                        if (vobj.ItemType ==
                            EnumerationExtensions.GetEnumByName <ItemTypes>(
                                component.RequiredData))
                        {
                            if (CheckFunctions.CheckIfTrue(ch, fail,
                                                           "Something disrupts the casting of this spell..."))
                            {
                                return(false);
                            }
                            found = true;
                            obj   = vobj;
                            break;
                        }
                    }
                    break;

                case ComponentRequiredTypes.ItemVnum:
                    foreach (var vobj in ch.Carrying)
                    {
                        if (vobj.ID == component.RequiredData.ToInt32())
                        {
                            if (CheckFunctions.CheckIfTrue(ch, fail,
                                                           "Something disrupts the casting of this spell..."))
                            {
                                return(false);
                            }
                            found = true;
                            obj   = vobj;
                            break;
                        }
                    }
                    break;

                case ComponentRequiredTypes.ItemKeyword:
                    foreach (var vobj in ch.Carrying)
                    {
                        if (vobj.Name.IsAnyEqual(component.RequiredData))
                        {
                            if (CheckFunctions.CheckIfTrue(ch, fail,
                                                           "Something disrupts the casting of this spell..."))
                            {
                                return(false);
                            }
                            found = true;
                            obj   = vobj;
                            break;
                        }
                    }
                    break;

                case ComponentRequiredTypes.PlayerCoin:
                    if (ch.CurrentCoin >= component.RequiredData.ToInt32())
                    {
                        if (CheckFunctions.CheckIfTrue(ch, fail,
                                                       "Something disrupts the casting of this spell..."))
                        {
                            return(false);
                        }
                        if (consume)
                        {
                            ch.SetColor(ATTypes.AT_GOLD);
                            ch.SendTo("You feel a little lighter...");
                            ch.CurrentCoin -= component.RequiredData.ToInt32();
                        }
                        continue;
                    }
                    break;

                case ComponentRequiredTypes.PlayerHealth:
                    if (ch.CurrentHealth >= component.RequiredData.ToInt32())
                    {
                        if (CheckFunctions.CheckIfTrue(ch, fail,
                                                       "Something disrupts the casting of this spell..."))
                        {
                            return(false);
                        }
                        if (consume)
                        {
                            ch.SetColor(ATTypes.AT_BLOOD);
                            ch.SendTo("You feel a little weaker...");
                            ch.CurrentHealth -= component.RequiredData.ToInt32();
                            ch.UpdatePositionByCurrentHealth();
                        }
                        continue;
                    }
                    break;
                }

                if (fail)
                {
                    continue;
                }
                if (CheckFunctions.CheckIfTrue(ch, !found, "Something is missing..."))
                {
                    return(false);
                }
                if (obj != null)
                {
                    if (val >= 0 && val < 6)
                    {
                        obj.Split();
                        if (obj.Value.ToList()[val] <= 0)
                        {
                            comm.act(ATTypes.AT_MAGIC, "$p dispapears in a puff of smoke!", ch, obj, null, ToTypes.Character);
                            comm.act(ATTypes.AT_MAGIC, "$p disappears in a puff of smoke!", ch, obj, null, ToTypes.Room);
                            obj.Extract();
                            return(false);
                        }

                        if (--obj.Value.ToList()[val] == 0)
                        {
                            comm.act(ATTypes.AT_MAGIC, "$p glows briefly, then disappears in a puff of smoke!", ch, obj, null, ToTypes.Character);
                            comm.act(ATTypes.AT_MAGIC, "$p glows briefly, then disappears in a puff of smoke!", ch, obj, null, ToTypes.Room);
                            obj.Extract();
                        }
                        else
                        {
                            comm.act(ATTypes.AT_MAGIC, "$p glows briefly and a whisp of smoke rises from it.", ch, obj,
                                     null, ToTypes.Room);
                        }
                    }
                    else if (consume)
                    {
                        obj.Split();
                        comm.act(ATTypes.AT_MAGIC, "$p glows briefly, then disappears in a puff of smoke!", ch, obj, null, ToTypes.Character);
                        comm.act(ATTypes.AT_MAGIC, "$p glows briefly, then disappears in a puff of smoke!", ch, obj, null, ToTypes.Room);
                        obj.Extract();
                    }
                    else
                    {
                        var count = obj.Count;
                        obj.Count = 1;
                        comm.act(ATTypes.AT_MAGIC, "$p glows briefly.", ch, obj, null, ToTypes.Character);
                        obj.Count = count;
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handlers to tell the victim which spell is being effected
        /// </summary>
        public static int dispel_casting(AffectData paf, CharacterInstance ch, CharacterInstance victim, int affect, bool dispel)
        {
            var isMage    = false;
            var hasDetect = false;

            if (ch.IsNpc() || ch.CurrentClass == ClassTypes.Mage)
            {
                isMage = true;
            }
            if (ch.IsAffected(AffectedByTypes.DetectMagic))
            {
                hasDetect = true;
            }

            string spell;

            if (paf != null)
            {
                var skill = RepositoryManager.Instance.GetEntity <SkillData>((int)paf.Type);
                if (skill == null)
                {
                    return(0);
                }
                spell = skill.Name;
            }
            else
            {
                spell = EnumerationExtensions.GetEnum <AffectedByTypes>(affect).GetName().ToLower();
            }

            ch.SetColor(ATTypes.AT_MAGIC);
            victim.SetColor(ATTypes.AT_HITME);

            var buffer = !ch.CanSee(victim)
                         ? "Someone"
                         : (victim.IsNpc()
                                ? victim.ShortDescription
                                : victim.Name).CapitalizeFirst();

            if (dispel)
            {
                victim.Printf("Your %s vanishes.", spell);
                if (isMage && hasDetect)
                {
                    ch.Printf("%s's %s vanishes.", buffer, spell);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (isMage && hasDetect)
                {
                    ch.Printf("%s's %s wavers but holds.", buffer, spell);
                }
                else
                {
                    return(0);
                }
            }

            return(1);
        }
Ejemplo n.º 14
0
        public static void show_char_to_char_1(CharacterInstance victim, PlayerInstance ch)
        {
            if (victim.CanSee(ch) && !ch.IsNpc() &&
                !ch.Act.IsSet((int)PlayerFlags.WizardInvisibility))
            {
                comm.act(ATTypes.AT_ACTION, "$n looks at you.", ch, null, victim, ToTypes.Victim);
                comm.act(ATTypes.AT_ACTION, victim != ch ? "$n looks at $N." : "$n looks at $mself.", ch, null, victim,
                         ToTypes.NotVictim);
            }

            if (!string.IsNullOrEmpty(victim.Description))
            {
                ch.SendTo(victim.CurrentMorph?.Morph != null
                    ? victim.CurrentMorph.Morph.Description
                    : victim.Description);
            }
            else
            {
                if (victim.CurrentMorph?.Morph != null)
                {
                    ch.SendTo(victim.CurrentMorph.Morph.Description);
                }
                else if (victim.IsNpc())
                {
                    comm.act(ATTypes.AT_PLAIN, "You see nothing special about $M.", ch, null, victim, ToTypes.Character);
                }
                else if (ch != victim)
                {
                    comm.act(ATTypes.AT_PLAIN, "$E isn't much to look at...", ch, null, victim, ToTypes.Character);
                }
                else
                {
                    comm.act(ATTypes.AT_PLAIN, "You're not much to look at...", ch, null, null, ToTypes.Character);
                }
            }

            ch.ShowRaceOf(victim);
            ch.ShowConditionTo(victim);

            var found = false;

            for (var i = 0; i < GameConstants.MaximumWearLocations; i++)
            {
                var wearLoc = EnumerationExtensions.GetEnum <WearLocations>(i);
                var obj     = victim.GetEquippedItem(wearLoc);
                if (obj != null && ch.CanSee(obj))
                {
                    if (!found)
                    {
                        ch.SendTo("\r\n");
                        if (victim != ch)
                        {
                            comm.act(ATTypes.AT_PLAIN, "$n is using:", ch, null, victim, ToTypes.Character);
                        }
                        else
                        {
                            comm.act(ATTypes.AT_PLAIN, "You are using:", ch, null, null, ToTypes.Character);
                        }
                        found = true;
                    }

                    if (!victim.IsNpc())
                    {
                        var race = RepositoryManager.Instance.GetRace(victim.CurrentRace);
                        ch.SendTo(race.WhereNames.ToList()[i]);
                    }
                    else
                    {
                        ch.SendTo(LookupManager.Instance.GetLookup("WhereNames", i));
                    }
                    ch.SendTo(obj.GetFormattedDescription(ch, true));
                    ch.SendTo("\r\n");
                }
            }

            if (ch.IsNpc() || victim == ch)
            {
                return;
            }

            if (ch.IsImmortal())
            {
                if (victim.IsNpc())
                {
                    ch.Printf("\r\nMobile #%d '%s' ", ((MobileInstance)victim).MobIndex.ID, victim.Name);
                }
                else
                {
                    ch.Printf("\r\n%s ", victim.Name);
                }

                ch.Printf("is a level %d %s %s.\r\n", victim.Level,
                          RepositoryManager.Instance.GetRace(victim.CurrentRace).Name,
                          RepositoryManager.Instance.GetClass(victim.CurrentClass).Name);
            }

            var skill = RepositoryManager.Instance.GetEntity <SkillData>("peek");

            if (skill == null)
            {
                throw new ObjectNotFoundException("Skill 'peek' not found");
            }

            if (SmaugRandom.D100() < Macros.LEARNED(ch, (int)skill.ID))
            {
                ch.Printf("\r\nYou peek at %s inventory:\r\n", victim.Gender.PossessivePronoun());
                show_list_to_char(victim.Carrying.ToList(), ch, true, true);
                skill.LearnFromSuccess(ch);
            }
            else if (ch.PlayerData.GetSkillMastery(skill.ID) > skill.GetMasteryLevel(ch))
            {
                skill.LearnFromFailure(ch);
            }
        }
Ejemplo n.º 15
0
        public static void do_drag(CharacterInstance ch, string argument)
        {
            if (CheckFunctions.CheckIfNpc(ch, ch, "Only characters can drag."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't drag a player right now."))
            {
                return;
            }

            var pch = (PlayerInstance)ch;

            var firstArg = argument.FirstWord();

            if (CheckFunctions.CheckIfEmptyString(pch, firstArg, "Drag whom?"))
            {
                return;
            }

            var victim = pch.GetCharacterInRoom(firstArg);

            if (CheckFunctions.CheckIfNullObject(pch, victim, "They aren't here."))
            {
                return;
            }
            if (CheckFunctions.CheckIfEquivalent(pch, pch, victim,
                                                 "You take yourself by the scruff of your neck, but go nowhere."))
            {
                return;
            }
            if (CheckFunctions.CheckIfNpc(ch, victim, "You can only drag characters."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           !victim.Act.IsSet((int)PlayerFlags.ShoveDrag) || (!victim.IsNpc() && !victim.IsDeadly()),
                                           "That character doesn't seem to appreciate your attentions."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, victim.HasTimer(TimerTypes.PKilled),
                                           "You can't drag that player right now."))
            {
                return;
            }
            if (CheckFunctions.CheckIf(ch, HelperFunctions.IsFighting,
                                       "You try, but can't get close enough.", new List <object> {
                ch
            }))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !victim.IsDeadly() && ch.IsDeadly(),
                                           "You can't drag a deadly character."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !ch.IsDeadly() && (int)ch.CurrentPosition > 3,
                                           "They don't seem to need your assistance."))
            {
                return;
            }

            var secondArg = argument.SecondWord();

            if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Drag them in which direction?"))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, Math.Abs(ch.Level - victim.Level) > 5,
                                           "There is too great an experience difference for you to even bother."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch,
                                           victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && victim.GetTimer(TimerTypes.ShoveDrag) == null,
                                           "That character cannot be dragged right now."))
            {
                return;
            }

            var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg);
            var exit    = ch.CurrentRoom.GetExit(exitDir);

            if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction."))
            {
                return;
            }
            if (CheckFunctions.CheckIfTrue(ch, !IsPassable(exit, victim), "There's no exit in that direction."))
            {
                return;
            }

            var toRoom = exit.GetDestination();

            if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death,
                                          "You cannot drag someone into a death trap."))
            {
                return;
            }

            if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim),
                                           "That character cannot enter that area."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            var chance = CalculateChanceToDrag(ch, victim);

            if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed."))
            {
                victim.CurrentPosition = PositionTypes.Standing;
                return;
            }

            if ((int)victim.CurrentPosition < (int)PositionTypes.Standing)
            {
                DragIntoNextRoom(ch, victim, exit);
                return;
            }

            ch.SendTo("You cannot do that to someone who is standing.");
        }