graphSettings = GraphSettings(args.startLocation, args.area, args.lightArea, args.bosses, args.escapeRando, minimizerN, dotFile, args.doorsColorsRando, args.allowGreyDoors, args.plandoRando["transitions"] if args.plandoRando != None else None) if args.plandoRando is None: DoorsManager.setDoorsColor() if not args.patchOnly: try: randoExec = RandoExec(seedName, args.vcr, randoSettings, graphSettings) (stuck, itemLocs, progItemLocs) = randoExec.randomize() # if we couldn't find an area layout then the escape graph is not created either # and getDoorConnections will crash if random escape is activated. if not stuck or args.vcr == True: doors = GraphUtils.getDoorConnections(randoExec.areaGraph, args.area, args.bosses, args.escapeRando if not stuck else False) escapeAttr = randoExec.areaGraph.EscapeAttributes if args.escapeRando else None if escapeAttr is not None: if "patches" not in escapeAttr: escapeAttr['patches'] = [] if args.noRemoveEscapeEnemies == True: escapeAttr['patches'].append("Escape_Rando_Enable_Enemies") if args.tourian == 'Disabled': escapeAttr['patches'].append('Escape_Trigger') if args.majorsSplit == 'Scavenger' and any(il for il in progItemLocs if il.Location.Name == "Ridley"): args.patches.append("Blinking[RidleyRoomIn]") except Exception as e: import traceback traceback.print_exc(file=sys.stdout) dumpErrorMsg(args.output, "Error: {}".format(e))
def savePlando(self, lock, escapeTimer): # store filled locations addresses in the ROM for next creating session from rando.Items import ItemManager locsItems = {} itemLocs = [] for loc in self.visitedLocations: locsItems[loc.Name] = loc.itemName for loc in self.locations: if loc.Name in locsItems: itemLocs.append( ItemLocation(ItemManager.getItem(loc.itemName), loc)) else: # put nothing items in unused locations itemLocs.append( ItemLocation(ItemManager.getItem("Nothing"), loc)) # patch the ROM if lock == True: import random magic = random.randint(1, 0xffff) else: magic = None romPatcher = RomPatcher(magic=magic, plando=True) patches = [ 'credits_varia.ips', 'tracking.ips', "Escape_Animals_Disable" ] if DoorsManager.isRandom(): patches += RomPatcher.IPSPatches['DoorsColors'] patches.append("Enable_Backup_Saves") if magic != None: patches.insert(0, 'race_mode.ips') patches.append('race_mode_credits.ips') romPatcher.addIPSPatches(patches) plms = [] if self.areaRando == True or self.bossRando == True or self.escapeRando == True: doors = GraphUtils.getDoorConnections( AccessGraph(Logic.accessPoints, self.fillGraph()), self.areaRando, self.bossRando, self.escapeRando, False) romPatcher.writeDoorConnections(doors) if magic == None: doorsPtrs = GraphUtils.getAps2DoorsPtrs() romPatcher.writePlandoTransitions( self.curGraphTransitions, doorsPtrs, len(vanillaBossesTransitions) + len(vanillaTransitions)) if self.escapeRando == True and escapeTimer != None: # convert from '03:00' to number of seconds escapeTimer = int(escapeTimer[0:2]) * 60 + int( escapeTimer[3:5]) romPatcher.applyEscapeAttributes( { 'Timer': escapeTimer, 'Animals': None }, plms) # write plm table & random doors romPatcher.writePlmTable(plms, self.areaRando, self.bossRando, self.startAP) romPatcher.writeItemsLocs(itemLocs) romPatcher.writeItemsNumber() romPatcher.writeSpoiler(itemLocs) # plando is considered Full romPatcher.writeSplitLocs(itemLocs, "Full") romPatcher.writeMajorsSplit("Full") class FakeRandoSettings: def __init__(self): self.qty = {'energy': 'plando'} self.progSpeed = 'plando' self.progDiff = 'plando' self.restrictions = {'Suits': False, 'Morph': 'plando'} self.superFun = {} randoSettings = FakeRandoSettings() romPatcher.writeRandoSettings(randoSettings, itemLocs) if magic != None: romPatcher.writeMagic() else: romPatcher.writePlandoAddresses(self.visitedLocations) romPatcher.commitIPS() romPatcher.end() data = romPatcher.romFile.data preset = os.path.splitext(os.path.basename(self.presetFileName))[0] seedCode = 'FX' if self.bossRando == True: seedCode = 'B' + seedCode if DoorsManager.isRandom(): seedCode = 'D' + seedCode if self.areaRando == True: seedCode = 'A' + seedCode from time import gmtime, strftime fileName = 'VARIA_Plandomizer_{}{}_{}.sfc'.format( seedCode, strftime("%Y%m%d%H%M%S", gmtime()), preset) data["fileName"] = fileName # error msg in json to be displayed by the web site data["errorMsg"] = "" with open(self.outputFileName, 'w') as jsonFile: json.dump(data, jsonFile)
minimizerN, dotFile, args.doorsColorsRando, args.allowGreyDoors, args.plandoRando["transitions"] if args.plandoRando != None else None) if args.plandoRando is None: DoorsManager.setDoorsColor() if args.patchOnly == False: try: randoExec = RandoExec(seedName, args.vcr, randoSettings, graphSettings) (stuck, itemLocs, progItemLocs) = randoExec.randomize() # if we couldn't find an area layout then the escape graph is not created either # and getDoorConnections will crash if random escape is activated. if not stuck or args.vcr == True: doors = GraphUtils.getDoorConnections(randoExec.areaGraph, args.area, args.bosses, args.escapeRando) escapeAttr = randoExec.areaGraph.EscapeAttributes if args.escapeRando else None except Exception as e: import traceback traceback.print_exc(file=sys.stdout) dumpErrorMsg(args.output, "Error: {}".format(e)) sys.exit(-1) else: stuck = False itemLocs = [] progItemLocs = None if stuck == True: dumpErrorMsg(args.output, randoExec.errorMsg) print("Can't generate " + fileName + " with the given parameters: {}".format(randoExec.errorMsg))