Skip to content

Commit

Permalink
Adventure: when loading enemies on a map, if an enemy definition cann…
Browse files Browse the repository at this point in the history
…ot be found choose a random one from the current biome
  • Loading branch information
Jorilx committed Jan 1, 2024
1 parent 9a5fe05 commit 164197b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions forge-gui-mobile/src/forge/adventure/stage/MapStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,11 @@ else if (prop.containsKey("portalState")) {
if (enemy != null && !enemy.toString().isEmpty()) {
EnemyData EN = WorldData.getEnemy(enemy.toString());
if (EN == null) {
System.err.printf("Enemy \"%s\" not found.", enemy);
break;
System.err.printf("Enemy \"%s\" not found, choosing a random one for current biome\n", enemy);
forge.adventure.world.World world = Current.world();
Vector2 poiPos = AdventureQuestController.instance().mostRecentPOI.getPosition();
int currentBiome = forge.adventure.world.World.highestBiome(world.getBiome((int) poiPos.x / world.getTileSize(), (int) poiPos.y / world.getTileSize()));
EN = world.getData().GetBiomes().get(currentBiome).getEnemy(1.0f);
}
EnemySprite mob = new EnemySprite(id, EN);
Object dialogObject = prop.get("dialog"); //Check if the enemy has a dialogue attached to it.
Expand Down

0 comments on commit 164197b

Please sign in to comment.