Merge pull request #2 from KevinCathcart/Dev

Dev
This commit is contained in:
AmazingAmpharos 2017-11-24 18:42:58 -06:00 committed by GitHub
commit 595e2a20b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 367 additions and 566 deletions

View File

@ -232,7 +232,7 @@ class World(object):
goal = ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals'].index(self.goal)
shuffle = ['vanilla', 'simple', 'restricted', 'full', 'madness', 'insanity', 'dungeonsfull', 'dungeonssimple'].index(self.shuffle)
difficulty = ['easy', 'normal', 'hard', 'expert', 'insane'].index(self.difficulty)
timer = ['none', 'display', 'timed', 'timed-ohko', 'timed-countdown'].index(self.timer)
timer = ['none', 'display', 'timed', 'timed-ohko', 'timed-countdown','ohko'].index(self.timer)
progressive = ['on', 'off', 'random'].index(self.progressive)
algorithm = ['freshness', 'flood', 'vt21', 'vt22', 'vt25', 'vt26', 'balanced'].index(self.algorithm)
beatableonly = 1 if self.check_beatable_only else 0
@ -337,7 +337,7 @@ class CollectionState(object):
return self.has('Power Glove') or self.has('Titans Mitts')
def has_bottle(self):
return self.has('Bottle') or self.has('BottleRedPotion') or self.has('BottleGreenPotion') or self.has('BottleBluePotion') or self.has('BottleFairy') or self.has('BottleBee') or self.has('BottleGoodBee')
return self.has('Bottle') or self.has('Bottle (Red Potion)') or self.has('Bottle (Green Potion)') or self.has('Bottle (Blue Potion)') or self.has('Bottle (Fairy)') or self.has('Bottle (Bee)') or self.has('Bottle (Good Bee)')
def can_lift_heavy_rocks(self):
return self.has('Titans Mitts')

View File

@ -3,6 +3,7 @@ import os
import logging
import random
import textwrap
import sys
from Main import main
from Gui import guiMain
@ -60,7 +61,7 @@ if __name__ == '__main__':
Expert: A harder yet setting with minimum equipment and health.
Insane: A setting with the absolute minimum in equipment and no extra health.
''')
parser.add_argument('--timer', default='none', const='normal', nargs='?', choices=['none', 'display', 'timed', 'timed-ohko', 'timed-countdown'],
parser.add_argument('--timer', default='none', const='normal', nargs='?', choices=['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'],
help='''\
Select game timer setting. Affects available itempool. (default: %(default)s)
None: No timer.
@ -74,6 +75,8 @@ if __name__ == '__main__':
Timed OHKO: Starts clock at 10 minutes. Green Clocks add
5 minutes (Total: 25). As long as clock is at 0,
Link will die in one hit.
OHKO: Like Timed OHKO, but no clock items are present
and the clock is permenantly at zero.
Timed Countdown: Starts with clock at 40 minutes. Same clocks as
Timed mode. If time runs out, you lose (but can
still keep playing).
@ -189,11 +192,11 @@ if __name__ == '__main__':
# ToDo: Validate files further than mere existance
if not args.jsonout and not os.path.isfile(args.rom):
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
exit(1)
sys.exit(1)
if args.sprite is not None and not os.path.isfile(args.sprite):
if not args.jsonout:
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
exit(1)
sys.exit(1)
else:
raise IOError('Cannot find sprite file at %s' % args.sprite)

2
Gui.py
View File

@ -113,7 +113,7 @@ def guiMain(args=None):
timerFrame = Frame(drowDownFrame)
timerVar = StringVar()
timerVar.set('none')
timerOptionMenu = OptionMenu(timerFrame, timerVar, 'none', 'display', 'timed', 'timed-ohko', 'timed-countdown')
timerOptionMenu = OptionMenu(timerFrame, timerVar, 'none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown')
timerOptionMenu.pack(side=RIGHT)
timerLabel = Label(timerFrame, text='Timer setting')
timerLabel.pack(side=LEFT)

View File

