Skip to content

Adding gym leader rematches

thoth-33 edited this page Jul 6, 2025 · 5 revisions

Gym Leader Rematches

Today we're going to add gym leader rematches to the game. This means that we are going to add rematchable gym leaders once the game is beaten. In this tutorial we'll add it to Brock, but it's done in nearly the same way for every gym leader.

Contents

1. Define Event to check post game

Let's start by defining a constant in constants/event_constants.asm for checking if it's post game or not, as rematches will only be enabled post game.

...
	const EVENT_BEAT_ARTICUNO
	
+; Post Game events
+	const_next $9E0
+	const EVENT_PLAYER_IS_CHAMPION

; End of events
	const_next $A00
DEF NUM_EVENTS EQU const_value

We need to set an appropriate place for this event to trigger. Head over to scripts/HallOfFame.asm and add the following near the bottom.

...
	ld a, HS_CERULEAN_CAVE_GUY
	ld [wMissableObjectIndex], a
	predef HideObject
+	SetEvent EVENT_PLAYER_IS_CHAMPION
	ld a, SCRIPT_HALLOFFAME_RESET_EVENTS_AND_SAVE
...

2. Create Party

Since we're making a rematch for Brock, we'll add him a party in data/trainers/parties.asm. Make these changes, or create your own team if you don't like it.

...
BrockData:
	db $FF, 12, GEODUDE, 14, ONIX, 0
+; Rematch
+	db $FF, 62, OMASTAR, 63, ONIX, 63, KABUTOPS, 62, GOLEM, 64, DUGTRIO, 64, AERODACTYL, 0
...

3. Make Scripts

Open scripts/PewterGym.asm and make these changes.

PewterGymBrockPostBattle:
	ld a, [wIsInBattle]
	cp $ff
	jp z, PewterGymResetScripts
	ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
	ld [wJoyIgnore], a
+	CheckEvent EVENT_PLAYER_IS_CHAMPION
+	jr nz, BrockRematchPostBattle
; fallthrough
PewterGymScriptReceiveTM34:
...
...
+BrockRematchPostBattle:
+	ld a, TEXT_PEWTERGYM_REMATCH_POST_BATTLE
+	ldh [hTextID], a
+	call DisplayTextID
+	jp PewterGymResetScripts

PewterGym_TextPointers:
	def_text_pointers
	dw_const PewterGymBrockText,             TEXT_PEWTERGYM_BROCK
	dw_const PewterGymCooltrainerMText,      TEXT_PEWTERGYM_COOLTRAINER_M
	dw_const PewterGymGuideText,             TEXT_PEWTERGYM_GYM_GUIDE
	dw_const PewterGymBrockWaitTakeThisText, TEXT_PEWTERGYM_BROCK_WAIT_TAKE_THIS
	dw_const PewterGymReceivedTM34Text,      TEXT_PEWTERGYM_RECEIVED_TM34
	dw_const PewterGymTM34NoRoomText,        TEXT_PEWTERGYM_TM34_NO_ROOM
+	dw_const PewterGymRematchPostBattleText, TEXT_PEWTERGYM_REMATCH_POST_BATTLE
...
...
PewterGymBrockText:
	text_asm
	CheckEvent EVENT_BEAT_BROCK
	jr z, .beforeBeat
	CheckEventReuseA EVENT_GOT_TM34
	jr nz, .afterBeat
	call z, PewterGymScriptReceiveTM34
	call DisableWaitingAfterTextDisplay
-	jr .done
+	jp TextScriptEnd
.afterBeat
+	CheckEvent EVENT_PLAYER_IS_CHAMPION
+	jr nz, BrockRematchPostBattle
	ld hl, .PostBattleAdviceText
	call PrintText
