Example #1
0
        public void RandomizeCells(TimeInfoData gameTime)
        {
            for (var y = 0; y < Height; y++)
            {
                for (var x = 0; x < Width; x++)
                {
                    var cell = GetCellFromMap(x, y);

                    var rangeData = WeatherConstants.WeatherData.FirstOrDefault(d => d.Hemisphere == cell.Hemisphere &&
                                                                                d.Season == gameTime.Season &&
                                                                                d.Climate == cell.Climate);
                    if (rangeData == null)
                    {
                        // TODO Error
                        continue;
                    }

                    cell.ChangeTemperature(SmaugRandom.Between(rangeData.Temperature.ToList()[0], rangeData.Temperature.ToList()[1]));
                    cell.ChangePressure(SmaugRandom.Between(rangeData.Pressure.ToList()[0], rangeData.Pressure.ToList()[1]));
                    cell.ChangeCloudCover(SmaugRandom.Between(rangeData.CloudCover.ToList()[0], rangeData.CloudCover.ToList()[1]));
                    cell.ChangeHumidity(SmaugRandom.Between(rangeData.Humidity.ToList()[0], rangeData.Humidity.ToList()[1]));
                    cell.ChangePrecip(SmaugRandom.Between(rangeData.Precipitation.ToList()[0], rangeData.Precipitation.ToList()[1]));
                    cell.ChangeEnergy(SmaugRandom.Between(rangeData.Energy.ToList()[0], rangeData.Energy.ToList()[1]));
                    cell.ChangeWindSpeedX(SmaugRandom.Between(rangeData.WindSpeedX.ToList()[0], rangeData.WindSpeedX.ToList()[1]));
                    cell.ChangeWindSpeedY(SmaugRandom.Between(rangeData.WindSpeedY.ToList()[0], rangeData.WindSpeedY.ToList()[1]));
                }
            }
        }
Example #2
0
        private static void CreateAnimatedCorpse(int level, CharacterInstance ch, MobileTemplate template, ObjectInstance corpse)
        {
            var mob = RepositoryManager.Instance.CHARACTERS.Create(template, 0,
                                                                   $"animated corpse {template.PlayerName}");

            ch.CurrentRoom.AddTo(mob);
            mob.Level       = (ch.Level / 2).GetLowestOfTwoNumbers(template.Level);
            mob.CurrentRace = EnumerationExtensions.GetEnumByName <RaceTypes>(template.Race);

            mob.MaximumHealth = template.Level * 8 +
                                SmaugRandom.Between(template.Level * template.Level / 4, template.Level * template.Level);
            mob.MaximumHealth = (mob.MaximumHealth / 4).GetNumberThatIsBetween(
                mob.MaximumHealth * corpse.Value.ToList()[3] / 100, ch.Level * SmaugRandom.D20(10));
            mob.MaximumHealth = mob.MaximumHealth.GetHighestOfTwoNumbers(1);
            mob.CurrentHealth = mob.MaximumHealth;
            mob.DamageRoll    = new DiceData {
                SizeOf = ch.Level / 8
            };
            mob.HitRoll = new DiceData {
                SizeOf = ch.Level / 6
            };
            mob.CurrentAlignment = ch.CurrentAlignment;
            mob.ShortDescription = $"The animated corpse of {template.ShortDescription}";
            mob.LongDescription  =
                $"An animated corpse of {template.ShortDescription} struggles with the horror of its undeath.";
            mob.AddFollower(ch);

            MakeCorpseTemporary(level, mob);
            TransferContentsOfCorpse(corpse);
        }
Example #3
0
        public static ReturnTypes spell_change_sex(int sn, int level, CharacterInstance ch, object vo)
        {
            var victim = (CharacterInstance)vo;
            var skill  = RepositoryManager.Instance.GetEntity <SkillData>(sn);

            if (CheckFunctions.CheckIfTrueCasting(victim.IsImmune(ResistanceTypes.Magic), skill, ch,
                                                  CastingFunctionType.Immune, victim))
            {
                return(ReturnTypes.SpellFailed);
            }

            if (CheckFunctions.CheckIfTrueCasting(victim.IsAffectedBy(sn), skill, ch, CastingFunctionType.Failed, victim))
            {
                return(ReturnTypes.SpellFailed);
            }

            var af = new AffectData
            {
                SkillNumber = sn,
                Duration    = GetDuration(level),
                Location    = ApplyTypes.Gender
            };

            do
            {
                af.Modifier = SmaugRandom.Between(0, 2) - (int)victim.Gender;
            } while (af.Modifier == 0);

            victim.AddAffect(af);
            ch.SuccessfulCast(skill, victim);

            return(ReturnTypes.None);
        }
