Skip to content

Make the Lottery Corner generate a lucky number daily instead of weekly

FrenchOrange edited this page Dec 2, 2022 · 10 revisions

In generation 2, the Lottery Corner is located in the 1st floor of the Radio Tower and we can get a random ID number by either talking to a recepcionist or listening to the Lucky Number Show on the Lucky Channel every Friday. As we know, in future generations this number is generated daily instead of weekly, so the objective of this tutorial will be to make it behave like in modern generations so that we can try our luck more often.

Contents

  1. Reset wLuckyNumberShowFlag daily instead of weekly
  2. Change the behavior of both CheckLuckyNumberShowFlag and ResetLuckyNumberShowFlag
  3. Modify the recepcionist's script
  4. Edit the Lucky Number Show
  5. Edit dialogues

1. Reset wLuckyNumberShowFlag daily instead of weekly

There's a variable in WRAM called wLuckyNumberShowFlag which contains the flag that gets set when we get a prize from the Lottery Corner and gets reset every Friday. This flag is called ENGINE_LUCKY_NUMBER_SHOW, which corresponds to bit 0 of wLuckyNumberShowFlag. We'll make it reset daily by going to engine/overworld/time.asm and editing CheckDailyResetTimer:

CheckDailyResetTimer::
	ld hl, wDailyResetTimer
	call CheckDayDependentEventHL
	ret nc
	xor a
	ld hl, wDailyFlags1
	ld [hli], a ; wDailyFlags1
	ld [hli], a ; wDailyFlags2
	ld [hli], a ; wSwarmFlags
	ld [hl], a  ; wSwarmFlags + 1
+	ld [wLuckyNumberShowFlag], a
	ld hl, wDailyRematchFlags

With this change, the contents of wLuckyNumberShowFlag will get reset every day. So now, let's go to the next part.

2. Change the behavior of both CheckLuckyNumberShowFlag and ResetLuckyNumberShowFlag

In maps/RadioTower1F.asm, there are two special event commands that get called whenever we either talk to the recepcionist or listen to the Lucky Number Show: CheckLuckyNumberShowFlag and ResetLuckyNumberShowFlag. The first one checks if the flag is set or not and how many days are left until the next Friday; the second resets the flag when it's Friday again and also generates the random number. Since we managed to reset wLuckyNumberShowFlag daily, we need to modify ResetLuckyNumberShowFlag so that it only generates our desired random number. Go to engine/events/specials.asm:

ResetLuckyNumberShowFlag:
-	farcall RestartLuckyNumberCountdown
-	ld hl, wLuckyNumberShowFlag
-	res LUCKYNUMBERSHOW_GAME_OVER_F, [hl]
	farcall LoadOrRegenerateLuckyIDNumber
	ret

And we also need to modify CheckLuckyNumberShowFlag so that it only checks whether the flag is set or not:

CheckLuckyNumberShowFlag:
-	farcall _CheckLuckyNumberShowFlag
-	jp ScriptReturnCarry
+	ld hl, wLuckyNumberShowFlag
+	bit LUCKYNUMBERSHOW_GAME_OVER_F, [hl]
+	ret

3. Modify the recepcionist's script

Go to maps/RadioTower1F.asm:

RadioTower1FLuckyNumberManScript:
	faceplayer
	opentext
	writetext RadioTower1FLuckyNumberManAskToPlayText
	promptbutton
-	special CheckLuckyNumberShowFlag
-	iffalse .skip
+	checkflag ENGINE_LUCKY_NUMBER_SHOW
+	iftrue .skip
	special ResetLuckyNumberShowFlag
.skip
	...

Now the script will first check the flag's status and, in case it's reset, proceed to generate the new daily random number. But you might be wondering "Why did we modify CheckLuckyNumberShowFlag in the first place if we ended up removing it from the script?" Because we'll need this new version for the Lucky Number Show, which we're going to edit in the next step!

4. Edit the Lucky Number Show

Go to engine/pokegear/radio.asm and edit LuckyNumberShow1:

LuckyNumberShow1:
	call StartRadioStation
	callfar CheckLuckyNumberShowFlag
-	jr nc, .dontreset
+	jr nz, .dontreset
	callfar ResetLuckyNumberShowFlag
.dontreset
	...

Here we follow a logic similar to the previous step: CheckLuckyNumberShowFlag copies the value of the ENGINE_LUCKY_NUMBER_SHOW flag into the Z flag and if it's set (Z = 1, or NZ), we jump to .dontreset so we don't reset the lucky number yet; if the flag is reset then it means it's a new day and we can safely reset the number.

5. Edit some NPCs' dialogues

The only thing left is to edit some NPCs' dialogues to indicate the Lucky Number Show is now a daily event instead of weekly. For that, let's first edit data/text/common_1.asm:

 _LC_Text7::
	text_start
-	line "This week's Lucky"
+	line "Today's Lucky"
	done
	...

Then maps/RadioTower1F.asm:

 RadioTower1FLuckyNumberManThisWeeksIdIsText:
-	text "This week's ID"
+	text "Today's ID number"
	line "is @"
	text_ram wStringBuffer3
	text "."
	done

	...

 RadioTower1FLuckyNumberManComeAgainText:
	text "Please come back"
-	line "next week for the"
+	line "tomorrow for the"
	cont "next LUCKY NUMBER."
	done

And finally maps/FastShipCabins_SW_SSW_NW.asm:

 GuitaristClydeAfterBattleText:
	text "Speaking of the"
	line "RADIO STATION,"

-	para "what's this week's"
-	line "lucky number?"
+	para "what's today's lucky"
+	line "number?"
	done

And that's it! Now the Lucky Number Show will generate a lucky number daily and we can get it by either talking to the receptionist or listening to the show, so go try your luck and get a prize! (And if you don't get it, don't worry, you can now try the next day). ;-)

Clone this wiki locally