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 8, 2022
1 parent
4e04985
commit 3b4b5aa
Showing
9 changed files
with
178 additions
and
16 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
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,114 @@ | ||
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.UnitLogic; | ||
using Kingmaker.UnitLogic.Buffs.Blueprints; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ChampionFeats.Components | ||
{ | ||
[AllowedOn(typeof(BlueprintBuff))] | ||
[AllowedOn(typeof(BlueprintFeature))] | ||
[AllowedOn(typeof(BlueprintUnitFact), false)] | ||
[AllowMultipleComponents] | ||
[TypeId("9804852F50534445A3A51769CC00DD80")] | ||
public class AddScalingSkillBonus : UnitFactComponentDelegate | ||
{ | ||
public const string BLUEPRINTNAME = "RMChampionFeatSkills"; | ||
|
||
public static void OnSettingsSave() | ||
{ | ||
UpdateSkillBonuses(); | ||
} | ||
|
||
private static void UpdateSkillBonuses() | ||
{ | ||
foreach (var unit in Game.Instance.State.Units) | ||
{ | ||
Feature feature = unit.GetFeature(Resources.GetModBlueprint<BlueprintFeature>(BLUEPRINTNAME)); | ||
if (feature != null) | ||
{ | ||
feature.TurnOff(); | ||
feature.TurnOn(); | ||
} | ||
} | ||
} | ||
|
||
private static void RemoveSkillBonus(UnitEntityData unit, StatType skillType) | ||
{ | ||
SkillModifier modToRemove = null; | ||
foreach (var list in unit.Stats.GetStat(skillType).ModifierList) | ||
{ | ||
foreach (var mod in list.Value) | ||
{ | ||
if (mod is SkillModifier) | ||
{ | ||
modToRemove = (SkillModifier)mod; | ||
} | ||
if (modToRemove != null) | ||
{ | ||
break; | ||
} | ||
} | ||
if (modToRemove != null) | ||
{ | ||
break; | ||
} | ||
} | ||
if (modToRemove != null) | ||
{ | ||
unit.Stats.GetStat(skillType).RemoveModifier(modToRemove); | ||
} | ||
} | ||
|
||
private static void RemoveSkillBonuses(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
foreach (StatType type in StatTypeHelper.Skills) | ||
{ | ||
RemoveSkillBonus(unit, type); | ||
} | ||
} | ||
|
||
private static void AddSkillBonuses(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
foreach (StatType type in StatTypeHelper.Skills) | ||
{ | ||
unit.Stats.GetStat<ModifiableValue>(type).AddModifier(GetNewModifier(unit, runtime)); | ||
} | ||
} | ||
|
||
private static ModifiableValue.Modifier GetNewModifier(UnitEntityData unit, EntityFactComponent runtime) | ||
{ | ||
return new SkillModifier() | ||
{ | ||
ModDescriptor = Kingmaker.Enums.ModifierDescriptor.UntypedStackable, | ||
Source = runtime.Fact, | ||
ModValue = (((unit.Progression.CharacterLevel - 1) / Main.settings.ScalingSkillsLevelsPerStep) + 1) * Main.settings.ScalingSkillsBonusPerLevel | ||
}; | ||
} | ||
|
||
public override void OnTurnOff() | ||
{ | ||
RemoveSkillBonuses(base.Owner, base.Runtime); | ||
} | ||
|
||
public override void OnTurnOn() | ||
{ | ||
AddSkillBonuses(base.Owner, base.Runtime); | ||
} | ||
} | ||
|
||
public class SkillModifier : 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
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,15 +1,16 @@ | ||
{ | ||
"OverrideIds": false, | ||
"NewBlueprints": { | ||
"RMChampionFeatDefenceDR": "ab678c3f-346e-44cf-8ad5-c157324e8c28", | ||
"RMChampionFeatDefenceAC": "d0f2447e-6aa3-4dce-8f7f-17a5baeff9dc", | ||
"RMChampionFeatOffenceAim": "c60fe592-1c11-4c89-9bdc-5a7e76344412", | ||
"RMChampionFeatOffenceDam": "ea14baff-008f-4bf1-b492-26581ca67de9", | ||
"RMChampionFeatOffenceSpellDam": "d9538dec-e371-4d71-803a-18ede627638b", | ||
"RMChampionFeatOffenceSpellDC": "b666f5b3-ee66-4b0f-9cb9-e9c974858982", | ||
"RMChampionFeatOffenceSpellPen": "042a76ff-d6e1-4b86-8765-16da19fdbe6d", | ||
"RMChampionFeatSavingThrow": "D09E14DC-C147-4870-8E79-AE101363676D" | ||
}, | ||
"NewBlueprints": { | ||
"RMChampionFeatDefenceDR": "ab678c3f-346e-44cf-8ad5-c157324e8c28", | ||
"RMChampionFeatDefenceAC": "d0f2447e-6aa3-4dce-8f7f-17a5baeff9dc", | ||
"RMChampionFeatOffenceAim": "c60fe592-1c11-4c89-9bdc-5a7e76344412", | ||
"RMChampionFeatOffenceDam": "ea14baff-008f-4bf1-b492-26581ca67de9", | ||
"RMChampionFeatOffenceSpellDam": "d9538dec-e371-4d71-803a-18ede627638b", | ||
"RMChampionFeatOffenceSpellDC": "b666f5b3-ee66-4b0f-9cb9-e9c974858982", | ||
"RMChampionFeatOffenceSpellPen": "042a76ff-d6e1-4b86-8765-16da19fdbe6d", | ||
"RMChampionFeatSavingThrow": "D09E14DC-C147-4870-8E79-AE101363676D", | ||
"RMChampionFeatSkills": "A21CE248-AC0F-4851-89A4-70A0BD87E0AF" | ||
}, | ||
"AutoGenerated": {}, | ||
"UnusedGUIDs": {} | ||
} |
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