From 3b9ea5b54c44d21631389df25e62db60598e9c54 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:04:21 +0200 Subject: [PATCH] Adds battle frontier conversion script (#5040) Adds script to convert battle frontier mons to new format Fixes existing battle frontier mons to match vanilla --- .../1.9/battle_frontier_convert_parties.py | 62 +++++++++++++++++++ migration_scripts/README.md | 21 +++++++ .../battle_frontier/battle_frontier_mons.h | 12 ++-- 3 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 migration_scripts/1.9/battle_frontier_convert_parties.py diff --git a/migration_scripts/1.9/battle_frontier_convert_parties.py b/migration_scripts/1.9/battle_frontier_convert_parties.py new file mode 100644 index 000000000000..83982bbe465d --- /dev/null +++ b/migration_scripts/1.9/battle_frontier_convert_parties.py @@ -0,0 +1,62 @@ +import re + +def battle_frontier_mons(data): + data = re.sub(re.escape(".itemTableId = BATTLE_FRONTIER_"), ".heldItem = ", data) + data = re.sub(re.escape("FacilityMon"), "TrainerMon", data) + data = re.sub(re.escape(".evSpread = 0,"), ".ev = NULL,", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 0, 0, 0, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 170, 170, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 252, 0, 0, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED,"), ".ev = TRAINER_PARTY_EVS(0, 0, 0, 252, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 170, 170, 0, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 170, 0, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 0, 170, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 0, 170, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE,"), ".ev = TRAINER_PARTY_EVS(0, 0, 170, 170, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 0, 170, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 0, 0, 0, 252, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 252, 0, 0, 252, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE,"), ".ev = TRAINER_PARTY_EVS(0, 0, 252, 0, 252, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED,"), ".ev = TRAINER_PARTY_EVS(0, 0, 0, 252, 252, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(102, 102, 102, 102, 0, 102),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 128, 128, 0, 128, 128),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE,"), ".ev = TRAINER_PARTY_EVS(0, 0, 170, 0, 170, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(84, 84, 84, 84, 84, 84),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 128, 128, 128, 0, 128),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 170, 0, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(102, 0, 102, 102, 102, 102),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 0, 0, 170, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(128, 0, 128, 0, 128, 128),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(128, 128, 128, 0, 0, 128),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 0, 170, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 170, 0, 170, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 0, 0, 0, 0, 252),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE,"), ".ev = TRAINER_PARTY_EVS(0, 0, 170, 170, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(128, 0, 128, 128, 0, 128),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 0, 0, 170, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 0, 170),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 252, 0, 0, 0, 252),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_SP_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 0, 0, 0, 252, 252),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SP_DEFENSE | F_EV_SPREAD_DEFENSE,"), ".ev = TRAINER_PARTY_EVS(0, 0, 252, 0, 0, 252),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 252, 0, 0, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 0, 0, 252, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED | F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 0, 170, 170, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED | F_EV_SPREAD_ATTACK | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(170, 170, 0, 170, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_SPEED | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 252, 0, 252, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_DEFENSE | F_EV_SPREAD_HP,"), ".ev = TRAINER_PARTY_EVS(252, 0, 252, 0, 0, 0),", data) + data = re.sub(re.escape(".evSpread = F_EV_SPREAD_DEFENSE | F_EV_SPREAD_ATTACK,"), ".ev = TRAINER_PARTY_EVS(0, 252, 252, 0, 0, 0),", data) + + return data + +with open('src/data/battle_frontier/battle_frontier_mons.h', 'r') as file: + data = file.read() +with open('src/data/battle_frontier/battle_frontier_mons.h', 'w') as file: + file.write(battle_frontier_mons(data)) + +with open('src/data/battle_frontier/battle_tent.h', 'r') as file: + data = file.read() +with open('src/data/battle_frontier/battle_tent.h', 'w') as file: + file.write(battle_frontier_mons(data)) diff --git a/migration_scripts/README.md b/migration_scripts/README.md index cfa1d23638ca..5ae26c1c0afc 100644 --- a/migration_scripts/README.md +++ b/migration_scripts/README.md @@ -336,3 +336,24 @@ Modifies all item ball scripts defined using to original Game Freak method to th "flag": "FLAG_ITEM_ROUTE_102_POTION" }, ``` + +### Facility Mons + +* Filepath [`migration_scripts/1.9/battle_frontier_convert_parties.py`](1.8/battle_frontier_convert_parties.py) +* Introduced in [Adds battle frontier conversion script #5040](https://github.com/rh-hideout/pokeemerald-expansion/pull/5040) +* Original refactor in [Customizable FrontierMon Sets #4313](https://github.com/rh-hideout/pokeemerald-expansion/pull/4313) + +Replaces itemTableId with heldItem and evSpread with ev. + +#### [src/data/battle_frontier/battle_frontier_mons.h](../src/data/battle_frontier/battle_frontier_mons.h) +```diff + [FRONTIER_MON_SUNKERN] = { + .species = SPECIES_SUNKERN, + .moves = {MOVE_MEGA_DRAIN, MOVE_HELPING_HAND, MOVE_SUNNY_DAY, MOVE_LIGHT_SCREEN}, +- .itemTableId = BATTLE_FRONTIER_ITEM_LAX_INCENSE, ++ .heldItem = ITEM_LAX_INCENSE, +- .evSpread = F_EV_SPREAD_SP_ATTACK | F_EV_SPREAD_HP, ++ .ev = TRAINER_PARTY_EVS(252, 0, 0, 0, 252, 0), + .nature = NATURE_RELAXED + }, +``` \ No newline at end of file diff --git a/src/data/battle_frontier/battle_frontier_mons.h b/src/data/battle_frontier/battle_frontier_mons.h index 7299e78a03fb..e83a25e82998 100644 --- a/src/data/battle_frontier/battle_frontier_mons.h +++ b/src/data/battle_frontier/battle_frontier_mons.h @@ -2804,7 +2804,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_LUDICOLO, .moves = {MOVE_SURF, MOVE_RAIN_DANCE, MOVE_THUNDER_PUNCH, MOVE_FIRE_PUNCH}, .heldItem = ITEM_SHELL_BELL, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_QUIET }, [FRONTIER_MON_HYPNO_1] = { @@ -2853,7 +2853,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_ELECTABUZZ, .moves = {MOVE_THUNDERBOLT, MOVE_THUNDER_WAVE, MOVE_BRICK_BREAK, MOVE_LIGHT_SCREEN}, .heldItem = ITEM_CHERI_BERRY, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_RELAXED }, [FRONTIER_MON_TAUROS_1] = { @@ -2909,7 +2909,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_MAGMAR, .moves = {MOVE_FLAMETHROWER, MOVE_SMOKESCREEN, MOVE_BRICK_BREAK, MOVE_BARRIER}, .heldItem = ITEM_RAWST_BERRY, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_RELAXED }, [FRONTIER_MON_CRADILY_1] = { @@ -3245,7 +3245,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_MILOTIC, .moves = {MOVE_HYDRO_PUMP, MOVE_ICY_WIND, MOVE_RECOVER, MOVE_MIRROR_COAT}, .heldItem = ITEM_LUM_BERRY, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_MODEST }, [FRONTIER_MON_ARCANINE_1] = { @@ -3714,7 +3714,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_TENTACRUEL, .moves = {MOVE_TOXIC, MOVE_GIGA_DRAIN, MOVE_CONFUSE_RAY, MOVE_SURF}, .heldItem = ITEM_LEFTOVERS, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_HARDY }, [FRONTIER_MON_AERODACTYL_2] = { @@ -5870,7 +5870,7 @@ const struct TrainerMon gBattleFrontierMons[NUM_FRONTIER_MONS] = .species = SPECIES_REGICE, .moves = {MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_CURSE, MOVE_COUNTER}, .heldItem = ITEM_LEFTOVERS, - .ev = TRAINER_PARTY_EVS(170, 170, 0, 0, 170, 0), + .ev = TRAINER_PARTY_EVS(170, 0, 170, 0, 170, 0), .nature = NATURE_BRAVE }, [FRONTIER_MON_REGICE_6] = {