internal bool IsAffectedBy(PuzzlePiece toolPuzzlePiece) { if (AffectedBy == null) { return(false); } return(AffectedBy.Contains(toolPuzzlePiece.Type)); }
public CharacterData(MobPrototypeData prototype) : this() { // Simple assignments Prototype = prototype; Name = prototype.Name; ShortDescription = prototype.ShortDescription; LongDescription = prototype.LongDescription; Description = prototype.Description; SpecialFunction = prototype.SpecialFunction; Prompt = null; Group = prototype.Group; Action = prototype.Actions; Communication = CommunicationFlag.NoChannels | CommunicationFlag.NoShout | CommunicationFlag.NoTell; AffectedBy = prototype.AffectedBy; Alignment = prototype.Alignment; Level = prototype.Level; HitRoll = prototype.HitRoll; DamRoll = prototype.Damage.Bonus; Damage = prototype.Damage; Armor = prototype.ArmorRating; Offense = prototype.Offense; Immunity = prototype.Immunity; Resist = prototype.Resistance; Vulnerability = prototype.Vulnerability; StartPosition = prototype.StartingPosition; DefaultPosition = prototype.DefaultPosition; Race = prototype.Race; Form = prototype.Form; Parts = prototype.Parts; Size = prototype.Size; Material = prototype.Material; Affects = new List <AffectData>(); PermanentStats = new Stats(); ModifiedStats = new Stats(); // Calculated assignments if (prototype.Wealth == 0) { Gold = 0; Silver = 0; } else { Random rand = new Random(); // Calculate the randomized wealth of the mob (0.5x - 1.5x the mob's wealth value) long actualWealth = rand.Next(prototype.Wealth / 2, 3 * prototype.Wealth / 2); // Set gold based on actual wealth Gold = rand.Next((int)actualWealth / 200, (int)actualWealth / 100); Silver = actualWealth - (Gold * 100); } // Roll the hit dice to determine max health; set current to the max. MaxHealth = prototype.Health.RollDice(); Health = MaxHealth; // Roll the mana dice to determine max mana; set current to the max MaxMana = prototype.Mana.RollDice(); Mana = MaxMana; // If no damage class is set, choose from slash, pound, and pierce if (prototype.DamageType.DamageClass == DamageClass.None) { Random rand = new Random(); DamageType = Consts.DamageTypes.AttackTable[rand.Next(3)]; } else { DamageType = prototype.DamageType; } // If the prototype gender is random, choose one now; otherwise, set if (prototype.Gender.GenderCode == Sex.Random) { Random rng = new Random(); Gender = Consts.Gender.GenderTable[rng.Next(2)]; } else { Gender = prototype.Gender; } // Set stats - first, set a base across all stats PermanentStats = new Stats(Helpers.Miscellaneous.LowestOf(new int[] { 25, 11 + (Level / 4) })); // Next, adjust stats based on action flags (classes, mostly) if (Action.HasFlag(ActionFlag.Warrior)) { PermanentStats.Strength += 3; PermanentStats.Intelligence -= 1; PermanentStats.Constitution += 2; } if (Action.HasFlag(ActionFlag.Thief)) { PermanentStats.Dexterity += 3; PermanentStats.Intelligence += 1; PermanentStats.Wisdom -= 1; } if (Action.HasFlag(ActionFlag.Cleric)) { PermanentStats.Wisdom += 3; PermanentStats.Dexterity -= 1; PermanentStats.Strength += 1; } if (Action.HasFlag(ActionFlag.Mage)) { PermanentStats.Intelligence += 3; PermanentStats.Strength -= 1; PermanentStats.Dexterity += 1; } // 2 point dexterity bonus for Fast if (Offense.HasFlag(OffensiveFlag.Offense_Fast)) { PermanentStats.Dexterity += 2; } // Size modifiers to strength and constitution - increase when size > medium PermanentStats.Strength += (int)Size.SizeCode - (int)Enums.Size.Medium; PermanentStats.Constitution += ((int)Size.SizeCode - (int)Enums.Size.Medium) / 2; // Permanent spells // Sanctuary if (AffectedBy.HasFlag(AffectedByFlag.Sanctuary)) { SkillType skill = Consts.Skills.SkillTable.SingleOrDefault(s => s.Name.ToLower().Equals("sanctuary")); AffectData affect = new AffectData() { Where = ToWhere.Affects, Type = skill, Level = Level, Duration = -1, Location = ApplyType.None, Modifier = 0, BitVector = AffectedByFlag.Sanctuary }; ApplyAffect(affect); } // Haste - also applies a dexterity modifier based on level if (AffectedBy.HasFlag(AffectedByFlag.Haste)) { SkillType skill = Consts.Skills.SkillTable.Single(s => s.Name.ToLower().Equals("haste")); AffectData affect = new AffectData() { Where = ToWhere.Affects, Type = skill, Level = Level, Duration = -1, Location = ApplyType.Dexterity, Modifier = (Level >= 32) ? 4 : (Level >= 25) ? 3 : (Level >= 18) ? 2 : 1, BitVector = AffectedByFlag.Haste }; ApplyAffect(affect); } // Protection from Evil if (AffectedBy.HasFlag(AffectedByFlag.ProtectEvil)) { SkillType skill = Consts.Skills.SkillTable.Single(s => s.Name.ToLower().Equals("protection evil")); AffectData affect = new AffectData() { Where = ToWhere.Affects, Type = skill, Level = Level, Duration = -1, Location = ApplyType.Saves, Modifier = -1, BitVector = AffectedByFlag.ProtectEvil }; ApplyAffect(affect); } // Protection from Good if (AffectedBy.HasFlag(AffectedByFlag.ProtectGood)) { SkillType skill = Consts.Skills.SkillTable.Single(s => s.Name.ToLower().Equals("protection good")); AffectData affect = new AffectData() { Where = ToWhere.Affects, Type = skill, Level = Level, Duration = -1, Location = ApplyType.Saves, Modifier = -1, BitVector = AffectedByFlag.ProtectGood }; ApplyAffect(affect); } }
public void AddAffectedBy(string name) { AffectedByTypes type = Realm.Library.Common.Extensions.EnumerationExtensions.GetEnumByName <AffectedByTypes>(name); AffectedBy.SetBit((int)type); }
public bool IsAffected(AffectedByTypes affectedBy) => AffectedBy.IsSet((int)affectedBy);