Skip to content

Commit

Permalink
Added homebrew armor master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Oct 22, 2021
1 parent 528b523 commit 02cad17
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 32 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Version 1.9.3
* Added new modified version of Armor Master as a homebrew option

## Version 1.9.2
* Removed the movement impairing descriptor from staggered
* Fixed issue with DR config not working correctly
Expand Down
1 change: 1 addition & 0 deletions TabletopTweaks/Bugfixes/Abilities/Spells.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static void PatchBreakEnchantment() {
.OfType<ContextActionDispelMagic>()
.ForEach(dispel => {
dispel.OnlyTargetEnemyBuffs = true;
//dispel.m_MaxSpellLevel.Value = 10;
});
Main.LogPatch("Patched", BreakEnchantment);
}
Expand Down
9 changes: 7 additions & 2 deletions TabletopTweaks/Config/AddedContent.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,14 @@
"Description": "You treat the armor bonus from your armor as 50% higher than normal, to a maximum increase of half your mythic rank plus one."
},
"ArmorMaster": {
"Enabled": true,
"Enabled": false,
"Homebrew": false,
"Description": "You don't take an armor check penalty or incur an arcane spell failure chance when wearing the selected type of armor or using any shield. In addition, the maximum Dexterity bonus of light armor doesn’t apply to you."
"Description": "You don't take an armor check penalty or incur an arcane spell failure chance when wearing the selected type of armor or using any shield. In addition, the maximum Dexterity bonus of the selected armor type doesn't apply to you."
},
"ArmorMasterHomebrew": {
"Enabled": true,
"Homebrew": true,
"Description": "Alternate versrion of Armor Master. While wearing armor, you reduce the armor check penalty by 1 per mythic rank and increase the maximum Dexterity bonus allowed by by 1 per mythic rank. Additionally you reduce your arcane spell failure chance from armor and sheilds by 5% per mythic rank."
},
"ImpossibleSpeed": {
"Enabled": true,
Expand Down
1 change: 1 addition & 0 deletions TabletopTweaks/Config/Blueprints.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"ArmoredJuggernautMediumEffect": "875333ed-56bb-4911-9985-3366c8f82cd0",
"ArmoredMightFeature": "9315267a-e128-452f-8695-5c354c5489e2",
"ArmorMasterHeavyFeature": "351dfff9-5701-4679-9100-0dee66f3cfb7",
"ArmorMasterHomebrewFeature": "dfa00e6d-f357-46f9-bdaf-1fb448565627",
"ArmorMasterLightFeature": "2fd6f711-bb99-4509-8f19-779986fe4461",
"ArmorMasterMediumFeature": "eb1c16e5-3f65-472f-ba6d-d7e5452de83a",
"ArmorSpecializationHeavyEffect": "ce4c4331-087f-4245-aa18-cada916992f7",
Expand Down
28 changes: 22 additions & 6 deletions TabletopTweaks/NewComponents/ArmorFeatureUnlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ArmorFeatureUnlock : UnitFactComponentDelegate<ArmorFeatureUnlock.ArmorFea
IUnitEquipmentHandler {
public override void OnTurnOn() {
base.OnTurnOn();
CheckEligibility();
Update();
}

public override void OnTurnOff() {
Expand All @@ -35,17 +35,17 @@ public override void OnTurnOff() {
}

public override void OnActivate() {
CheckEligibility();
Update();
}

public override void OnDeactivate() {
RemoveFact();
}

public void HandleUnitChangeActiveEquipmentSet(UnitDescriptor unit) {
CheckEligibility();
Update();
}

/*
private void CheckEligibility() {
RemoveFact();
if (Owner.Body.IsPolymorphed) { return; }
Expand All @@ -62,6 +62,14 @@ private void CheckEligibility() {
return;
};
}
*/
private bool ShouldApply() {
if (Owner.Body.IsPolymorphed) { return false; }
var Armor = Owner.Body?.Armor?.MaybeArmor;
var Shield = Owner.Body?.SecondaryHand?.MaybeShield?.ArmorComponent;
return (Armor != null && (RequiredArmor.Contains(Armor.Blueprint.ProficiencyGroup) == !Invert))
|| (Shield != null && (RequiredArmor.Contains(Shield.Blueprint.ProficiencyGroup) == !Invert));
}

private void AddFact() {
if (Data.AppliedFact == null) {
Expand All @@ -76,21 +84,29 @@ private void RemoveFact() {
}
}

private void Update() {
if (ShouldApply()) {
AddFact();
} else {
RemoveFact();
}
}

public void HandleEquipmentSlotUpdated(ItemSlot slot, ItemEntity previousItem) {
if (slot.Owner != Owner) {
return;
}
if (!slot.Active) {
return;
}
CheckEligibility();
Update();
}

public void HandleUnitBeforeLevelUp(UnitEntityData unit) {
}

public void HandleUnitAfterLevelUp(UnitEntityData unit, LevelUpController controller) {
CheckEligibility();
Update();
}

[SerializeField]
Expand Down
36 changes: 36 additions & 0 deletions TabletopTweaks/NewComponents/ContextArcaneSpellFailureIncrease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.Facts;
using Kingmaker.Blueprints.Items.Armors;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.PubSubSystem;
using Kingmaker.RuleSystem.Rules.Abilities;
using Kingmaker.UnitLogic;
using Kingmaker.UnitLogic.Mechanics;
using System.Linq;

namespace TabletopTweaks.NewComponents {
[AllowedOn(typeof(BlueprintUnitFact), false)]
[TypeId("83ce1f63bacb4494887fb0b2080eddcd")]
class ContextArcaneSpellFailureIncrease : UnitFactComponentDelegate,
IInitiatorRulebookHandler<RuleCalculateArcaneSpellFailureChance>,
IRulebookHandler<RuleCalculateArcaneSpellFailureChance>,
ISubscriber, IInitiatorRulebookSubscriber {

public void OnEventAboutToTrigger(RuleCalculateArcaneSpellFailureChance evt) {
if (!evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.ArmorType()))) {
evt.AddArmorBonus(Reduce ? -Value.Calculate(base.Context) : Value.Calculate(base.Context));
}
if (evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.Blueprint.ProficiencyGroup))) {
evt.AddShieldBonus(Reduce ? -Value.Calculate(base.Context) : Value.Calculate(base.Context));
}
}

public void OnEventDidTrigger(RuleCalculateArcaneSpellFailureChance evt) {
}

public bool Reduce;
public ContextValue Value;
public bool CheckCategory;
public ArmorProficiencyGroup[] Categorys;
}
}
50 changes: 50 additions & 0 deletions TabletopTweaks/NewComponents/ContextArmorCheckPenaltyIncrease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.Facts;
using Kingmaker.Blueprints.Items.Armors;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.Items;
using Kingmaker.PubSubSystem;
using Kingmaker.RuleSystem.Rules;
using Kingmaker.UnitLogic;
using Kingmaker.UnitLogic.Mechanics;
using System.Linq;

