From c44b9df706de24f416812d3578ad3e5d58b80ed6 Mon Sep 17 00:00:00 2001 From: James Wang <007jcw@gmail.com> Date: Fri, 5 Feb 2021 00:13:31 -0500 Subject: [PATCH] Withering now affects IntangiblePower used by Nemesis --- CHANGELOG.md | 1 + .../stsjorbsmod/patches/WitheringPatch.java | 49 +++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8886274fd..7ce9afa05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Fixed issue with not being able to play cards with Sacrifice if you had 0 energy (thanks LankSSBM) * Fixed Assertion card text (thanks LankSSBM) * Fixed Taunt+ upgrade text and amount of vulnerable applied 8->5 (thanks LankSSBM) +* Fixed issue where Withering did not affect Nemesis (thanks wang429) ### CULL updates diff --git a/src/main/java/stsjorbsmod/patches/WitheringPatch.java b/src/main/java/stsjorbsmod/patches/WitheringPatch.java index 01c9cb94e..a5e075d5f 100644 --- a/src/main/java/stsjorbsmod/patches/WitheringPatch.java +++ b/src/main/java/stsjorbsmod/patches/WitheringPatch.java @@ -3,15 +3,18 @@ import com.evacipated.cardcrawl.modthespire.lib.*; import com.megacrit.cardcrawl.cards.DamageInfo; import com.megacrit.cardcrawl.characters.AbstractPlayer; +import com.megacrit.cardcrawl.dungeons.AbstractDungeon; +import com.megacrit.cardcrawl.monsters.AbstractMonster; import com.megacrit.cardcrawl.powers.AbstractPower; import com.megacrit.cardcrawl.powers.IntangiblePlayerPower; +import com.megacrit.cardcrawl.powers.IntangiblePower; import javassist.CtBehavior; import stsjorbsmod.powers.CoupDeGracePower; import stsjorbsmod.powers.WitheringPower; public class WitheringPatch { @SpirePatch(clz = IntangiblePlayerPower.class, method = "atDamageFinalReceive") - public static class ReduceIntangibleDamageReductionPatch + public static class ReduceIntangiblePlayerDamageReductionPatch { @SpirePrefixPatch public static SpireReturn patch(IntangiblePlayerPower __instance, float dmg, DamageInfo.DamageType type) { @@ -26,6 +29,22 @@ public static SpireReturn patch(IntangiblePlayerPower __instance, float dmg, Dam } } + @SpirePatch(clz = IntangiblePower.class, method = "atDamageFinalReceive") + public static class ReduceIntangibleDamageReductionPatch + { + @SpirePrefixPatch + public static SpireReturn patch(IntangiblePower __instance, float dmg, DamageInfo.DamageType type) { + AbstractPower maybeWithering = AbstractDungeon.player.getPower(WitheringPower.POWER_ID); + AbstractPower maybeCoupDeGrace = AbstractDungeon.player.getPower(CoupDeGracePower.POWER_ID); + // damage gets handled in coup de grace patch, but needs to be calculated first + if(maybeWithering != null && maybeCoupDeGrace == null) + { + return SpireReturn.Return(Math.min(dmg, maybeWithering.amount + 1)); + } + return SpireReturn.Continue(); + } + } + @SpirePatch(clz = AbstractPlayer.class, method = "damage") public static class ReduceIntangibleDamageReductionInPlayerDamageMethod { @@ -33,8 +52,8 @@ public static class ReduceIntangibleDamageReductionInPlayerDamageMethod public static void patch(AbstractPlayer __instance, DamageInfo info, @ByRef int[] damageAmount) { AbstractPower maybeWithering = __instance.getPower(WitheringPower.POWER_ID); if (__instance.hasPower(IntangiblePlayerPower.POWER_ID) - && maybeWithering != null - && !TrueDamagePatch.TrueDamageInfoField.isTrueDamage.get(info)) + && maybeWithering != null + && !TrueDamagePatch.TrueDamageInfoField.isTrueDamage.get(info)) { damageAmount[0] = Math.min(maybeWithering.amount + 1, info.output); } @@ -49,4 +68,28 @@ public int[] Locate(CtBehavior ctMethodToPatch) throws Exception { } } } + + @SpirePatch(clz = AbstractMonster.class, method = "damage") + public static class ReduceIntangibleDamageReductionInMonsterDamageMethod + { + @SpireInsertPatch(locator = Locator.class, localvars = {"damageAmount"}) + public static void patch(AbstractMonster __instance, DamageInfo info, @ByRef int[] damageAmount) { + AbstractPower maybeWithering = AbstractDungeon.player.getPower(WitheringPower.POWER_ID); + if ((__instance.hasPower(IntangiblePlayerPower.POWER_ID) || __instance.hasPower(IntangiblePower.POWER_ID)) + && maybeWithering != null + && !TrueDamagePatch.TrueDamageInfoField.isTrueDamage.get(info)) + { + damageAmount[0] = Math.min(maybeWithering.amount + 1, info.output); + } + } + + private static class Locator extends SpireInsertLocator { + @Override + public int[] Locate(CtBehavior ctMethodToPatch) throws Exception { + Matcher finalMatcher = new Matcher.MethodCallMatcher(AbstractMonster.class, "decrementBlock"); + int[] found = LineFinder.findAllInOrder(ctMethodToPatch, finalMatcher); + return found; + } + } + } }