Skip to content

Reset Legendaries When Beating Elite Four

judicornadamsfoster edited this page Aug 26, 2026 · 1 revision

When you defeat some legendaries (mainly event legends), beating the Elite Four can reset these so you get a second chance to battle/catch them.

But the Regi's and the box art trio don't get reset, meaning if you defeat them in battle they're gone forever.

This adds code to reset these legendaries so they get reset when beating the Elite Four.


pull from branch

git remote add tenaya15 https://github.com/tenaya15/tenaya15emerald
git pull tenaya15 reset_defeated_legendaries

compare

or manually add using the below guide


include/constants.flags.h

rename 6 unused flags (0x4A to 0x4F in this example)

#define FLAG_CAUGHT_REGIROCK    0x4A
#define FLAG_CAUGHT_REGICE      0x4B
#define FLAG_CAUGHT_REGISTEEL   0x4C
#define FLAG_CAUGHT_KYOGRE      0x4D
#define FLAG_CAUGHT_GROUDON     0x4E
#define FLAG_CAUGHT_RAYQUAZA    0x4F

data/event_scripts.inc

this code negates having to create a script for end in every map file

add this to the bottom of the file

Common_EventScript_End::
	end


data/scripts/hall_of_fame.inc

replace everything in EverGrandeCity_HallOfFame_EventScript_ResetDefeatedEventLegendaries
with:

	clearflag FLAG_DEFEATED_MEW
	clearflag FLAG_DEFEATED_LATIAS_OR_LATIOS
	clearflag FLAG_DEFEATED_DEOXYS
	clearflag FLAG_DEFEATED_LUGIA
	clearflag FLAG_DEFEATED_HO_OH
	clearflag FLAG_DEFEATED_REGIROCK
	clearflag FLAG_DEFEATED_REGICE
	clearflag FLAG_DEFEATED_REGISTEEL
	clearflag FLAG_DEFEATED_KYOGRE
	clearflag FLAG_DEFEATED_GROUDON
	clearflag FLAG_DEFEATED_RAYQUAZA
	return

data/maps/DesertRuins/scripts.inc

in section DesertRuins_OnTransition
add after setflag FLAG_LANDMARK_DESERT_RUINS

	goto_if_set FLAG_CAUGHT_REGIROCK, Common_EventScript_End

so the section should be:

DesertRuins_OnTransition:
setflag FLAG_LANDMARK_DESERT_RUINS
goto_if_set FLAG_CAUGHT_REGIROCK, Common_EventScript_End
call_if_unset FLAG_DEFEATED_REGIROCK, DesertRuins_EventScript_ShowRegirock
end

in section DesertRuins_EventScript_Regirock
add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, DesertRuins_EventScript_CaughtRegirock

add this after the end of section DesertRuins_EventScript_Regirock

DesertRuins_EventScript_CaughtRegirock::
	setflag FLAG_CAUGHT_REGIROCK
	setflag FLAG_DEFEATED_REGIROCK
	goto Common_EventScript_RemoveStaticPokemon
	end


data/maps/IslandCave/scripts.inc

in section IslandCave_OnTransition
add after line call IslandCave_EventScript_ClearSteps

	goto_if_set FLAG_CAUGHT_REGICE, Common_EventScript_End

so the section should be:

IslandCave_OnTransition:
setflag FLAG_LANDMARK_ISLAND_CAVE
call IslandCave_EventScript_ClearSteps
goto_if_set FLAG_CAUGHT_REGICE, Common_EventScript_End
call_if_unset FLAG_DEFEATED_REGICE, IslandCave_EventScript_ShowRegice
end

in section IslandCave_EventScript_Regice

add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, IslandCave_EventScript_CaughtRegice

add this after the end of section IslandCave_EventScript_Regice

IslandCave_EventScript_CaughtRegice::
	setflag FLAG_CAUGHT_REGICE
	setflag FLAG_DEFEATED_REGICE
	goto Common_EventScript_RemoveStaticPokemon
	end


data/maps/AncientTomb/scripts.inc

in section AncientTomb_OnTransition
add after setflag FLAG_LANDMARK_ANCIENT_TOMB

	goto_if_set FLAG_CAUGHT_REGISTEEL, Common_EventScript_End

