Groundwork for the Candy Jar rework

This does everything except the incrementation.

If you defeat a Meltan, `wCandyJarCount` increments by 1, capping at 40. This is represented in-game as 10, going up to 400, simply by adding a 0 at the end. This, in effect, replicates the Meltan quest from Pokemon Go.

Once 40/400 is reached, the Candy Jar will become an evolution stone, evolving Meltan. Instead of consuming the Jar, the Candies inside are zeroed out.

Currently, the Candy Jar increments, but only once, thus why this is being committed on a separate branch. The bug appears to be at `engine\battle\core.asm`, line 842-861, likely 854-856. It's possible that it could be due to its position in WRAM, or that it's a `db` instead of a `dw`.
This commit is contained in:
Llinos Evans 2023-05-31 13:37:55 +01:00
parent 934f8adcac
commit 228de2b718
7 changed files with 93 additions and 16 deletions

View file

@ -92,7 +92,7 @@ ItemUsePtrTable:
dw ItemUsePokeflute ; POKE_FLUTE
dw UnusableItem ; LIFT_KEY
dw UnusableItem ; EXP_ALL
dw ItemUseEvoStone ; was OLD_ROD, now CANDY_SACK
dw ItemUseCandyJar ; was OLD_ROD, now CANDY_JAR
dw UnusableItem ; was GOOD_ROD, now BOTTLE_CAP
dw ItemUseSuperRod ; SUPER_ROD
dw ItemUsePPUp ; PP_UP (real one)
@ -138,6 +138,21 @@ ItemUseMysteryBox:
call PrintText
jp TextScriptEnd
ItemUseCandyJar:
; Candy Jar can't be used in battle.
ld a, [wIsInBattle]
and a
jp nz, ItemUseNotTime
ld [wCandyJarCount], a ; Get the Candy count
cp 40 ; Is it 40? (represented as 400)
jr z, .Evolve ; If yes, jump to Evo Stone Script
ld hl, CandyJarCount ; Otherwise, load the Candy total...
call PrintText ; and display it as text.
jp TextScriptEnd ; se acabo!
.Evolve ; Evo stone script time
jp ItemUseEvoStone ; Jump there!
ItemUseBall:
; Balls can't be used out of battle.
@ -824,10 +839,20 @@ ItemUseEvoStone:
jr z, .noEffect
pop af
ld [wWhichPokemon], a
; The Candy Jar jumps here to save space if it's capable of evolving Meltan.
; However, we don't want it to leave the inventory - we want it to lose the candy.
ld a, [wEvoStoneItemID] ; Load the item ID we just got
cp CANDY_JAR ; Is it the Candy Jar?
jr z, .zeroOutJar ; If return zero (true), save the Jar from destruction.
ld hl, wNumBagItems
ld a, 1 ; remove 1 stone
ld [wItemQuantity], a
jp RemoveItemFromInventory
.zeroOutJar
ld a, $0
ld [wCandyJarCount], a
ret
.noEffect
call ItemUseNoEffect
.canceledItemUse
@ -2998,3 +3023,7 @@ CheckMapForMon:
MysteryBoxText:
text_far _MysteryBoxText
text_end
CandyJarCount:
text_far _CandyJarCount
text_end