Example #4
0
        public void Initialize()
        {
            for (var y = 0; y < Height; y++)
            {
                for (var x = 0; x < Width; x++)
                {
                    var cell = new WeatherCell(0)
                    {
                        Hemisphere =
                            EnumerationExtensions.GetEnum <HemisphereTypes>(SmaugRandom.Between(0, 1))
                    };

                    cell.ChangeTemperature(SmaugRandom.Between(-30, 100));
                    cell.ChangePressure(SmaugRandom.Between(0, 100));
                    cell.ChangeCloudCover(SmaugRandom.Between(0, 100));
                    cell.ChangeHumidity(SmaugRandom.Between(0, 100));
                    cell.ChangePrecip(SmaugRandom.Between(0, 100));
                    cell.ChangeWindSpeedX(SmaugRandom.Between(-100, 100));
                    cell.ChangeWindSpeedY(SmaugRandom.Between(-100, 100));
                    cell.ChangeEnergy(SmaugRandom.Between(0, 100));

                    _map[x][y] = cell;
                }
            }
        }
Example #5
0
        public static int ComputeExperienceGain(this CharacterInstance ch, CharacterInstance victim)
        {
            var xp    = victim.GetExperienceWorth() * 0.GetNumberThatIsBetween(victim.Level - ch.Level + 10, 13) / 10;
            var align = ch.CurrentAlignment - victim.CurrentAlignment;

            if (align > 990 || align < -990)
            {
                xp = ModifyXPForAttackingOppositeAlignment(xp);
            }
            else if (ch.CurrentAlignment > 300 && align < 250)
            {
                xp = ModifyXPForGoodPlayerAttackingSameAlignment(xp);
            }

            xp = SmaugRandom.Between((xp * 3) >> 2, (xp * 5) >> 2);

            if (!victim.IsNpc())
            {
                xp /= 4;
            }
            else if (!ch.IsNpc())
            {
                xp = ReduceXPForKillingSameMobRepeatedly(ch, (MobileInstance)victim, xp);
            }

            if (!ch.IsNpc() && ch.Level > 5)
            {
                xp = ModifyXPForExperiencedVsNovicePlayer(ch, xp);
            }

            //// Level based experience gain cap.  Cannot get more experience for
            //// a kill than the amount for your current experience level
            return(0.GetNumberThatIsBetween(xp, ch.GetExperienceLevel(ch.Level + 1) - ch.GetExperienceLevel(ch.Level)));
        }
Example #6
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);
        }
        public static void CreateBloodstain(CharacterInstance ch, IRepositoryManager dbManager = null)
        {
            var databaseMgr = dbManager ?? RepositoryManager.Instance;
            var obj         = databaseMgr.OBJECTS.Create(databaseMgr.OBJECTTEMPLATES.CastAs <Repository <long, ObjectTemplate> >()
                                                         .Get(VnumConstants.OBJ_VNUM_BLOODSTAIN), 0);

            obj.Timer = SmaugRandom.Between(1, 2);
            ch.CurrentRoom.AddTo(obj);
        }