namespace TabletopTweaks.NewComponents {
[AllowedOn(typeof(BlueprintUnitFact), false)]
[TypeId("5c83ff59ace044d19376f4bbe035b544")]
class ContextArmorCheckPenaltyIncrease : UnitFactComponentDelegate,
IInitiatorRulebookHandler<RuleCalculateArmorCheckPenalty>,
IRulebookHandler<RuleCalculateArmorCheckPenalty>,
ISubscriber, IInitiatorRulebookSubscriber {

public override void OnTurnOn() {
ItemEntityArmor maybeArmor = base.Owner.Body.Armor.MaybeArmor;
if (maybeArmor != null) {
maybeArmor.RecalculateStats();
}
ItemEntityShield maybeShield = base.Owner.Body.SecondaryHand.MaybeShield;
if (maybeShield == null) {
return;
}
maybeShield.ArmorComponent.RecalculateStats();
}

public void OnEventAboutToTrigger(RuleCalculateArmorCheckPenalty evt) {
if (!evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.ArmorType()))) {
evt.AddBonus(Value.Calculate(base.Context));
return;
}
if (evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.Blueprint.ProficiencyGroup))) {
evt.AddBonus(Value.Calculate(base.Context));
}
}

public void OnEventDidTrigger(RuleCalculateArmorCheckPenalty evt) {
}

public bool Reduce;
public ContextValue Value;
public bool CheckCategory;
public ArmorProficiencyGroup[] Categorys;
}
}
49 changes: 49 additions & 0 deletions TabletopTweaks/NewComponents/ContextMaxDexBonusIncrease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.Facts;
using Kingmaker.Blueprints.Items.Armors;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.Items;
using Kingmaker.PubSubSystem;
using Kingmaker.RuleSystem.Rules;
using Kingmaker.UnitLogic;
using Kingmaker.UnitLogic.Mechanics;
using System.Linq;

