Пример #1
0
        public static CharacterInstance LuaFindCharacter(CharacterInstance instance, string arg)
        {
            if (arg.EqualsIgnoreCase("self"))
            {
                return(instance);
            }

            return
                (instance.CurrentRoom.Persons.FirstOrDefault(
                     vch => instance.CanSee(vch) && !vch.IsNpc() && vch.Name.EqualsIgnoreCase(arg)) ??
                 _dbManager.CHARACTERS.Values.FirstOrDefault(
                     vch => instance.CanSee(vch) && !vch.IsNpc() && vch.Name.EqualsIgnoreCase(arg)));
        }
Пример #2
0
        private static IEnumerable <CharacterInstance> GetVisiblePlayersInArea(CharacterInstance ch)
        {
            var list = new List <CharacterInstance>();

            foreach (var room in ch.CurrentRoom.Area.Rooms)
            {
                foreach (var victim in room.Persons.Where(x => !x.IsNpc()))
                {
                    if (((PlayerInstance)victim).PlayerData != null && ((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.DoNotDisturb))
                    {
                        continue;
                    }
                    if (ch.Trust < victim.Trust)
                    {
                        continue;
                    }
                    if (((PlayerInstance)victim).Descriptor == null || ((PlayerInstance)victim).Descriptor.ConnectionStatus != ConnectionTypes.Playing || ((PlayerInstance)victim).Descriptor.ConnectionStatus != ConnectionTypes.Editing)
                    {
                        continue;
                    }
                    if (!ch.CanSee(victim))
                    {
                        continue;
                    }

                    list.Add(victim);
                }
            }

            return(list);
        }
Пример #3
0
        private static void group_all(CharacterInstance ch)
        {
            var count = 0;

            foreach (var rch in ch.CurrentRoom.Persons.Where(x =>
                                                             x != ch &&
                                                             !x.IsNpc() &&
                                                             ch.CanSee(x) &&
                                                             x.Master == ch &&
                                                             ch.Master == null &&
                                                             ch.Leader == null &&
                                                             Math.Abs(ch.Level - x.Level) > 9 &&
                                                             !x.IsSameGroup(ch) &&
                                                             ch.IsPKill() == x.IsPKill()))
            {
                rch.Leader = ch;
                count++;
            }

            if (count == 0)
            {
                ch.SendTo("You have no eligible group members.");
            }
            else
            {
                comm.act(ATTypes.AT_ACTION, "$n groups $s followers.", ch, null, null, ToTypes.Room);
                ch.SendTo("You group your followers.");
            }
        }
Пример #4
0
        private static bool IsVisibleToKeeper(CharacterInstance keeper, CharacterInstance ch)
        {
            if (keeper.CanSee(ch))
            {
                return(false);
            }

            Say.do_say(keeper, "I don't trade with folks I can't see.");
            return(true);
        }
        public static bool LuaCanSee(CharacterInstance ch, Instance target)
        {
            if (ch == null)
            {
                throw new LuaException("Character cannot be null");
            }
            if (target == null)
            {
                throw new LuaException("Target cannot be null");
            }

            if (target is CharacterInstance)
            {
                return(ch.CanSee((CharacterInstance)target));
            }
            if (target is ObjectInstance)
            {
                return(ch.CanSee((ObjectInstance)target));
            }

            return(false);
        }
Пример #6
0
        public static ObjectInstance GetCarriedObject(this CharacterInstance ch, string argument)
        {
            var number = argument.IsNumberArgument() ? argument.GetNumberArgument() : 1;
            var arg    = argument.IsNumberArgument() ? argument.StripNumberArgument() : argument;

            var items =
                ch.Carrying.Where(obj => obj.WearLocation == WearLocations.None && ch.CanSee(obj));

            var vnum = GetVnumFromArgumentIfImmortal(ch, arg);

            return(vnum > 0
                ? GetObjectInList(items.Where(obj => obj.ObjectIndex.ID == vnum), number)
                : GetObjectInList(items.Where(obj => arg.IsAnyEqual(obj.Name) || arg.IsAnyEqualPrefix(obj.Name)), number));
        }
Пример #7
0
        private static void ViewIndividualPlayer(CharacterInstance ch, string firstArg)
        {
            var victim = ch.GetCharacterInWorld(firstArg);

            if (victim?.CurrentRoom != null &&
                victim.CurrentRoom.Area == ch.CurrentRoom.Area &&
                !victim.IsAffected(AffectedByTypes.Hide) &&
                !victim.IsAffected(AffectedByTypes.Sneak) &&
                ch.CanSee(victim))
            {
                ch.PagerPrintf("{0} {1}", Macros.PERS(victim, ch).PadRight(28, ' '), victim.CurrentRoom.Name);
                return;
            }

            comm.act(ATTypes.AT_PLAIN, "You didn't find any $T.", ch, null, firstArg, ToTypes.Character);
        }
Пример #8
0
        public static void appraise_all(CharacterInstance ch, MobileInstance keeper, string fixstr)
        {
            int    total = 0, cost = 0;
            string buffer;

            foreach (var obj in ch.Carrying.Where(obj => obj.WearLocation == WearLocations.None &&
                                                  ch.CanSee(obj) &&
                                                  (obj.ItemType.GetAttribute <ValuedAttribute>() != null)))
            {
                if (!ch.CanDrop(obj))
                {
                    ch.Printf("You can't let go of %s.", obj.Name);
                    continue;
                }

                if ((cost = Appraise.GetAdjustedRepairCost(keeper, obj)) > 0)
                {
                    comm.act(ATTypes.AT_TELL,
                             cost != -2
                            ? "$n tells you, 'Sorry, I can't do anything with $p.'"
                            : "$n tells you, '$p looks fine to me!'", keeper, obj, ch, ToTypes.Victim);
                    continue;
                }

                buffer =
                    $"$N tells you, 'It will cost {cost} piece{(cost == 1 ? "" : "s")} of gold to {fixstr} {obj.Name}.'";
                comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character);
                total += cost;
            }

            if (total <= 0)
            {
                return;
            }

            ch.SendTo("\r\n");

            buffer = $"$N tells you, 'It will cost {total} piece{(cost == 1 ? "" : "s")} of gold in total.'";
            comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character);
            comm.act(ATTypes.AT_TELL, "$N tells you, 'Remember there is a 10% surcharge for repairing all your items.", ch, null, keeper, ToTypes.Character);
        }
