Skip to content

Commit

Permalink
Adds battle frontier conversion script (#5040)
Browse files Browse the repository at this point in the history
Adds script to convert battle frontier mons to new format
Fixes existing battle frontier mons to match vanilla
  • Loading branch information
AlexOn1ine authored Jul 31, 2024
1 parent 05ff7ce commit 3b9ea5b
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 6 deletions.
62 changes: 62 additions & 0 deletions migration_scripts/1.9/battle_frontier_convert_parties.py
Original file line number Diff line number Diff line change
@@ -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))
21 changes: 21 additions & 0 deletions migration_scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
```
12 changes: 6 additions & 6 deletions src/data/battle_frontier/battle_frontier_mons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down

0 comments on commit 3b9ea5b

Please sign in to comment.