so the section should be:

AncientTomb_OnTransition:
setflag FLAG_LANDMARK_ANCIENT_TOMB
goto_if_set FLAG_CAUGHT_REGISTEEL, Common_EventScript_End
call_if_unset FLAG_DEFEATED_REGISTEEL, AncientTomb_EventScript_ShowRegisteel
end

in section AncientTomb_EventScript_Registeel

add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, AncientTomb_EventScript_CaughtRegisteel

add this after the end of section AncientTomb_EventScript_Registeel

AncientTomb_EventScript_CaughtRegisteel::
	setflag FLAG_CAUGHT_REGISTEEL
	setflag FLAG_DEFEATED_REGISTEEL
	goto Common_EventScript_RemoveStaticPokemon
	end


data/maps/Marine_Cave_End/scripts.inc

in section MarineCave_End_OnTransition
add as the first line

	goto_if_set FLAG_CAUGHT_KYOGRE, Common_EventScript_End

so the section should be:

MarineCave_End_OnTransition:
goto_if_set FLAG_CAUGHT_KYOGRE, Common_EventScript_End
call_if_unset FLAG_DEFEATED_KYOGRE, MarineCave_End_EventScript_ShowKyogre
end

in section MarineCave_End_EventScript_Kyogre

add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, MarineCave_End_EventScript_CaughtKyogre

add this after the end of section MarineCave_End_EventScript_Kyogre

MarineCave_End_EventScript_CaughtKyogre::
	setvar VAR_SHOULD_END_ABNORMAL_WEATHER, 1
	setflag FLAG_CAUGHT_KYOGRE
	setflag FLAG_DEFEATED_KYOGRE
	goto Common_EventScript_RemoveStaticPokemon
	end


data/maps/TerraCave_End/scripts.inc

in section TerraCave_End_OnTransition
add as the first line

TerraCave_End_OnTransition:
	goto_if_set FLAG_CAUGHT_GROUDON, Common_EventScript_End

so the section should be:

TerraCave_End_OnTransition:
goto_if_set FLAG_CAUGHT_GROUDON, Common_EventScript_End
call_if_unset FLAG_DEFEATED_GROUDON, TerraCave_End_EventScript_ShowGroudon
end

in section TerraCave_End_EventScript_Groudon

add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, TerraCave_End_EventScript_CaughtGroudon

add this after the end of section TerraCave_End_EventScript_Groudon

TerraCave_End_EventScript_CaughtGroudon::
	setvar VAR_SHOULD_END_ABNORMAL_WEATHER, 1
	setflag FLAG_CAUGHT_GROUDON
	setflag FLAG_DEFEATED_GROUDON
	goto Common_EventScript_RemoveStaticPokemon
	end


data/maps/SkyPillar_Top/scripts.inc

in section SkyPillar_Top_OnTransition
add after call_if_lt VAR_SKY_PILLAR_STATE, 2, SkyPillar_Top_EventScript_SetCleanLayout

	goto_if_set FLAG_CAUGHT_RAYQUAZA, Common_EventScript_End

so the section should be:

SkyPillar_Top_OnTransition:
call_if_lt VAR_SKY_PILLAR_STATE, 2, SkyPillar_Top_EventScript_SetCleanLayout
goto_if_set FLAG_CAUGHT_RAYQUAZA, Common_EventScript_End
call_if_ge VAR_SKY_PILLAR_STATE, 2, SkyPillar_Top_EventScript_TryShowRayquaza
end

in section SkyPillar_Top_EventScript_Rayquaza

add after specialvar VAR_RESULT, GetBattleOutcome

	goto_if_eq VAR_RESULT, B_OUTCOME_CAUGHT, SkyPillar_Top_EventScript_CaughtRayquaza

add this after the end of section SkyPillar_Top_EventScript_Rayquaza

SkyPillar_Top_EventScript_CaughtRayquaza::
	setflag FLAG_CAUGHT_RAYQUAZA
	setflag FLAG_DEFEATED_RAYQUAZA
	goto SkyPillar_Top_EventScript_DefeatedRayquaza2
	end


Clone this wiki locally