Example #8
0
        public static ReturnTypes spell_create_mob(int sn, int level, CharacterInstance ch, object vo)
        {
            var skill = RepositoryManager.Instance.SKILLS.Get(sn);

            var targetName = Cast.TargetName;

            var lvl = GetMobLevel(skill, level);
            var id  = skill.value;

            if (id == 0)
            {
                if (!targetName.Equals("cityguard"))
                {
                    id = GameConstants.GetVnum("cityguard");
                }
                else if (!targetName.Equals("vampire"))
                {
                    id = GameConstants.GetVnum("vampire");
                }
            }

            var mi = RepositoryManager.Instance.MOBILETEMPLATES.Get(id);

            if (CheckFunctions.CheckIfNullObjectCasting(mi, skill, ch))
            {
                return(ReturnTypes.None);
            }

            var mob = RepositoryManager.Instance.CHARACTERS.Create(mi);

            if (CheckFunctions.CheckIfNullObjectCasting(mob, skill, ch))
            {
                return(ReturnTypes.None);
            }

            mob.Level         = lvl.GetLowestOfTwoNumbers(!string.IsNullOrEmpty(skill.Dice) ? magic.ParseDiceExpression(ch, skill.Dice) : mob.Level);
            mob.ArmorClass    = mob.Level.Interpolate(100, -100);
            mob.MaximumHealth = mob.Level * 8 + SmaugRandom.Between(mob.Level * mob.Level / 4, mob.Level * mob.Level);
            mob.CurrentHealth = mob.MaximumHealth;
            mob.CurrentCoin   = 0;

            ch.SuccessfulCast(skill, mob);
            ch.CurrentRoom.AddTo(mob);
            mob.AddFollower(ch);

            var af = new AffectData
            {
                Type     = EnumerationExtensions.GetEnum <AffectedByTypes>((int)skill.ID),
                Duration = (SmaugRandom.Fuzzy((level + 1) / 3) + 1) *
                           GameConstants.GetConstant <int>("AffectDurationConversionValue")
            };

            mob.AddAffect(af);

            return(ReturnTypes.None);
        }
        public static void CreateBlood(CharacterInstance ch, IRepositoryManager dbManager = null)
        {
            var databaseMgr = dbManager ?? RepositoryManager.Instance;
            var obj         = databaseMgr.OBJECTS.Create(databaseMgr.OBJECTTEMPLATES.CastAs <Repository <long,
                                                                                                         ObjectTemplate> >().Get(VnumConstants.OBJ_VNUM_BLOOD), 0);

            obj.Timer             = SmaugRandom.Between(2, 4);
            obj.Value.ToList()[1] = SmaugRandom.Between(3, 5.GetLowestOfTwoNumbers(ch.Level));
            ch.CurrentRoom.AddTo(obj);
        }
Example #10
0
 private static void AdjustHumidityForPrecipitation(WeatherCell cell, WeatherCell delta)
 {
     if (cell.Precipitation > 40)
     {
         delta.ChangeHumidity(0 - cell.Precipitation / 20);
     }
     else
     {
         delta.ChangeHumidity(SmaugRandom.Between(0, 3));
     }
 }
Example #11
0
 private static void AdjustTemperatureForDayNight(TimeInfoData gameTime, WeatherCell delta, WeatherCell cell)
 {
     if (gameTime.Sunlight == SunPositionTypes.Sunrise ||
         gameTime.Sunlight == SunPositionTypes.Light)
     {
         delta.ChangeTemperature(SmaugRandom.Between(-1, 2) + (cell.CloudCover / 10 > 5 ? -1 : 1));
     }
     else
     {
         delta.ChangeTemperature(SmaugRandom.Between(-2, 0) + (cell.CloudCover / 10 > 5 ? 2 : -3));
     }
 }