Пример #9
0
        public static void AddFollower(this CharacterInstance ch, CharacterInstance master)
        {
            if (ch.Master != null)
            {
                return;
            }

            ch.Master = master;
            ch.Leader = null;

            if (ch.IsNpc() && ch.Act.IsSet((int)ActFlags.Pet) && !master.IsNpc())
            {
                ((PlayerInstance)master).PlayerData.Pet = ch;
            }

            if (master.CanSee(ch))
            {
                comm.act(ATTypes.AT_ACTION, "$n now follows you.", ch, null, master, ToTypes.Victim);
            }

            comm.act(ATTypes.AT_ACTION, "You now follow $N.", ch, null, master, ToTypes.Character);
        }
Пример #10
0
        private static void DropAllOrSome(CharacterInstance ch, string firstArg)
        {
            var all = firstArg.EqualsIgnoreCase("all");
            var arg = all ? firstArg.Substring(4) : firstArg;

            if (CheckFunctions.CheckIfTrue(ch,
                                           ch.CurrentRoom.Flags.IsSet(RoomFlags.NoDropAll) || ch.CurrentRoom.Flags.IsSet(RoomFlags.ClanStoreroom),
                                           "You can't seem to do that."))
            {
                return;
            }

            var found = false;

            foreach (var obj in ch.Carrying)
            {
                if ((all || obj.Name.IsAnyEqual(arg)) && ch.CanSee(obj) && obj.WearLocation == WearLocations.None &&
                    ch.CanDrop(obj))
                {
                    // TODO
                }
            }
        }
Пример #11
0
        public static CharacterInstance IsDoNotDisturb(this RoomTemplate room, CharacterInstance ch)
        {
            if (room.Flags.IsSet(RoomFlags.DoNotDisturb))
            {
                return(null);
            }

            return(room.Persons.FirstOrDefault(rch => !rch.IsNpc() && ((PlayerInstance)rch).PlayerData != null && rch.IsImmortal() &&
                                               ((PlayerInstance)rch).PlayerData.Flags.IsSet(PCFlags.DoNotDisturb) && ch.Trust < rch.Trust && ch.CanSee(rch)));
        }
