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; } } }
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))); }
public static bool Execute(MobileInstance ch, string spellName, IManager dbManager) { if (!ch.IsInCombatPosition()) { return(false); } var victim = ch.CurrentRoom.Persons.Where(v => v != ch) .FirstOrDefault(vch => SmaugRandom.Bits(2) == 0 && vch.GetMyTarget() == ch); if (victim == null) { return(false); } var databaseMgr = (IRepositoryManager)(dbManager ?? RepositoryManager.Instance); var skill = databaseMgr.GetEntity <SkillData>(spellName); if (skill?.SpellFunction == null) { return(false); } skill.SpellFunction.Value.Invoke((int)skill.ID, ch.Level, ch, victim); return(true); }
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); }
public static bool Execute(MobileInstance ch, IManager dbManager) { var handler = Program.Kernel.Get <ISpecFunHandler>(); ch.SummonIfHating(); if (!ch.IsInCombatPosition()) { return(false); } var victim = ch.CurrentRoom.Persons.Where(v => v != ch) .FirstOrDefault(vch => SmaugRandom.Bits(2) == 0 && vch.GetMyTarget() == ch); if (victim == null || victim == ch) { return(false); } var skill = handler.PickSpell(SpellLevelLookupTable, ch.Level); if (skill?.SpellFunction == null) { return(false); } skill.SpellFunction.Value.DynamicInvoke(skill.ID, ch.Level, ch, victim); return(true); }
private static object TargetCharacterWithDefensiveSpell(string arg, CharacterInstance ch, bool silence, SkillData skill) { CharacterInstance victim; if (arg.IsNullOrEmpty()) { victim = ch; } else { victim = ch.GetCharacterInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, !silence ? "They aren't here." : "")) { return(null); } } // Nuisance flag will pick who you are fighting for defensive spells up to 36% of the time if (!ch.IsNpc() && ch.CurrentFighting != null && ((PlayerInstance)ch).PlayerData.Nuisance != null && ((PlayerInstance)ch).PlayerData.Nuisance.Flags > 5 && SmaugRandom.D100() < (((PlayerInstance)ch).PlayerData.Nuisance.Flags - 5) * 8 + 6 * ((PlayerInstance)ch).PlayerData.Nuisance.Power) { victim = ch.GetMyTarget(); } return(CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), !silence ? "You can't cast this on yourself!" : "") ? null : victim); }
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); }
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])); } } }
private static ReturnTypes ConditionFull(CharacterInstance ch, int conditionValue) { ReturnTypes retcode = ReturnTypes.None; if (ch.Level < LevelConstants.AvatarLevel && ch.CurrentClass != ClassTypes.Vampire) { color.set_char_color(ATTypes.AT_HUNGRY, ch); DescriptorAttribute attrib = ConditionTypes.Full.GetAttribute <DescriptorAttribute>(); color.send_to_char(attrib.Messages[conditionValue * 2], ch); if (conditionValue < 2) { comm.act(ATTypes.AT_HUNGRY, attrib.Messages[(conditionValue * 2) + 1], ch, null, null, ToTypes.Room); if (conditionValue == 0) { if (!ch.IsPKill() || SmaugRandom.Bits(1) == 0) { ch.WorsenMentalState(1); } retcode = ch.CauseDamageTo(ch, 2, (int)SkillNumberTypes.Undefined); } else { if (SmaugRandom.Bits(1) == 0) { ch.WorsenMentalState(1); } } } } return(retcode); }
public static void do_cast(CharacterInstance ch, string argument) { var pch = (PlayerInstance)ch; switch (pch.SubState) { case CharacterSubStates.TimerDoAbort: if (!CastAbortTimer(pch, argument)) { return; } break; case CharacterSubStates.Pause: if (!CastPause(pch, argument)) { return; } break; default: if (!DefaultCast(ch, argument)) { return; } break; } if (_skill != null && _skill.Name.EqualsIgnoreCase("ventriloquate")) { magic.say_spell(ch, (int)_skill.ID); } if (!_dontWait) { Macros.WAIT_STATE(ch, _skill.Rounds); } if (!magic.process_spell_components(ch, (int)_skill.ID)) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -1 * 1.GetHighestOfTwoNumbers(_blood / 2)); } else if (ch.Level < LevelConstants.ImmortalLevel) { ch.CurrentMana -= _mana / 2; } //skills.learn_from_failure(ch, (int)_skill.ID); return; } if (!ch.IsNpc() && SmaugRandom.D100() + _skill.difficulty * 5 > pch.PlayerData.GetSkillMastery(_skill.ID)) { } else { } }
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); }
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 CreateFire(RoomTemplate inRoom, int duration, IRepositoryManager dbManager = null) { var databaseMgr = dbManager ?? RepositoryManager.Instance; var fire = databaseMgr.OBJECTS.Create(databaseMgr.OBJECTTEMPLATES.CastAs <Repository <long, ObjectTemplate> >() .Get(VnumConstants.OBJ_VNUM_FIRE), 0); fire.Timer = SmaugRandom.Fuzzy(duration); inRoom.AddTo(fire); }
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); }
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)); } }
public static int number_door() { int door; while ((door = SmaugRandom.RandomMM() % (16 - 1)) > 9) { // do nothing } return(door); }
private static void MakeCorpseTemporary(int level, CharacterInstance mob) { var af = new AffectData { Type = AffectedByTypes.Charm, Duration = (SmaugRandom.Fuzzy((level + 1) / 4) + 1) * GameConstants.GetSystemValue <int>("AffectDurationConversionValue") }; mob.AddAffect(af); }
private static bool CantSleepDueToMentalState(CharacterInstance ch, int modifier) { if (ch.MentalState > 30 && SmaugRandom.D100() + modifier < ch.MentalState) { ch.SendTo("You just can't seem to calm yourself down enough to sleep."); comm.act(ATTypes.AT_PLAIN, "$n closes $s eyes for a few moments, but just can't seem to go to sleep.", ch, null, null, ToTypes.Room); return(true); } return(false); }
public static void AbilityLearnFromSuccess(this SkillData skill, PlayerInstance ch) { var sn = (int)skill.ID; var skillMastery = ch.PlayerData.GetSkillMastery(sn); if (ch.IsNpc() || skillMastery <= 0) { return; } var adept = skill.RaceAdept.ToList()[(int)ch.CurrentRace]; var skillLevel = skill.RaceLevel.ToList()[(int)ch.CurrentRace]; if (skillLevel == 0) { skillLevel = ch.Level; } if (skillMastery < adept) { var schance = skillMastery + 5 * skill.difficulty; var percent = SmaugRandom.D100(); var learn = 1; if (percent >= schance) { learn = 2; } else if (schance - percent > 25) { return; } ch.PlayerData.UpdateSkillMastery(sn, adept.GetLowestOfTwoNumbers(skillMastery + learn)); int gain; if (ch.PlayerData.GetSkillMastery(sn) == adept) { gain = 1000 * skillLevel; ch.SetColor(ATTypes.AT_WHITE); ch.Printf("You are now an adept of %s! You gain %d bonus experience!", skill.Name, gain); } else { gain = 20 * skillLevel; if (ch.CurrentFighting == null) // TODO: Check gsn_hide && gsn_sneak { ch.SetColor(ATTypes.AT_WHITE); ch.Printf("You gain %d experience points from your success!", gain); } } ch.GainXP(gain); } }
private static void UpdateArmor(ObjectInstance obj) { if (obj.Value.ToList()[0] == 0) { obj.Value.ToList()[0] = SmaugRandom.Fuzzy(obj.Level / 4 + 2); } if (obj.Value.ToList()[1] == 0) { obj.Value.ToList()[1] = obj.Value.ToList()[0]; } }
private static void DoFlee(CharacterInstance ch, CharacterInstance victim) { if ((victim.Act.IsSet((int)ActFlags.Wimpy) && SmaugRandom.Bits(1) == 0 && victim.CurrentHealth < victim.MaximumHealth / 2) || (victim.IsAffected(AffectedByTypes.Charm) && victim.Master != null && victim.Master.CurrentRoom != victim.CurrentRoom)) { var mob = (MobileInstance)victim; mob.StartFearing(ch); mob.StopHunting(); Flee.do_flee(victim, string.Empty); } }
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)); } }
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); }
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"); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsInCombatPosition()) { return(false); } var bits = SmaugRandom.Bits(3); return(bits == 2 ? Dragon.Execute(ch, "lightning breath", dbManager) : Dragon.Execute(ch, BreathTable.ContainsKey(bits) ? BreathTable[bits] : "frost breath", dbManager)); }
public static ReturnTypes spell_acetum_primus(int sn, int level, CharacterInstance ch, object vo) { var victim = (CharacterInstance)vo; var lvl = 0.GetHighestOfTwoNumbers(level); var damage = (int)(1.3f * (2 * lvl * SmaugRandom.D4() + 7)); if (victim.SavingThrows.CheckSaveVsSpellStaff(lvl, victim)) { damage = 3 * damage / 4; } return(ch.CauseDamageTo(victim, damage, sn)); }
public static ReturnTypes spell_acid_blast(int sn, int level, CharacterInstance ch, object vo) { var victim = vo.CastAs <CharacterInstance>(); var damage = SmaugRandom.D6(level); if (victim.SavingThrows.CheckSaveVsSpellStaff(level, victim)) { damage /= 2; } return(ch.CauseDamageTo(victim, damage, sn)); }
private static int ModifyDamageForEquipment(CharacterInstance victim, int dam) { var wearLoc = GetRandomWearLocation(); var obj = victim.GetEquippedItem(wearLoc); if (obj != null && dam > obj.GetResistance() && SmaugRandom.Bits(1) == 0) { handler.set_cur_obj(obj); obj.CauseDamageTo(); return(dam - 5); } return(dam + 5); }
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()); } }