Esempio n. 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.");
         }
     }
 }
Esempio n. 2
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.");
            }
        }
Esempio n. 3
0
        private static string GenerateBufferForAffectedBy(CharacterInstance victim, PlayerInstance ch)
        {
            if (victim.IsAffected(AffectedByTypes.Invisible))
            {
                return(AffectedByTypes.Invisible.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsAffected(AffectedByTypes.Hide))
            {
                return(AffectedByTypes.Hide.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsAffected(AffectedByTypes.PassDoor))
            {
                return(AffectedByTypes.PassDoor.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsAffected(AffectedByTypes.FaerieFire))
            {
                return(AffectedByTypes.FaerieFire.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if ((ch.IsAffected(AffectedByTypes.DetectEvil) && victim.IsEvil()) ||
                ch.CurrentClass == ClassTypes.Paladin)
            {
                return(ClassTypes.Paladin.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsNeutral() && ch.CurrentClass == ClassTypes.Paladin)
            {
                return(ClassTypes.Paladin.GetAttribute <DescriptorAttribute>().Messages.ToList()[1]);
            }
            if (victim.IsGood() && ch.CurrentClass == ClassTypes.Paladin)
            {
                return(ClassTypes.Paladin.GetAttribute <DescriptorAttribute>().Messages.ToList()[2]);
            }

            if (victim.IsAffected(AffectedByTypes.Berserk))
            {
                return(AffectedByTypes.Berserk.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Attacker))
            {
                return(PlayerFlags.Attacker.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Killer))
            {
                return(PlayerFlags.Killer.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Thief))
            {
                return(PlayerFlags.Thief.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (!victim.IsNpc() && victim.Act.IsSet((int)PlayerFlags.Litterbug))
            {
                return(PlayerFlags.Litterbug.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsNpc() && ch.IsImmortal() && victim.Act.IsSet((int)ActFlags.Prototype))
            {
                return(ActFlags.Prototype.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            if (victim.IsNpc() && ch.CurrentMount != null &&
                ch.CurrentMount == victim && ch.CurrentRoom == ch.CurrentMount.CurrentRoom)
            {
                return("(Mount) ");
            }
            if (victim.Switched != null && ((PlayerInstance)victim.Switched).Descriptor.ConnectionStatus == ConnectionTypes.Editing)
            {
                return(ConnectionTypes.Editing.GetAttribute <DescriptorAttribute>().Messages.First());
            }
            return(victim.CurrentMorph != null ? "(Morphed) " : string.Empty);
        }