Пример #12
0
        /// <summary>
        ///This function shared by do_transfer and do_mptransfer
        /// Immortals bypass most restrictions on where to transfer victims.
        /// NPCs cannot transfer victims who are:
        /// 1. Not authorized yet.
        /// 2. Outside of the level range for the target room's area.
        /// 3. Being sent to private rooms.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="victim"></param>
        /// <param name="location"></param>
        public static void transfer_char(CharacterInstance ch, CharacterInstance victim, RoomTemplate location)
        {
            if (victim.CurrentRoom == null)
            {
                LogManager.Instance.Bug("Victim {0} in null room", victim.Name);
                return;
            }

            if (ch.IsNpc() && location.IsPrivate())
            {
                //progbug("Mptransfer - Private room", ch);
                return;
            }

            if (!ch.CanSee(victim))
            {
                return;
            }

            if (ch.IsNpc() && victim.IsNotAuthorized() &&
                location.Area != victim.CurrentRoom.Area)
            {
                var buffer = $"Mptransfer - unauthed char ({victim.Name})";
                //progbug(buffer, ch);
                return;
            }

            // if victim not in area's level range, do not transfer
            if (ch.IsNpc() && !location.Area.IsInHardRange(victim) &&
                !location.Flags.IsSet((int)RoomFlags.Prototype))
            {
                return;
            }

            if (victim.CurrentFighting != null)
            {
                victim.StopFighting(true);
            }

            if (!ch.IsNpc())
            {
                comm.act(ATTypes.AT_MAGIC, "$n disappears in a cloud of swirling colors.", victim, null, null, ToTypes.Room);
                victim.retran = (int)victim.CurrentRoom.ID;
            }

            victim.CurrentRoom.RemoveFrom(victim);
            location.AddTo(victim);

            if (!ch.IsNpc())
            {
                comm.act(ATTypes.AT_MAGIC, "$n arrives from a puff of smoke.", victim, null, null, ToTypes.Room);
                if (ch != victim)
                {
                    comm.act(ATTypes.AT_IMMORT, "$n has transferred you.", ch, null, victim, ToTypes.Victim);
                }
                Look.do_look(victim, "auto");
                if (!victim.IsImmortal() &&
                    !victim.IsNpc() &&
                    !location.Area.IsInHardRange(victim))
                {
                    comm.act(ATTypes.AT_DANGER, "Warning: this player's level is not within the area's level range.", ch, null, null, ToTypes.Character);
                }
            }
        }
Пример #13
0
        public static void do_reply(CharacterInstance ch, string argument)
        {
#if !SCRAMBLE
            var speaking = -1;

            /*foreach (int key in GameConstants.LanguageTable.Keys
             *                           .Where(key => (key & ch.Speaking) > 0))
             * {
             *  speaking = key;
             *  break;
             * }*/
#endif

            ch.Deaf.RemoveBit(ChannelTypes.Tells);
            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Silence))
            {
                ch.SendTo("You can't do that here.\r\n");
                return;
            }

            if (!ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Silence))
            {
                ch.SendTo("Your message didn't get through.\r\n");
                return;
            }

            var victim = ((PlayerInstance)ch).ReplyTo;
            if (victim == null)
            {
                ch.SendTo("They aren't here.\r\n");
                return;
            }

            if (!victim.IsNpc() &&
                victim.Switched != null &&
                ch.CanSee(victim) &&
                ch.Trust > LevelConstants.AvatarLevel)
            {
                ch.SendTo("That player is switched.\r\n");
                return;
            }

            if (!victim.IsNpc() && ((PlayerInstance)victim).Descriptor == null)
            {
                ch.SendTo("That player is link-dead.\r\n");
                return;
            }

            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.AwayFromKeyboard))
            {
                ch.SendTo("That player is afk.\r\n");
                return;
            }

            if (victim.Deaf.IsSet(ChannelTypes.Tells) &&
                (!ch.IsImmortal() || ch.Trust < victim.Trust))
            {
                comm.act(ATTypes.AT_PLAIN, "$E has $S tells turned off.", ch, null, victim, ToTypes.Character);
                return;
            }

            if ((!ch.IsImmortal() && !victim.IsAwake()) ||
                (!victim.IsNpc() && victim.CurrentRoom.Flags.IsSet(RoomFlags.Silence)))
            {
                comm.act(ATTypes.AT_PLAIN, "$E can't hear you.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (((PlayerInstance)victim).Descriptor != null &&
                ((PlayerInstance)victim).Descriptor.ConnectionStatus == ConnectionTypes.Editing &&
                ch.Trust < LevelConstants.GetLevel(ImmortalTypes.God))
            {
                comm.act(ATTypes.AT_PLAIN, "$E is currently in a writing buffer. Please try again later.", ch, null, victim, ToTypes.Character);
                return;
            }

            if (victim.IsIgnoring(ch))
            {
                if (!ch.IsImmortal() || victim.Trust > ch.Trust)
                {
                    ch.SetColor(ATTypes.AT_IGNORE);
                    ch.Printf("%s is ignoring you.\r\n", victim.Name);
                    return;
                }

                victim.SetColor(ATTypes.AT_IGNORE);
                victim.Printf("You attempt to ignore %s, but are unable to do so.\r\n", ch.Name);
            }

            comm.act(ATTypes.AT_TELL, "You tell $N '$t'", ch, argument, victim, ToTypes.Character);
            var position = victim.CurrentPosition;
            victim.CurrentPosition = PositionTypes.Standing;

#if !SCRAMBLE
            /*if (speaking != -1 && (!ch.IsNpc() || ch.Speaking > 0))
             * {
             *  int speakswell = victim.KnowsLanguage(ch.Speaking, ch).GetLowestOfTwoNumbers(ch.KnowsLanguage(ch.Speaking, victim));
             *  if (speakswell < 85)
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
             *               ch, act_comm.TranslateLanguage(speakswell, argument,
             *                             GameConstants.LanguageTable[speaking]), victim, ToTypes.Victim);
             *  else
             *      comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
             *               ch, argument, victim, ToTypes.Victim);
             * }
             * else
             *  comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch, argument, victim, ToTypes.Victim);*/
#else
            if (act_comm.KnowsLanguage(victim, ch.Speaking, ch) == 0 &&
                (ch.IsNpc() || ch.Speaking != 0))
            {
                comm.act(ATTypes.AT_TELL, "$n tells you '$t'", ch,
                         TranslateLanguage(speakswell, argument, GameConstants.LanguageTable[speaking]),
                         victim, ToTypes.Victim);
            }
            else
            {
                comm.act(ATTypes.AT_TELL, "$n tells you '$t'",
                         ch, scramble(argument, ch.Speaking), victim, ToTypes.Victim);
            }
#endif

            victim.CurrentPosition           = position;
            ((PlayerInstance)victim).ReplyTo = ch;
            ((PlayerInstance)ch).RetellTo    = victim;

            if (ch.CurrentRoom.Flags.IsSet((int)RoomFlags.LogSpeech))
            {
                var buffer =
                    $"{(ch.IsNpc() ? ch.ShortDescription : ch.Name)}: {argument} (tell to) {(victim.IsNpc() ? victim.ShortDescription : victim.Name)}";
                db.append_to_file(SystemConstants.GetSystemFile(SystemFileTypes.Log), buffer);
            }

            MudProgHandler.ExecuteMobileProg(MudProgTypes.Tell, argument, ch);
        }