Example #12
0
        public static ReturnTypes SpringTheTrap(this CharacterInstance ch, ObjectInstance obj)
        {
            var level    = obj.Value.ToList()[2];
            var txt      = string.Empty;
            var trapType = TrapTypes.None;
            DescriptorAttribute attrib = null;

            try
            {
                trapType = EnumerationExtensions.GetEnum <TrapTypes>(obj.Value.ToList()[1]);
                attrib   = trapType.GetAttribute <DescriptorAttribute>();
                txt      = attrib.Messages.FirstOrDefault();
            }
            catch (ArgumentException)
            {
                txt = TrapTypeLookupDefault;
            }

            var dam = SmaugRandom.Between(obj.Value.ToList()[2], obj.Value.ToList()[2] * 2);

            comm.act(ATTypes.AT_HITME, $"You are {txt}!", ch, null, null, ToTypes.Character);
            comm.act(ATTypes.AT_ACTION, $"$n is {txt}.", ch, null, null, ToTypes.Room);

            --obj.Value.ToList()[0];
            if (obj.Value.ToList()[0] <= 0)
            {
                obj.Extract();
            }

            var returnCode = ReturnTypes.None;

            if (!string.IsNullOrEmpty(attrib?.Messages.ToList()[1]))
            {
                var skill = RepositoryManager.Instance.GetEntity <SkillData>(attrib.Messages.ToList()[1]);
                returnCode = ch.ObjectCastSpell((int)skill.ID, level, ch);
            }

            if (trapType == TrapTypes.Blade || trapType == TrapTypes.ElectricShock)
            {
                returnCode = ch.CauseDamageTo(ch, dam, Program.TYPE_UNDEFINED);
            }
            if ((trapType == TrapTypes.PoisonArrow ||
                 trapType == TrapTypes.PoisonDagger ||
                 trapType == TrapTypes.PoisonDart ||
                 trapType == TrapTypes.PoisonNeedle) &&
                returnCode == ReturnTypes.None)
            {
                returnCode = ch.CauseDamageTo(ch, dam, Program.TYPE_UNDEFINED);
            }

            return(returnCode);
        }
Example #13
0
        private static void UpdateTick(int pulseValue)
        {
            SetPulseTimer(PulseTypes.Point, SmaugRandom.Between((int)(pulseValue * 0.75f), (int)(pulseValue * 1.2f)));

            update.auth_update();
            update.time_update();
            WeatherManager.Instance.Weather.Update(Instance.GameTime);
            update.hint_update();
            update.char_update();
            update.obj_update();

            _logger.Info("Update Tick");
        }
Example #14
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());
            }
        }
Example #15
0
        private static void ChangePressure(WeatherCell delta, int totalPressure, int numPressureCells, WeatherCell cell)
        {
            delta.Pressure = totalPressure / numPressureCells - cell.Pressure;

            if (cell.Precipitation >= 70)
            {
                delta.ChangePressure(0 - cell.Pressure / 2);
            }
            else if (cell.Pressure < 70 && cell.Precipitation > 30)
            {
                delta.ChangePressure(SmaugRandom.Between(-5, 5));
            }
            else
            {
                delta.ChangePressure(cell.Pressure / 2);
            }
        }
Example #16
0
        private static void AdjustCloudCoverForHumitityAndPrecipitation(WeatherCell cell, WeatherCell delta)
        {
            var humidityAndPrecip = cell.Humidity + cell.Precipitation;

            if (humidityAndPrecip / 2 >= 60)
            {
                delta.ChangeCloudCover(0 - cell.Humidity / 10);
            }
            else if ((humidityAndPrecip / 2 < 60) && (humidityAndPrecip / 2 > 40))
            {
                delta.ChangeCloudCover(SmaugRandom.Between(-2, 2));
            }
            else
            {
                delta.ChangeCloudCover(cell.Humidity / 5);
            }
        }
Example #17
0
        private static void AdjustPrecipitationForHumidityAndPressure(WeatherCell cell)
        {
            var humidityAndPressure = cell.Humidity + cell.Pressure;

            if (humidityAndPressure / 2 >= 60)
            {
                cell.ChangePrecip(cell.Humidity / 10);
            }
            else if ((humidityAndPressure / 2 < 60) && (humidityAndPressure / 2 > 40))
            {
                cell.ChangePrecip(SmaugRandom.Between(-2, 2));
            }
            else
            {
                cell.ChangePrecip(0 - cell.Humidity / 5);
            }
        }
Example #18
0
        public static ReturnTypes spell_black_fist(int sn, int level, CharacterInstance ch, object vo)
        {
            var lvl = 0.GetHighestOfTwoNumbers(level);

            lvl = 30.GetLowestOfTwoNumbers(lvl);

            var dam = (int)(1.3f * (lvl * SmaugRandom.Between(1, 9) + 4));

            var victim = (CharacterInstance)vo;

            if (victim.SavingThrows.CheckSaveVsSpellStaff(lvl, victim))
            {
                dam /= 4;
            }

            return(ch.CauseDamageTo(victim, dam, sn));
        }
