• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

I am having issues changing the encounter table for the Old Rod in my ROM Hack of Pokemon Red

  • 7
    Posts
    121
    Days
    • Seen Oct 8, 2024
    Hello!

    I am working on my ROM hack of Pokemon Red and Blue and trying to change how the Fishing Rods work in the game.

    My main objectives are:
    - to make the Old Rod obtainable earlier and to have a designated pool of encounters similar to the Good Rod
    - to make the Good Rod obtainable earlier and to have designated encounter tables based on location similar to the Super Rod
    - to make the Super Rod have more varied encounters across more areas

    Currently, I am working on the Old Rod

    I have successfully created a new house in Cerulean City where players can obtain the Old Rod and I am working on modifying the Old Rod functionality so that it looks at a file similar to GoodRodMons to check which Pokemon should be encountered with a successful bite, however, the code is copied from the Good Rod code and currently only considers the first 2 encounters in the file, rather than the 10 encounters I have added.

    Does anyone have any tips or ideas on ensuring the code doesn't ignore the other encounters in the encounter table?

    This is the customer code I am using for the Old Rod in my ROM hack, from the file max_pokered/engine/items/item_effects.asm:
    ItemUseOldRod:
    call FishingInit
    jp c, ItemUseNotTime
    .RandomLoop
    call Random
    srl a
    jr c, .SetBite
    and %11
    cp 2
    jr nc, .RandomLoop
    ; choose which monster appears
    ld hl, OldRodMons
    add a
    ld c, a
    ld b, 0
    add hl, bc
    ld b, [hl]
    inc hl
    ld c, [hl]
    and a
    .SetBite
    ld a, 0
    rla
    xor 1
    jr RodResponse

    INCLUDE "data/wild/old_rod.asm"

    And this is the content of the file max_pokered/data/wild/old_rod.asm:
    ; random choice of 10 old rod encounters
    OldRodMons:
    ; level, species
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 10, MAGIKARP
    db 10, MAGIKARP
    db 10, MAGIKARP
    db 15, MAGIKARP
    db 15, MAGIKARP
    db 12, GOLDEEN
     
    Hello!

    I am working on my ROM hack of Pokemon Red and Blue and trying to change how the Fishing Rods work in the game.

    My main objectives are:
    - to make the Old Rod obtainable earlier and to have a designated pool of encounters similar to the Good Rod
    - to make the Good Rod obtainable earlier and to have designated encounter tables based on location similar to the Super Rod
    - to make the Super Rod have more varied encounters across more areas

    Currently, I am working on the Old Rod

    I have successfully created a new house in Cerulean City where players can obtain the Old Rod and I am working on modifying the Old Rod functionality so that it looks at a file similar to GoodRodMons to check which Pokemon should be encountered with a successful bite, however, the code is copied from the Good Rod code and currently only considers the first 2 encounters in the file, rather than the 10 encounters I have added.

    Does anyone have any tips or ideas on ensuring the code doesn't ignore the other encounters in the encounter table?

    This is the customer code I am using for the Old Rod in my ROM hack, from the file max_pokered/engine/items/item_effects.asm:
    ItemUseOldRod:
    call FishingInit
    jp c, ItemUseNotTime
    .RandomLoop
    call Random
    srl a
    jr c, .SetBite
    and %11
    cp 2
    jr nc, .RandomLoop
    ; choose which monster appears
    ld hl, OldRodMons
    add a
    ld c, a
    ld b, 0
    add hl, bc
    ld b, [hl]
    inc hl
    ld c, [hl]
    and a
    .SetBite
    ld a, 0
    rla
    xor 1
    jr RodResponse

    INCLUDE "data/wild/old_rod.asm"

    And this is the content of the file max_pokered/data/wild/old_rod.asm:
    ; random choice of 10 old rod encounters
    OldRodMons:
    ; level, species
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 5, MAGIKARP
    db 10, MAGIKARP
    db 10, MAGIKARP
    db 10, MAGIKARP
    db 15, MAGIKARP
    db 15, MAGIKARP
    db 12, GOLDEEN
    The code uses only the first two encounters because .RandomLoop is selecting a random value between 0 and 1 to use as an index to the table. For 10 slots you should modify it so that it selects a value between 0 and 9.
     
    The code uses only the first two encounters because .RandomLoop is selecting a random value between 0 and 1 to use as an index to the table. For 10 slots you should modify it so that it selects a value between 0 and 9.
    Thank you so much for your help!

    I have tried modifying this function to get a random number between 0 and 9 instead, but this is a bit beyond me.
    The only way I can think of doing this would be something like this:
    ItemUseOldRod:
    call FishingInit
    jp c, ItemUseNotTime
    .RandomLoop
    call Random ; Get a random byte (0-255)
    ld a, 9 ; Load 9 into A
    div a ; Divide the random byte by 10 (0-9)
    ld c, a ; Store result in C
    ; Choose which monster appears
    ld hl, OldRodMons ; Load the base address of OldRodMons
    ld a, c ; Load random number into A
    ld c, a ; Set C as the offset (in bytes, considering each entry is 2 bytes)
    ld b, 0 ; Set B to 0 for offset calculation
    add hl, bc ; Calculate the address of the encounter entry
    ld b, [hl] ; Load Pokémon ID from the encounter table
    inc hl ; Move to the next byte
    ld c, [hl] ; Load Pokémon level from the encounter table
    ; Perform any encounter validity checks if needed
    and a ; Modify as necessary for encounter validity check
    jr c, .SetBite ; If valid, go to .SetBite
    ; If encounter is not valid, loop back to .RandomLoop
    jr .RandomLoop
    .SetBite
    ld a, 0
    rla
    xor 1
    jr RodResponse

    INCLUDE "data/wild/old_rod.asm"

    But this doesn't work in RGBASM
     
    The code uses only the first two encounters because .RandomLoop is selecting a random value between 0 and 1 to use as an index to the table. For 10 slots you should modify it so that it selects a value between 0 and 9.
    I got it to work!

    I just needed to do this adjustment to the .RandomLoop function:
    .RandomLoop
    call Random
    srl a
    jr c, .SetBite
    and %0000_1111
    cp 10
    jr nc, .RandomLoop

    Thank you so much for the insight into this issue!
     
    I got it to work!

    I just needed to do this adjustment to the .RandomLoop function:
    .RandomLoop
    call Random
    srl a
    jr c, .SetBite
    and %0000_1111
    cp 10
    jr nc, .RandomLoop

    Thank you so much for the insight into this issue!
    While that modification works, you should note that it also increases the chance of getting an encounter from 33% to around 38%.
     
    While that modification works, you should note that it also increases the chance of getting an encounter from 33% to around 38%.
    Oh! I hadn't thought of that at all. That is because the two random numbers used for the .setbite and the index of the encounter table are in the same loop, correct?
    I would need to separate them to make sure that I keep the same odds of an encounter.

    Thank you for all the insight into this.
     
    Back
    Top