def run(self, status: Status):
        mappa = FileType.MAPPA_BIN.deserialize(
            self.rom.getFileByName('BALANCE/mappa_s.bin'))

        item_lists = None
        trap_lists = None

        if self.config['dungeons']['items']:
            status.step("Randomizing dungeon items...")
            item_lists = []
            for _ in range(0, MAX_ITEM_LISTS):
                item_lists.append(self._randomize_items())

        if self.config['dungeons']['traps']:
            status.step("Randomizing dungeon traps...")
            trap_lists = []
            for _ in range(0, MAX_TRAP_LISTS):
                trap_lists.append(self._randomize_traps())

        status.step("Randomizing dungeons...")
        self._randomize(mappa, trap_lists, item_lists)

        mappa_after = FileType.MAPPA_BIN.serialize(mappa)
        self.rom.setFileByName('BALANCE/mappa_s.bin', mappa_after)
        mappag_after = FileType.MAPPA_G_BIN.serialize(
            convert_mappa_to_mappag(mappa))
        self.rom.setFileByName('BALANCE/mappa_gs.bin', mappag_after)

        status.done()
Example #2
0
    def run(self, status: Status):
        if not self.config['dungeons']['fixed_rooms']:
            return status.done()

        mappa: MappaBin = FileType.MAPPA_BIN.deserialize(
            self.rom.getFileByName('BALANCE/mappa_s.bin'))
        fixed: FixedBin = FileType.FIXED_BIN.deserialize(
            self.rom.getFileByName('BALANCE/fixed.bin'),
            static_data=self.static_data)

        status.step('Randomizing Boss Floor Layouts...')
        for i in BOSS_ROOMS:
            fixed_room = fixed.fixed_floors[i]
            for floor_list, floor_id in self._get_dungeon_floors_for_fixed_room(
                    mappa.floor_lists, i):
                self._assign_dungeon_floor_regular_tileset(
                    floor_list, floor_id)
            w, h, new_layout = self._get_random_room(
                self._get_special_in_floor(fixed_room))
            fixed_room.width = w
            fixed_room.height = h
            fixed_room.actions = new_layout

        self.rom.setFileByName('BALANCE/fixed.bin',
                               FileType.FIXED_BIN.serialize(fixed))
        self.rom.setFileByName('BALANCE/mappa_s.bin',
                               FileType.MAPPA_BIN.serialize(mappa))
        mappag_after = FileType.MAPPA_G_BIN.serialize(
            convert_mappa_to_mappag(mappa))
        self.rom.setFileByName('BALANCE/mappa_gs.bin', mappag_after)

        status.done()
Example #3
0
 def save_mappa(self):
     self.project.mark_as_modified(MAPPA_PATH)
     self.project.save_file_manually(
         MAPPAG_PATH,
         FileType.MAPPA_G_BIN.serialize(
             convert_mappa_to_mappag(self.get_mappa())))
Example #4
0
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  SkyTemple is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with SkyTemple.  If not, see <https://www.gnu.org/licenses/>.
import os

from ndspy.rom import NintendoDSRom

from skytemple_files.dungeon_data.mappa_bin.handler import MappaBinHandler
from skytemple_files.dungeon_data.mappa_g_bin.handler import MappaGBinHandler
from skytemple_files.dungeon_data.mappa_g_bin.mappa_converter import convert_mappa_to_mappag

base_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
                        '..')

rom = NintendoDSRom.fromFile(os.path.join(base_dir, 'skyworkcopy_us.nds'))

mappag_bin = rom.getFileByName('BALANCE/mappa_gs.bin')
mappa_g = MappaGBinHandler.deserialize(mappag_bin)

mappa_bin = rom.getFileByName('BALANCE/mappa_s.bin')
mappa = MappaBinHandler.deserialize(mappa_bin)

assert mappa_g == convert_mappa_to_mappag(mappa)