Пример #14
0
 public static string PERS(CharacterInstance ch, CharacterInstance looker)
 {
     return(ch.CanSee(looker)
                ? ch.IsNpc() ? ch.ShortDescription : ch.Name
                : "someone");
 }
Пример #15
0
        public static string act_string(string format, CharacterInstance to, CharacterInstance ch, object arg1, object arg2, int flags)
        {
            var dontUpper = !format.StartsWith("$");

            int varPosition;
            var startIndex = 0;
            var sb         = new StringBuilder(format);
            var buffer     = string.Empty;

            do
            {
                const string chars = "$";
                var          anyOf = chars.ToCharArray();

                varPosition = sb.IndexOfAny(anyOf, startIndex);
                if (varPosition == -1)
                {
                    continue;
                }

                //// Is it a valid variable?
                var var = sb.Substring(varPosition, 2);
                if (!string.IsNullOrEmpty(var))
                {
                    CharacterInstance vch;
                    ObjectInstance    obj;

                    switch (var)
                    {
                    case "$t":
                        buffer = arg1.ToString();
                        break;

                    case "$T":
                        buffer = arg2.ToString();
                        break;

                    case "$n":
                        if (ch.CurrentMorph == null)
                        {
                            buffer = to != null?Macros.PERS(ch, to) : Macros.NAME(ch);
                        }
                        else if (!flags.IsSet(Program.STRING_IMM))
                        {
                            buffer = to != null?Macros.MORPHERS(ch, to) : MORPHNAME(ch);
                        }
                        else
                        {
                            buffer = $"(MORPH) {(to != null ? Macros.PERS(ch, to) : Macros.NAME(ch))}";
                        }
                        break;

                    case "$N":
                        vch = arg2.CastAs <CharacterInstance>();
                        if (vch.CurrentMorph == null)
                        {
                            buffer = to != null?Macros.PERS(vch, to) : Macros.NAME(vch);
                        }
                        else if (!flags.IsSet(Program.STRING_IMM))
                        {
                            buffer = to != null?Macros.MORPHERS(vch, to) : MORPHNAME(vch);
                        }
                        else
                        {
                            buffer = $"(MORPH) {(to != null ? Macros.PERS(vch, to) : Macros.NAME(vch))}";
                        }
                        break;

                    case "$e":
                        buffer = ch.Gender.SubjectPronoun();
                        break;

                    case "$E":
                        vch    = arg2.CastAs <CharacterInstance>();
                        buffer = vch.Gender.SubjectPronoun();
                        break;

                    case "$m":
                        buffer = ch.Gender.ObjectPronoun();
                        break;

                    case "$M":
                        vch    = arg2.CastAs <CharacterInstance>();
                        buffer = vch.Gender.ObjectPronoun();
                        break;

                    case "$s":
                        buffer = ch.Gender.PossessivePronoun();
                        break;

                    case "$S":
                        vch    = arg2.CastAs <CharacterInstance>();
                        buffer = vch.Gender.PossessivePronoun();
                        break;

                    case "$q":
                        buffer = to == ch ? "" : "s";
                        break;

                    case "$Q":
                        buffer = to == ch ? "your" : ch.Gender.PossessivePronoun();
                        break;

                    case "$p":
                        obj    = arg1.CastAs <ObjectInstance>();
                        buffer = to == null || to.CanSee(obj)
                                         ? obj_short(obj)
                                         : "something";
                        break;

                    case "$P":
                        obj    = arg2.CastAs <ObjectInstance>();
                        buffer = to == null || to.CanSee(obj)
                                         ? obj_short(obj)
                                         : "something";
                        break;

                    case "$d":
                        if (string.IsNullOrEmpty(arg2?.ToString()))
                        {
                            buffer = "door";
                        }
                        else
                        {
                            var tuple = arg2.ToString().FirstArgument();
                            buffer = tuple.Item1;
                        }
                        break;
                    }
                    sb.ReplaceFirst(var, buffer);
                }

                startIndex = varPosition + 1;
            }while (varPosition != -1);

            if (!dontUpper)
            {
                sb.CapitalizeFirst();
            }
            return(sb.ToString());
        }