Example #19
0
        private static void UpdateArea(int pulseValue)
        {
            SetPulseTimer(PulseTypes.Area, SmaugRandom.Between(pulseValue / 2, 3 * pulseValue / 2));

            var updated  = 0;
            var notified = 0;

            foreach (var area in _dbManager.AREAS.Values)
            {
                var resetAge = area.ResetFrequency > 0 ? area.ResetFrequency : 15;
                if ((resetAge == -1 && area.Age == -1) || (area.Age + 1 < resetAge - 1))
                {
                    continue;
                }

                if (area.NumberOfPlayers > 0 && area.Age == resetAge - 1)
                {
                    var buffer = !string.IsNullOrEmpty(area.ResetMessage)
                        ? area.ResetMessage
                        : "You hear some squeaking sounds...";

                    foreach (var pch in _dbManager.CHARACTERS.Values
                             .Where(x => !x.IsNpc())
                             .Where(x => x.IsAwake())
                             .Where(x => x.CurrentRoom != null)
                             .Where(x => x.CurrentRoom.Area.Equals(area)))
                    {
                        pch.SetColor(ATTypes.AT_RESET);
                        pch.SendTo(buffer);
                        notified++;
                    }
                }

                if (area.NumberOfPlayers == 0 || area.Age >= resetAge)
                {
                    reset.reset_area(area);
                    _logger.Info("Updated Area {0}/{1}", area.ID, area.Name);

                    updated++;
                    area.Age = resetAge == -1 ? -1 : SmaugRandom.Between(0, resetAge / 5);
                }
            }

            _logger.Info("Updated {0} areas and notified {1} players.", updated, notified);
        }
Example #20
0
        private static string GetDecorateRoom_PreAndPost_2(SectorTypes sector, int x)
        {
            string pre, post;
            var    random = SmaugRandom.Between(0, 3);

            if (random == 0 || random == 2)
            {
                post = ".";
                pre  = random == 0 ? "you notice " : "you see ";
            }
            else
            {
                post = ", and ";
                pre  = random == 1 ? "you see " : "over yonder ";
            }

            return($"{pre}{LookupConstants.RoomSents[(int)sector][x]}{post}");
        }
Example #21
0
        private static string GetDecorateRoom_PreAndPost_1(int iRand, int nRand, SectorTypes sector, int x)
        {
            string pre, post;
            var    result = SmaugRandom.Between(1, 2 * (iRand == nRand - 1 ? 1 : 2));

            if (result <= 2)
            {
                post = ".";
                pre  = result == 1 ? "You notice " : "You see ";
            }
            else
            {
                post = ", and ";
                pre  = result == 3 ? "You see " : "You notice ";
            }

            return($"{pre}{LookupConstants.RoomSents[(int)sector][x]}{post}");
        }
Example #22
0
        private void PickAndUpdateRandomCell()
        {
            var x = SmaugRandom.Between(0, Width);
            var y = SmaugRandom.Between(0, Height);

            var cell = GetCellFromMap(x, y);

            var rand = SmaugRandom.Between(-10, 10);

            switch (SmaugRandom.D8())
            {
            case 1:
                cell.ChangeCloudCover(rand);
                break;

            case 2:
                cell.ChangeEnergy(rand);
                break;

            case 3:
                cell.ChangeHumidity(rand);
                break;

            case 4:
                cell.ChangePrecip(rand);
                break;

            case 5:
                cell.ChangePressure(rand);
                break;

            case 6:
                cell.ChangeTemperature(rand);
                break;

            case 7:
                cell.ChangeWindSpeedX(rand);
                break;

            case 8:
                cell.ChangeWindSpeedY(rand);
                break;
            }
        }
