Skip to content

Commit

Permalink
Improve compatibility with BaseMod and character mods
Browse files Browse the repository at this point in the history
  • Loading branch information
ForgottenArbiter committed Feb 10, 2020
1 parent 7466525 commit 6fa613d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A mod that searches through Slay the Spire seeds.
* Slay the Spire
* ModTheSpire (https://github.com/kiooeht/ModTheSpire)

Note: Use of other mods, including BaseMod, with SeedSearch is not recommended and will likely fail.
Note: Because it runs a headless version of Slay the Spire and has no access to graphics, SeedSearch is not designed for compatibility with all other mods, and has no mod requirements. Also, any mod can change the outcome of seeds, so you should not use any mods, including BaseMod, with SeedSearch when searching for seeds to use in unmodded gameplay. Still, some character mods, such as Thorton and Jorbs Mod, have been found to work (or at least not crash/hang) with SeedSearch.

## Setup and Usage

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>seedsearch</groupId>
<artifactId>SeedSearch</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>SeedSearch</name>
<description>Finds seeds with desired properties</description>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedsearch/SeedRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.megacrit.cardcrawl.shop.ShopScreen;
import com.megacrit.cardcrawl.shop.StorePotion;
import com.megacrit.cardcrawl.shop.StoreRelic;
import com.megacrit.cardcrawl.vfx.AbstractGameEffect;
import seedsearch.patches.AbstractRoomPatch;
import seedsearch.patches.CardRewardScreenPatch;
import seedsearch.patches.EventHelperPatch;
Expand Down Expand Up @@ -67,6 +68,7 @@ public SeedRunner(SearchSettings settings) {
this.settings = settings;
AbstractDungeon.fadeColor = Settings.SHADOW_COLOR;
CharacterManager characterManager = new CharacterManager();
CardCrawlGame.characterManager = characterManager;
characterManager.setChosenCharacter(settings.playerClass);
currentSeed = settings.startSeed;
AbstractDungeon.ascensionLevel = settings.ascensionLevel;
Expand Down Expand Up @@ -503,6 +505,9 @@ private void runPath(ArrayList<MapRoomNode> path) {
}
}
AbstractDungeon.currMapNode = node;
if (AbstractDungeon.getCurrRoom().phase == AbstractRoom.RoomPhase.COMBAT) {
AbstractDungeon.getCurrRoom().phase = AbstractRoom.RoomPhase.COMPLETE;
}
switch(result) {
case EVENT:
Random eventRngDuplicate = new Random(Settings.seed, AbstractDungeon.eventRng.counter);
Expand Down Expand Up @@ -544,12 +549,16 @@ private void runPath(ArrayList<MapRoomNode> path) {
break;
case TREASURE:
AbstractChest chest = AbstractDungeon.getRandomChest();
ShowCardAndObtainEffectPatch.resetCards();
chest.open(false);
addGoldReward(combatGold);
Reward treasureRelicReward = new Reward(AbstractDungeon.floorNum);
for(AbstractRelic treasureRelic : combatRelics) {
awardRelic(treasureRelic, treasureRelicReward);
}
for (AbstractCard card : ShowCardAndObtainEffectPatch.obtainedCards) {
addInvoluntaryCardReward(card, treasureRelicReward);
}
seedResult.addAllCardRewards(combatCardRewards);
seedResult.addMiscReward(treasureRelicReward);
break;
Expand Down Expand Up @@ -909,6 +918,7 @@ private void getBossRewards() {
AbstractDungeon.floorNum += 1;
AbstractDungeon.currMapNode = new MapRoomNode(-1, 15);
AbstractDungeon.currMapNode.room = new MonsterRoomBoss();
AbstractDungeon.currMapNode.room.phase = AbstractRoom.RoomPhase.COMPLETE;
if (AbstractDungeon.ascensionLevel == 20 && currentAct == 2) {
seedResult.registerBossCombat(AbstractDungeon.bossList.get(1));
AbstractDungeon.floorNum += 1;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/seedsearch/patches/BaseModPatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package seedsearch.patches;

import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;

@SpirePatch(
cls="basemod.BaseMod",
method="setupAnimationGfx",
optional=true
)
public class BaseModPatch {

public static void Replace() {
// Do nothing
}

}
6 changes: 4 additions & 2 deletions src/main/java/seedsearch/patches/StartSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.evacipated.cardcrawl.modthespire.patcher.PatchingException;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.helpers.GameTips;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.screens.DisplayOption;
import javassist.CannotCompileException;
Expand Down Expand Up @@ -38,7 +39,8 @@ public static ExprEditor Instrument() {
return new ExprEditor() {
public void edit(NewExpr m) throws CannotCompileException {
if (m.getClassName().equals("com.badlogic.gdx.graphics.g2d.SpriteBatch")
|| m.getClassName().equals("com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch")) {
|| m.getClassName().equals("com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch")
|| m.getClassName().equals(GameTips.class.getName())) {
m.replace("{$_ = $0;}");
}
}
Expand All @@ -47,7 +49,7 @@ public void edit(NewExpr m) throws CannotCompileException {

private static class Locator extends SpireInsertLocator {
public int[] Locate(CtBehavior ctMethodToPatch) throws CannotCompileException, PatchingException {
Matcher matcher = new Matcher.FieldAccessMatcher(CardCrawlGame.class, "tips");
Matcher matcher = new Matcher.FieldAccessMatcher(CardCrawlGame.class, "splashScreen");
return LineFinder.findInOrder(ctMethodToPatch, new ArrayList<Matcher>(), matcher);
}
}
Expand Down

0 comments on commit 6fa613d

Please sign in to comment.