Пример #16
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);
            }
        }
Пример #17
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);
        }
Пример #18
0
        public static void CheckDisarm(CharacterInstance ch, CharacterInstance victim, IRepositoryManager dbManager = null)
        {
            var obj = victim.GetEquippedItem(WearLocations.Wield);

            if (CheckFunctions.CheckIfNullObject(ch, obj))
            {
                return;
            }

            var tempObj = victim.GetEquippedItem(WearLocations.DualWield);

            if (tempObj != null && SmaugRandom.Bits(1) == 0)
            {
                obj = tempObj;
            }

            var skill = (dbManager ?? RepositoryManager.Instance).GetEntity <SkillData>("disarm");

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

            if (!ch.IsNpc() && ch.GetEquippedItem(WearLocations.Wield) == null && SmaugRandom.Bits(1) == 0)
            {
                skill.LearnFromFailure(ch);
                return;
            }

            if (!ch.IsNpc() && !ch.CanSee(obj) && SmaugRandom.Bits(1) == 0)
            {
                skill.LearnFromFailure(ch);
                return;
            }

            if (Grip.CheckGrip(ch, victim) && !ch.IsNpc())
            {
                skill.LearnFromFailure(ch);
                return;
            }

            comm.act(ATTypes.AT_SKILL, "$n DISARMS you!", ch, null, victim, ToTypes.Victim);
            comm.act(ATTypes.AT_SKILL, "You disarm $N!", ch, null, victim, ToTypes.Character);
            comm.act(ATTypes.AT_SKILL, "$n disarms $N!", ch, null, victim, ToTypes.Room);

            skill.LearnFromFailure(ch);

            obj.RemoveFrom();

            if (!victim.IsNpc() && victim.CanPKill() && !obj.ExtraFlags.IsSet((int)ItemExtraFlags.Loyal))
            {
                obj.MagicFlags.SetBit(ItemMagicFlags.PKDisarmed);
                obj.Value.ToList()[5] = victim.Level;
            }

            if (victim.IsNpc() || (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Loyal) && victim.IsPKill() && !ch.IsNpc()))
            {
                obj.AddTo(victim);
            }
            else
            {
                victim.CurrentRoom.AddTo(obj);
            }
        }
Пример #19
0
 public static string MORPHERS(CharacterInstance ch, CharacterInstance looker)
 {
     return(looker.CanSee(ch) ? ch.CurrentMorph.Morph.ShortDescription : "someone");
 }