Add a new fishing rod - pret/pokecrystal GitHub Wiki
This tutorial is for how to add a new fishing rod. As an example, we'll add a Master Rod, even better than a Super Rod.
- Create the new Rod item
- Define the item effect
- Define wild data for the new Rod
- Update the code that loads the wild data
Follow the tutorial to add a new item to create the Master Rod. Replace ITEM_88
with MASTER_ROD
, and give it a name, description, and attributes (0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE
). (ITEM_88
is not in TimeCapsule_CatchRateItems
.)
Edit engine/items/item_effects.asm:
ItemEffects:
; entries correspond to item ids
dw PokeBallEffect ; MASTER_BALL
...
dw NoEffect ; ITEM_87
- dw NoEffect ; ITEM_88
+ dw MasterRodEffect ; MASTER_ROD
dw NoEffect ; ITEM_89
...
dw NoEffect ; ITEM_B3
...
OldRodEffect:
ld e, $0
jr UseRod
GoodRodEffect:
ld e, $1
jr UseRod
SuperRodEffect:
ld e, $2
jr UseRod
+
+MasterRodEffect:
+ ld e, $3
+ ; fallthrough
UseRod:
farcall FishFunction
ret
Pretty simple; we just observe how the other three Rods work, and follow their pattern. Since UseRod
is right there underneath where we're editing, we can just fall through to it instead of jumping with jr
; in fact, Game Freak could have done this themselves with SuperRodEffect
.
Edit data/wild/fish.asm:
time_group EQUS "0," ; use the nth TimeFishGroups entry
fishgroup: MACRO
-; chance, old rod, good rod, super rod
- dbwww \1, \2, \3, \4
+; chance, old rod, good rod, super rod, master rod
+ db \1
+ dw \2, \3, \4, \5
ENDM
FishGroups:
; entries correspond to FISHGROUP_* constants
- fishgroup 50 percent + 1, .Shore_Old, .Shore_Good, .Shore_Super
- ...
- fishgroup 50 percent + 1, .Qwilfish_NoSwarm_Old, .Qwilfish_NoSwarm_Good, .Qwilfish_NoSwarm_Super
+ fishgroup 50 percent + 1, .Shore_Old, .Shore_Good, .Shore_Super, .Shore_Master
+ ...
+ fishgroup 50 percent + 1, .Qwilfish_NoSwarm_Old, .Qwilfish_NoSwarm_Good, .Qwilfish_NoSwarm_Super, .Qwilfish_NoSwarm_Master
...
.Remoraid_Old:
db 70 percent + 1, MAGIKARP, 10
db 85 percent + 1, MAGIKARP, 10
db 100 percent, POLIWAG, 10
.Remoraid_Good:
db 35 percent, MAGIKARP, 20
db 70 percent, POLIWAG, 20
db 90 percent + 1, POLIWAG, 20
db 100 percent, time_group 6
.Remoraid_Super:
db 40 percent, POLIWAG, 40
db 70 percent, time_group 7
db 90 percent + 1, MAGIKARP, 40
db 100 percent, REMORAID, 40
+
+.Shore_Master:
+.Ocean_Master:
+.Lake_Master:
+.Pond_Master:
+.WhirlIslands_Master:
+ db 20 percent, OMASTAR, 60
+ db 40 percent, KABUTOPS, 60
+ db 70 percent, OCTILLERY, 60
+ db 90 percent + 1, LAPRAS, 60
+ db 100 percent, KINGDRA, 60
+
+.Gyarados_Master:
+ db 40 percent, MAGIKARP, 60
+ db 70 percent, GYARADOS, 60
+ db 90 percent + 1, GYARADOS, 60
+ db 100 percent, GYARADOS, 60
+
+.Dratini_Master:
+.Dratini_2_Master:
+ db 40 percent, GYARADOS, 60
+ db 70 percent, KINGDRA, 60
+ db 90 percent + 1, DRAGONAIR, 60
+ db 100 percent, DRAGONITE, 60
+
+.Qwilfish_Master:
+.Qwilfish_Swarm_Master:
+.Qwilfish_NoSwarm_Master:
+ db 40 percent, TENTACRUEL, 60
+ db 70 percent, QWILFISH, 60
+ db 90 percent + 1, QWILFISH, 60
+ db 100 percent, QWILFISH, 60
+
+.Remoraid_Master:
+.Remoraid_Swarm_Master:
+ db 40 percent, TENTACRUEL, 60
+ db 70 percent, REMORAID, 60
+ db 90 percent + 1, REMORAID, 60
+ db 100 percent, OCTILLERY, 60
Here we've modified the fishgroup
macro to take four pointers instead of three; added new pointers to the end of each fishgroup
line for the Master Rod; and declared the actual data for the new Master Rod pointers.
Notice the format of the wild data. Each line has the format "db chance, species, level
" or "db chance, time_group index
", with the chances increasing up to 100%. A random byte from 0% to 100% is generated, and compared with the chances to determine your encounter.
Edit constants/pokemon_data_constants.asm:
-FISHGROUP_DATA_LENGTH EQU 1 + 2 * 3
+FISHGROUP_DATA_LENGTH EQU 1 + 2 * 4
If you're using an older copy of pokecrystal and FISHGROUP_DATA_LENGTH
does not exist, then edit engine/events/fish.asm instead:
Fish:
; Using a fishing rod.
; Fish for monsters with rod e in encounter group d.
; Return monster e at level d.
push af
push bc
push hl
ld b, e
call GetFishGroupIndex
ld hl, FishGroups
-rept 7
+rept 9
add hl, de
endr
call .Fish
pop hl
pop bc
pop af
ret
Either way, this allows the FishGroups
table to be indexed by Rods from 0 to 3, instead of 0 to 2. (Remember how we defined MasterRodEffect
.)
We're done!