Skip to content

Commit

Permalink
minor tweaks before release
Browse files Browse the repository at this point in the history
  • Loading branch information
ThyWoof committed Dec 18, 2024
1 parent 431ec6e commit 110d91b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 101 deletions.
39 changes: 5 additions & 34 deletions SolastaUnfinishedBusiness/Models/2024ClericContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using SolastaUnfinishedBusiness.Api.GameExtensions;
using SolastaUnfinishedBusiness.Api.LanguageExtensions;
using SolastaUnfinishedBusiness.Behaviors;
using SolastaUnfinishedBusiness.Behaviors.Specific;
using SolastaUnfinishedBusiness.Builders;
using SolastaUnfinishedBusiness.Builders.Features;
Expand Down Expand Up @@ -100,18 +101,15 @@ private static void LoadClericChannelDivinity()
EffectFormBuilder
.Create()
.SetBonusMode(AddBonusMode.AbilityBonus)
// this doesn't seem to work with healing forms reason why the custom behavior
.SetDiceAdvancement(LevelSourceType.ClassLevel, 0, 20, (7, 2), (13, 3), (18, 4))
.SetHealingForm(
HealingComputation.Dice, 0, DieType.D8, 1, false, HealingCap.MaximumHitPoints)
.Build())
.SetParticleEffectParameters(CureWounds)
.Build())
.AddCustomSubFeatures(ClassHolder.Cleric)
.AddToDB();

powerDivineSparkHeal.AddCustomSubFeatures(
new ModifyEffectDescriptionPowerDivineSparkHeal(powerDivineSparkHeal));

var powerDivineSparkDamageNecrotic = FeatureDefinitionPowerSharedPoolBuilder
.Create("PowerClericDivineSparkDamageNecrotic")
.SetGuiPresentation(Category.Feature)
Expand All @@ -134,6 +132,7 @@ private static void LoadClericChannelDivinity()
.SetCasterEffectParameters(FalseLife)
.SetImpactEffectParameters(PowerWightLordRetaliate)
.Build())
.AddCustomSubFeatures(ClassHolder.Cleric)
.AddToDB();

var powerDivineSparkDamageRadiant = FeatureDefinitionPowerSharedPoolBuilder
Expand All @@ -158,6 +157,7 @@ private static void LoadClericChannelDivinity()
.SetCasterEffectParameters(ShadowArmor)
.SetImpactEffectParameters(PowerDomainBattleDecisiveStrike)
.Build())
.AddCustomSubFeatures(ClassHolder.Cleric)
.AddToDB();

PowerBundle.RegisterPowerBundle(PowerClericDivineSpark, false,
Expand Down Expand Up @@ -358,35 +358,6 @@ internal static void SwitchClericSearUndead()
Cleric.FeatureUnlocks.Sort(Sorting.CompareFeatureUnlock);
}

private sealed class ModifyEffectDescriptionPowerDivineSparkHeal(FeatureDefinitionPower powerDivineSparkHeal)
: IModifyEffectDescription
{
public bool IsValid(BaseDefinition definition, RulesetCharacter character, EffectDescription effectDescription)
{
return definition == powerDivineSparkHeal;
}

public EffectDescription GetEffectDescription(
BaseDefinition definition,
EffectDescription effectDescription,
RulesetCharacter character,
RulesetEffect rulesetEffect)
{
var level = character.GetClassLevel(Cleric);
var diceNumber = level switch
{
>= 18 => 4,
>= 13 => 3,
>= 7 => 2,
_ => 1
};

effectDescription.EffectForms[0].HealingForm.diceNumber = diceNumber;

return effectDescription;
}
}

private sealed class ModifyEffectDescriptionPowerTurnUndead : IModifyEffectDescription
{
public bool IsValid(BaseDefinition definition, RulesetCharacter character, EffectDescription effectDescription)
Expand Down Expand Up @@ -445,7 +416,7 @@ private static int GetWisdomModifierMinimumOne(RulesetCharacter character)
{
var wisdom = character.TryGetAttributeValue(AttributeDefinitions.Wisdom);
var wisMod = AttributeDefinitions.ComputeAbilityScoreModifier(wisdom);

return Math.Max(wisMod, 1);
}
}
48 changes: 13 additions & 35 deletions SolastaUnfinishedBusiness/Models/2024PaladinContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ internal static partial class Tabletop2024Context
ConditionDefinitions.ConditionStunned
];

internal static readonly string[] RestoringTouchConditionNames =
RestoringTouchConditions.Select(c => c.Name).ToArray();

