Skip to content

Commit

Permalink
Competitive-formatted parties (#3545)
Browse files Browse the repository at this point in the history
$ python3 migration_scripts/convert_parties.py src/data/trainers.h src/data/trainer_parties.h src/data/npc_trainers.party
Is available to convert Trainer Control-formatted trainers/parties into
Competitive-formatted ones.

Multiple '#include's can be placed in the trainer section of src/data.c
to support spreading the trainers across multiple .party files.

trainerproc does not interpret the values, leaving that job to the C
compiler, so we use '#line' to associate those errors with the lines in
the .party file(s). Because the columns don't make sense we use
-fno-show-column and -fno-diagostics-show-caret. We might want to move
gTrainers into its own file so that the rest of src/data.c isn't
affected by those flags.

Extensions (misfeatures, imo):
- .party files are passed through cpp, so '#define's are supported, and so
  are '// ...' and '/* ... */' comments.
- .party files also support writing, e.g. 'SPECIES_PIKACHU' instead of
  'Pikachu'. This allows people to write constants explicitly if they
  like.

Pragmas:
- '#pragma trainerproc ivs explicit' requires an explicit 'IVs:' line
  rather than defaulting to 31s.
- '#pragma trainerproc ivs <IVs>' changes the default IVs.
- '#pragma trainerproc level explicit' requires an explicit 'Level:'
  line rather than defaulting to 100.
- '#pragma trainerproc level <level>' changes the default level.

Co-authored-by: Eduardo Quezada <eduardo602002@gmail.com>
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 6, 2024
1 parent d8af620 commit 8bd5ac2
Show file tree
Hide file tree
Showing 17 changed files with 57,869 additions and 18,380 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ JSONPROC := tools/jsonproc/jsonproc$(EXE)
PATCHELF := tools/patchelf/patchelf$(EXE)
ROMTEST ?= $(shell { command -v mgba-rom-test || command -v tools/mgba/mgba-rom-test$(EXE); } 2>/dev/null)
ROMTESTHYDRA := tools/mgba-rom-test-hydra/mgba-rom-test-hydra$(EXE)
TRAINERPROC := tools/trainerproc/trainerproc$(EXE)

PERL := perl

# Inclusive list. If you don't want a tool to be built, don't add it here.
TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc
TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc tools/trainerproc
CHECKTOOLDIRS = tools/patchelf tools/mgba-rom-test-hydra
TOOLBASE = $(TOOLDIRS:tools/%=%)
TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE))
Expand Down Expand Up @@ -335,6 +336,10 @@ $(CRY_SUBDIR)/uncomp_%.bin: $(CRY_SUBDIR)/uncomp_%.aif ; $(AIF) $< $@
$(CRY_SUBDIR)/%.bin: $(CRY_SUBDIR)/%.aif ; $(AIF) $< $@ --compress
sound/%.bin: sound/%.aif ; $(AIF) $< $@

COMPETITIVE_PARTY_SYNTAX := $(shell echo 'COMPETITIVE_PARTY_SYNTAX' | $(CPP) $(CPPFLAGS) -imacros include/global.h | tail -n1)
ifeq ($(COMPETITIVE_PARTY_SYNTAX),1)
%.h: %.party tools ; $(CPP) $(CPPFLAGS) - < $< | sed '/#[^p]/d' | $(TRAINERPROC) -o $@ -i $< -
endif

