1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
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](#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. [Modify the recepcionist's script](#3-modify-the-recepcionists-script)
4. [Edit the Lucky Number Show](#4-edit-the-lucky-number-show)
5. [Edit dialogues](#5-edit-some-npcs-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](../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 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](../blob/engine/events/specials.asm):
```diff
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:
```diff
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](../blob/master/maps/RadioTower1F.asm):
```diff
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](../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 `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](../blob/master/data/text/common_1.asm):
```diff
_LC_Text7::
text_start
- line "This week's Lucky"
+ line "Today's Lucky"
done
...
```
And also [maps/RadioTower1F.asm](../blob/master/maps/RadioTower1F.asm):
```diff
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 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 a prize! (And if you don't get it, don't worry, you can now try the next day). ;-)
|