-	jr .done
+	jp TextScriptEnd
.beforeBeat
	ld hl, .PreBattleText
	call PrintText
	ld hl, wStatusFlags3
	set BIT_TALKED_TO_TRAINER, [hl]
	set BIT_PRINT_END_BATTLE_TEXT, [hl]
	ld hl, PewterGymBrockReceivedBoulderBadgeText
	ld de, PewterGymBrockReceivedBoulderBadgeText
	call SaveEndBattleTextPointers
	ldh a, [hSpriteIndex]
	ld [wSpriteIndex], a
	call EngageMapTrainer
	call InitBattleEnemyParameters
	ld a, $1
	ld [wGymLeaderNo], a
	xor a
	ldh [hJoyHeld], a
+	jr .endBattle
+.BrockRematch
+	ld hl, .PreBattleRematchText
+	call PrintText
+	call YesNoChoice
+	ld a, [wCurrentMenuItem]
+	and a
+	jr nz, .refused
+	ld hl, .PreBattleRematchAcceptedText
+	call PrintText
+	call Delay3
+	ld hl, wStatusFlags3
+	set BIT_TALKED_TO_TRAINER, [hl]
+	set BIT_PRINT_END_BATTLE_TEXT, [hl]
+	ld hl, PewterGymRematchDefeatedText
+	ld de, PewterGymRematchVictoryText
+	call SaveEndBattleTextPointers
+	ld a, OPP_BROCK
+	ld [wCurOpponent], a
+	ld a, 2
+	ld [wTrainerNo], a
+	ld a, $4 ; new script
+	ld [wPewterGymCurScript], a
+	ld [wCurMapScript], a
+	jr .endBattle
+.refused
+	ld hl, .PreBattleRematchRefusedText
+	call PrintText
+	jp TextScriptEnd
+.endBattle
	ld a, SCRIPT_PEWTERGYM_BROCK_POST_BATTLE
	ld [wPewterGymCurScript], a
	ld [wCurMapScript], a
-.done
	jp TextScriptEnd
...
...
.PostBattleAdviceText:
	text_far _PewterGymBrockPostBattleAdviceText
	text_end

+.PreBattleRematchText
+	text_far _PewterGymRematchPreBattleText
+	text_end
	
+.PreBattleRematchAcceptedText
+	text_far _PewterGymRematchAcceptedText
+	text_end
	
+.PreBattleRematchRefusedText
+	text_far _PewterGymRematchRefusedText
+	text_end

+PewterGymRematchDefeatedText:
+	text_far _PewterGymRematchDefeatedText
+	text_end

+PewterGymRematchVictoryText:
+	text_far _PewterGymRematchVictoryText
+	text_end

+PewterGymRematchPostBattleText:
+	text_far _PewterGymRematchPostBattleText
+	text_end
...

4. Add Text.

Open text/PewterGym.asm and put these lines at the end. Customize the text for other gym leaders to make them sound more like themselves.

...
+_PewterGymRematchPreBattleText::
+	text "Since our last"
+	line "battle, my"
	
+	para "#MON have"
+	line "grown!"

+	para "ROCK-hard will"
+	line "meets peak skill"
+	cont "today!"

+	para "Ready for the"
+	line "rematch of a"
+	cont "lifetime?"
+	done

+_PewterGymRematchAcceptedText::
+	text "Stones sharpen!"
+	line "Let's battle!"
+	done

+_PewterGymRematchRefusedText::
+	text "Maybe some other"
+	line "time."
+	done

+_PewterGymRematchDefeatedText::
+	text "I knew"
+	line "you were strong,"
+	cont "but this..."
+	prompt

+_PewterGymRematchVictoryText::
+	text "The best"
+	line "offense is a"
+	cont "good defense!"

+	para "That's my way of"
+	line "doing things!"
+	prompt

+_PewterGymRematchPostBattleText::
+	text "Incredible!"

+	para "Your strength"
+	line "is unmatched!"

+	para "True to your"
+	line "title, CHAMPION."

+	para "Continue to lead"
+	line "#MON with"
+	cont "honor and"
+	cont "courage!"

+	para "New challenges"
+	line "await."
+	done

And I think that's about it! Improve this tutorial if needed.

Clone this wiki locally