untangle patch_game

master
magical 2024-02-03 01:25:28 -08:00
parent afde644b38
commit 707a7b70a1
1 changed files with 219 additions and 237 deletions

View File

@ -2646,8 +2646,7 @@ def patch_game():
for line in symFile:
x = line.split()
if len(x) > 1 and re.search('^[a-zA-Z]', x[1]):
sym.update({
x[1]: x[0][2:] })
sym.update({ x[1]: x[0][2:] })
os.remove(os.path.join('.', 'data', 'asm', 'temp.sym'))
roomEventOffset = int(sym.get('t_bossanddownloadevents'), 16)
itemEventOffset = int(sym.get('t_obtainitemevents'), 16)
@ -2655,6 +2654,7 @@ def patch_game():
print('roomEventOffset: 0x{:06X}'.format(roomEventOffset))
print('itemEventOffset: 0x{:06X}'.format(itemEventOffset))
print('securityOffset: 0x{:06X}'.format(securityOffset))
else:
roomEventOffset = 8326320
itemEventOffset = 5726112
securityOffset = 479192
@ -2729,6 +2729,7 @@ def patch_game():
blockValue += 1
clipValue = ItemList.index(itemName)
if clipValue < 2:
# Energy Tank or Missile Tank
clipValue = clipValue ^ 99
if 'Hidden' in nodeType:
clipValue += 2
@ -2774,11 +2775,13 @@ def patch_game():
roomEvent = roomEvent + 3 + (slot + 1)*4
patchedGame.seek(roomEvent)
patchedGame.write(itemValue.to_bytes(1, 'little'))
if itemName in MajorItems:
offset = CreditsOffsets.get(itemName)
if 'Boss' in nodeType:
location = name
elif 'S0' in name:
else:
if 'S0' in name:
location = 'Main Deck : '
else:
location = 'Sector {} : '.format(name[6:7])
@ -2830,6 +2833,7 @@ def patch_game():
doorData = unpacked[0] - 134217728
patchedGame.seek(doorData, 0)
doorNumber = 0
while True:
connectionType = int.from_bytes(patchedGame.read(1), 'little')
patchedGame.seek(5, 1)
offset = patchedGame.tell()
@ -2837,7 +2841,7 @@ def patch_game():
patchedGame.seek(5, 1)
resume = patchedGame.tell()
if connectionType == 0 and connectedDoor == 0:
continue
break
sourceDoor = 'S{}-{:02X}'.format(currentArea, doorNumber)
targetDoorStr = World.doorConnections.get(sourceDoor)
connectedArea = World.areaConnections.get(sourceDoor, currentArea)
@ -2855,7 +2859,6 @@ def patch_game():
if areaByte != targetArea:
patchedGame.seek(offset)
patchedGame.write(targetArea.to_bytes(1, 'little'))
continue
for target in World.patcher:
value = World.patcher.get(target)
patchedGame.seek(target)
@ -2875,6 +2878,7 @@ def patch_game():
iterable = diff_bytearrays(blocksize, sourcedata, targetdata)
write_bps(bps_progress(iterable), patch)
print('')
ItemNames = [
'Missile Data',
'Morph Ball',
@ -2896,65 +2900,43 @@ def patch_game():
'Ice Beam']
if SeedSettings['RaceSeed'] == False:
spoilerLog = dict()
spoilerLog.update({
'MFOR Version': version })
spoilerLog.update({
'Seed': SeedValue })
spoilerLog.update({ 'MFOR Version': version })
spoilerLog.update({ 'Seed': SeedValue })
settingsDict = dict()
settingsDict.update({
'Difficulty': SeedSettings['Difficulty'] })
settingsDict.update({ 'Difficulty': SeedSettings['Difficulty'] })
if SeedSettings['MajorMinor'] == False:
settingsDict.update({
'Item pool': 'Major items anywhere' })
settingsDict.update({ 'Item pool': 'Major items anywhere' })
else:
settingsDict.update({
'Item pool': 'Limited major item locations' })
settingsDict.update({
'Missile upgrades enable Missiles': SeedSettings['MissilesWithoutMainData'] })
settingsDict.update({
'Power Bombs without normal Bombs': SeedSettings['PowerBombsWithoutBombs'] })
settingsDict.update({
'Allow logical damage runs': SeedSettings['DamageRuns'] })
settingsDict.update({
'Separated security levels': SeedSettings['SplitSecurity'] })
settingsDict.update({
'Sector shuffle': SeedSettings['SectorShuffle'] })
settingsDict.update({ 'Item pool': 'Limited major item locations' })
settingsDict.update({ 'Missile upgrades enable Missiles': SeedSettings['MissilesWithoutMainData'] })
settingsDict.update({ 'Power Bombs without normal Bombs': SeedSettings['PowerBombsWithoutBombs'] })
settingsDict.update({ 'Allow logical damage runs': SeedSettings['DamageRuns'] })
settingsDict.update({ 'Separated security levels': SeedSettings['SplitSecurity'] })
settingsDict.update({ 'Sector shuffle': SeedSettings['SectorShuffle'] })
if SeedSettings['SectorShuffle'] == True:
sectorLayout = str()
for x in areaLayout:
sectorLayout = sectorLayout.strip() + ' {}'.format(x)
settingsDict.update({
'Sector layout:': sectorLayout })
settingsDict.update({
'Hide item graphics': SeedSettings['HideItems'] })
settingsDict.update({
'E-Tanks': PlacedETanks })
settingsDict.update({
'Missile Tanks': PlacedMissiles })
settingsDict.update({
'Power Bomb Tanks': PlacedPowerBombs })
spoilerLog.update({
'Settings': settingsDict })
settingsDict.update({ 'Sector layout:': sectorLayout })
settingsDict.update({ 'Hide item graphics': SeedSettings['HideItems'] })
settingsDict.update({ 'E-Tanks': PlacedETanks })
settingsDict.update({ 'Missile Tanks': PlacedMissiles })
settingsDict.update({ 'Power Bomb Tanks': PlacedPowerBombs })
spoilerLog.update({ 'Settings': settingsDict })
itemProgression = dict()
for x in range(len(PlacedItems)):
if PlacedItems[x] in MajorItems:
namedItem = ItemNames[MajorItems.index(PlacedItems[x])]
PlacedItems[x] = namedItem
itemProgression.update({
UsedLocations[x]: PlacedItems[x] })
continue
spoilerLog.update({
'Item order': itemProgression })
itemProgression.update({ UsedLocations[x]: PlacedItems[x] })
spoilerLog.update({ 'Item order': itemProgression })
itemDict = dict()
World.itemLocations.sort()
for x in range(0, len(World.itemLocations)):
itemDict.update({
World.itemLocations[x]: 0 })
itemDict.update({ World.itemLocations[x]: 0 })
for x in range(0, len(PlacedItems)):
itemDict.update({
UsedLocations[x]: PlacedItems[x] })
spoilerLog.update({
'Items': itemDict })
itemDict.update({ UsedLocations[x]: PlacedItems[x] })
spoilerLog.update({ 'Items': itemDict })
with open(os.path.join('.', 'spoilers', '{}.json'.format(FileName)), 'w') as spoiler:
json.dump(spoilerLog, spoiler, indent=4)