some stuff fixed; stuff still broken
parent
8674605497
commit
86b344f933
|
@ -32,6 +32,8 @@ class Game:
|
||||||
self.itemLocations.clear()
|
self.itemLocations.clear()
|
||||||
self.patcher.clear()
|
self.patcher.clear()
|
||||||
|
|
||||||
|
print('DEBUG: Opening ROM to pick stuff')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(vanillaGame, 'rb') as sourceRom:
|
with open(vanillaGame, 'rb') as sourceRom:
|
||||||
sourceRom.seek(3967888, 0)
|
sourceRom.seek(3967888, 0)
|
||||||
|
@ -48,7 +50,6 @@ class Game:
|
||||||
sourceDoor = int.from_bytes(sourceRom.read(1), 'little')
|
sourceDoor = int.from_bytes(sourceRom.read(1), 'little')
|
||||||
targetOffset = sourceRom.tell()
|
targetOffset = sourceRom.tell()
|
||||||
targetArea = int.from_bytes(sourceRom.read(1), 'little')
|
targetArea = int.from_bytes(sourceRom.read(1), 'little')
|
||||||
continue
|
|
||||||
for currentArea in range(7):
|
for currentArea in range(7):
|
||||||
sourceRom.seek(7977108 + currentArea * 4, 0)
|
sourceRom.seek(7977108 + currentArea * 4, 0)
|
||||||
data = sourceRom.read(4)
|
data = sourceRom.read(4)
|
||||||
|
@ -71,18 +72,17 @@ class Game:
|
||||||
roomNumber = format(roomNumber, '02X')
|
roomNumber = format(roomNumber, '02X')
|
||||||
roomString = 'Room-S{}-{}'.format(currentArea, roomNumber)
|
roomString = 'Room-S{}-{}'.format(currentArea, roomNumber)
|
||||||
doorString = 'S{}-{:02X}'.format(currentArea, doorNumber)
|
doorString = 'S{}-{:02X}'.format(currentArea, doorNumber)
|
||||||
|
print('DEBUG: Adding door {} to S{}-{:02X}'.format(doorNumber, currentArea, roomNumber))
|
||||||
if roomString in self.rooms:
|
if roomString in self.rooms:
|
||||||
self.rooms[roomString].append(doorString)
|
self.rooms[roomString].append(doorString)
|
||||||
else:
|
else:
|
||||||
self.rooms[roomString] = [
|
self.rooms[roomString] = [
|
||||||
doorString]
|
doorString]
|
||||||
doorNumber += 1
|
doorNumber += 1
|
||||||
finally:
|
print('DEBUG: Parsing seemingly done?')
|
||||||
pass
|
except:
|
||||||
except FileNotFoundError:
|
sys.exit('Error:', vanillaGame, 'could not be opened.')
|
||||||
sys.exit('Error:', vanillaGame, 'could not be opened.')
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def set_setting(self, setting, value):
|
def set_setting(self, setting, value):
|
||||||
|
@ -126,19 +126,12 @@ class Game:
|
||||||
for end in self.rooms[room]:
|
for end in self.rooms[room]:
|
||||||
if start != end:
|
if start != end:
|
||||||
self.add_edges(start, end)
|
self.add_edges(start, end)
|
||||||
continue
|
|
||||||
continue
|
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def ConnectNodesBetweenRooms(self):
|
def ConnectNodesBetweenRooms(self):
|
||||||
for connection in self.doorConnections.items():
|
for connection in self.doorConnections.items():
|
||||||
if len(connection) == 2:
|
if len(connection) == 2:
|
||||||
self.add_directed_edge(connection[0], connection[1])
|
self.add_directed_edge(connection[0], connection[1])
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def UpdateDoorConnection(self, source, destination):
|
def UpdateDoorConnection(self, source, destination):
|
||||||
self.doorConnections.update({
|
self.doorConnections.update({
|
||||||
|
@ -172,7 +165,6 @@ class Game:
|
||||||
else:
|
else:
|
||||||
self.graph[start] = [
|
self.graph[start] = [
|
||||||
end]
|
end]
|
||||||
|
|
||||||
|
|
||||||
def add_edges(self, start, *nodes):
|
def add_edges(self, start, *nodes):
|
||||||
for end in nodes:
|
for end in nodes:
|
||||||
|
@ -193,16 +185,12 @@ class Game:
|
||||||
self.itemLocations.append(item)
|
self.itemLocations.append(item)
|
||||||
if item not in self.majorItemLocations:
|
if item not in self.majorItemLocations:
|
||||||
self.majorItemLocations.append(item)
|
self.majorItemLocations.append(item)
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_minors(self, item):
|
def add_to_minors(self, item):
|
||||||
if item not in self.itemLocations:
|
if item not in self.itemLocations:
|
||||||
self.itemLocations.append(item)
|
self.itemLocations.append(item)
|
||||||
if item not in self.minorItemLocations:
|
if item not in self.minorItemLocations:
|
||||||
self.minorItemLocations.append(item)
|
self.minorItemLocations.append(item)
|
||||||
|
|
||||||
|
|
||||||
def add_list_to_minors(self, locations):
|
def add_list_to_minors(self, locations):
|
||||||
for item in locations:
|
for item in locations:
|
||||||
|
@ -210,14 +198,10 @@ class Game:
|
||||||
self.itemLocations.append(item)
|
self.itemLocations.append(item)
|
||||||
if item not in self.minorItemLocations:
|
if item not in self.minorItemLocations:
|
||||||
self.minorItemLocations.append(item)
|
self.minorItemLocations.append(item)
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_requirements(self, start, end):
|
def get_requirements(self, start, end):
|
||||||
checkRequirement = (start, end)
|
checkRequirement = (start, end)
|
||||||
return self.requirements.get(checkRequirement)
|
return self.requirements.get(checkRequirement)
|
||||||
|
|
||||||
|
|
||||||
def get_path(self, start, end, LimitArea, path, depth = (False, None, 100)):
|
def get_path(self, start, end, LimitArea, path, depth = (False, None, 100)):
|
||||||
if path == None:
|
if path == None:
|
||||||
|
@ -262,7 +246,5 @@ class Game:
|
||||||
path = path + [
|
path = path + [
|
||||||
node]
|
node]
|
||||||
return newpath
|
return newpath
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
MFOR.py
1
MFOR.py
|
@ -20,6 +20,7 @@ parser.add_argument('-num', help='Number of seeds to generate (default 1)')
|
||||||
parser.add_argument('-hideitems', default=False, action='store_true', help='All items use ? tank graphics')
|
parser.add_argument('-hideitems', default=False, action='store_true', help='All items use ? tank graphics')
|
||||||
parser.add_argument('-debug', default=False, action='store_true', help='Debugging, for my own use')
|
parser.add_argument('-debug', default=False, action='store_true', help='Debugging, for my own use')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not os.path.exists(os.path.join('.', 'data')):
|
if not os.path.exists(os.path.join('.', 'data')):
|
||||||
os.mkdir('data')
|
os.mkdir('data')
|
||||||
if not os.path.exists(os.path.join('.', 'seeds')):
|
if not os.path.exists(os.path.join('.', 'seeds')):
|
||||||
|
|
|
@ -17,6 +17,9 @@ from bps.apply import apply_to_files
|
||||||
|
|
||||||
version = '0.11.6'
|
version = '0.11.6'
|
||||||
|
|
||||||
|
# FIXME: Debug should not be set here
|
||||||
|
Debug = False
|
||||||
|
|
||||||
def ceiling(num, denom):
|
def ceiling(num, denom):
|
||||||
return -(num // -denom)
|
return -(num // -denom)
|
||||||
|
|
||||||
|
@ -4696,8 +4699,6 @@ def patch_game():
|
||||||
if len(x) > 1 and re.search('^[a-zA-Z]', x[1]):
|
if len(x) > 1 and re.search('^[a-zA-Z]', x[1]):
|
||||||
sym.update({
|
sym.update({
|
||||||
x[1]: x[0][2:] })
|
x[1]: x[0][2:] })
|
||||||
finally:
|
|
||||||
pass
|
|
||||||
os.remove(os.path.join('.', 'data', 'asm', 'temp.sym'))
|
os.remove(os.path.join('.', 'data', 'asm', 'temp.sym'))
|
||||||
roomEventOffset = int(sym.get('t_bossanddownloadevents'), 16)
|
roomEventOffset = int(sym.get('t_bossanddownloadevents'), 16)
|
||||||
itemEventOffset = int(sym.get('t_obtainitemevents'), 16)
|
itemEventOffset = int(sym.get('t_obtainitemevents'), 16)
|
||||||
|
@ -4841,37 +4842,37 @@ def patch_game():
|
||||||
patchedGame.seek(offset)
|
patchedGame.seek(offset)
|
||||||
patchedGame.write(location.encode('ascii'))
|
patchedGame.write(location.encode('ascii'))
|
||||||
for x in range(len(location), 35):
|
for x in range(len(location), 35):
|
||||||
patchedGame.write(0.to_bytes(1, 'little'))
|
patchedGame.write((0).to_bytes(1, 'little'))
|
||||||
if SeedSettings['HideItems']:
|
if SeedSettings['HideItems']:
|
||||||
patchedGame.seek(3926048)
|
patchedGame.seek(3926048)
|
||||||
patchedGame.write(76.to_bytes(2, 'little'))
|
patchedGame.write((76).to_bytes(2, 'little'))
|
||||||
patchedGame.write(77.to_bytes(2, 'little'))
|
patchedGame.write((77).to_bytes(2, 'little'))
|
||||||
patchedGame.write(78.to_bytes(2, 'little'))
|
patchedGame.write((78).to_bytes(2, 'little'))
|
||||||
patchedGame.write(79.to_bytes(2, 'little'))
|
patchedGame.write((79).to_bytes(2, 'little'))
|
||||||
patchedGame.write(76.to_bytes(2, 'little'))
|
patchedGame.write((76).to_bytes(2, 'little'))
|
||||||
patchedGame.write(77.to_bytes(2, 'little'))
|
patchedGame.write((77).to_bytes(2, 'little'))
|
||||||
patchedGame.write(78.to_bytes(2, 'little'))
|
patchedGame.write((78).to_bytes(2, 'little'))
|
||||||
patchedGame.write(79.to_bytes(2, 'little'))
|
patchedGame.write((79).to_bytes(2, 'little'))
|
||||||
patchedGame.write(76.to_bytes(2, 'little'))
|
patchedGame.write((76).to_bytes(2, 'little'))
|
||||||
patchedGame.write(77.to_bytes(2, 'little'))
|
patchedGame.write((77).to_bytes(2, 'little'))
|
||||||
patchedGame.write(78.to_bytes(2, 'little'))
|
patchedGame.write((78).to_bytes(2, 'little'))
|
||||||
patchedGame.write(79.to_bytes(2, 'little'))
|
patchedGame.write((79).to_bytes(2, 'little'))
|
||||||
if SeedSettings['SplitSecurity'] == True:
|
if SeedSettings['SplitSecurity'] == True:
|
||||||
security = securityOffset
|
security = securityOffset
|
||||||
patchedGame.seek(security)
|
patchedGame.seek(security)
|
||||||
patchedGame.write(0.to_bytes(2, 'little'))
|
patchedGame.write((0).to_bytes(2, 'little'))
|
||||||
if SeedSettings['MissilesWithoutMainData']:
|
if SeedSettings['MissilesWithoutMainData']:
|
||||||
patchedGame.seek(24828)
|
patchedGame.seek(24828)
|
||||||
patchedGame.write(15.to_bytes(1, 'little'))
|
patchedGame.write((15).to_bytes(1, 'little'))
|
||||||
patchedGame.seek(395742)
|
patchedGame.seek(395742)
|
||||||
patchedGame.write(15.to_bytes(1, 'little'))
|
patchedGame.write((15).to_bytes(1, 'little'))
|
||||||
patchedGame.seek(465582)
|
patchedGame.seek(465582)
|
||||||
patchedGame.write(15.to_bytes(1, 'little'))
|
patchedGame.write((15).to_bytes(1, 'little'))
|
||||||
if SeedSettings['PowerBombsWithoutBombs']:
|
if SeedSettings['PowerBombsWithoutBombs']:
|
||||||
patchedGame.seek(24756)
|
patchedGame.seek(24756)
|
||||||
patchedGame.write(32.to_bytes(1, 'little'))
|
patchedGame.write((32).to_bytes(1, 'little'))
|
||||||
patchedGame.seek(465672)
|
patchedGame.seek(465672)
|
||||||
patchedGame.write(32.to_bytes(1, 'little'))
|
patchedGame.write((32).to_bytes(1, 'little'))
|
||||||
if SeedSettings['SectorShuffle'] == True:
|
if SeedSettings['SectorShuffle'] == True:
|
||||||
for currentArea in range(7):
|
for currentArea in range(7):
|
||||||
patchedGame.seek(7977108 + currentArea * 4, 0)
|
patchedGame.seek(7977108 + currentArea * 4, 0)
|
||||||
|
@ -4910,8 +4911,7 @@ def patch_game():
|
||||||
value = World.patcher.get(target)
|
value = World.patcher.get(target)
|
||||||
patchedGame.seek(target)
|
patchedGame.seek(target)
|
||||||
patchedGame.write(value.to_bytes(1, 'little'))
|
patchedGame.write(value.to_bytes(1, 'little'))
|
||||||
finally:
|
|
||||||
pass
|
|
||||||
if Patch:
|
if Patch:
|
||||||
# FIXME: replace with internal patch creator
|
# FIXME: replace with internal patch creator
|
||||||
os.system('.\\flips\\flips.exe --create --bps "{}" ".\\seeds\\{}.gba"'.format(BaseGame, FileName))
|
os.system('.\\flips\\flips.exe --create --bps "{}" ".\\seeds\\{}.gba"'.format(BaseGame, FileName))
|
||||||
|
@ -4998,8 +4998,6 @@ def patch_game():
|
||||||
'Items': itemDict })
|
'Items': itemDict })
|
||||||
with open(os.path.join('.', 'spoilers', '{}.json'.format(FileName)), 'w') as spoiler:
|
with open(os.path.join('.', 'spoilers', '{}.json'.format(FileName)), 'w') as spoiler:
|
||||||
json.dump(spoilerLog, spoiler, indent=4)
|
json.dump(spoilerLog, spoiler, indent=4)
|
||||||
finally:
|
|
||||||
pass
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -5008,8 +5006,6 @@ def initialize():
|
||||||
HashList = list()
|
HashList = list()
|
||||||
with open(os.path.join('.', 'data', 'SeedHash.json')) as jsonFile:
|
with open(os.path.join('.', 'data', 'SeedHash.json')) as jsonFile:
|
||||||
HashList = json.load(jsonFile)
|
HashList = json.load(jsonFile)
|
||||||
finally:
|
|
||||||
pass
|
|
||||||
HashList.sort()
|
HashList.sort()
|
||||||
AreaOpen = list()
|
AreaOpen = list()
|
||||||
for area in range(0, 7):
|
for area in range(0, 7):
|
||||||
|
@ -5113,6 +5109,7 @@ def start_randomizer(rom, settings):
|
||||||
Difficulty = SeedSettings['Difficulty']
|
Difficulty = SeedSettings['Difficulty']
|
||||||
DamageRuns = SeedSettings['DamageRuns']
|
DamageRuns = SeedSettings['DamageRuns']
|
||||||
random.seed(SeedValue + str(SeedSettings))
|
random.seed(SeedValue + str(SeedSettings))
|
||||||
|
print('DEBUG: Calling Graph creation')
|
||||||
World = Graph.Game(BaseGame)
|
World = Graph.Game(BaseGame)
|
||||||
World.RemoveNodeFromRoom('Room-S2-07', 'S2-10')
|
World.RemoveNodeFromRoom('Room-S2-07', 'S2-10')
|
||||||
World.RemoveNodeFromRoom('Room-S2-0D', 'S2-1E')
|
World.RemoveNodeFromRoom('Room-S2-0D', 'S2-1E')
|
||||||
|
@ -5140,8 +5137,6 @@ def start_randomizer(rom, settings):
|
||||||
AreaItemLocations.append(list())
|
AreaItemLocations.append(list())
|
||||||
with open(os.path.join('.', 'data', 'NodeData.json')) as jsonFile:
|
with open(os.path.join('.', 'data', 'NodeData.json')) as jsonFile:
|
||||||
RoomNodes = json.load(jsonFile)
|
RoomNodes = json.load(jsonFile)
|
||||||
finally:
|
|
||||||
pass
|
|
||||||
for area in RoomNodes:
|
for area in RoomNodes:
|
||||||
areaIndex = list(RoomNodes.keys()).index(area)
|
areaIndex = list(RoomNodes.keys()).index(area)
|
||||||
for node in RoomNodes[area]:
|
for node in RoomNodes[area]:
|
||||||
|
|
Loading…
Reference in New Issue