Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2018-02-19 17:04:53

TRIFORCE89
Member
Registered: 2013-05-20
Post 20/29

[pokeyellow] Game Corner Conditional Prizes

I'm trying to get the prizes in the game corner to change based on certain conditions. But I don't think my syntax is correct.

In prizes.asm:

PrizeMenuMon1Entries:
    db CLEFAIRY
    CheckEvent EVENT_GOT_HITMONCHAN
        jr nz, db HITMONLEE
        db ABRA
    CheckEvent EVENT_GOT_HITMONLEE
        jr nz, db HITMONCHAN
        db ABRA
    db EEVEE
    db "@"

PrizeMenuMon1Cost:
    coins 750
    CheckEitherEventSet EVENT_GOT_HITMONLEE, EVENT_GOT_HITMONCHAN
        jr z, coins 1200
        coins 230
    coins 2680
    db "@"

In prize_mon_levels.asm:

PrizeMonLevelDictionary:
    db CLEFAIRY,12
    CheckEvent EVENT_GOT_HITMONCHAN
        jr nz, db HITMONLEE,20
        db ABRA,15
    CheckEvent EVENT_GOT_HITMONLEE
        jr nz, db HITMONCHAN,20
        db ABRA,15
    db EEVEE,25

Basically, if they have obtained a Hitmon from the Dojo, I want the counterpart available as a prize. Otherwise, default to Abra. Where did I screw up?

Last edited by TRIFORCE89 (2018-02-19 17:05:45)

Offline

#2 2018-02-21 17:37:54

Danny-E 33
Administrator
Registered: 2012-06-09
Post 1,072/1,119

Re: [pokeyellow] Game Corner Conditional Prizes

The data tables like PrizeMenuMon1Entries are determined at compile-time, so it doesn't make sense to have code like "CheckEvent" to make a run-time decision based on the players save file.

The way you have it, you have inserted assembly instructions into a data table. The original assembly routine that reads from this data table will now begin reading in asm opcodes instead of the intended data.

A better approach would be to create two copies of the data table, like:

PrizeMenuMon1Entries_GotNeither:
    db CLEFAIRY
    db ABRA
    db EEVEE
    db "@"

PrizeMenuMon1Cost_GotNeither:
    coins 750
    coins 230
    coins 2680
    db "@"

PrizeMenuMon1Entries_GotHitmonchan:
    db CLEFAIRY
    db HITMONLEE
    db EEVEE
    db "@"

PrizeMenuMon1Cost_GotHitmonchan:
    coins 750
    coins 1200
    coins 2680
    db "@"

PrizeMenuMon1Entries_GotHitmonlee:
    db CLEFAIRY
    db HITMONCHAN
    db EEVEE
    db "@"

PrizeMenuMon1Cost_GotHitmonlee:
    coins 750
    coins 1200
    coins 2680
    db "@"

Then modify the original routine that reads from these data tables. Modify it so that it uses one of the three sets of tables based on the events that you are checking.

The routine you want to modify is GetPrizeMenuId: in engine/menu/prize_menu.asm

You could change the top of data/prizes.asm to:

PrizeDifferentMenuPtrs_GotNeither:
    dw PrizeMenuMon1Entries_GotNeither
    dw PrizeMenuMon1Cost_GotNeither

    dw PrizeMenuMon2Entries
    dw PrizeMenuMon2Cost

    dw PrizeMenuTMsEntries
    dw PrizeMenuTMsCost

PrizeDifferentMenuPtrs_GotHitmonchan:
    dw PrizeMenuMon1Entries_GotHitmonchan
    dw PrizeMenuMon1Cost_GotHitmonchan

    dw PrizeMenuMon2Entries
    dw PrizeMenuMon2Cost

    dw PrizeMenuTMsEntries
    dw PrizeMenuTMsCost

PrizeDifferentMenuPtrs_GotHitmonlee:
    dw PrizeMenuMon1Entries_GotHitmonlee
    dw PrizeMenuMon1Cost_GotHitmonlee

    dw PrizeMenuMon2Entries
    dw PrizeMenuMon2Cost

    dw PrizeMenuTMsEntries
    dw PrizeMenuTMsCost

Then in GetPrizeMenuId, load either PrizeDifferentMenuPtrs_GotNeither, PrizeDifferentMenuPtrs_GotHitmonchan, or PrizeDifferentMenuPtrs_GotHitmonlee in hl based on the event flags

The level dictionary doesn't exactly have to be modified in the same way, because the code that reads the dictionary just scans the whole thing until the right Pokemon ID is found, so you could just change it to:

PrizeMonLevelDictionary:
    db CLEFAIRY,12
    db HITMONLEE,20
    db HITMONCHAN,20
    db ABRA,15
    db EEVEE,25

    ...

Let me know if you want more help modifying GetPrizeMenuId, but I think you should be able to do it.

Offline

#3 2018-02-24 15:02:24

TRIFORCE89
Member
Registered: 2013-05-20
Post 21/29

Re: [pokeyellow] Game Corner Conditional Prizes

Thank you kindly!

Offline

Board footer

Powered by FluxBB