Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Withering now affects IntangiblePower used by Nemesis #592

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
49 changes: 46 additions & 3 deletions src/main/java/stsjorbsmod/patches/WitheringPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -26,15 +29,31 @@ 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
{
@SpireInsertPatch(locator = Locator.class, localvars = {"damageAmount"})
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);
}
Expand All @@ -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;
}
}
}
}