Пример #1
0
 public static void show_char_to_char(IEnumerable <CharacterInstance> list, PlayerInstance ch)
 {
     foreach (var rch in list.Where(x => x != ch))
     {
         if (ch.CanSee(rch))
         {
             rch.ShowToCharacter(ch);
         }
         else if (ch.CurrentRoom.IsDark() && ch.IsAffected(AffectedByTypes.Infrared))
         {
             ch.SetColor(ATTypes.AT_BLOOD);
             ch.SendTo("The red form of a living creature is here.");
         }
     }
 }
Пример #2
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);
            }
        }
Пример #3
0
        public static void show_list_to_char(List <ObjectInstance> list, PlayerInstance ch, bool fShort, bool fShowNothing)
        {
            if (ch.Descriptor == null)
            {
                return;
            }

            if (list == null)
            {
                if (fShowNothing)
                {
                    if (ch.Act.IsSet((int)PlayerFlags.Combine))
                    {
                        ch.SendTo("     ");
                    }
                    ch.SetColor(ATTypes.AT_OBJECT);
                    ch.SendTo("Nothing.");
                }
                return;
            }

            var count = list.Count;

            var ms = (ch.MentalState > 0 ? ch.MentalState : 1) *
                     (ch.PlayerData.GetConditionValue(ConditionTypes.Drunk) > 0
                         ? ch.PlayerData.GetConditionValue(ConditionTypes.Drunk) / 12
                         : 1);

            int offcount;

            if (Math.Abs(ms) > 40)
            {
                offcount = (count * ms / 100).GetNumberThatIsBetween(-count, count * 2);
                if (offcount < 0)
                {
                    offcount += SmaugRandom.Between(0, Math.Abs(offcount));
                }
                else if (offcount > 0)
                {
                    offcount -= SmaugRandom.Between(0, offcount);
                }
            }
            else
            {
                offcount = 0;
            }

            if (count + offcount <= 0)
            {
                if (fShowNothing)
                {
                    if (ch.Act.IsSet((int)PlayerFlags.Combine))
                    {
                        ch.SendTo("     ");
                    }
                    ch.SetColor(ATTypes.AT_OBJECT);
                    ch.SendTo("Nothing.");
                }
                return;
            }

            var tmp = offcount > 0 ? offcount : 0;
            var cnt = 0;

            var size        = count + (offcount > 0 ? offcount : 0);
            var prgpstrShow = new string[size];
            var prgnShow    = new int[size];
            var pitShow     = new int[size];
            var nShow       = 0;

            foreach (var obj in list)
            {
                if (offcount < 0 && ++cnt > count + offcount)
                {
                    break;
                }

                if (tmp > 0 && SmaugRandom.Bits(1) == 0)
                {
                    prgpstrShow[nShow] = hallucinated_object(ms, fShort);
                    prgnShow[nShow]    = 1;
                    pitShow[nShow]     = SmaugRandom.Between((int)ItemTypes.Light, (int)ItemTypes.Book);
                    nShow++;
                    --tmp;
                }

                if (obj.WearLocation == WearLocations.None &&
                    ch.CanSee(obj) &&
                    (obj.ItemType != ItemTypes.Trap ||
                     ch.IsAffected(AffectedByTypes.DetectInvisibility)))
                {
                    string pstrShow = obj.GetFormattedDescription(ch, fShort);
                    bool   fCombine = false;

                    if (ch.Act.IsSet((int)PlayerFlags.Combine))
                    {
                        for (var i = nShow - 1; i >= 0; i--)
                        {
                            if (prgpstrShow[i] == pstrShow)
                            {
                                prgnShow[i] += obj.Count;
                                fCombine     = true;
                                break;
                            }
                        }
                    }

                    pitShow[nShow] = (int)obj.ItemType;

                    if (!fCombine)
                    {
                        prgpstrShow[nShow] = pstrShow;
                        prgnShow[nShow]    = obj.Count;
                        nShow++;
                    }
                }
            }

            if (tmp > 0)
            {
                for (var i = 0; i < tmp; i++)
                {
                    prgpstrShow[nShow] = hallucinated_object(ms, fShort);
                    prgnShow[nShow]    = 1;
                    pitShow[nShow]     = SmaugRandom.Between((int)ItemTypes.Light, (int)ItemTypes.Book);
                    nShow++;
                }
            }

            for (var i = 0; i < nShow; i++)
            {
                SetCharacterColorByItemType(ch, pitShow, i);

                if (fShowNothing)
                {
                    ch.SendTo("     ");
                }
                ch.SendTo(prgpstrShow[i]);

                if (prgnShow[i] != 1)
                {
                    ch.Printf(" (%d)", prgnShow[i]);
                }

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

            if (fShowNothing && nShow == 0)
            {
                if (ch.Act.IsSet((int)PlayerFlags.Combine))
                {
                    ch.SendTo("     ");
                }
                ch.SetColor(ATTypes.AT_OBJECT);
                ch.SendTo("Nothing.");
            }
        }