Example #23
0
        public static void area_update()
        {
            foreach (var area in RepositoryManager.Instance.AREAS.Values)
            {
                var resetAge = area.ResetFrequency > 0 ? area.ResetFrequency : 15;
                if ((resetAge == -1 && area.Age == -1) ||
                    (++area.Age < resetAge - 1))
                {
                    continue;
                }

                //// Check players
                if (area.NumberOfPlayers > 0 && area.Age == resetAge - 1)
                {
                    var buffer = !string.IsNullOrEmpty(area.ResetMessage)
                                        ? area.ResetMessage + "\r\n"
                                        : "You hear some squeaking sounds...\r\n";

                    foreach (var pch in RepositoryManager.Instance.CHARACTERS.CastAs <Repository <long, CharacterInstance> >().Values
                             .Where(pch => !pch.IsNpc() &&
                                    pch.IsAwake() &&
                                    pch.CurrentRoom != null &&
                                    pch.CurrentRoom.Area == area))
                    {
                        pch.SetColor(ATTypes.AT_RESET);
                        pch.SendTo(buffer);
                    }
                }

                //// Check age and reset
                if (area.NumberOfPlayers == 0 || area.Age >= resetAge)
                {
                    reset.reset_area(area);
                    area.Age = resetAge == -1 ? -1 : SmaugRandom.Between(0, resetAge / 5);

                    //// Mud Academy resets every 3 minutes
                    var room = RepositoryManager.Instance.ROOMS.CastAs <Repository <long, RoomTemplate> >().Get(VnumConstants.ROOM_VNUM_SCHOOL);
                    if (room != null && room.Area == area && area.ResetFrequency == 0)
                    {
                        area.Age = 15 - 3;
                    }
                }
            }
        }
Example #24
0
        public static ReturnTypes spell_control_weather(int sn, int level, CharacterInstance ch, object vo)
        {
            if (CheckFunctions.CheckIfTrue(ch, !WeatherChangeTable.ContainsKey(Cast.TargetName.ToLower()),
                                           "What do you want to change about the weather?"))
            {
                return(ReturnTypes.SpellFailed);
            }

            var cell   = WeatherManager.Instance.GetWeather(ch.CurrentRoom.Area);
            var change = 5.GetNumberThatIsBetween(SmaugRandom.Between(5, 15) + ch.Level / 10, 15);

            WeatherChangeTable[Cast.TargetName.ToLower()].Invoke(cell, change);

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

            ch.SuccessfulCast(skill);

            return(ReturnTypes.None);
        }
Example #25
0
        public static bool Execute(MobileInstance ch, IManager dbManager)
        {
            if (ch.CurrentPosition != PositionTypes.Standing)
            {
                return(false);
            }
            if (SmaugRandom.Bits(2) != 0)
            {
                return(false);
            }

            foreach (var victim in ch.CurrentRoom.Persons.Where(victim => victim != ch)
                     .Where(victim => !victim.IsNpc())
                     .Where(victim => victim.Level < LevelConstants.ImmortalLevel)
                     .Where(ch.CanSee))
            {
                if (victim.IsAwake() && SmaugRandom.Between(0, ch.Level) == 0)
                {
                    comm.act(ATTypes.AT_ACTION, "You discover $n's hands in your sack of gold!", ch, null, victim,
                             ToTypes.Victim);
                    comm.act(ATTypes.AT_ACTION, "$N discovers $n's hands in $S sack of gold!", ch, null, victim,
                             ToTypes.NotVictim);
                    return(true);
                }

                var maxgold = ch.Level * ch.Level * 1000;
                var gold    = victim.CurrentCoin *
                              SmaugRandom.Between(1, 2.GetNumberThatIsBetween(ch.Level / 4, 10)) / 100;

                ch.CurrentCoin     += 9 * gold / 10;
                victim.CurrentCoin -= gold;
                if (ch.CurrentCoin <= maxgold)
                {
                    return(true);
                }

                ch.CurrentRoom.Area.BoostEconomy(ch.CurrentCoin - maxgold / 2);
                ch.CurrentCoin = maxgold / 2;
                return(true);
            }
            return(false);
        }
Example #26
0
        public static string GetHint(int level)
        {
            if (level < 0)
            {
                return($"HintLevel error, level was {level}");
            }

            var count = HINTS.Count(hint => level >= hint.Low && level <= hint.High);

            if (count > 1)
            {
                var which = SmaugRandom.Between(1, count);
                count = 0;
                foreach (var hint in HINTS)
                {
                    if (level >= hint.Low && level <= hint.High)
                    {
                        ++count;
                    }
                    if (count == which)
                    {
                        return(hint.Text);
                    }
                }
            }
            else if (count == 1)
            {
                foreach (var hint in HINTS)
                {
                    if (level >= hint.Low && level <= hint.High)
                    {
                        return(hint.Text);
                    }
                }
            }

            return(" ");
        }
