private void UpdateCreatureAttacks(Creature creature) { creature.BaseAttackBonus = attacksGenerator.GenerateBaseAttackBonus(creature.Type, creature.HitPoints); var zombieAttacks = attacksGenerator.GenerateAttacks( CreatureConstants.Templates.Zombie, SizeConstants.Medium, creature.Size, creature.BaseAttackBonus, creature.Abilities, creature.HitPoints.RoundedHitDiceQuantity); zombieAttacks = attacksGenerator.ApplyAttackBonuses(zombieAttacks, creature.SpecialQualities, creature.Abilities); var newSlam = zombieAttacks.First(a => a.Name == "Slam"); if (creature.Attacks.Any(a => a.Name == "Slam")) { var oldSlam = creature.Attacks.First(a => a.Name == "Slam"); var oldMax = dice.Roll(oldSlam.Damages[0].Roll).AsPotentialMaximum(); var newMax = dice.Roll(newSlam.Damages[0].Roll).AsPotentialMaximum(); if (newMax > oldMax) { oldSlam.Damages.Clear(); oldSlam.Damages.Add(newSlam.Damages[0]); } zombieAttacks = zombieAttacks.Except(new[] { newSlam }); } creature.Attacks = creature.Attacks .Union(zombieAttacks) .Where(a => !a.IsSpecial); }
private void UpdateCreatureAttacks(Creature creature) { creature.BaseAttackBonus = attacksGenerator.GenerateBaseAttackBonus(creature.Type, creature.HitPoints); var skeletonAttacks = attacksGenerator.GenerateAttacks( CreatureConstants.Templates.Skeleton, SizeConstants.Medium, creature.Size, creature.BaseAttackBonus, creature.Abilities, creature.HitPoints.RoundedHitDiceQuantity); skeletonAttacks = attacksGenerator.ApplyAttackBonuses(skeletonAttacks, creature.SpecialQualities, creature.Abilities); var newClaw = skeletonAttacks.First(a => a.Name == "Claw"); if (creature.Attacks.Any(a => a.Name == "Claw")) { var oldClaw = creature.Attacks.First(a => a.Name == "Claw"); var oldMax = dice.Roll(oldClaw.Damages[0].Roll).AsPotentialMaximum(); var newMax = dice.Roll(newClaw.Damages[0].Roll).AsPotentialMaximum(); if (newMax > oldMax) { oldClaw.Damages.Clear(); oldClaw.Damages.Add(newClaw.Damages[0]); } skeletonAttacks = skeletonAttacks.Except(new[] { newClaw }); } else { newClaw.Frequency.Quantity = creature.NumberOfHands; if (creature.NumberOfHands == 0) { skeletonAttacks = skeletonAttacks.Except(new[] { newClaw }); } } creature.Attacks = creature.Attacks .Union(skeletonAttacks) .Where(a => !a.IsSpecial); }
private Creature GeneratePrototype(string creatureName, bool asCharacter) { var creature = new Creature(); creature.Name = creatureName; var creatureData = creatureDataSelector.SelectFor(creatureName); creature.Size = creatureData.Size; creature.Space.Value = creatureData.Space; creature.Reach.Value = creatureData.Reach; creature.CanUseEquipment = creatureData.CanUseEquipment; creature.ChallengeRating = creatureData.ChallengeRating; creature.LevelAdjustment = creatureData.LevelAdjustment; creature.CasterLevel = creatureData.CasterLevel; creature.NumberOfHands = creatureData.NumberOfHands; creature.Type = GetCreatureType(creatureName); creature.Abilities = abilitiesGenerator.GenerateFor(creatureName); if (advancementSelector.IsAdvanced(creatureName)) { var advancement = advancementSelector.SelectRandomFor(creatureName, creature.Type, creature.Size, creature.ChallengeRating); creature.IsAdvanced = true; creature.Size = advancement.Size; creature.Space.Value = advancement.Space; creature.Reach.Value = advancement.Reach; creature.CasterLevel += advancement.CasterLevelAdjustment; creature.ChallengeRating = advancement.AdjustedChallengeRating; creatureData.NaturalArmor += advancement.NaturalArmorAdjustment; creature.Abilities[AbilityConstants.Strength].AdvancementAdjustment += advancement.StrengthAdjustment; creature.Abilities[AbilityConstants.Dexterity].AdvancementAdjustment += advancement.DexterityAdjustment; creature.Abilities[AbilityConstants.Constitution].AdvancementAdjustment += advancement.ConstitutionAdjustment; creature.HitPoints = hitPointsGenerator.GenerateFor( creatureName, creature.Type, creature.Abilities[AbilityConstants.Constitution], creature.Size, advancement.AdditionalHitDice, asCharacter); } else { creature.HitPoints = hitPointsGenerator.GenerateFor( creatureName, creature.Type, creature.Abilities[AbilityConstants.Constitution], creature.Size, asCharacter: asCharacter); } if (creature.HitPoints.HitDiceQuantity == 0) { creature.ChallengeRating = ChallengeRatingConstants.Zero; } creature.Alignment = alignmentGenerator.Generate(creatureName); creature.Skills = skillsGenerator.GenerateFor(creature.HitPoints, creatureName, creature.Type, creature.Abilities, creature.CanUseEquipment, creature.Size); creature.Languages = languageGenerator.GenerateWith(creatureName, creature.Abilities, creature.Skills); creature.SpecialQualities = featsGenerator.GenerateSpecialQualities( creatureName, creature.Type, creature.HitPoints, creature.Abilities, creature.Skills, creature.CanUseEquipment, creature.Size, creature.Alignment); creature.BaseAttackBonus = attacksGenerator.GenerateBaseAttackBonus(creature.Type, creature.HitPoints); creature.Attacks = attacksGenerator.GenerateAttacks( creatureName, creatureData.Size, creature.Size, creature.BaseAttackBonus, creature.Abilities, creature.HitPoints.RoundedHitDiceQuantity); creature.Feats = featsGenerator.GenerateFeats( creature.HitPoints, creature.BaseAttackBonus, creature.Abilities, creature.Skills, creature.Attacks, creature.SpecialQualities, creature.CasterLevel, creature.Speeds, creatureData.NaturalArmor, creature.NumberOfHands, creature.Size, creature.CanUseEquipment); creature.Skills = skillsGenerator.ApplyBonusesFromFeats(creature.Skills, creature.Feats, creature.Abilities); creature.HitPoints = hitPointsGenerator.RegenerateWith(creature.HitPoints, creature.Feats); creature.GrappleBonus = attacksGenerator.GenerateGrappleBonus( creatureName, creature.Size, creature.BaseAttackBonus, creature.Abilities[AbilityConstants.Strength]); var allFeats = creature.Feats.Union(creature.SpecialQualities); creature.Attacks = attacksGenerator.ApplyAttackBonuses(creature.Attacks, allFeats, creature.Abilities); creature.Attacks = equipmentGenerator.AddAttacks(allFeats, creature.Attacks, creature.NumberOfHands); creature.Equipment = equipmentGenerator.Generate( creature.Name, creature.CanUseEquipment, allFeats, creature.HitPoints.RoundedHitDiceQuantity, creature.Attacks, creature.Abilities, creature.Size); creature.Abilities = abilitiesGenerator.SetMaxBonuses(creature.Abilities, creature.Equipment); creature.Skills = skillsGenerator.SetArmorCheckPenalties(creature.Name, creature.Skills, creature.Equipment); creature.InitiativeBonus = ComputeInitiativeBonus(creature.Feats); creature.Speeds = speedsGenerator.Generate(creature.Name); creature.ArmorClass = armorClassGenerator.GenerateWith( creature.Abilities, creature.Size, creatureName, creature.Type, allFeats, creatureData.NaturalArmor, creature.Equipment); creature.Saves = savesGenerator.GenerateWith(creature.Name, creature.Type, creature.HitPoints, allFeats, creature.Abilities); creature.Magic = magicGenerator.GenerateWith(creature.Name, creature.Alignment, creature.Abilities, creature.Equipment); return(creature); }
private (IEnumerable <Attack> AnimalAttacks, int AnimalBaseAttack) UpdateCreatureAttacks(Creature creature, CreatureType animalCreatureType, HitPoints animalHitPoints, CreatureDataSelection animalData) { var baseAttackBonus = attacksGenerator.GenerateBaseAttackBonus(animalCreatureType, animalHitPoints); creature.BaseAttackBonus += baseAttackBonus; foreach (var attack in creature.Attacks) { if (attack.IsSpecial) { attack.Name += $" (in {creature.Type.Name} form)"; } else { attack.Name += $" (in {creature.Type.Name} or Hybrid form)"; } } creature.GrappleBonus = attacksGenerator.GenerateGrappleBonus( creature.Name, creature.Size, creature.BaseAttackBonus, creature.Abilities[AbilityConstants.Strength]); var animalAttacks = attacksGenerator.GenerateAttacks( AnimalSpecies, animalData.Size, animalData.Size, creature.BaseAttackBonus, creature.Abilities, creature.HitPoints.RoundedHitDiceQuantity); var allFeats = creature.Feats.Union(creature.SpecialQualities); animalAttacks = attacksGenerator.ApplyAttackBonuses(animalAttacks, allFeats, creature.Abilities); foreach (var animalAttack in animalAttacks) { animalAttack.Name += " (in Animal form)"; } var biggerSize = GetBiggerSize(creature.Size, animalData.Size); var lycanthropeAttacks = attacksGenerator.GenerateAttacks( LycanthropeSpecies, SizeConstants.Medium, biggerSize, creature.BaseAttackBonus, creature.Abilities, creature.HitPoints.RoundedHitDiceQuantity); lycanthropeAttacks = attacksGenerator.ApplyAttackBonuses(lycanthropeAttacks, allFeats, creature.Abilities); foreach (var lycanthropeAttack in lycanthropeAttacks) { var searchName = lycanthropeAttack.Name.Replace(" (in Hybrid form)", string.Empty); var animalAttack = animalAttacks.FirstOrDefault(a => a.Name.StartsWith(searchName)); if (animalAttack == null) { continue; } if (!string.IsNullOrEmpty(lycanthropeAttack.DamageEffect)) { animalAttack.DamageEffect = lycanthropeAttack.DamageEffect; } } creature.Attacks = creature.Attacks.Union(animalAttacks).Union(lycanthropeAttacks); return(animalAttacks, baseAttackBonus); }