Skip to content

Commit

Permalink
Minor bugfixs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Mar 4, 2023
1 parent c9a8553 commit df37b60
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* Fixes
* AreaOfEffectDoubleTrigger set to off by default due to some issues with some areas.
* Fixed issues where spear charges did twice as much damage as intended.
* Removed duplicate Favorite Metamagic Selective.
* Shifter
* Griffon Heart Shifter has been made selectable in character creation.
* Wild Effigy has been adjusted to work correctly when multiple archetypes are used.
* Winter Witch
* Winter witch levels should now properly progress patron spells granted by Second Patron.
* Feats
* Energized Wild Shape
* Fixed incorrect triggering of fake attacks.
Expand All @@ -15,6 +18,8 @@
* Fixed prerequites for non druid classes with Wild Shape.
* Shifter Rush
* Fixed prerequites for non druid classes with Wild Shape.
* Vital Strike
* Now works correctly with overhand chop.
* Spells
* Magical Vestment
* Fixed incorrect stacking with armor bonuses.
Expand Down
53 changes: 53 additions & 0 deletions TabletopTweaks-Base/Bugfixes/Features/Feats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
using Kingmaker.Designers.Mechanics.Facts;
using Kingmaker.Designers.Mechanics.Recommendations;
using Kingmaker.ElementsSystem;
using Kingmaker.EntitySystem;
using Kingmaker.EntitySystem.Entities;
using Kingmaker.EntitySystem.Stats;
using Kingmaker.Enums;
using Kingmaker.Enums.Damage;
using Kingmaker.PubSubSystem;
using Kingmaker.RuleSystem;
using Kingmaker.RuleSystem.Rules;
using Kingmaker.RuleSystem.Rules.Damage;
using Kingmaker.UnitLogic.Abilities;
using Kingmaker.UnitLogic.Abilities.Blueprints;
Expand All @@ -29,11 +32,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection;
using TabletopTweaks.Core.NewActions;
using TabletopTweaks.Core.NewComponents;
using TabletopTweaks.Core.NewComponents.AbilitySpecific;
using TabletopTweaks.Core.NewComponents.OwlcatReplacements;
using TabletopTweaks.Core.NewComponents.Prerequisites;
using TabletopTweaks.Core.NewRules;
using TabletopTweaks.Core.Utilities;
using static TabletopTweaks.Base.Main;

Expand Down Expand Up @@ -919,5 +925,52 @@ static void Postfix(TargetWrapper origin, ref List<UnitEntityData> __result) {
__result = __result.Where(unit => unit.AttackFactions.IsPlayerEnemy).ToList();
}
}
[HarmonyPatch]
static class VitalStrike_OnEventDidTrigger_Rowdy_Patch {
private static Type _type = typeof(AbilityCustomVitalStrike).GetNestedType("<Deliver>d__7", AccessTools.all);
internal static MethodInfo TargetMethod(Harmony instance) {
return AccessTools.Method(_type, "MoveNext");
}

static readonly MethodInfo MechanicsContext_TriggerRule = AccessTools.Method(
typeof(MechanicsContext),
"TriggerRule",
generics: new Type[] { typeof(RuleAttackWithWeapon) }
);
static readonly MethodInfo RuleAttackWithWeapon_IsFirstAttack_Set = AccessTools.PropertySetter(
typeof(RuleAttackWithWeapon),
"IsFirstAttack"
);
// ------------before------------
// context.TriggerRule<RuleAttackWithWeapon>(ruleAttackWithWeapon);
// ------------after-------------
// ruleAttackWithWeapon.FirstAttack = true;
// context.TriggerRule<RuleAttackWithWeapon>(ruleAttackWithWeapon);
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
var codes = new List<CodeInstruction>(instructions);
if (Main.TTTContext.Fixes.Feats.IsDisabled("VitalStrike")) { return instructions; }
int target = FindInsertionTarget(codes);
//TTTContext.Logger.Log($"OpperandType: {codes[71].operand.GetType()}");
//ILUtils.LogIL(TTTContext, codes);
var load = codes[target - 1];
codes.InsertRange(target, new CodeInstruction[] {
new CodeInstruction(OpCodes.Ldc_I4_1),
new CodeInstruction(OpCodes.Call, RuleAttackWithWeapon_IsFirstAttack_Set),
load.Clone()
});
//ILUtils.LogIL(TTTContext, codes);
return codes.AsEnumerable();
}
private static int FindInsertionTarget(List<CodeInstruction> codes) {
//Looking for the arguments that define the object creation because searching for the object creation itself is hard
for (int i = 0; i < codes.Count; i++) {
if (codes[i].Calls(MechanicsContext_TriggerRule)) {
return i;
}
}
TTTContext.Logger.Log("VITALSTRIKEPATCH: COULD NOT FIND TARGET");
return -1;
}
}
}
}
2 changes: 1 addition & 1 deletion TabletopTweaks-Base/Bugfixes/General/AreaOfEffectsTick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class AreaOfEffectsTick {
static class AreaOfEffectsTick_Round_Patch {
static void Postfix(AreaEffectEntityData __instance) {
if (Main.TTTContext.Fixes.BaseFixes.IsDisabled("AreaOfEffectDoubleTrigger")) { return; }
if (__instance.Blueprint.GetComponent<AbilityAreaEffectRunAction>().UnitEnter.HasActions) {
if (__instance.Blueprint.GetComponent<AbilityAreaEffectRunAction>()?.UnitEnter?.HasActions ?? false) {
__instance.m_TimeToNextRound = 6f;
}
}
Expand Down
5 changes: 0 additions & 5 deletions TabletopTweaks-Base/Config/AddedContent.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,6 @@
"Homebrew": true,
"Description": "The effects from your blessings now last twice as long."
},
"FavoriteMetamagicSelective": {
"Enabled": true,
"Homebrew": false,
"Description": "Reduce the cost of Selective metamagic by 1."
},
"FavoriteMetamagicPersistent": {
"Enabled": true,
"Homebrew": false,
Expand Down
5 changes: 5 additions & 0 deletions TabletopTweaks-Base/Config/Fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,11 @@
"Enabled": true,
"Homebrew": false,
"Description": "No longer treats any weapon with Fencing/Slashing grace into a finesse weapon."
},
"VitalStrike": {
"Enabled": true,
"Homebrew": false,
"Description": "Now works correctly with overhand chop."
}
},
"IsExpanded": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static void AddFavoriteMetamagicSelective() {
bp.AddPrerequisiteFeature(SelectiveSpellFeat);
});

if (TTTContext.AddedContent.MythicAbilities.IsDisabled("FavoriteMetamagicSelective")) { return; }
FavoriteMetamagicSelection.AddFeatures(FavoriteMetamagicSelective);
//if (TTTContext.AddedContent.MythicAbilities.IsDisabled("FavoriteMetamagicSelective")) { return; }
//FavoriteMetamagicSelection.AddFeatures(FavoriteMetamagicSelective);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static void AddSecondPatron() {
.OfType<BlueprintProgression>()
.ForEach(patron => {
patron.GiveFeaturesForPreviousLevels = true;
patron.AddClass(ClassTools.Classes.WinterWitchClass);
patron.AddComponent<AddFacts>(c => {
c.m_Facts = new BlueprintUnitFactReference[] { SecondPatronRequisiteFeature.ToReference<BlueprintUnitFactReference>() };
});
Expand Down

0 comments on commit df37b60

Please sign in to comment.