ifeq ($(MODERN),0)
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
Expand All @@ -354,6 +359,8 @@ $(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
else
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
$(C_BUILDDIR)/pokedex_plus_hgss.o: CFLAGS := -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -Wno-pointer-to-int-cast -std=gnu17 -Werror -Wall -Wno-strict-aliasing -Wno-attribute-alias -Woverride-init
# Annoyingly we can't turn this on just for src/data/trainers.h
$(C_BUILDDIR)/data.o: CFLAGS += -fno-show-column -fno-diagnostics-show-caret
endif

ifeq ($(DINFO),1)
Expand Down
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#define POKEDEX_PLUS_HGSS FALSE // If TRUE, enables the custom HGSS style Pokedex.
#define SUMMARY_SCREEN_NATURE_COLORS TRUE // If TRUE, nature-based stat boosts and reductions will be red and blue in the summary screen.
#define HQ_RANDOM TRUE // If TRUE, replaces the default RNG with an implementation of SFC32 RNG. May break code that relies on RNG.
#define COMPETITIVE_PARTY_SYNTAX TRUE // If TRUE, parties are defined in "competitive syntax".

// Measurement system constants to be used for UNITS
#define UNITS_IMPERIAL 0 // Inches, feet, pounds
Expand Down
1 change: 1 addition & 0 deletions include/constants/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@
// Signature Z Moves
#define MOVE_CATASTROPIKA (MOVES_COUNT + 18)
#define MOVE_10000000_VOLT_THUNDERBOLT (MOVES_COUNT + 19)
#define MOVE_10_000_000_VOLT_THUNDERBOLT MOVE_10000000_VOLT_THUNDERBOLT
#define MOVE_STOKED_SPARKSURFER (MOVES_COUNT + 20)
#define MOVE_EXTREME_EVOBOOST (MOVES_COUNT + 21)
#define MOVE_PULVERIZING_PANCAKE (MOVES_COUNT + 22)
Expand Down
134 changes: 134 additions & 0 deletions include/constants/species.h
Original file line number Diff line number Diff line change
Expand Up @@ -1633,4 +1633,138 @@

#define NUM_SPECIES SPECIES_EGG

// Competitive format aliases
#define SPECIES_ALCREMIE_GMAX SPECIES_ALCREMIE_GIGANTAMAX
#define SPECIES_APPLETUN_GMAX SPECIES_APPLETUN_GIGANTAMAX
#define SPECIES_ARCANINE_HISUI SPECIES_ARCANINE_HISUIAN
#define SPECIES_ARTICUNO_GALAR SPECIES_ARTICUNO_GALARIAN
#define SPECIES_AVALUGG_HISUI SPECIES_AVALUGG_HISUIAN
#define SPECIES_BLASTOISE_GMAX SPECIES_BLASTOISE_GIGANTAMAX
#define SPECIES_BRAVIARY_HISUI SPECIES_BRAVIARY_HISUIAN
#define SPECIES_BURMY_SANDY SPECIES_BURMY_SANDY_CLOAK
#define SPECIES_BURMY_TRASH SPECIES_BURMY_TRASH_CLOAK
#define SPECIES_BUTTERFREE_GMAX SPECIES_BUTTERFREE_GIGANTAMAX
#define SPECIES_CALYREX_ICE SPECIES_CALYREX_ICE_RIDER
#define SPECIES_CALYREX_SHADOW SPECIES_CALYREX_SHADOW_RIDER
#define SPECIES_CENTISKORCH_GMAX SPECIES_CENTISKORCH_GIGANTAMAX
#define SPECIES_CHARIZARD_GMAX SPECIES_CHARIZARD_GIGANTAMAX
#define SPECIES_CINDERACE_GMAX SPECIES_CINDERACE_GIGANTAMAX
#define SPECIES_COALOSSAL_GMAX SPECIES_COALOSSAL_GIGANTAMAX
#define SPECIES_COPPERAJAH_GMAX SPECIES_COPPERAJAH_GIGANTAMAX
#define SPECIES_CORSOLA_GALAR SPECIES_CORSOLA_GALARIAN
#define SPECIES_CORVIKNIGHT_GMAX SPECIES_CORVIKNIGHT_GIGANTAMAX
#define SPECIES_DARMANITAN_GALAR SPECIES_DARMANITAN_GALARIAN_STANDARD_MODE
#define SPECIES_DARMANITAN_GALAR_ZEN SPECIES_DARMANITAN_GALARIAN_ZEN_MODE
#define SPECIES_DARMANITAN_ZEN SPECIES_DARMANITAN_ZEN_MODE
#define SPECIES_DARUMAKA_GALAR SPECIES_DARUMAKA_GALARIAN
#define SPECIES_DECIDUEYE_HISUI SPECIES_DECIDUEYE_HISUIAN
#define SPECIES_DIGLETT_ALOLA SPECIES_DIGLETT_ALOLAN
#define SPECIES_DREDNAW_GMAX SPECIES_DREDNAW_GIGANTAMAX
#define SPECIES_DUGTRIO_ALOLA SPECIES_DUGTRIO_ALOLAN
#define SPECIES_DURALUDON_GMAX SPECIES_DURALUDON_GIGANTAMAX
#define SPECIES_EEVEE_GMAX SPECIES_EEVEE_GIGANTAMAX
#define SPECIES_EEVEE_STARTER SPECIES_EEVEE_PARTNER
#define SPECIES_EISCUE_NOICE SPECIES_EISCUE_NOICE_FACE
#define SPECIES_ELECTRODE_HISUI SPECIES_ELECTRODE_HISUIAN
#define SPECIES_EXEGGUTOR_ALOLA SPECIES_EXEGGUTOR_ALOLAN
#define SPECIES_FARFETCHD_GALAR SPECIES_FARFETCHD_GALARIAN
#define SPECIES_FLAPPLE_GMAX SPECIES_FLAPPLE_GIGANTAMAX
#define SPECIES_FLOETTE_ETERNAL SPECIES_FLOETTE_ETERNAL_FLOWER
#define SPECIES_GARBODOR_GMAX SPECIES_GARBODOR_GIGANTAMAX
#define SPECIES_GASTRODON_EAST SPECIES_GASTRODON_EAST_SEA
#define SPECIES_GENESECT_BURN SPECIES_GENESECT_BURN_DRIVE
#define SPECIES_GENESECT_CHILL SPECIES_GENESECT_CHILL_DRIVE
#define SPECIES_GENESECT_DOUSE SPECIES_GENESECT_DOUSE_DRIVE
#define SPECIES_GENESECT_SHOCK SPECIES_GENESECT_SHOCK_DRIVE
#define SPECIES_GENGAR_GMAX SPECIES_GENGAR_GIGANTAMAX
#define SPECIES_GEODUDE_ALOLA SPECIES_GEODUDE_ALOLAN
#define SPECIES_GOLEM_ALOLA SPECIES_GOLEM_ALOLAN
#define SPECIES_GOODRA_HISUI SPECIES_GOODRA_HISUIAN
#define SPECIES_GRAVELER_ALOLA SPECIES_GRAVELER_ALOLAN
#define SPECIES_GRENINJA_BOND SPECIES_GRENINJA_BATTLE_BOND
#define SPECIES_GRIMER_ALOLA SPECIES_GRIMER_ALOLAN
#define SPECIES_GRIMMSNARL_GMAX SPECIES_GRIMMSNARL_GIGANTAMAX
#define SPECIES_GROWLITHE_HISUI SPECIES_GROWLITHE_HISUIAN
#define SPECIES_HATTERENE_GMAX SPECIES_HATTERENE_GIGANTAMAX
#define SPECIES_INTELEON_GMAX SPECIES_INTELEON_GIGANTAMAX
#define SPECIES_KINGLER_GMAX SPECIES_KINGLER_GIGANTAMAX
#define SPECIES_LAPRAS_GMAX SPECIES_LAPRAS_GIGANTAMAX
#define SPECIES_LILLIGANT_HISUI SPECIES_LILLIGANT_HISUIAN
#define SPECIES_LINOONE_GALAR SPECIES_LINOONE_GALARIAN
#define SPECIES_MACHAMP_GMAX SPECIES_MACHAMP_GIGANTAMAX
#define SPECIES_MAGEARNA_ORIGINAL SPECIES_MAGEARNA_ORIGINAL_COLOR
#define SPECIES_MAROWAK_ALOLA SPECIES_MAROWAK_ALOLAN
#define SPECIES_MAROWAX_ALOLA_TOTEM SPECIES_MAROWAK_ALOLAN_TOTEM
#define SPECIES_MAUSHOLD_FOUR SPECIES_MAUSHOLD_FAMILY_OF_FOUR
#define SPECIES_MELMETAL_GMAX SPECIES_MELMETAL_GIGANTAMAX
#define SPECIES_MEOWTH_ALOLA SPECIES_MEOWTH_ALOLAN
#define SPECIES_MEOWTH_GALAR SPECIES_MEOWTH_GALARIAN
#define SPECIES_MEOWTH_GMAX SPECIES_MEOWTH_GIGANTAMAX
#define SPECIES_MOLTRES_GALAR SPECIES_MOLTRES_GALARIAN
#define SPECIES_MR_MIME_GALAR SPECIES_MR_MIME_GALARIAN
#define SPECIES_MUK_ALOLA SPECIES_MUK_ALOLAN
#define SPECIES_NINETALES_ALOLA SPECIES_NINETALES_ALOLAN
#define SPECIES_ORBEETLE_GMAX SPECIES_ORBEETLE_GIGANTAMAX
#define SPECIES_PERSIAN_ALOLA SPECIES_PERSIAN_ALOLAN
#define SPECIES_PIKACHU_ALOLA SPECIES_PIKACHU_ALOLA_CAP
#define SPECIES_PIKACHU_GMAX SPECIES_PIKACHU_GIGANTAMAX
#define SPECIES_PIKACHU_HOENN SPECIES_PIKACHU_HOENN_CAP
#define SPECIES_PIKACHU_KALOS SPECIES_PIKACHU_KALOS_CAP
#define SPECIES_PIKACHU_ORIGINAL SPECIES_PIKACHU_ORIGINAL_CAP
//#define SPECIES_PIKACHU_PARTNER SPECIES_PIKACHU_PARTNER_CAP
#define SPECIES_PIKACHU_PHD SPECIES_PIKACHU_PH_D
#define SPECIES_PIKACHU_SINNOH SPECIES_PIKACHU_SINNOH_CAP
#define SPECIES_PIKACHU_STARTER SPECIES_PIKACHU_PARTNER
#define SPECIES_PIKACHU_UNOVA SPECIES_PIKACHU_UNOVA_CAP
#define SPECIES_PIKACHU_WORLD SPECIES_PIKACHU_WORLD_CAP
#define SPECIES_PONYTA_GALAR SPECIES_PONYTA_GALARIAN
#define SPECIES_QWILFISH_HISUI SPECIES_QWILFISH_HISUIAN
#define SPECIES_RAICHU_ALOLA SPECIES_RAICHU_ALOLAN
#define SPECIES_RAPIDASH_GALAR SPECIES_RAPIDASH_GALARIAN
#define SPECIES_RATICATE_ALOLA SPECIES_RATICATE_ALOLAN
#define SPECIES_RATICATE_ALOLA_TOTEM SPECIES_RATICATE_ALOLAN_TOTEM
#define SPECIES_RATTATA_ALOLA SPECIES_RATTATA_ALOLAN
#define SPECIES_RILLABOOM_GMAX SPECIES_RILLABOOM_GIGANTAMAX
#define SPECIES_SAMUROTT_HISUI SPECIES_SAMUROTT_HISUIAN
#define SPECIES_SANDACONDA_GMAX SPECIES_SANDACONDA_GIGANTAMAX
#define SPECIES_SANDSHREW_ALOLA SPECIES_SANDSHREW_ALOLAN
#define SPECIES_SANDSLASH_ALOLA SPECIES_SANDSLASH_ALOLAN
#define SPECIES_SHELLOS_EAST SPECIES_SHELLOS_EAST_SEA
#define SPECIES_SLIGGOO_HISUI SPECIES_SLIGGOO_HISUIAN
#define SPECIES_SLOWBRO_GALAR SPECIES_SLOWBRO_GALARIAN
#define SPECIES_SLOWKING_GALAR SPECIES_SLOWKING_GALARIAN
#define SPECIES_SLOWPOKE_GALAR SPECIES_SLOWPOKE_GALARIAN
#define SPECIES_SNEASEL_HISUI SPECIES_SNEASEL_HISUIAN
#define SPECIES_SNORLAX_GMAX SPECIES_SNORLAX_GIGANTAMAX
#define SPECIES_SQUAWKABILLY_BLUE SPECIES_SQUAWKABILLY_BLUE_PLUMAGE
#define SPECIES_SQUAWKABILLY_WHITE SPECIES_SQUAWKABILLY_WHITE_PLUMAGE
#define SPECIES_SQUAWKABILLY_YELLOW SPECIES_SQUAWKABILLY_YELLOW_PLUMAGE
#define SPECIES_STUNFISK_GALAR SPECIES_STUNFISK_GALARIAN
#define SPECIES_TAUROS_PALDEA_AQUA SPECIES_TAUROS_PALDEAN_AQUA_BREED
#define SPECIES_TAUROS_PALDEA_BLAZE SPECIES_TAUROS_PALDEAN_BLAZE_BREED
#define SPECIES_TAUROS_PALDEA_COMBAT SPECIES_TAUROS_PALDEAN_COMBAT_BREED
#define SPECIES_TOXTRICITY_AMPED_GMAX SPECIES_TOXTRICITY_AMPED_GIGANTAMAX
#define SPECIES_TOXTRICITY_LOW_KEY_GMAX SPECIES_TOXTRICITY_LOW_KEY_GIGANTAMAX
#define SPECIES_TYPHLOSION_HISUI SPECIES_TYPHLOSION_HISUIAN
#define SPECIES_UNOWN_EXCLAMATION SPECIES_UNOWN_EMARK
#define SPECIES_UNOWN_QUESTION SPECIES_UNOWN_QMARK
#define SPECIES_URSHIFU_GMAX SPECIES_URSHIFU_SINGLE_STRIKE_STYLE_GIGANTAMAX
#define SPECIES_URSHIFU_RAPID_STRIKE SPECIES_URSHIFU_RAPID_STRIKE_STYLE
#define SPECIES_URSHIFU_RAPID_STRIKE_GMAX SPECIES_URSHIFU_RAPID_STRIKE_STYLE_GIGANTAMAX
#define SPECIES_VENUSAUR_GMAX SPECIES_VENUSAUR_GIGANTAMAX
#define SPECIES_VIVILLON_POKEBALL SPECIES_VIVILLON_POKE_BALL
#define SPECIES_VOLTORB_HISUI SPECIES_VOLTORB_HISUIAN
#define SPECIES_VULPIX_ALOLA SPECIES_VULPIX_ALOLAN
#define SPECIES_WEEZING_GALAR SPECIES_WEEZING_GALARIAN
#define SPECIES_WOOPER_PALDEA SPECIES_WOOPER_PALDEAN
#define SPECIES_WORMADAM_SANDY SPECIES_WORMADAM_SANDY_CLOAK
#define SPECIES_WORMADAM_TRASH SPECIES_WORMADAM_TRASH_CLOAK
#define SPECIES_YAMASK_GALAR SPECIES_YAMASK_GALARIAN
#define SPECIES_ZACIAN_CROWNED SPECIES_ZACIAN_CROWNED_SWORD
#define SPECIES_ZAMAZENTA_CROWNED SPECIES_ZAMAZENTA_CROWNED_SHIELD
#define SPECIES_ZAPDOS_GALAR SPECIES_ZAPDOS_GALARIAN
#define SPECIES_ZIGZAGOON_GALAR SPECIES_ZIGZAGOON_GALARIAN
#define SPECIES_ZOROARK_HISUI SPECIES_ZOROARK_HISUIAN
#define SPECIES_ZORUA_HISUI SPECIES_ZORUA_HISUIAN

#endif // GUARD_CONSTANTS_SPECIES_H
5 changes: 3 additions & 2 deletions include/constants/trainers.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@
#define F_TRAINER_FEMALE (1 << 7)

// Trainer party defines
#define TRAINER_MON_MALE 1
#define TRAINER_MON_FEMALE 2
#define TRAINER_MON_MALE 1
#define TRAINER_MON_FEMALE 2
#define TRAINER_MON_RANDOM_GENDER 3

#endif // GUARD_TRAINERS_H
Loading

0 comments on commit 8bd5ac2

Please sign in to comment.