public void CheckWillValue() { try { string CheckName = "Will"; int OnGoingMods = 0; string onGoingModFormula = string.Empty; if (_indvSB != null) { OnGoingMods = _indvSB.GetOnGoingStatBlockModValue(OnGoingStatBlockModifier.StatBlockModifierTypes.SavingThrow, OnGoingStatBlockModifier.StatBlockModifierSubTypes.None, false, ref onGoingModFormula); OnGoingMods += _indvSB.GetOnGoingStatBlockModValue(OnGoingStatBlockModifier.StatBlockModifierTypes.SavingThrow, OnGoingStatBlockModifier.StatBlockModifierSubTypes.SavingThrow_Will, false, ref onGoingModFormula); } int ClassMod = CharacterClasses.GetWillSaveValue(); int RaceMod = CharacterClasses.HasClass("animal companion") ? 0 : Race_Base.RaceWill(); int Mod = 0; string ModString = string.Empty; if (_monSBSearch.HasSQ("madness")) { Mod = _abilityScores.ChaMod; ModString = " ChaMod"; } else { Mod = _abilityScores.WisMod; ModString = " WisMod"; } int WillMod = ClassMod + RaceMod + Mod + OnGoingMods; int WillSB = Convert.ToInt32(Utility.GetNonParenValue(MonSB.Will)); string formula = "+" + ClassMod.ToString() + " ClassMod " + " +" + RaceMod.ToString() + " RaceMod " + " +" + Mod.ToString() + ModString; if (OnGoingMods != 0) { formula += " +" + OnGoingMods.ToString() + " OnGoingMods(" + onGoingModFormula + ")"; } if (_monSBSearch.HasFeat("Iron Will")) { WillMod += 2; formula += " +2 Iron Will"; } if (_monSBSearch.HasTrait("Indomitable Faith")) { WillMod += 1; formula += " +1 Indomitable Faith"; } if (MonSB.SubType.IndexOf("nightshade") >= 0) { WillMod += 2; formula += " +2 nightshade"; } if (_monSBSearch.HasSQ("inner strength")) { WillMod += 2; formula += " +2 inner strength"; } if (Race_Base.Name() == "Svirfneblin") { WillMod += 2; formula += " +2 Svirfneblin"; } if (_monSBSearch.HasDomain("Protection")) { int clericLevel = CharacterClasses.FindClassLevel("cleric"); if (clericLevel == 0) { clericLevel = CharacterClasses.FindClassLevel("druid"); } int tempMod = (clericLevel / 5) + 1; WillMod += tempMod; formula += " +" + tempMod.ToString() + " Protection domain"; } if (CharacterClasses.HasClass("Paladin")) { int level = CharacterClasses.FindClassLevel("paladin"); if (level >= 2) //Divine Grace { WillMod += _abilityScores.ChaMod; formula += " +" + _abilityScores.ChaMod.ToString() + " Divine Grace"; } } if (CharacterClasses.HasClass("prophet of kalistrade")) { int level = CharacterClasses.FindClassLevel("prophet of kalistrade"); //Auspicious Display --assumes the bling is present int mod = 1; if (level >= 4) { mod++; } if (level >= 7) { mod++; } if (level >= 10) { mod++; } WillMod += mod; formula += " + " + mod.ToString() + " Auspicious Display"; } if (CharacterClasses.HasClass("Antipaladin")) { int level = CharacterClasses.FindClassLevel("Antipaladin"); if (level >= 2) //Unholy Resilience { WillMod += _abilityScores.ChaMod; formula += " +" + _abilityScores.ChaMod.ToString() + " Unholy Resilience"; } } if (_monSBSearch.HasTemplate("graveknight")) { WillMod += 2; formula += " +2 Sacrilegious Aura"; } WillMod += GetMagicItemSaveMods(ref formula); if (CharacterClasses.HasClass("barbarian")) { int barbarianLevel = CharacterClasses.FindClassLevel("barbarian"); if (barbarianLevel <= 10) { WillMod += 2; formula += " +2 rage"; } if (barbarianLevel > 10 && barbarianLevel <= 19) { WillMod += 3; formula += " +3 greater rage"; } if (barbarianLevel >= 20) { WillMod += 4; formula += " +4 mighty rage"; } } if (_monSBSearch.HasGear("heartstone")) { WillMod += 2; formula += " + 2 heartstone"; } if (_monSBSearch.HasClassArchetype("sczarni swindler")) { int rogueLevel = CharacterClasses.FindClassLevel("rogue"); int tempMod = 0; if (rogueLevel >= 4) { tempMod++; } if (rogueLevel >= 8) { tempMod++; } if (rogueLevel >= 12) { tempMod++; } if (rogueLevel >= 16) { tempMod++; } if (rogueLevel >= 20) { tempMod++; } if (tempMod > 0) { WillMod += tempMod; formula += " +" + tempMod.ToString() + " No Fool"; } } if (_monSBSearch.HasArchetype("Sharper"))//Lucky Save { int rogueLevel = CharacterClasses.FindClassLevel("rogue"); int tempMod = 0; if (rogueLevel >= 3) { tempMod++; } if (rogueLevel >= 9) { tempMod++; } if (rogueLevel >= 15) { tempMod++; } if (tempMod > 0) { WillMod += tempMod; formula += " + " + tempMod.ToString() + " Lucky Save"; } } if (WillMod == WillSB) { _messageXML.AddPass(CheckName, formula); } else { _messageXML.AddFail(CheckName, WillMod.ToString(), WillSB.ToString(), formula); } } catch (Exception ex) { _messageXML.AddFail("CheckWillValue", ex.Message); } }