diff options
-rw-r--r-- | Make-the-Lottery-Corner-generate-a-lucky-number-daily-instead-of-weekly.md | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Make-the-Lottery-Corner-generate-a-lucky-number-daily-instead-of-weekly.md b/Make-the-Lottery-Corner-generate-a-lucky-number-daily-instead-of-weekly.md new file mode 100644 index 0000000..ada241e --- /dev/null +++ b/Make-the-Lottery-Corner-generate-a-lucky-number-daily-instead-of-weekly.md @@ -0,0 +1,97 @@ +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 it on the Lucky Channel every Friday, and therefore try our luck to get a prize. As we know, in future generations this number is generated _daily_ instead of weekly, so the objective of this tutorial will be to generate this number daily so that we can try our luck more often. + +## Contents + +1. [Reset `wLuckyNumberShowFlag` daily instead of weekly](#1-reset-wluckynumbershowflag-daily-instead-of-weekly) +2. [Change the behavior of both `CheckLuckyNumberShowFlag` and `ResetLuckyNumberShowFlag`](#2-change-the-behavior-of-both-checkluckynumbershowflag-and-resetluckynumbershowflag) +3. [Edit the recepcionist's script](#3-edit-the-recepcionists-script) +4. [Edit the Lucky Number Show](#4-edit-the-lucky-number-show) + + +## 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 `LUCKYNUMBERSHOW_GAME_OVER_F`, which corresponds to bit 0 of `wLuckyNumberShowFlag`. We'll make it reset daily by going to [engine/overworld/time.asm](../blob/master/engine/overworld/time.asm) and editing `CheckDailyResetTimer`: + +```diff +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](../blob/master/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 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](../blob/engine/events/specials.asm): + +```diff +ResetLuckyNumberShow: +- 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: + +```diff +CheckLuckyNumberShowFlag: +- farcall _CheckLuckyNumberShowFlag +- jp ScriptReturnCarry ++ ld hl, wLuckyNumberShowFlag ++ bit LUCKYNUMBERSHOW_GAME_OVER_F, [hl] ++ ret +``` + +## 3. Edit the recepcionist's script + +Go to [maps/RadioTower1F.asm](../blob/master/maps/RadioTower1F.asm): + +```diff +RadioTower1FLuckyNumberManScript: + faceplayer + opentext + writetext RadioTower1FLuckyNumberManAskToPlayText + promptbutton +- special CheckLuckyNumberShowFlag +- iffalse .skip ++ checkflag ENGINE_LUCKY_NUMBER_SHOW ++ iftrue, .skip + special ResetLuckyNumberShow +.skip + ... +``` + +Now the script will first check the flag's status and, in case it's set, proceed to reset it and also generate the new daily random number. But you might be wondering "Why did we modify `CheckLuckyNumberShowFlag` in the first place if we removed it?" 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](../blob/master/engine/pokegear/radio.asm) and edit `LuckyNumberShow1`: + +```diff +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 `LUCKYNUMBERSHOW_GAME_OVER_F` 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. + + +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 recepcionist or listening to the show, so go try your luck and get that prize! (And if you don't get it, don't worry, you still have the next day).
\ No newline at end of file |