@ -1,5 +1,6 @@
from Items import ItemFactory
from Fill import fill_restrictive
from collections import namedtuple
import random
#This file sets the item pools for various modes. Timed modes and triforce hunt are enforced first, and then extra items are specified per mode to fill in the remaining space.
@ -10,8 +11,8 @@ alwaysitems = ['Bombos', 'Book of Mudora', 'Bow', 'Cane of Somaria', 'Ether', 'F
progressivegloves = ['Progressive Glove'] * 2
basicgloves = ['Power Glove', 'Titans Mitts']
normalbottles = ['Bottle', 'BottleRedPotion', 'BottleGreenPotion', 'BottleBluePotion', 'BottleFairy', 'BottleBee', 'BottleGoodBee']
hardbottles = ['Bottle', 'BottleRedPotion', 'BottleGreenPotion', 'BottleBluePotion', 'BottleBee', 'BottleGoodBee']
normalbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bottle (Blue Potion)', 'Bottle (Fairy)', 'Bottle (Bee)', 'Bottle (Good Bee)']
hardbottles = ['Bottle', 'Bottle (Red Potion)', 'Bottle (Green Potion)', 'Bottle (Blue Potion)', 'Bottle (Bee)', 'Bottle (Good Bee)']
normalbaseitems = (['Blue Boomerang', 'Red Boomerang', 'Silver Arrows', 'Magic Upgrade (1/2)'] + ['Rupees (300)'] * 4 +
['Single Arrow', 'Sanctuary Heart Container', 'Arrow Upgrade (+10)', 'Bomb Upgrade (+10)'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 24)
@ -20,36 +21,17 @@ normalsecond15extra = ['Bombs (3)'] * 10 + ['Rupees (50)'] * 2 + ['Arrows (10)']
normalthird10extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 3 + ['Arrows (10)', 'Rupee (1)', 'Rupees (5)']
normalfourth5extra = ['Arrows (10)'] * 2 + ['Rupees (20)'] * 2 + ['Rupees (5)']
normalfinal25extra = ['Rupees (20)'] * 23 + ['Rupees (5)'] * 2
normaltimedohko = ['Green Clock'] * 25
normaltimedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10
normaltriforcehunt = ['Triforce Piece'] * 30
normalprogressivesword = ['Progressive Sword'] * 3
normalbasicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword']
normalswordless = ['Rupees (20)'] * 4
normalprogressiveshield = ['Progressive Shield'] * 3
normalbasicshield = ['Blue Shield', 'Red Shield', 'Mirror Shield']
normalprogressivearmor = ['Progressive Armor'] * 2
normalbasicarmor = ['Blue Mail', 'Red Mail']
easybaseitems = (['Blue Boomerang', 'Red Boomerang', 'Silver Arrows'] + ['Rupees (300)'] * 4 + ['Magic Upgrade (1/2)'] * 2 +
['Single Arrow', 'Sanctuary Heart Container', 'Arrow Upgrade (+10)', 'Bomb Upgrade (+10)'] + ['Boss Heart Container'] * 10 + ['Piece of Heart'] * 12)
easyextra = ['Piece of Heart'] * 12 + ['Rupees (300)']
easylimitedextra = ['Boss Heart Container'] * 3
easylimitedextra = ['Boss Heart Container'] * 3 # collapsing down the 12 peices of heart
easyfirst15extra = ['Rupees (100)'] + ['Rupees (50)'] + ['Arrow Upgrade (+5)'] * 6 + ['Bomb Upgrade (+5)'] * 6 + ['Bombs (3)']
easysecond10extra = ['Bombs (3)'] * 9 + ['Rupee (1)']
easythird5extra = ['Rupees (50)'] * 2 + ['Arrows (10)'] * 2 + ['Rupees (5)']
easyfinal25extra = ['Rupees (50)'] * 4 + ['Rupees (20)'] * 14 + ['Rupee (1)'] + ['Arrows (10)'] * 3 + ['Rupees (5)'] * 3
easytimedohko = ['Green Clock'] * 25
easytimedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 5
easytimedotherextra = ['Red Clock'] * 5
easytriforcehunt = ['Triforce Piece'] * 30
easyprogressivesword = ['Progressive Sword'] * 7
easybasicsword = ['Fighter Sword', 'Master Sword', 'Master Sword', 'Tempered Sword', 'Tempered Sword', 'Golden Sword', 'Golden Sword']
easyswordless = ['Rupees (20)'] * 8
easyprogressiveshield = ['Progressive Shield'] * 6
easybasicshield = ['Blue Shield', 'Blue Shield', 'Red Shield', 'Red Shield', 'Mirror Shield', 'Mirror Shield']
easyprogressivearmor = ['Progressive Armor'] * 4
easybasicarmor = ['Blue Mail', 'Blue Mail', 'Red Mail', 'Red Mail']
hardbaseitems = (['Silver Arrows', 'Single Arrow'] + ['Rupees (300)'] + ['Rupees (100)'] * 2 + ['Rupees (50)'] + ['Bombs (3)'] +
['Boss Heart Container'] * 5 + ['Piece of Heart'] * 24)
@ -57,15 +39,6 @@ hardfirst20extra = ['Bombs (3)'] * 4 + ['Single Bomb'] * 4 + ['Rupees (5)'] * 5
hardsecond20extra = ['Single Bomb'] * 4 + ['Rupees (5)'] * 10 + ['Rupees (20)'] * 2 + ['Rupee (1)'] * 3 + ['Arrows (10)']
hardthird20extra = ['Arrows (10)'] * 4 + ['Rupees (20)'] * 3 + ['Rupees (5)'] * 3 + ['Single Bomb'] * 5 + ['Single Arrow'] * 5
hardfinal20extra = ['Single Bomb'] * 4 + ['Rupees (5)'] * 2 + ['Single Arrow'] * 14
hardtimedohko = ['Green Clock'] * 20
hardtimedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10
hardtriforcehunt = ['Triforce Piece'] * 40
hardprogressivesword = ['Progressive Sword'] * 3
hardbasicsword = ['Master Sword', 'Master Sword', 'Tempered Sword']
hardswordless = ['Rupees (20)'] * 4
hardprogressiveshield = ['Progressive Shield'] * 3
hardbasicshield = ['Blue Shield', 'Red Shield', 'Red Shield']
hardarmor = ['Progressive Armor', 'Progressive Armor']
expertbaseitems = (['Single Arrow', 'Rupees (300)', 'Rupees (100)', 'Bombs (3)', 'Arrows (10)'] + ['Rupees (50)'] * 4 + ['Rupees (5)'] * 5 +
['Rupees (20)'] + ['Single Bomb'] * 2 + ['Piece of Heart'] * 24)
@ -73,12 +46,6 @@ expertfirst15extra = ['Single Bomb'] * 13 + ['Rupees (20)'] * 2
expertsecond25extra = ['Single Bomb'] * 8 + ['Single Arrow'] * 9 + ['Rupees (20)'] * 3 + ['Rupee (1)'] * 5
expertthird15extra = ['Rupees (5)'] * 5 + ['Single Bomb'] * 3 + ['Rupees (20)'] * 2 + ['Single Arrow'] * 5
expertfinal25extra = ['Single Bomb'] * 4 + ['Rupees (20)'] * 3 + ['Single Arrow'] * 18
experttimedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5
experttimedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10
experttriforcehunt = ['Triforce Piece'] * 40
expertprogressivesword = ['Progressive Sword'] * 3
expertbasicsword = ['Fighter Sword', 'Master Sword', 'Master Sword']
expertswordless = ['Rupees (20)'] * 3 + ['Silver Arrows']
insanebaseitems = (['Single Arrow', 'Bombs (3)', 'Arrows (10)'] + ['Rupees (50)'] * 3 + ['Rupees (5)'] * 10 + ['Rupees (300)'] * 4 + ['Rupees (100)'] * 3 +
['Rupee (1)'] * 4 + ['Single Bomb'] * 4)
@ -87,16 +54,131 @@ insanesecond25extra = ['Single Bomb'] * 7 + ['Single Arrow'] * 7 + ['Rupee (1)']
insanethird10extra = ['Single Bomb'] * 3 + ['Single Arrow'] * 3 + ['Rupee (1)'] * 3 + ['Rupees (20)']
insanefourth15extra = ['Single Bomb'] * 5 + ['Single Arrow'] * 5 + ['Rupee (1)'] * 5
insanefinal25extra = ['Single Bomb'] * 2 + ['Single Arrow'] * 10 + ['Rupee (1)'] * 7 + ['Rupees (20)'] * 6
insanetimedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5
insanetimedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10
insanetriforcehunt = ['Triforce Piece'] * 50
insaneprogressivesword = ['Progressive Sword'] * 3
insanebasicsword = ['Fighter Sword', 'Master Sword', 'Master Sword']
insaneswordless = ['Rupees (20)'] * 3 + ['Silver Arrows']
Difficulty = namedtuple('Difficulty',
['baseitems', 'bottles', 'bottle_count','same_bottle', 'progressiveshield',
'basicshield', 'progressivearmor', 'basicarmor', 'swordless',
'progressivesword', 'basicsword', 'timedohko', 'timedother',
'triforcehunt', 'triforce_pieces_required', 'conditional_extras',
'extras'])
TotalItemsToPlace = 153
def easy_conditional_extras(timer, goal, mode, pool, placed_items):
extraitems = TotalItemsToPlace - len(pool) - len(placed_items)
if extraitems < len(easyextra):
return easylimitedextra
if timer in ['timed', 'timed-countdown']:
return easytimedotherextra
return []
def no_conditonal_extras(*args):
return []
#def Difficulty(**kwargs):
# protodifficulty._replace(**kwargs)
difficulties= {
'normal': Difficulty(
baseitems = normalbaseitems,
bottles = normalbottles,
bottle_count = 4,
same_bottle = False,
progressiveshield = ['Progressive Shield'] * 3,
basicshield = ['Blue Shield', 'Red Shield', 'Mirror Shield'],
progressivearmor = ['Progressive Armor'] * 2,
basicarmor = ['Blue Mail', 'Red Mail'],
swordless = ['Rupees (20)'] * 4,
progressivesword = ['Progressive Sword'] * 3,
basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'],
timedohko = ['Green Clock'] * 25,
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10,
triforcehunt = ['Triforce Piece'] * 30,
triforce_pieces_required = 20,
conditional_extras = no_conditonal_extras,
extras = [normalfirst15extra,normalsecond15extra,normalthird10extra,normalfourth5extra,normalfinal25extra]
),
'easy': Difficulty(
baseitems = easybaseitems,
bottles = normalbottles,
bottle_count = 8,
same_bottle = False,
progressiveshield = ['Progressive Shield'] * 6,
basicshield = ['Blue Shield', 'Red Shield', 'Mirror Shield'] * 2,
progressivearmor = ['Progressive Armor'] * 4,
basicarmor = ['Blue Mail', 'Red Mail'] * 2,
swordless = ['Rupees (20)'] * 8,
progressivesword = ['Progressive Sword'] * 7,
basicsword = ['Master Sword', 'Tempered Sword', 'Golden Sword'] *2 + ['Fighter Sword'],
timedohko = ['Green Clock'] * 25,
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 5, # +5 more Red Clocks if there is room
triforcehunt = ['Triforce Piece'] * 30,
triforce_pieces_required = 10,
conditional_extras = easy_conditional_extras,
extras = [easyextra, easyfirst15extra, easysecond10extra, easythird5extra, easyfinal25extra],
),
'hard': Difficulty(
baseitems = hardbaseitems,
bottles = hardbottles,
bottle_count = 4,
same_bottle = False,
progressiveshield = ['Progressive Shield'] * 3,
basicshield = ['Blue Shield', 'Red Shield', 'Red Shield'],
progressivearmor = ['Progressive Armor'] * 2,
basicarmor = ['Progressive Armor'] * 2, #only the first one will upgrade, making this equivlent to two blue mail
swordless = ['Rupees (20)'] * 4,
progressivesword = ['Progressive Sword'] * 3,
basicsword = ['Master Sword', 'Master Sword', 'Tempered Sword'],
timedohko = ['Green Clock'] * 20,
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10,
triforcehunt = ['Triforce Piece'] * 40,
triforce_pieces_required = 30,
conditional_extras = no_conditonal_extras,
extras = [hardfirst20extra, hardsecond20extra, hardthird20extra, hardfinal20extra],
),
'expert': Difficulty(
baseitems = expertbaseitems,
bottles = hardbottles,
bottle_count = 4,
same_bottle = True,
progressiveshield = [],
basicshield = [],
progressivearmor = [],
basicarmor = [],
swordless = ['Rupees (20)'] * 3 + ['Silver Arrows'],
progressivesword = ['Progressive Sword'] * 3,
basicsword = ['Fighter Sword', 'Master Sword', 'Master Sword'],
timedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5,
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10,
triforcehunt = ['Triforce Piece'] * 40,
triforce_pieces_required = 40,
conditional_extras = no_conditonal_extras,
extras = [expertfirst15extra, expertsecond25extra, expertthird15extra, expertfinal25extra],
),
'insane': Difficulty(
baseitems = insanebaseitems,
bottles = hardbottles,
bottle_count = 4,
same_bottle = True,
progressiveshield = [],
basicshield = [],
progressivearmor = [],
basicarmor = [],
swordless = ['Rupees (20)'] * 3 + ['Silver Arrows'],
progressivesword = ['Progressive Sword'] * 3,
basicsword = ['Fighter Sword', 'Master Sword', 'Master Sword'],
timedohko = ['Green Clock'] * 20 + ['Red Clock'] * 5,
timedother = ['Green Clock'] * 20 + ['Blue Clock'] * 10 + ['Red Clock'] * 10,
triforcehunt = ['Triforce Piece'] * 50,
triforce_pieces_required = 50,
conditional_extras = no_conditonal_extras,
extras = [insanefirst15extra, insanesecond25extra, insanethird10extra, insanefourth15extra, insanefinal25extra],
),
}
def generate_itempool(world):
if (world.difficulty not in ['easy', 'normal', 'hard', 'expert', 'insane'] or world.goal not in ['ganon', 'pedestal', 'dungeons', 'triforcehunt', 'crystals']
or world.mode not in ['open', 'standard', 'swordless'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']):
or world.mode not in ['open', 'standard', 'swordless'] or world.timer not in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown'] or world.progressive not in ['on', 'off', 'random']):
raise NotImplementedError('Not supported yet')
world.push_item('Ganon', ItemFactory('Triforce'), False)
@ -107,431 +189,17 @@ def generate_itempool(world):
world.get_location('Agahnim 2').event = True
# set up item pool
world.itempool = ItemFactory(alwaysitems)
if world.progressive == 'on':
world.itempool.extend(ItemFactory(progressivegloves))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(basicgloves))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(progressivegloves))
else:
world.itempool.extend(ItemFactory(basicgloves))
# insanity shuffle doesn't have fake LW/DW logic so for now guaranteed Mirror and Moon Pearl at the start
if world.shuffle == 'insanity':
world.push_item('Link\'s House', ItemFactory('Magic Mirror'), False)
world.get_location('Link\'s House').event = True
world.push_item('Sanctuary', ItemFactory('Moon Pearl'), False)
world.get_location('Sanctuary').event = True
else:
world.itempool.extend(ItemFactory(['Magic Mirror', 'Moon Pearl']))
if world.timer == 'display':
world.clock_mode = 'stopwatch'
if world.difficulty == 'normal':
world.itempool.extend(ItemFactory(normalbaseitems))
for i in range (0, 4):
thisbottle = normalbottles[random.randint(0, 6)]
world.itempool.append(ItemFactory(thisbottle))
extraitems = 70
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(normaltimedother))
extraitems = extraitems - 40
world.clock_mode = 'stopwatch' if world.timer == 'timed' else 'countdown'
elif world.timer == 'timed-ohko':
world.itempool.extend(ItemFactory(normaltimedohko))
extraitems = extraitems - 25
world.clock_mode = 'ohko'
if world.goal == 'triforcehunt':
world.itempool.extend(ItemFactory(normaltriforcehunt))
extraitems = extraitems - 30
world.treasure_hunt_count = 20
world.treasure_hunt_icon = 'Triforce Piece'
if extraitems > 0:
world.itempool.extend(ItemFactory(normalfirst15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(normalsecond15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(normalthird10extra))
extraitems = extraitems - 10
if extraitems > 0:
world.itempool.extend(ItemFactory(normalfourth5extra))
extraitems = extraitems - 5
if extraitems > 0:
world.itempool.extend(ItemFactory(normalfinal25extra))
extraitems = extraitems - 25
if world.progressive == 'on':
world.itempool.extend(ItemFactory(normalprogressiveshield))
world.itempool.extend(ItemFactory(normalprogressivearmor))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(normalbasicshield))
world.itempool.extend(ItemFactory(normalbasicarmor))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(normalprogressiveshield))
else:
world.itempool.extend(ItemFactory(normalbasicshield))
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(normalprogressivearmor))
else:
world.itempool.extend(ItemFactory(normalbasicarmor))
if world.mode == 'swordless':
world.itempool.extend(ItemFactory(normalswordless))
elif world.mode == 'standard':
if world.progressive == 'on':
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(normalprogressivesword))
elif world.progressive == 'off':
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(normalbasicsword))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(normalprogressivesword))
else:
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(normalbasicsword))
else:
if world.progressive == 'on':
world.itempool.extend(ItemFactory(normalprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(normalbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(normalprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
else:
world.itempool.extend(ItemFactory(normalbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
elif world.difficulty == 'easy':
world.itempool.extend(ItemFactory(easybaseitems))
for i in range (0, 8):
thisbottle = normalbottles[random.randint(0, 6)]
world.itempool.append(ItemFactory(thisbottle))
extraitems = 70
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(easytimedother))
extraitems = extraitems - 40
world.clock_mode = 'stopwatch' if world.timer == 'timed' else 'countdown'
elif world.timer == 'timed-ohko':
world.itempool.extend(ItemFactory(easytimedohko))
extraitems = extraitems - 25
world.clock_mode = 'ohko'
if world.goal == 'triforcehunt':
world.itempool.extend(ItemFactory(easytriforcehunt))
extraitems = extraitems - 30
world.treasure_hunt_count = 10
world.treasure_hunt_icon = 'Triforce Piece'
if extraitems == 0:
world.itempool.extend(ItemFactory(easylimitedextra))
else:
world.itempool.extend(ItemFactory(easyextra))
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(easytimedotherextra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(easyfirst15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(easysecond10extra))
extraitems = extraitems - 10
if extraitems > 0:
world.itempool.extend(ItemFactory(easythird5extra))
extraitems = extraitems - 5
if extraitems > 0:
world.itempool.extend(ItemFactory(easyfinal25extra))
extraitems = extraitems - 25
if world.progressive == 'on':
world.itempool.extend(ItemFactory(easyprogressiveshield))
world.itempool.extend(ItemFactory(easyprogressivearmor))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(easybasicshield))
world.itempool.extend(ItemFactory(easybasicarmor))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(easyprogressiveshield))
else:
world.itempool.extend(ItemFactory(easybasicshield))
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(easyprogressivearmor))
else:
world.itempool.extend(ItemFactory(easybasicarmor))
if world.mode == 'swordless':
world.itempool.extend(ItemFactory(easyswordless))
elif world.mode == 'standard':
if world.progressive == 'on':
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(easyprogressivesword))
elif world.progressive == 'off':
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(easybasicsword))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(easyprogressivesword))
else:
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(easybasicsword))
else:
if world.progressive == 'on':
world.itempool.extend(ItemFactory(easyprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(easybasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(easyprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
else:
world.itempool.extend(ItemFactory(easybasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
elif world.difficulty == 'hard':
world.itempool.extend(ItemFactory(hardbaseitems))
for i in range (0, 4):
thisbottle = hardbottles[random.randint(0, 5)]
world.itempool.append(ItemFactory(thisbottle))
extraitems = 80
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(hardtimedother))
extraitems = extraitems - 40
world.clock_mode = 'stopwatch' if world.timer == 'timed' else 'countdown'
elif world.timer == 'timed-ohko':
world.itempool.extend(ItemFactory(hardtimedohko))
extraitems = extraitems - 25
world.clock_mode = 'ohko'
if world.goal == 'triforcehunt':
world.itempool.extend(ItemFactory(hardtriforcehunt))
extraitems = extraitems - 40
world.treasure_hunt_count = 30
world.treasure_hunt_icon = 'Triforce Piece'
if extraitems > 0:
world.itempool.extend(ItemFactory(hardfirst20extra))
extraitems = extraitems - 20
if extraitems > 0:
world.itempool.extend(ItemFactory(hardsecond20extra))
extraitems = extraitems - 20
if extraitems > 0:
world.itempool.extend(ItemFactory(hardthird20extra))
extraitems = extraitems - 20
if extraitems > 0:
world.itempool.extend(ItemFactory(hardfinal20extra))
extraitems = extraitems - 20
world.itempool.extend(ItemFactory(hardarmor))
if world.progressive == 'on':
world.itempool.extend(ItemFactory(hardprogressiveshield))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(hardbasicshield))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(hardprogressiveshield))
else:
world.itempool.extend(ItemFactory(hardbasicshield))
if world.mode == 'swordless':
world.itempool.extend(ItemFactory(hardswordless))
elif world.mode == 'standard':
if world.progressive == 'on':
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(hardprogressivesword))
elif world.progressive == 'off':
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(hardbasicsword))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(hardprogressivesword))
else:
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(hardbasicsword))
else:
if world.progressive == 'on':
world.itempool.extend(ItemFactory(hardprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(hardbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(hardprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
else:
world.itempool.extend(ItemFactory(hardbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
elif world.difficulty == 'expert':
world.itempool.extend(ItemFactory(expertbaseitems))
thisbottle = hardbottles[random.randint(0, 5)]
for i in range (0, 4):
world.itempool.append(ItemFactory(thisbottle))
extraitems = 80
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(experttimedother))
extraitems = extraitems - 40
world.clock_mode = 'stopwatch' if world.timer == 'timed' else 'countdown'
elif world.timer == 'timed-ohko':
world.itempool.extend(ItemFactory(experttimedohko))
extraitems = extraitems - 25
world.clock_mode = 'ohko'
if world.goal == 'triforcehunt':
world.itempool.extend(ItemFactory(experttriforcehunt))
extraitems = extraitems - 40
world.treasure_hunt_count = 40
world.treasure_hunt_icon = 'Triforce Piece'
if extraitems > 0:
world.itempool.extend(ItemFactory(expertfirst15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(expertsecond25extra))
extraitems = extraitems - 25
if extraitems > 0:
world.itempool.extend(ItemFactory(expertthird15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(expertfinal25extra))
extraitems = extraitems - 25
if world.mode == 'swordless':
world.itempool.extend(ItemFactory(expertswordless))
elif world.mode == 'standard':
if world.progressive == 'on':
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(expertprogressivesword))
elif world.progressive == 'off':
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(expertbasicsword))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(expertprogressivesword))
else:
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(expertbasicsword))
else:
if world.progressive == 'on':
world.itempool.extend(ItemFactory(expertprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(expertbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(expertprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
else:
world.itempool.extend(ItemFactory(expertbasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
elif world.difficulty == 'insane':
world.itempool.extend(ItemFactory(insanebaseitems))
thisbottle = hardbottles[random.randint(0, 5)]
for i in range (0, 4):
world.itempool.append(ItemFactory(thisbottle))
extraitems = 90
if world.timer in ['timed', 'timed-countdown']:
world.itempool.extend(ItemFactory(insanetimedother))
extraitems = extraitems - 40
world.clock_mode = 'stopwatch' if world.timer == 'timed' else 'countdown'
elif world.timer == 'timed-ohko':
world.itempool.extend(ItemFactory(insanetimedohko))
extraitems = extraitems - 25
world.clock_mode = 'ohko'
if world.goal == 'triforcehunt':
world.itempool.extend(ItemFactory(insanetriforcehunt))
extraitems = extraitems - 50
world.treasure_hunt_count = 50
world.treasure_hunt_icon = 'Triforce Piece'
if extraitems > 0:
world.itempool.extend(ItemFactory(insanefirst15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(insanesecond25extra))
extraitems = extraitems - 25
if extraitems > 0:
world.itempool.extend(ItemFactory(insanethird10extra))
extraitems = extraitems - 10
if extraitems > 0:
world.itempool.extend(ItemFactory(insanefourth15extra))
extraitems = extraitems - 15
if extraitems > 0:
world.itempool.extend(ItemFactory(insanefinal25extra))
extraitems = extraitems - 25
if world.mode == 'swordless':
world.itempool.extend(ItemFactory(insaneswordless))
elif world.mode == 'standard':
if world.progressive == 'on':
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(insaneprogressivesword))
elif world.progressive == 'off':
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(insanebasicsword))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.push_item('Link\'s Uncle', ItemFactory('Progressive Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(insaneprogressivesword))
else:
world.push_item('Link\'s Uncle', ItemFactory('Fighter Sword'), False)
world.get_location('Link\'s Uncle').event = True
world.itempool.extend(ItemFactory(insanebasicsword))
else:
if world.progressive == 'on':
world.itempool.extend(ItemFactory(insaneprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
elif world.progressive == 'off':
world.itempool.extend(ItemFactory(insanebasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
else:
randvalue = random.randint(0, 1)
if (randvalue == 0):
world.itempool.extend(ItemFactory(insaneprogressivesword))
world.itempool.extend(ItemFactory(['Progressive Sword']))
else:
world.itempool.extend(ItemFactory(insanebasicsword))
world.itempool.extend(ItemFactory(['Fighter Sword']))
if world.goal == 'pedestal':
world.push_item('Master Sword Pedestal', ItemFactory('Triforce'), False)
world.get_location('Master Sword Pedestal').event = True
(pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon) = get_pool_core(world.progressive, world.shuffle, world.difficulty, world.timer, world.goal, world.mode)
world.itempool = ItemFactory(pool)
for (location, item) in placed_items:
world.push_item(location, ItemFactory(item), False)
world.get_location(location).event = True
if clock_mode is not None:
world.clock_mode = clock_mode
if treasure_hunt_count is not None:
world.treasure_hunt_count = treasure_hunt_count
if treasure_hunt_icon is not None:
wrold.treasure_hunt_icon = treasure_hunt_icon
# shuffle medallions
mm_medallion = ['Ether', 'Quake', 'Bombos'][random.randint(0, 2)]
@ -547,3 +215,119 @@ def generate_itempool(world):
random.shuffle(crystal_locations)
fill_restrictive(world, world.get_all_state(keys=True), crystal_locations, crystals)
def get_pool_core(progressive,shuffle,difficulty,timer, goal, mode):
pool=[]
placed_items=[]
clock_mode=None
treasure_hunt_count=None
treasure_hunt_icon=None
pool.extend(alwaysitems)
def wantProgressives():
return random.choice([True, False]) if progressive == 'random' else progressive=='on'
if wantProgressives():
pool.extend(progressivegloves)
else:
pool.extend(basicgloves)
# insanity shuffle doesn't have fake LW/DW logic so for now guaranteed Mirror and Moon Pearl at the start
if shuffle == 'insanity':
placed_items.append(('Link\'s House', 'Magic Mirror'))
placed_items.append(('Sanctuary', 'Moon Pearl'))
else:
pool.extend(['Magic Mirror', 'Moon Pearl'])
if timer == 'display':
clock_mode = 'stopwatch'
elif timer == 'ohko':
clock_mode = 'ohko'
diff = difficulties[difficulty]
pool.extend(diff.baseitems)
# expert+ difficulties produce the same contents for
# all bottles, since only one bottle is available
if diff.same_bottle:
thisbottle = random.choice(diff.bottles)
for i in range (diff.bottle_count):
if not diff.same_bottle:
thisbottle = random.choice(diff.bottles)
pool.append(thisbottle)
if wantProgressives():
pool.extend(diff.progressiveshield)
else:
pool.extend(diff.basicshield)
if wantProgressives():
pool.extend(diff.progressivearmor)
else:
pool.extend(diff.basicarmor)
if mode == 'swordless':
pool.extend(diff.swordless)
elif mode == 'standard':
if wantProgressives():
placed_items.append(('Link\'s Uncle', 'Progressive Sword'))
pool.extend(diff.progressivesword)
else:
placed_items.append(('Link\'s Uncle', 'Fighter Sword'))
pool.extend(diff.basicsword)
else:
if wantProgressives():
pool.extend(diff.progressivesword)
pool.extend(['Progressive Sword'])
else:
pool.extend(diff.basicsword)
pool.extend(['Fighter Sword'])
extraitems = TotalItemsToPlace - len(pool) - len(placed_items)
if timer in ['timed', 'timed-countdown']:
pool.extend(diff.timedother)
extraitems -= len(diff.timedother)
clock_mode = 'stopwatch' if timer == 'timed' else 'countdown'
elif timer == 'timed-ohko':
pool.extend(diff.timedohko)
extraitems -= len(diff.timedohko)
clock_mode = 'countdown-ohko'
if goal == 'triforcehunt':
pool.extend(diff.triforcehunt)
extraitems -= len(diff.triforcehunt)
treasure_hunt_count = diff.triforce_pieces_required
treasure_hunt_icon = 'Triforce Piece'
cond_extras = diff.conditional_extras(timer, goal, mode, pool, placed_items)
pool.extend(cond_extras)
extraitems -= len(cond_extras)
for extra in diff.extras:
if(extraitems > 0):
pool.extend(extra )
extraitems -= len(extra)
if goal == 'pedestal':
placed_items.append(('Master Sword Pedestal', 'Triforce'))
return (pool, placed_items, clock_mode, treasure_hunt_count, treasure_hunt_icon)
# A quick test to ensure all combinations generate the correct amount of items.
if __name__ == '__main__':
for difficulty in ['easy', 'normal', 'hard', 'expert', 'insane']:
for goal in ['ganon', 'triforcehunt', 'pedestal']:
for timer in ['none', 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown']:
for mode in ['open', 'standard', 'swordless']:
for progressive in ['on','off']:
for shuffle in ['full','insane']:
out = get_pool_core(progressive, shuffle, difficulty, timer, goal, mode)
count = len(out[0]) + len(out[1])
correct_count = TotalItemsToPlace
if goal in ['pedestal']:
# pedestal goals generate one extra item
correct_count += 1
assert count == correct_count, "expected {0} items but found {1} items for {2}".format(correct_count, count, (progressive, shuffle, difficulty, timer, goal, mode))

View File

@ -47,12 +47,12 @@ item_table = {'Bow': (True, False, None, 0x0B, 'You have\nchosen the\narcher cla
'Bombos': (True, False, None, 0x0F, 'Burn, baby,\nburn! Fear my\nring of fire!', 'and the swirly coin', 'coin-collecting kid', 'swirly coin for sale', 'shrooms for swirly-coin', 'boy hides coin again'),
'Quake': (True, False, None, 0x11, 'Maxing out the\nRichter scale\nis what I do!', 'and the wavy coin', 'coin-collecting kid', 'wavy coin for sale', 'shrooms for wavy-coin', 'boy hides coin again'),
'Bottle': (True, False, None, 0x16, 'Now you can\nstore potions\nand stuff!', 'and the terrarium', 'the terrarium kid', 'terrarium for sale', 'special promotion', 'boy stores things again'),
'BottleRedPotion': (True, False, None, 0x2B, 'Hearty red goop!', 'and the red goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy drinks again'),
'BottleGreenPotion': (True, False, None, 0x2C, 'Refreshing green goop!', 'and the green goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy drinks again'),
'BottleBluePotion': (True, False, None, 0x2D, 'Delicious blue goop!', 'and the blue goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy stores drinks again'),
'BottleFairy': (True, False, None, 0x3D, 'Save me and I will revive you', 'and the captive', 'the tingle kid', 'hostage for sale', 'fairy dust and shrooms', 'boy revives again'),
'BottleBee': (True, False, None, 0x3C, 'I will sting your foes a few times', 'and the sting buddy', 'the beekeeper kid', 'insect for sale', 'shroom pollenation', 'boy is stung again'),
'BottleGoodBee': (True, False, None, 0x48, 'I will sting your foes a whole lot!', 'and the sparkle sting', 'the beekeeper kid', 'insect for sale', 'shroom pollenation', 'boy is stung again'),
'Bottle (Red Potion)': (True, False, None, 0x2B, 'Hearty red goop!', 'and the red goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy drinks again'),
'Bottle (Green Potion)': (True, False, None, 0x2C, 'Refreshing green goop!', 'and the green goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy drinks again'),
'Bottle (Blue Potion)': (True, False, None, 0x2D, 'Delicious blue goop!', 'and the blue goo', 'the liquid kid', 'potion for sale', 'free samples', 'boy stores drinks again'),
'Bottle (Fairy)': (True, False, None, 0x3D, 'Save me and I will revive you', 'and the captive', 'the tingle kid', 'hostage for sale', 'fairy dust and shrooms', 'boy revives again'),
'Bottle (Bee)': (True, False, None, 0x3C, 'I will sting your foes a few times', 'and the sting buddy', 'the beekeeper kid', 'insect for sale', 'shroom pollenation', 'boy is stung again'),
'Bottle (Good Bee)': (True, False, None, 0x48, 'I will sting your foes a whole lot!', 'and the sparkle sting', 'the beekeeper kid', 'insect for sale', 'shroom pollenation', 'boy is stung again'),
'Master Sword': (True, False, None, 0x50, 'I beat barries and pigs alike', 'and the master sword', 'sword-wielding kid', 'glow sword for sale', 'fungus for blue slasher', 'boy fights again'),
'Tempered Sword': (True, False, None, 0x02, 'I stole the\nblacksmith\'s\njob!', 'the tempered sword', 'sword-wielding kid', 'flame sword for sale', 'fungus for red slasher', 'boy fights again'),
'Fighter Sword': (True, False, None, 0x49, 'A pathetic\nsword rests\nhere!', 'the tiny sword', 'sword-wielding kid', 'tiny sword for sale', 'fungus for tiny slasher', 'boy fights again'),

View File

@ -1,7 +1,7 @@
from BaseClasses import World
from Regions import create_regions
from EntranceShuffle import link_entrances, connect_entrance, connect_two_way, connect_exit
from Rom import patch_rom, LocalRom, write_string_to_rom, write_credits_string_to_rom
from Rom import patch_rom, LocalRom, write_string_to_rom
from Rules import set_rules
from Dungeons import create_dungeons
from Items import ItemFactory
@ -12,6 +12,7 @@ import logging
import argparse
import os
import hashlib
import sys
__version__ = '0.2-dev'
@ -161,9 +162,10 @@ def fill_world(world, plando, text_patches):
elif line.startswith('!text_'):
textname, text = line.split(':', 1)
text_patches.append([textname.lstrip('!text_').strip(), 'text', text.strip()])
elif line.startswith('!credits_'):
textname, text = line.split(':', 1)
text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()])
#temporarilly removed. New credits system not ready to handle this.
#elif line.startswith('!credits_'):
# textname, text = line.split(':', 1)
# text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()])
continue
locationstr, itemstr = line.split(':', 1)
@ -214,13 +216,13 @@ if __name__ == '__main__':
# ToDo: Validate files further than mere existance
if not os.path.isfile(args.rom):
input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom)
exit(1)
sys.exit(1)
if not os.path.isfile(args.plando):
input('Could not find Plandomizer distribution at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.plando)
exit(1)
sys.exit(1)
if args.sprite is not None and not os.path.isfile(args.rom):
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
exit(1)
sys.exit(1)
# set up logger
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]

View File

@ -143,7 +143,7 @@ This setting is a modest step up from Expert. The main difference is that the pl
additional health.
```
--timer [{none,display,timed,timed-ohko,timed-countdown}]
--timer [{none,display,timed,timed-ohko,ohko,timed-countdown}]
```
Select the timer setting.
@ -168,10 +168,16 @@ Displays a countdown timer on screen that, when it hits zero, will put the playe
knockout state until more time is added to the clock via some of the Green Clocks that will be added
to the itempool.
### OHKO
The player into a one hit state the entire game. This is the same as Timed-OHKO,
except that the clock starts at zero, and there are no Clock items, so it will
always stay at zero, resulting in a permanent one hit knockout state.
### Timed-countdown
Displays a countdown timer on screen that can be increased with Green Clocks and Blue Clocks or
increased with Red Clocks found in chests that will be added to the itempool. The goal of this mode
decreased with Red Clocks found in chests that will be added to the itempool. The goal of this mode
is to finish the game without the timer reaching zero, but the game will continue uninterrupted if
the player runs out of time.

44
Rom.py
View File

@ -66,7 +66,7 @@ class LocalRom(object):
self.buffer.extend(bytearray([0x00] * (2097152 - len(self.buffer))))
# load randomizer patches
patches = json.load(open('base2current.json', 'r'))
patches = json.load(open('data/base2current.json', 'r'))
for patch in patches:
if isinstance(patch, dict):
for baseaddress, values in patch.items():
@ -391,33 +391,39 @@ def patch_rom(world, rom, hashtable, beep='normal', sprite=None):
# set up clocks for timed modes
if world.clock_mode == 'off':
rom.write_bytes(0x180190, [0x00, 0x00, 0x00]) # turn off clock mode
rom.write_bytes(0x180200, [0x00, 0x00, 0x00, 0x00]) # red clock adjustment time (in frames, sint32)
rom.write_bytes(0x180204, [0x00, 0x00, 0x00, 0x00]) # blue clock adjustment time (in frames, sint32)
rom.write_bytes(0x180208, [0x00, 0x00, 0x00, 0x00]) # green clock adjustment time (in frames, sint32)
rom.write_bytes(0x18020C, [0x00, 0x00, 0x00, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x180200, 0) # red clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180204, 0) # blue clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180208, 0) # green clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 0) # starting time (in frames, sint32)
elif world.clock_mode == 'ohko':
rom.write_bytes(0x180190, [0x01, 0x02, 0x01]) # ohko timer with resetable timer functionality
rom.write_bytes(0x180200, [0x00, 0x00, 0x00, 0x81]) # red clock adjustment time (in frames, sint32)
rom.write_bytes(0x180204, [0x20, 0x1C, 0x00, 0x00]) # blue clock adjustment time (in frames, sint32)
rom.write_bytes(0x180208, [0x40, 0x38, 0x00, 0x00]) # green clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180200, 0) # red clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180204, 0) # blue clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180208, 0) # green clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 0) # starting time (in frames, sint32)
elif world.clock_mode == 'countdown-ohko':
rom.write_bytes(0x180190, [0x01, 0x02, 0x01]) # ohko timer with resetable timer functionality
rom.write_int32_to_rom(0x180200, -100 * 60 * 60 * 60) # red clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180208, 4 * 60 * 60) # green clock adjustment time (in frames, sint32)
if world.difficulty == 'easy':
rom.write_bytes(0x18020C, [0x40, 0x19, 0x01, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 20 * 60 * 60) # starting time (in frames, sint32)
elif world.difficulty == 'normal':
rom.write_bytes(0x18020C, [0xA0, 0x8C, 0x00, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 10 * 60 * 60) # starting time (in frames, sint32)
else:
rom.write_bytes(0x18020C, [0x50, 0x46, 0x00, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 5 * 60 * 60) # starting time (in frames, sint32)
if world.clock_mode == 'stopwatch':
rom.write_bytes(0x180190, [0x02, 0x01, 0x00]) # set stopwatch mode
rom.write_bytes(0x180200, [0xE0, 0xE3, 0xFF, 0xFF]) # red clock adjustment time (in frames, sint32)
rom.write_bytes(0x180204, [0x20, 0x1C, 0x00, 0x00]) # blue clock adjustment time (in frames, sint32)
rom.write_bytes(0x180208, [0x40, 0x38, 0x00, 0x00]) # green clock adjustment time (in frames, sint32)
rom.write_bytes(0x18020C, [0x00, 0x00, 0x00, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x180200, -2 * 60 * 60) # red clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180208, 4 * 60 * 60) # green clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 0) # starting time (in frames, sint32)
if world.clock_mode == 'countdown':
rom.write_bytes(0x180190, [0x01, 0x01, 0x00]) # set countdown, with no reset available
rom.write_bytes(0x180200, [0xE0, 0xE3, 0xFF, 0xFF]) # red clock adjustment time (in frames, sint32)
rom.write_bytes(0x180204, [0x20, 0x1C, 0x00, 0x00]) # blue clock adjustment time (in frames, sint32)
rom.write_bytes(0x180208, [0x40, 0x38, 0x00, 0x00]) # green clock adjustment time (in frames, sint32)
rom.write_bytes(0x18020C, [0x80, 0x32, 0x02, 0x00]) # starting time (in frames, sint32)
rom.write_int32_to_rom(0x180200, -2 * 60 * 60) # red clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180204, 2 * 60 * 60) # blue clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x180208, 4 * 60 * 60) # green clock adjustment time (in frames, sint32)
rom.write_int32_to_rom(0x18020C, 40 * 60 * 60) # starting time (in frames, sint32)
# set up goals for treasure hunt
rom.write_bytes(0x180165, [0x0E, 0x28] if world.treasure_hunt_icon == 'Triforce Piece' else [0x0D, 0x28])