private static void LoadPaladinRestoringTouch()
{
PowerPaladinLayOnHands.AddCustomSubFeatures(new PowerOrSpellFinishedByMeRestoringTouch());
Expand Down Expand Up @@ -249,53 +246,34 @@ public IEnumerator OnPowerOrSpellFinishedByMe(CharacterActionMagicEffect action,
var rulesetTarget = target.RulesetCharacter;
var usablePowerPool = PowerProvider.Get(PowerPaladinRestoringTouch, rulesetCaster);

while (rulesetCaster.GetRemainingUsesOfPower(usablePowerPool) > 0)
while (!aborted && rulesetCaster.GetRemainingUsesOfPower(usablePowerPool) > 0)
{
var usablePowers = new List<RulesetUsablePower>();

foreach (var condition in RestoringTouchConditions)
{
if (!rulesetTarget.HasConditionOfTypeOrSubType(condition.Name))
{
continue;
}

var power = GetDefinition<FeatureDefinitionPower>(
$"PowerPaladinRestoringTouch{condition.Name}");
var usablePower = PowerProvider.Get(power, rulesetCaster);

usablePowers.Add(usablePower);
rulesetCaster.UsablePowers.Add(usablePower);
}

if (usablePowers.Count == 0)
var usablePowers = RestoringTouchConditions
.Where(x => rulesetTarget.HasConditionOfTypeOrSubType(x.Name))
.Select(x =>
PowerProvider.Get(
GetDefinition<FeatureDefinitionPower>($"PowerPaladinRestoringTouch{x.Name}"),
rulesetCaster))
.ToArray();

if (usablePowers.Length == 0)
{
yield break;
}

rulesetCaster.UsablePowers.AddRange(usablePowers);

yield return caster.MyReactToSpendPowerBundle(
usablePowerPool,
[target],
caster,
"RestoringTouch",
reactionNotValidated: ReactionNotValidated);
reactionNotValidated: _ => aborted = true);

foreach (var usablePower in usablePowers)
{
rulesetCaster.UsablePowers.Remove(usablePower);
}

if (aborted)
{
yield break;
}

continue;

void ReactionNotValidated(ReactionRequestSpendBundlePower reactionRequest)
{
aborted = true;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using SolastaUnfinishedBusiness.Models;
using UnityEngine;
using static RuleDefinitions;
using static SolastaUnfinishedBusiness.Api.DatabaseHelper.CharacterClassDefinitions;
using static SolastaUnfinishedBusiness.Api.DatabaseHelper.FeatureDefinitionPowers;

namespace SolastaUnfinishedBusiness.Patches;

Expand Down Expand Up @@ -454,9 +452,7 @@ public static bool Prefix(
return false;
}

var targetedCharacter = __instance.targetedCharacter;

__instance.GameLocationSelectionService.SelectTarget(targetedCharacter);
__instance.GameLocationSelectionService.SelectTarget(__instance.targetedCharacter);
__instance.actionModifiersList.Add(__instance.actionModifier.Clone());

if (__instance.maxTargets > 0)
Expand Down Expand Up @@ -506,10 +502,8 @@ public static bool Prefix(

if (__instance.ActionParams.activeEffect is RulesetEffectPower rulesetEffect)
{
var powerDefinition = rulesetEffect.PowerDefinition;

if (powerDefinition.RechargeRate == RechargeRate.HealingPool &&
powerDefinition.CostPerUse <= 0)
if (rulesetEffect.PowerDefinition.RechargeRate == RechargeRate.HealingPool &&
rulesetEffect.PowerDefinition.CostPerUse <= 0)
{
if (__instance.effectDescription.EffectForms.Any(effectForm =>
effectForm.FormType == EffectForm.EffectFormType.Healing &&
Expand All @@ -518,28 +512,12 @@ public static bool Prefix(
{
flag3 = false;

var rulesetTarget = targetedCharacter.RulesetCharacter;
var minValue = 1;
var maxValue = Mathf.Min(
rulesetEffect.UsablePower.SpentPoints, rulesetTarget.MissingHitPoints);

//PATCH: support lay on hands special case
if (Main.Settings.EnablePaladinRestoringTouch2024 &&
powerDefinition == PowerPaladinLayOnHands &&
rulesetTarget.HasAnyConditionOfTypeOrSubType(Tabletop2024Context
.RestoringTouchConditionNames))
{
var paladinLevel = rulesetTarget.GetClassLevel(Paladin);

if (paladinLevel >= 14)
{
minValue = 0;
}
}
//END PATCH

Gui.GuiService.GetScreen<NumberSelectionModal>().ShowPower(
powerDefinition, minValue, maxValue, maxValue, rulesetEffect.UsablePower);
var num = Mathf.Min(rulesetEffect.UsablePower.SpentPoints,
__instance.targetedCharacter.RulesetCharacter.MissingHitPoints);

Gui.GuiService.GetScreen<NumberSelectionModal>()
.ShowPower(rulesetEffect.PowerDefinition, 1, num, num,
rulesetEffect.UsablePower);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion SolastaUnfinishedBusiness/Subclasses/InnovationVitriolist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public InnovationVitriolist()
.Build(),
EffectFormBuilder.ConditionForm(conditionCorroded))
.Build())
.AddCustomSubFeatures(ModifyPowerVisibility.Hidden)
// required as in a feature set
.AddCustomSubFeatures(ClassHolder.Inventor, ModifyPowerVisibility.Hidden)
.AddToDB();

// Misery
Expand Down Expand Up @@ -155,6 +156,7 @@ public InnovationVitriolist()
.Build(),
EffectFormBuilder.ConditionForm(conditionMiserable))
.Build())
// required as in a feature set
.AddCustomSubFeatures(ClassHolder.Inventor, ModifyPowerVisibility.Hidden)
.AddToDB();

Expand Down Expand Up @@ -187,6 +189,7 @@ public InnovationVitriolist()
.Build(),
EffectFormBuilder.ConditionForm(ConditionDefinitions.ConditionPoisoned))
.Build())
// required as in a feature set
.AddCustomSubFeatures(ClassHolder.Inventor, ModifyPowerVisibility.Hidden)
.AddToDB();

Expand Down Expand Up @@ -214,6 +217,7 @@ public InnovationVitriolist()
.Build(),
EffectFormBuilder.ConditionForm(ConditionDefinitions.ConditionHindered))
.Build())
// required as in a feature set
.AddCustomSubFeatures(ClassHolder.Inventor, ModifyPowerVisibility.Hidden)
.AddToDB();

Expand Down

0 comments on commit 110d91b

Please sign in to comment.