You are not logged in.
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.
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 "@"
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)
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.