Pokemon Emerald: Ensure dig tutor is always usable (#3660)
* Pokemon Emerald: Ensure dig tutor is always usable * Pokemon Emerald: Clarify comment Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --------- Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
parent
81092247c6
commit
f5218faea7
|
@ -817,6 +817,8 @@ def _randomize_opponent_battle_type(world: "PokemonEmeraldWorld", patch: Pokemon
|
|||
|
||||
|
||||
def _randomize_move_tutor_moves(world: "PokemonEmeraldWorld", patch: PokemonEmeraldProcedurePatch, easter_egg: Tuple[int, int]) -> None:
|
||||
FORTREE_MOVE_TUTOR_INDEX = 24
|
||||
|
||||
if easter_egg[0] == 2:
|
||||
for i in range(30):
|
||||
patch.write_token(
|
||||
|
@ -840,18 +842,26 @@ def _randomize_move_tutor_moves(world: "PokemonEmeraldWorld", patch: PokemonEmer
|
|||
# Always set Fortree move tutor to Dig
|
||||
patch.write_token(
|
||||
APTokenTypes.WRITE,
|
||||
data.rom_addresses["gTutorMoves"] + (24 * 2),
|
||||
data.rom_addresses["gTutorMoves"] + (FORTREE_MOVE_TUTOR_INDEX * 2),
|
||||
struct.pack("<H", data.constants["MOVE_DIG"])
|
||||
)
|
||||
|
||||
# Modify compatibility
|
||||
if world.options.tm_tutor_compatibility.value != -1:
|
||||
for species in data.species.values():
|
||||
compatibility = bool_array_to_int([
|
||||
world.random.randrange(0, 100) < world.options.tm_tutor_compatibility.value
|
||||
for _ in range(32)
|
||||
])
|
||||
|
||||
# Make sure Dig tutor has reasonable (>=50%) compatibility
|
||||
if world.options.tm_tutor_compatibility.value < 50:
|
||||
compatibility &= ~(1 << FORTREE_MOVE_TUTOR_INDEX)
|
||||
if world.random.random() < 0.5:
|
||||
compatibility |= 1 << FORTREE_MOVE_TUTOR_INDEX
|
||||
|
||||
patch.write_token(
|
||||
APTokenTypes.WRITE,
|
||||
data.rom_addresses["sTutorLearnsets"] + (species.species_id * 4),
|
||||
struct.pack("<I", bool_array_to_int([
|
||||
world.random.randrange(0, 100) < world.options.tm_tutor_compatibility.value
|
||||
for _ in range(32)
|
||||
]))
|
||||
struct.pack("<I", compatibility)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue