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); }
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 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 UpdateWeapon(ObjectInstance obj) { if (obj.Value.ToList()[1] > 0 && obj.Value.ToList()[2] > 0) { obj.Value.ToList()[2] = obj.Value.ToList()[1]; } else { obj.Value.ToList()[1] = SmaugRandom.Fuzzy(1 * obj.Level / 4 + 2); obj.Value.ToList()[2] = SmaugRandom.Fuzzy(3 * obj.Level / 4 + 6); } if (obj.Value.ToList()[0] == 0) { obj.Value.ToList()[0] = GameConstants.GetConstant <int>("InitWeaponCondition"); } }
public static int GetResistance(this ObjectInstance obj) { var resist = SmaugRandom.Fuzzy(Program.MAX_ITEM_IMPACT); if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Magical)) { resist += SmaugRandom.Fuzzy(12); } if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Metallic)) { resist += SmaugRandom.Fuzzy(5); } if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Organic)) { resist -= SmaugRandom.Fuzzy(5); } if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Blessed)) { resist += SmaugRandom.Fuzzy(5); } if (obj.ExtraFlags.IsSet((int)ItemExtraFlags.Inventory)) { resist += 20; } resist += obj.Level / 10 - 2; if (obj.ItemType == ItemTypes.Armor || obj.ItemType == ItemTypes.Weapon) { resist += obj.Value.ToList()[0] / 2 - 2; } return(resist.GetNumberThatIsBetween(10, 99)); }
private static int GetDuration(int level) { return((SmaugRandom.Fuzzy((level + 1) / 5) + 1) * GameConstants.GetConstant <int>("AffectDurationConversionValue")); }
private static void UpdatePotion(ObjectInstance obj) { obj.Value.ToList()[0] = SmaugRandom.Fuzzy(obj.Value.ToList()[0]); }
private static void UpdateMagicalImplement(ObjectInstance obj) { obj.Value.ToList()[0] = SmaugRandom.Fuzzy(obj.Value.ToList()[0]); obj.Value.ToList()[1] = SmaugRandom.Fuzzy(obj.Value.ToList()[1]); obj.Value.ToList()[2] = obj.Value.ToList()[1]; }
private static void UpdateSalve(ObjectInstance obj) { obj.Value.ToList()[3] = SmaugRandom.Fuzzy(obj.Value.ToList()[3]); }
public CharacterInstance Create(Template parent, params object[] args) { Validation.IsNotNull(parent, "parent"); Validation.Validate(parent is MobileTemplate, "Invalid Template Type"); var mobParent = parent.CastAs <MobileTemplate>(); long id; if (args != null && args.Length > 0) { id = Convert.ToInt64(args[0]); } else { id = GetNextId; } var name = parent.Name; if (args != null && args.Length > 1) { name = args[1].ToString(); } var isMobile = true; //if (args != null && args.Length > 2) // isMobile = (bool) args[2]; var mob = new CharacterInstance(id, name) { Parent = parent, ShortDescription = mobParent.ShortDescription, LongDescription = mobParent.LongDescription, Description = parent.Description, Level = SmaugRandom.Fuzzy(mobParent.Level), Act = mobParent.GetActFlags(), HomeVNum = -1, ResetVnum = -1, ResetNum = -1, AffectedBy = mobParent.GetAffected(), CurrentAlignment = mobParent.GetStatistic <int>(StatisticTypes.Alignment), Gender = EnumerationExtensions.GetEnum <GenderTypes>(mobParent.GetStatistic <string>(StatisticTypes.Gender)) }; if (isMobile) { var mi = (MobileInstance)mob; mi.SpecialFunction = mobParent.SpecialFunction; if (!string.IsNullOrEmpty(mobParent.SpecFun)) { mi.SpecialFunctionName = mobParent.SpecFun; } } if (mob.Act.IsSet((int)ActFlags.MobInvisibility)) { mob.MobInvisible = mob.Level; } mob.ArmorClass = mobParent.GetStatistic <int>(StatisticTypes.ArmorClass) > 0 ? mobParent.GetStatistic <int>(StatisticTypes.ArmorClass) : mob.Level.Interpolate(100, -100); if (mobParent.HitDice == null || mobParent.HitDice.NumberOf == 0) { mob.MaximumHealth = mob.Level * 8 + SmaugRandom.Between(mob.Level * mob.Level / 4, mob.Level * mob.Level); } else { mob.MaximumHealth = mobParent.HitDice.NumberOf * SmaugRandom.Between(1, mobParent.HitDice.SizeOf) + mobParent.HitDice.Bonus; } mob.CurrentCoin = mobParent.GetStatistic <int>(StatisticTypes.Coin); mob.Experience = mobParent.GetStatistic <int>(StatisticTypes.Experience); mob.CurrentPosition = mobParent.GetPosition(); mob.CurrentDefensivePosition = mobParent.GetDefensivePosition(); mob.BareDice = new DiceData { NumberOf = mobParent.DamageDice.NumberOf, SizeOf = mobParent.DamageDice.SizeOf }; mob.ToHitArmorClass0 = mobParent.GetStatistic <int>(StatisticTypes.ToHitArmorClass0); mob.HitRoll = new DiceData { Bonus = mobParent.HitDice.Bonus }; mob.DamageRoll = new DiceData { Bonus = mobParent.DamageDice.Bonus }; mob.PermanentStrength = mobParent.GetStatistic <int>(StatisticTypes.PermanentStrength); mob.PermanentDexterity = mobParent.GetStatistic <int>(StatisticTypes.PermanentDexterity); mob.PermanentWisdom = mobParent.GetStatistic <int>(StatisticTypes.PermanentWisdom); mob.PermanentIntelligence = mobParent.GetStatistic <int>(StatisticTypes.PermanentIntelligence); mob.PermanentConstitution = mobParent.GetStatistic <int>(StatisticTypes.PermanentConstitution); mob.PermanentCharisma = mobParent.GetStatistic <int>(StatisticTypes.PermanentCharisma); mob.PermanentLuck = mobParent.GetStatistic <int>(StatisticTypes.PermanentLuck); mob.CurrentRace = EnumerationExtensions.GetEnum <RaceTypes>(mobParent.GetRace()); mob.CurrentClass = EnumerationExtensions.GetEnum <ClassTypes>(mobParent.Class); mob.ExtraFlags = mobParent.ExtraFlags; mob.SavingThrows = new SavingThrowData(mobParent.SavingThrows); mob.Height = mobParent.GetStatistic <int>(StatisticTypes.Height); mob.Weight = mobParent.GetStatistic <int>(StatisticTypes.Weight); mob.Resistance = mobParent.GetResistance(); mob.Immunity = mobParent.GetImmunity(); mob.Susceptibility = mobParent.GetSusceptibility(); if (isMobile) { ((MobileInstance)mob).Attacks = new ExtendedBitvector(mobParent.GetAttacks()); } mob.Defenses = mobParent.GetDefenses(); mob.NumberOfAttacks = mobParent.GetStatistic <int>(StatisticTypes.NumberOfAttacks); //mob.Speaks = build.get_langflag(mobParent.Speaks); //mob.Speaking = build.get_langflag(mobParent.Speaking); Add(mob.ID, mob); return(mob); }
public int FuzzifyFavor(DeityFieldTypes field, int mod) { int fieldvalue = GetFieldValue(field); return(SmaugRandom.Fuzzy(fieldvalue / mod)); }