Skip to content

Commit

Permalink
Fixes for reduced boss count with nonrandom starting weapon and locat…
Browse files Browse the repository at this point in the history
…ion, plus logic cleanup and some background stuff
  • Loading branch information
thezerothcat committed Feb 6, 2022
1 parent 49e9248 commit d92b68b
Show file tree
Hide file tree
Showing 26 changed files with 2,347 additions and 1,077 deletions.
4 changes: 4 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Please see the wiki page on github for information on how to use the randomizer, and other things you may need to know about it.
https://github.com/thezerothcat/LaMulanaRandomizer/wiki

2.32
-----------------------------
Fixes for reduced boss count setting interactions, and some assorted logic updates.

2.31
-----------------------------
Logic fixes for reduced boss count.
Expand Down
4 changes: 2 additions & 2 deletions misc/custom-text.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#Tablet_Guidance_Entrance.Text.Text=
#Tablet_Guidance_HolyGround.Text=
#Tablet_Guidance_ProveThineCourage.Text=
#Tablet_Guidance_Offer3Lights.Text=
#Tablet_Guidance_Offer3Lights.Text=Offer 3 lights to the heavens.
#Tablet_Guidance_8Ankhs.Text=
#Tablet_Guidance_GiantsHistory.Text=
#Tablet_Guidance_ChiYou.Text=
Expand Down Expand Up @@ -80,7 +80,7 @@
#Tablet_Sun_AimAndShoot.Text=
#DamagedTablet_Sun_FillThisPlaceWithWater.Text=
#Tablet_Spring_AboveTheSun.Text=
#Tablet_Spring_Fairy.Text=
#Tablet_Spring_Fairy.Text=Heal thine tired body.\nThe {COLOR=BLUE}fairy {COLOR=DEFAULT}will gently heal thou.\nThe {COLOR=BLUE}fairy {COLOR=DEFAULT}will help thy fight.\nThe {COLOR=BLUE}fairy {COLOR=DEFAULT}will provide treasure.\nThe {COLOR=BLUE}fairy {COLOR=DEFAULT}will reveal secrets.
#Tablet_Spring_OpenTheFloodgate.Text=
#Tablet_Spring_OannesFormOfAFish.Text=
#Tablet_Spring_SailAway.Text=
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 @@
<modelVersion>4.0.0</modelVersion>
<groupId>lmr.randomizer</groupId>
<artifactId>randomizer</artifactId>
<version>2.31.0</version>
<version>2.32.0</version>
<name>La-Mulana Remake Randomizer</name>
<description>La-Mulana Remake Randomizer</description>
<packaging>jar</packaging>
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/lmr/randomizer/DataFromFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import lmr.randomizer.node.NodeWithRequirements;
import lmr.randomizer.randomization.ShopRandomizationEnum;
import lmr.randomizer.randomization.data.GameObjectId;
import lmr.randomizer.util.BlockConstants;
import lmr.randomizer.util.FlagConstants;
import lmr.randomizer.util.LocationCoordinateMapper;
import lmr.randomizer.util.MiscConstants;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -106,6 +109,8 @@ public final class DataFromFile {
private static List<String> winRequirements;
private static List<String> chestOnlyLocations;

private static List<Integer> removedTabletGlowFlags;

private static CustomPlacementData customPlacementData;

private DataFromFile() { }
Expand Down Expand Up @@ -541,6 +546,32 @@ public static List<String> getAllCoinChests() {
return allCoinChests;
}

public static List<Integer> getRemovedTabletGlowFlags() {
if(removedTabletGlowFlags == null ) {
removedTabletGlowFlags = getFlagsForRemovedTabletGlow();
}
return removedTabletGlowFlags;
}

private static List<Integer> getFlagsForRemovedTabletGlow() {
List<Integer> tabletGlowFlags = new ArrayList<>();
boolean customTabletExists = false;
for(Integer tabletGlowFlag : FlagConstants.CUSTOMIZABLE_TABLET_GLOW_FLAGS) {
if(hasCustomTablet(tabletGlowFlag)) {
customTabletExists = true;
}
else {
tabletGlowFlags.add(tabletGlowFlag);
}
}
return customTabletExists ? tabletGlowFlags : new ArrayList<>(0);
}

private static boolean hasCustomTablet(int tabletGlowFlag) {
Integer blockNumber = BlockConstants.getTabletBlockFromGlowFlag(tabletGlowFlag);
return blockNumber != null && (Translations.hasKey(MiscConstants.getScannableId(blockNumber) + ".Text"));
}

public static List<String> getHTItems(List<String> possibleItems) {
List<String> enabledItems = new ArrayList<>(possibleItems.size());
if(Settings.isHTFullRandom()) {
Expand Down Expand Up @@ -593,5 +624,6 @@ public static void clearAllData() {
initialShops = null;
initialNonShopItemLocations = null;
bannedTrapLocations = null;
removedTabletGlowFlags = null;
}
}
2 changes: 1 addition & 1 deletion src/main/java/lmr/randomizer/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Created by thezerothcat on 7/10/2017.
*/
public class FileUtils {
public static final String VERSION = "2.31.0";
public static final String VERSION = "2.32.0";

private static BufferedWriter logWriter;
private static final List<String> KNOWN_RCD_FILE_HASHES = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lmr/randomizer/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ public static void setSkipValidation(int skipValidationAttemptNumber) {

public static boolean isSaveFileNeeded() {
return isAllowMainWeaponStart() || isAllowSubweaponStart() || isRandomizeStartingLocation()
|| HolidaySettings.isSaveFileNeeded();
|| isReducedBossCount() || HolidaySettings.isSaveFileNeeded();
}

public static boolean isCheapAmmo() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/lmr/randomizer/Translations.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public static String getText(String key) {
return allTranslations.getProperty(key);
}

public static boolean hasKey(String key) {
return allTranslations.stringPropertyNames().contains(key);
}

public static String getLocationAndNpc(String npc) {
return getLocationAndNpc(npc, npc);
}
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/lmr/randomizer/dat/DatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,30 @@ private static MasterNpcBlock buildMasterNpcBlock(int blockIndex, DataInputStrea
return masterNpcBlock;
}

private static MapGraphicsBlock buildMapGraphicsBlock(int blockIndex, DataInputStream dataInputStream, int numberOfShortsInThisBlock) throws IOException {
int dataIndex = 0;
MapGraphicsBlock mapGraphicsBlock = new MapGraphicsBlock(blockIndex);
MapGraphicsEntry mapGraphicsEntry;

while(dataIndex < numberOfShortsInThisBlock) {
dataInputStream.readShort(); // CMD
++dataIndex;
dataInputStream.readShort(); // List length is always 2
++dataIndex;
int positionData = dataInputStream.readShort();
++dataIndex;
int appearanceData = dataInputStream.readShort();
++dataIndex;
mapGraphicsEntry = new MapGraphicsEntry(positionData, appearanceData);
if(dataIndex < numberOfShortsInThisBlock) {
dataInputStream.readShort(); // 0x000a
++dataIndex;
}
mapGraphicsBlock.addRoom(mapGraphicsEntry);
}
return mapGraphicsBlock;
}

private static Block buildCheckBlock(int blockIndex, DataInputStream dataInputStream, int numberOfShortsInThisBlock) throws IOException {
int dataIndex = 0;
CheckBlock checkBlock = new CheckBlock(blockIndex);
Expand Down Expand Up @@ -933,6 +957,28 @@ private static boolean isMasterNpcBlock(int blockIndex) {
|| blockIndex == BlockConstants.Master_Mulbruk_ProvocativeBathingSuitReaction;
}

private static boolean isMapGraphicsBlock(int blockIndex) {
return blockIndex == BlockConstants.MapGraphics_GateOfGuidance
|| blockIndex == BlockConstants.MapGraphics_Surface
|| blockIndex == BlockConstants.MapGraphics_Mausoleum
|| blockIndex == BlockConstants.MapGraphics_Sun
|| blockIndex == BlockConstants.MapGraphics_Spring
|| blockIndex == BlockConstants.MapGraphics_Inferno
|| blockIndex == BlockConstants.MapGraphics_Extinction
|| blockIndex == BlockConstants.MapGraphics_TwinLabyrinths
|| blockIndex == BlockConstants.MapGraphics_Endless
|| blockIndex == BlockConstants.MapGraphics_Shrine
|| blockIndex == BlockConstants.MapGraphics_Illusion
|| blockIndex == BlockConstants.MapGraphics_Graveyard
|| blockIndex == BlockConstants.MapGraphics_Moonlight
|| blockIndex == BlockConstants.MapGraphics_Goddess
|| blockIndex == BlockConstants.MapGraphics_Ruin
|| blockIndex == BlockConstants.MapGraphics_Birth_Swords
|| blockIndex == BlockConstants.MapGraphics_Birth_Skanda
|| blockIndex == BlockConstants.MapGraphics_Dimensional
|| blockIndex == BlockConstants.MapGraphics_HT;
}

private static DataInputStream getDatFile(boolean loadFromBackup) throws Exception {
if(loadFromBackup) {
return new DataInputStream(new FileInputStream(Settings.getBackupDatFile()));
Expand Down Expand Up @@ -983,6 +1029,9 @@ else if(blockIndex == BlockConstants.XelpudFlagCheckBlock || blockIndex == Block
else if(isMasterNpcBlock(blockIndex)) {
block = buildMasterNpcBlock(blockIndex, dataInputStream, numberOfBytesInThisBlock / 2);
}
else if(isMapGraphicsBlock(blockIndex)) {
block = buildMapGraphicsBlock(blockIndex, dataInputStream, numberOfBytesInThisBlock / 2);
}
else if(DataFromFile.getMapOfShopNameToShopBlock().values().contains((Integer)blockIndex)) {
block = buildShopBlock(blockIndex, dataInputStream, numberOfBytesInThisBlock / 2);
}
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/lmr/randomizer/dat/blocks/MapGraphicsBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package lmr.randomizer.dat.blocks;

import lmr.randomizer.util.BlockDataConstants;

import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MapGraphicsBlock extends Block {
private List<MapGraphicsEntry> roomGraphics = new ArrayList<>();

public MapGraphicsBlock(int blockNumber) {
super(blockNumber);
}

public void addRoom(MapGraphicsEntry mapGraphicsEntry) {
roomGraphics.add(mapGraphicsEntry);
}

private MapGraphicsEntry getMapGraphics(int roomNumber) {
return roomGraphics.get(roomNumber);
}

@Override
public List<Short> getRawData() {
List<Short> rawData = new ArrayList<>();
rawData.add((short)getBlockSize());
for(int i = 0; i < roomGraphics.size(); i++) {
rawData.addAll(roomGraphics.get(i).getRawData());
if(i < roomGraphics.size() - 1) {
rawData.add(BlockDataConstants.EndOfEntry);
}
}
return rawData;
}

@Override
public int getBlockSize() {
int size = 0;
for(MapGraphicsEntry mapGraphicsEntry : roomGraphics) {
size += mapGraphicsEntry.getSize() + 2;
}
size -= 2; // The final BlockDataConstants.EndOfEntry is omitted
return size;
}

@Override
public void write(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeShort(getBlockSize());

for(int i = 0; i < roomGraphics.size(); i++) {
roomGraphics.get(i).writeBytes(dataOutputStream);
if(i < roomGraphics.size() - 1) {
dataOutputStream.writeShort(BlockDataConstants.EndOfEntry);
}
}
}
}
120 changes: 120 additions & 0 deletions src/main/java/lmr/randomizer/dat/blocks/MapGraphicsEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package lmr.randomizer.dat.blocks;

import lmr.randomizer.dat.blocks.contents.BlockContents;
import lmr.randomizer.util.BlockDataConstants;

import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MapGraphicsEntry implements BlockContents {
public static int Icon_Blank = 0;
public static int Icon_BacksideDoor = 1;
public static int Icon_GrailTablet = 2;
public static int Icon_CrossOfLight = 3;
public static int Icon_FairyPoint = 4;
public static int Icon_BrownDoor = 5;
public static int Icon_BlueDoor = 6;
public static int Icon_PhilosopherDoor = 7;
public static int Icon_UpExit = 8;
public static int Icon_DownExit = 9;
public static int Icon_LeftExit = 10;
public static int Icon_RightExit = 11;
public static int Icon_DragonBone = 12;

public static int IconColor_Invisible = 0;
public static int IconColor_White = 1;
public static int IconColor_Green = 2;
public static int IconColor_Yellow = 3;
public static int IconColor_Red = 4;
public static int IconColor_Blue = 5;
public static int IconColor_Transparent = 6;

private int positionData; // position = issecret * 10000 + X*100 + Y
private int appearanceData;// appearance: Icon1 * 1000 + Icon2 * 10 + Color

public MapGraphicsEntry(int positionData, int appearanceData) {
this.positionData = positionData;
this.appearanceData = appearanceData;
}

public int getIcon1() {
return appearanceData / 1000;
}

public int getIcon2() {
return appearanceData % 1000 / 10;
}

public int getIconColor() {
return appearanceData % 10;
}

public void setIcon1(int icon) {
setAppearanceData(icon, getIcon2(), getIconColor());
}

public void setIcon2(int icon) {
setAppearanceData(getIcon1(), icon, getIconColor());
}

public void setIconColor(int iconColor) {
setAppearanceData(getIcon1(), getIcon2(), iconColor);
}

private void setAppearanceData(int icon1, int icon2, int iconColor) {
appearanceData = icon1 * 1000 + icon2 * 10 + iconColor;
}

public boolean isSecret() {
return positionData >= 10000;
}

public int getX() {
return positionData % 10000 / 100;
}

public int getY() {
return positionData % 100;
}

public void setX(int x) {
setPositionData(x, getY(), isSecret());
}

public void setY(int y) {
setPositionData(getX(), y, isSecret());
}

public void setSecret(boolean isSecret) {
setPositionData(getX(), getY(), isSecret);
}

private void setPositionData(int x, int y, boolean isSecret) {
positionData = (isSecret ? 10000 : 0) + x * 100 + y;
}

@Override
public int getSize() {
return 8; // CMD, list length, then two items
}

@Override
public List<Short> getRawData() {
List<Short> rawData = new ArrayList<>();
rawData.add(BlockDataConstants.DataList);
rawData.add((short)2);
rawData.add((short)positionData);
rawData.add((short)appearanceData);
return rawData;
}

@Override
public void writeBytes(DataOutputStream dataOutputStream) throws IOException {
dataOutputStream.writeShort(BlockDataConstants.DataList);
dataOutputStream.writeShort(2);
dataOutputStream.writeShort(positionData);
dataOutputStream.writeShort(appearanceData);
}
}
Loading

0 comments on commit d92b68b

Please sign in to comment.