コード例 #1
0
 def copy_chests(self, location):
     from chestrandomizer import ChestBlock
     self.chests = []
     for chest in location.chests:
         c = ChestBlock(pointer=None, location=self.locid)
         c.copy(chest)
         self.chests.append(c)
コード例 #2
0
 def copy_chests(self, location):
     from chestrandomizer import ChestBlock
     self.chests = []
     for chest in location.chests:
         c = ChestBlock(pointer=None, location=self.locid)
         c.copy(chest)
         self.chests.append(c)
コード例 #3
0
 def description(self):
     c = ChestBlock(0x0, 0x0)
     c.memid = self.mem_id
     c.contenttype = self.contenttype
     c.contents = self.contents
     desc = c.description
     if self.mem_id in multiple_event_items:
         desc = "*%s" % desc
     return desc
コード例 #4
0
    def mutate_contents(self,
                        cutscene_skip=False,
                        crazy_prices=False,
                        no_monsters=False,
                        uncapped_monsters=False):
        from chestrandomizer import ChestBlock
        c = ChestBlock(0x0, 0x0)
        c.memid = 0
        c.contenttype = self.contenttype
        c.contents = self.contents

        cannot_show_text = not self.text or (cutscene_skip
                                             and self.cutscene_skip_pointer)
        monster = self.monster
        if no_monsters or cannot_show_text:
            monster = False

        c.mutate_contents(monster=monster,
                          crazy_prices=crazy_prices,
                          uncapped_monsters=uncapped_monsters)
        # If we can't show text, we don't want it to be GP,
        # because that event takes 3 bytes instead of 2,
        # and I'd have to rearrange or remove stuff to fit it.
        # So just make sure it's an item.
        if cannot_show_text:
            while c.contenttype != 0x40:
                c.mutate_contents(monster=False, crazy_prices=crazy_prices)

        self.contenttype = c.contenttype
        self.contents = c.contents
コード例 #5
0
def make_secret_treasure_room(mapid, beltroom):
    from itemrandomizer import get_secret_item
    candidates = []
    for line in open(TREASURE_ROOMS_TABLE):
        locid, entid, chestid = tuple(map(int, line.strip().split(',')))
        location = get_location(locid)
        entrance = location.get_entrance(entid)
        chest = location.get_chest(chestid)
        candidates.append((location, entrance, chest))
    location, entrance, chest = random.choice(candidates)
    newlocation = Location(mapid)
    newlocation.copy(location)
    newlocation.make_tower_basic()
    newlocation.entrance_set.entrances = []
    newlocation.events = []
    newlocation.npcs = []

    c = ChestBlock(pointer=None, location=newlocation.locid)
    c.copy(chest)
    c.set_content_type(0x40)
    item = get_secret_item()
    c.contents = item.itemid
    c.set_new_id()
    c.do_not_mutate = True
    c.ignore_dummy = True
    newlocation.chests = [c]
    newlocation.secret_treasure = True
    newlocation.ancient_rank = 0

    e = Entrance(None)
    e.copy(entrance)
    e.set_location(newlocation)
    e.destx, e.desty, e.dest = 36, 27, 287
    newlocation.entrances.append(e)
    assert len(newlocation.entrances) == 1

    e2 = Entrance()
    e2.x = 36
    e2.y = 25
    e2.destx, e2.desty, e2.dest = e.x, e.y, mapid
    beltroom.entrance_set.entrances = [ent for ent in beltroom.entrances
                                       if not (ent.x == 36 and ent.y == 25)]
    beltroom.entrance_set.entrances.append(e2)

    final_room = get_location(411)
    e3 = Entrance()
    e3.x = 109
    e3.y = 46
    e3.destx, e3.desty, e3.dest = 82, 46, 412 | 0x2000
    final_room.entrance_set.entrances.append(e3)

    newlocation.attacks = 0
    newlocation.setid = 0
    newlocation.music = 21
    return newlocation, beltroom
コード例 #6
0
 def read_chests(self, filename):
     from chestrandomizer import ChestBlock
     f = open(filename, 'r+b')
     f.seek(self.chestpointer)
     begin = read_multi(f, length=2)
     end = read_multi(f, length=2)
     numchests = (end - begin) / 5
     self.chests = []
     for i in xrange(numchests):
         pointer = begin + (i*5) + 0x2d8634
         c = ChestBlock(pointer, self.locid)
         c.read_data(filename)
         c.set_id(i)
         self.chests.append(c)
コード例 #7
0
 def read_chests(self, filename):
     from chestrandomizer import ChestBlock
     f = open(filename, 'r+b')
     f.seek(self.chestpointer)
     begin = read_multi(f, length=2)
     end = read_multi(f, length=2)
     numchests = (end - begin) // 5
     self.chests = []
     for i in range(numchests):
         pointer = begin + (i * 5) + 0x2d8634
         c = ChestBlock(pointer, self.locid)
         c.read_data(filename)
         c.set_id(i)
         self.chests.append(c)
コード例 #8
0
def make_secret_treasure_room(mapid, beltroom):
    from itemrandomizer import get_secret_item
    candidates = []
    for line in open(TREASURE_ROOMS_TABLE):
        locid, entid, chestid = tuple(map(int, line.strip().split(',')))
        location = get_location(locid)
        entrance = location.get_entrance(entid)
        chest = location.get_chest(chestid)
        candidates.append((location, entrance, chest))
    location, entrance, chest = random.choice(candidates)
    newlocation = Location(mapid)
    newlocation.copy(location)
    newlocation.make_tower_basic()
    newlocation.entrance_set.entrances = []
    newlocation.events = []
    newlocation.npcs = []

    c = ChestBlock(pointer=None, location=newlocation.locid)
    c.copy(chest)
    c.set_content_type(0x40)
    item = get_secret_item()
    c.contents = item.itemid
    c.set_new_id()
    c.do_not_mutate = True
    c.ignore_dummy = True
    newlocation.chests = [c]
    newlocation.secret_treasure = True
    newlocation.ancient_rank = 0

    e = Entrance(None)
    e.copy(entrance)
    e.set_location(newlocation)
    e.destx, e.desty, e.dest = 36, 27, 287
    newlocation.entrances.append(e)
    assert len(newlocation.entrances) == 1

    e2 = Entrance()
    e2.x = 36
    e2.y = 25
    e2.destx, e2.desty, e2.dest = e.x, e.y, mapid
    beltroom.entrance_set.entrances = [
        ent for ent in beltroom.entrances if not (ent.x == 36 and ent.y == 25)
    ]
    beltroom.entrance_set.entrances.append(e2)

    final_room = get_location(411)
    e3 = Entrance()
    e3.x = 109
    e3.y = 46
    e3.destx, e3.desty, e3.dest = 82, 46, 412 | 0x2000
    final_room.entrance_set.entrances.append(e3)

    newlocation.attacks = 0
    newlocation.setid = 0
    newlocation.music = 21
    return newlocation, beltroom