forked from txangel/Champion-Feats
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lynn Pye
committed
Nov 6, 2022
1 parent
8babe8e
commit 4e9f770
Showing
15 changed files
with
402 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Kingmaker.Blueprints.Facts; | ||
using Kingmaker.Blueprints.JsonSystem; | ||
using Kingmaker.Blueprints; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Kingmaker.UnitLogic.FactLogic; | ||
using System.Runtime.InteropServices; | ||
using Kingmaker.RuleSystem.Rules.Damage; | ||
using Kingmaker.Items; | ||
using Kingmaker.Blueprints.Classes; | ||
using Kingmaker.UnitLogic.Buffs.Blueprints; | ||
using Kingmaker.UnitLogic; | ||
using Kingmaker.PubSubSystem; | ||
using ChampionFeats.Extensions; | ||
using ChampionFeats.Utilities; | ||
using Kingmaker.Enums; | ||
using Kingmaker.UnitLogic.Mechanics.Components; | ||
using Kingmaker.Enums.Damage; | ||
using Kingmaker.UnitLogic.Mechanics; | ||
using Kingmaker.EntitySystem.Entities; | ||
|
||
namespace ChampionFeats.Components | ||
{ | ||
[AllowedOn(typeof(BlueprintUnit), false)] | ||
[AllowedOn(typeof(BlueprintUnitFact), false)] | ||
[AllowedOn(typeof(BlueprintFeature))] | ||
[AllowMultipleComponents] | ||
[TypeId("5EEED74D80FF46ACA9FB2A15025B4727")] | ||
/* | ||
* See comments in ContextValuePatches for why this class is basically barren. | ||
* Only exists to hold the blueprint name now. | ||
*/ | ||
public class AddScalingDamageResistance : UnitFactComponentDelegate, ISubscriber | ||
{ | ||
public const string BLUEPRINTNAME = "RMChampionFeatDefenceDR"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,118 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using ChampionFeats.Config; | ||
using Kingmaker; | ||
using Kingmaker.Blueprints; | ||
using Kingmaker.Blueprints.Classes; | ||
using Kingmaker.Blueprints.Facts; | ||
using Kingmaker.Blueprints.JsonSystem; | ||
using Kingmaker.EntitySystem; | ||
using Kingmaker.EntitySystem.Entities; | ||
using Kingmaker.EntitySystem.Stats; | ||
using Kingmaker.Enums; | ||
using Kingmaker.PubSubSystem; | ||
using Kingmaker.RuleSystem.Rules; | ||
using Kingmaker.UnitLogic; | ||
using Kingmaker.UnitLogic.Buffs.Blueprints; | ||
using Kingmaker.UnitLogic.FactLogic; | ||
using Kingmaker.UnitLogic.Mechanics; | ||
using static Kingmaker.Blueprints.Area.FactHolder; | ||
using static Kingmaker.Kingdom.KingdomStats; | ||
using static UnityModManagerNet.UnityModManager.Param; | ||
|
||
namespace ChampionFeats.Components | ||
{ | ||
[AllowedOn(typeof(BlueprintUnitFact), false)] | ||
[AllowedOn(typeof(BlueprintBuff))] | ||
[AllowedOn(typeof(BlueprintFeature))] | ||
[AllowMultipleComponents] | ||
[TypeId("D09E14DCC14748708E79AE101363676E")] | ||
class AddScalingSavingThrows : UnitFactComponentDelegate, IInitiatorRulebookHandler<RuleSavingThrow>, IRulebookHandler<RuleSavingThrow>, ISubscriber, IInitiatorRulebookSubscriber | ||
public class AddScalingSavingThrows : UnitFactComponentDelegate, ISubscriber | ||
{ | ||
public void OnEventAboutToTrigger(RuleSavingThrow evt) | ||
public const string BLUEPRINTNAME = "RMChampionFeatSavingThrow"; | ||
|
||
/* | ||
* Used after settings are saved, to recalculate saving throw values in case the step/bonus | ||
* values for Champion Saves was changed | ||
*/ | ||
public static void OnSettingsSave() | ||
{ | ||
UpdateSavingThrows(); | ||
} | ||
|
||
private static void UpdateSavingThrows() | ||
{ | ||
foreach (var unit in Game.Instance.State.Units) | ||
{ | ||
Feature feature = unit.GetFeature(Resources.GetModBlueprint<BlueprintFeature>(BLUEPRINTNAME)); | ||
feature.TurnOff(); | ||
feature.TurnOn(); | ||
} | ||
} | ||
|
||
private static void RemoveModifier(UnitEntityData unit, StatType statType) | ||
{ | ||
SaveModifier modToRemove = null; | ||
foreach (var list in unit.Stats.GetStat(statType).ModifierList) | ||
{ | ||
foreach (var mod in list.Value) | ||
{ | ||
if (mod is SaveModifier) | ||
{ | ||
modToRemove = (SaveModifier)mod; | ||
} | ||
if (modToRemove != null) | ||
{ | ||
break; | ||
} | ||
} | ||
if (modToRemove != null) | ||
{ | ||
break; | ||
} | ||
} | ||
if (modToRemove != null) | ||
{ | ||
unit.Stats.GetStat(statType).RemoveModifier(modToRemove); | ||
} | ||
} | ||
|
||
private static void RemoveModifiers(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
int bonus = Main.settings.ScalingSaveBonusPerLevel; | ||
evt.AddModifier(bonus, Fact, ModifierDescriptor.UntypedStackable); | ||
RemoveModifier(unit, StatType.SaveFortitude); | ||
RemoveModifier(unit, StatType.SaveReflex); | ||
RemoveModifier(unit, StatType.SaveWill); | ||
} | ||
|
||
public void OnEventDidTrigger(RuleSavingThrow evt) | ||
private static void AddModifiers(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
unit.Stats.GetStat(StatType.SaveFortitude)?.AddModifier(GetNewModifier(unit, runtime)); | ||
unit.Stats.GetStat(StatType.SaveReflex)?.AddModifier(GetNewModifier(unit, runtime)); | ||
unit.Stats.GetStat(StatType.SaveWill)?.AddModifier(GetNewModifier(unit, runtime)); | ||
} | ||
|
||
private static ModifiableValue.Modifier GetNewModifier(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
return new SaveModifier() | ||
{ | ||
ModDescriptor = ModifierDescriptor.UntypedStackable, | ||
Source = runtime.Fact, | ||
ModValue = Main.settings.ScalingSaveBonusPerLevel * unit.Progression.CharacterLevel | ||
}; | ||
} | ||
|
||
public override void OnTurnOff() | ||
{ | ||
RemoveModifiers(base.Owner, base.Runtime); | ||
} | ||
|
||
public override void OnTurnOn() | ||
{ | ||
base.OnTurnOn(); | ||
AddModifiers(base.Owner, base.Runtime); | ||
} | ||
} | ||
|
||
public class SaveModifier : ModifiableValue.Modifier | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.