Skip to content

Commit

Permalink
Fixed broken vital strike
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Sep 10, 2021
1 parent abc26f6 commit 3654f55
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* added config options for crusade fixes
* added defensive weapon training
* fixed lich spellbook merging
* fixed mod not loading due to vital strike changes

## Version 1.0.6
* metamagic rods no longer are on by default
Expand Down
2 changes: 1 addition & 1 deletion Repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Releases": [
{
"Id": "TabletopTweaks",
"Version": "1.0.6"
"Version": "1.0.7"
}
]
}
56 changes: 0 additions & 56 deletions TabletopTweaks/Bugfixes/Classes/Rogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ static void Postfix() {

PatchBase();
PatchEldritchScoundrel();
PatchRowdy();
}
static void PatchBase() {
PatchTrapfinding();
Expand Down Expand Up @@ -100,61 +99,6 @@ void PatchRogueTalentProgression() {
Main.LogPatch("Patched", EldritchScoundrelArchetype);
}
}
static void PatchRowdy() {
if (ModSettings.Fixes.Rogue.Archetypes["Rowdy"].IsDisabled("VitalForce")) { return; }
var VitalStrikeAbility = Resources.GetBlueprint<BlueprintAbility>("efc60c91b8e64f244b95c66b270dbd7c");
var VitalStrikeAbilityImproved = Resources.GetBlueprint<BlueprintAbility>("c714cd636700ac24a91ca3df43326b00");
var VitalStrikeAbilityGreater = Resources.GetBlueprint<BlueprintAbility>("11f971b6453f74d4594c538e3c88d499");

AttachRowdyFeature(VitalStrikeAbility);
AttachRowdyFeature(VitalStrikeAbilityImproved);
AttachRowdyFeature(VitalStrikeAbilityGreater);

static void AttachRowdyFeature(BlueprintAbility VitalStrike) {
var RowdyVitalDamage = Resources.GetBlueprint<BlueprintFeature>("6ce0dd0cd1ef43eda9e62cdf483e05c3");

VitalStrike.GetComponent<AbilityCustomMeleeAttack>().m_RowdyFeature = RowdyVitalDamage.ToReference<BlueprintFeatureReference>();
Main.LogPatch("Patched", VitalStrike);
}
}
}
[HarmonyPatch(typeof(AbilityCustomMeleeAttack.VitalStrike), "OnEventDidTrigger", new Type[] { typeof(RuleCalculateWeaponStats) })]
static class VitalStrike_OnEventDidTrigger_Rowdy_Patch {

static bool Prefix(AbilityCustomMeleeAttack.VitalStrike __instance, RuleCalculateWeaponStats evt) {
if (ModSettings.Fixes.Rogue.Archetypes["Rowdy"].IsDisabled("VitalForce")) { return true; }

DamageDescription damageDescription = evt.DamageDescription.FirstItem();
if (damageDescription != null && damageDescription.TypeDescription.Type == DamageType.Physical) {
if (ModSettings.Fixes.Feats.Enabled["VitalStrike"] && !ModSettings.Fixes.Feats.DisableAll) {
var vitalDamage = new DamageDescription() {
Dice = new DiceFormula(damageDescription.Dice.Rolls * Math.Max(1, __instance.m_DamageMod - 1), damageDescription.Dice.Dice),
Bonus = __instance.m_Mythic ? damageDescription.Bonus * Math.Max(1, __instance.m_DamageMod - 1) : 0,
TypeDescription = damageDescription.TypeDescription,
IgnoreReduction = damageDescription.IgnoreReduction,
IgnoreImmunities = damageDescription.IgnoreImmunities,
SourceFact = damageDescription.SourceFact,
CausedByCheckFail = damageDescription.CausedByCheckFail,
m_BonusWithSource = 0
};
evt.DamageDescription.Insert(1, vitalDamage);
} else {
damageDescription.Dice = new DiceFormula(damageDescription.Dice.Rolls * __instance.m_DamageMod, damageDescription.Dice.Dice);
if (__instance.m_Mythic) {
damageDescription.Bonus *= __instance.m_DamageMod;
}
}
if (__instance.m_Rowdy) {
DamageDescription damageDescription2 = new DamageDescription {
TypeDescription = evt.DamageDescription.FirstItem().TypeDescription,
Dice = new DiceFormula(evt.Initiator.Descriptor.Stats.SneakAttack * 2, DiceType.D6),

};
evt.DamageDescription.Add(damageDescription2);
}
}
return false;
}
}
}
}
36 changes: 36 additions & 0 deletions TabletopTweaks/Bugfixes/Features/Feats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
using Kingmaker.Designers.Mechanics.Facts;
using Kingmaker.EntitySystem.Stats;
using Kingmaker.Enums;
using Kingmaker.RuleSystem;
using Kingmaker.RuleSystem.Rules;
using Kingmaker.RuleSystem.Rules.Damage;
using Kingmaker.UnitLogic.Abilities;
using Kingmaker.UnitLogic.Abilities.Components;
using Kingmaker.UnitLogic.Buffs.Blueprints;
using Kingmaker.UnitLogic.FactLogic;
using Kingmaker.UnitLogic.Mechanics;
using Kingmaker.UnitLogic.Mechanics.Actions;
using Kingmaker.UnitLogic.Mechanics.Components;
using Kingmaker.Utility;
using System;
using System.Linq;
using TabletopTweaks.Config;
using TabletopTweaks.Extensions;
Expand Down Expand Up @@ -186,5 +191,36 @@ static void PatchWeaponFinesse() {
Main.LogPatch("Patched", WeaponFinesse);
}
}