Example #27
0
        public static ReturnTypes spell_colour_spray(int sn, int level, CharacterInstance ch, object vo)
        {
            var victim = (CharacterInstance)vo;

            var modLevel = level.GetLowestOfTwoNumbers(DamageValues.Length * 2 / 2 - 1);

            modLevel = modLevel.GetHighestOfTwoNumbers(0);

            if (DamageValues.Length >= modLevel)
            {
                throw new InvalidDataException(
                          $"ModLevel {modLevel} is larger than the Damage Array size of {DamageValues.Length}");
            }

            var dam = SmaugRandom.Between(DamageValues[modLevel] / 2, DamageValues[modLevel] * 2);

            if (victim.SavingThrows.CheckSaveVsSpellStaff(modLevel, victim))
            {
                dam /= 2;
            }

            return(ch.CauseDamageTo(victim, dam, sn));
        }
Example #28
0
        /// <summary>
        /// Mental state can affect finding an object, used by get/drop/put/quaff/etc.
        /// Gets increasingly "freaky" based on mental state and drunkenness
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static bool FindObject_CheckMentalState(CharacterInstance ch)
        {
            var ms = ch.MentalState;

            // We're going to be nice and let nothing weird happen unless you're a tad messed up
            var drunk = 1.GetHighestOfTwoNumbers(ch.IsNpc() ? 0 : ((PlayerInstance)ch).PlayerData.ConditionTable[ConditionTypes.Drunk]);

            if (Math.Abs(ms) + drunk / 3 < 30)
            {
                return(false);
            }
            if (SmaugRandom.D100() + (ms < 0 ? 15 : 5) > Math.Abs(ms) / 2 + drunk / 4)
            {
                return(false);
            }

            var output = ms > 15
                ? ObjectMessageLargeMap[SmaugRandom.Between(1.GetHighestOfTwoNumbers(ms / 5 - 15), (ms + 4) / 5)]
                : ObjectMessageSmallMap[SmaugRandom.Between(1, (Math.Abs(ms) / 2 + drunk).GetNumberThatIsBetween(1, 60) / 10)];

            ch.SendTo(output);
            return(true);
        }
Example #29
0
        public static ReturnTypes spell_acid_breath(int sn, int level, CharacterInstance ch, object vo)
        {
            var victim = (CharacterInstance)vo;

            int chance;

            checked
            {
                chance = 2 * level;
            }

            if (ch.Chance(chance) && !victim.SavingThrows.CheckSaveVsBreath(level, victim))
            {
                foreach (var obj in victim.Carrying.Where(obj => SmaugRandom.Bits(2) == 0))
                {
                    switch (obj.ItemType)
                    {
                    case ItemTypes.Armor:
                        CheckDamageArmor(obj, victim);
                        break;

                    case ItemTypes.Container:
                        CheckDamageContainer(obj, victim);
                        break;
                    }
                }
            }

            var hpChange = 10.GetHighestOfTwoNumbers(ch.CurrentHealth);
            var damage   = SmaugRandom.Between(hpChange / 16 + 1, hpChange / 8);

            if (victim.SavingThrows.CheckSaveVsBreath(level, victim))
            {
                damage /= 2;
            }
            return(ch.CauseDamageTo(victim, damage, sn));
        }
Example #30
0
        public static string hallucinated_object(int ms, bool fShort)
        {
            if (ms == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException();
            }

            var temp = ms + 10;

            if (temp == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException();
            }

            var sms = (temp / 5).GetNumberThatIsBetween(1, 20);

            return(fShort
                       ? LookupManager.Instance.GetLookup("HallucinatedShortNames",
                                                          SmaugRandom.Between(
                                                              6 - (sms / 2).GetNumberThatIsBetween(1, 5), sms) - 1)
                       : LookupManager.Instance.GetLookup("HallucinatedLongNames",
                                                          SmaugRandom.Between(
                                                              6 - (sms / 2).GetNumberThatIsBetween(1, 5), sms) - 1));
        }