namespace TabletopTweaks.NewComponents {
[AllowedOn(typeof(BlueprintUnitFact), false)]
[TypeId("39d2343f6d254e44ac05f3efb2c1937d")]
class ContextMaxDexBonusIncrease : UnitFactComponentDelegate,
IInitiatorRulebookHandler<RuleCalculateArmorMaxDexBonusLimit>,
IRulebookHandler<RuleCalculateArmorMaxDexBonusLimit>,
ISubscriber, IInitiatorRulebookSubscriber {

public override void OnTurnOn() {
ItemEntityArmor maybeArmor = base.Owner.Body.Armor.MaybeArmor;
if (maybeArmor != null) {
maybeArmor.RecalculateStats();
}
ItemEntityShield maybeShield = base.Owner.Body.SecondaryHand.MaybeShield;
if (maybeShield == null) {
return;
}
maybeShield.ArmorComponent.RecalculateStats();
}

public void OnEventAboutToTrigger(RuleCalculateArmorMaxDexBonusLimit evt) {
if (!evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.ArmorType()))) {
evt.AddBonus(Value.Calculate(base.Context));
return;
}
if (evt.Armor.Blueprint.IsShield && (!CheckCategory || Categorys.Contains(evt.Armor.Blueprint.ProficiencyGroup))) {
evt.AddBonus(Value.Calculate(base.Context));
}
}

public void OnEventDidTrigger(RuleCalculateArmorMaxDexBonusLimit evt) {
}

public ContextValue Value;
public bool CheckCategory;
public ArmorProficiencyGroup[] Categorys;
}
}
13 changes: 12 additions & 1 deletion TabletopTweaks/NewComponents/PseudoActivatable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using Kingmaker.Blueprints;
using HarmonyLib;
using Kingmaker.Blueprints;
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.UnitLogic.Abilities;
using Kingmaker.UnitLogic.Abilities.Blueprints;
using Kingmaker.UnitLogic.FactLogic;
using Kingmaker.Utility;

namespace TabletopTweaks.NewComponents {

Expand All @@ -10,5 +14,12 @@ public class PseudoActivatable : BlueprintComponent {
public BlueprintBuffReference m_BuffToWatch;

public BlueprintBuffReference BuffToWatch => m_BuffToWatch ?? BlueprintReferenceBase.CreateTyped<BlueprintBuffReference>(null);

[HarmonyPatch(typeof(AddAbilityUseTrigger), nameof(AddAbilityUseTrigger.RunAction))]
static class AddFacts_UpdateFacts_CL_Patch {
static bool Prefix(AbilityData spell) {
return !spell.Blueprint.GetComponent<PseudoActivatable>();
}
}
}
}
19 changes: 19 additions & 0 deletions TabletopTweaks/NewComponents/RecalculateOnLevelUp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Kingmaker.Blueprints.JsonSystem;
using Kingmaker.EntitySystem.Entities;
using Kingmaker.PubSubSystem;
using Kingmaker.UnitLogic;
using Kingmaker.UnitLogic.Class.LevelUp;

namespace TabletopTweaks.NewComponents {
[TypeId("0104e3c3ea2e4f789bc1b1ac4a874d7b")]
class RecalculateOnLevelUp : UnitFactComponentDelegate, IUnitLevelUpHandler {
public void HandleUnitAfterLevelUp(UnitEntityData unit, LevelUpController controller) {
if (base.Fact.Owner == unit) {
base.Fact.Reapply();
}
}

public void HandleUnitBeforeLevelUp(UnitEntityData unit) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static void AddAdvancedArmorTraining() {
bp.AddComponent<ArmorSpeedPenaltyRemoval>();
});
var AdvancedArmorTrainingSelection = Helpers.CreateBlueprint<BlueprintFeatureSelection>("AdvancedArmorTrainingSelection", bp => {
bp.Ranks = 3;
bp.SetName("Advanced Armor Training");
bp.SetDescription("Beginning at 7th level, instead of increasing the benefits provided by armor training " +
"(reducing his armor check penalty by 1 and increasing its maximum Dexterity bonus by 1), a fighter can " +
Expand Down
Loading

0 comments on commit 02cad17

Please sign in to comment.