[HarmonyPatch(typeof(AbilityCustomVitalStrike.VitalStrike), "OnEventDidTrigger", new Type[] { typeof(RuleCalculateWeaponStats) })]
static class VitalStrike_OnEventDidTrigger_Rowdy_Patch {

static bool Prefix(AbilityCustomMeleeAttack.VitalStrike __instance, RuleCalculateWeaponStats evt) {
if (ModSettings.Fixes.Feats.IsDisabled("VitalStrike")) { return true; }

DamageDescription damageDescription = evt.DamageDescription.FirstItem();
if (damageDescription != null && damageDescription.TypeDescription.Type == DamageType.Physical) {
var vitalDamage = new DamageDescription() {
Dice = new DiceFormula(damageDescription.Dice.Rolls * Math.Max(1, __instance.m_DamageMod - 1), damageDescription.Dice.Dice),
Bonus = __instance.m_Mythic ? damageDescription.Bonus * Math.Max(1, __instance.m_DamageMod - 1) : 0,
TypeDescription = damageDescription.TypeDescription,
IgnoreReduction = damageDescription.IgnoreReduction,
IgnoreImmunities = damageDescription.IgnoreImmunities,
SourceFact = damageDescription.SourceFact,
CausedByCheckFail = damageDescription.CausedByCheckFail,
m_BonusWithSource = 0
};
evt.DamageDescription.Insert(1, vitalDamage);
if (__instance.m_Rowdy && evt.Initiator.Descriptor.Stats.SneakAttack.ModifiedValue > 0) {
DamageDescription damageDescription2 = new DamageDescription {
TypeDescription = evt.DamageDescription.FirstItem().TypeDescription,
Dice = new DiceFormula(evt.Initiator.Descriptor.Stats.SneakAttack * 2, DiceType.D6),
};
evt.DamageDescription.Add(damageDescription2);
}
}
return false;
}
}
}
}
6 changes: 0 additions & 6 deletions TabletopTweaks/Config/Fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@
"SneakAttackProgression": true,
"RogueTalentProgression": true
}
},
"Rowdy": {
"DisableAll": false,
"Enabled": {
"VitalForce": true
}
}
}
},
Expand Down

0 comments on commit 3654f55

Please sign in to comment.