From 9c953339aff0b23027ca42070da70bcd597e7974 Mon Sep 17 00:00:00 2001 From: Llinos Evans <36418502+PlagueVonKarma@users.noreply.github.com> Date: Wed, 31 May 2023 23:56:22 +0100 Subject: [PATCH] Candy Jar finished - Fixed a bug where the Candy Jar would load `wIsInBattle`'s 01, causing it to zero itself out every time. - Fixed a bug where the Candy Jar would display `wMysteryBoxActive` due to the way `text_bcd` was being used. Replaced with `text_decimal` so it actually displays properly as well. No hex!! - Added a test function for the evolution in the debug party because that's cool --- data/text/text_2.asm | 2 +- engine/battle/core.asm | 9 +++++---- engine/debug/debug_party.asm | 4 ++++ engine/items/item_effects.asm | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/data/text/text_2.asm b/data/text/text_2.asm index 4fbeae07..18cd3bab 100644 --- a/data/text/text_2.asm +++ b/data/text/text_2.asm @@ -1838,6 +1838,6 @@ _MysteryBoxCloseText:: _CandyJarCount:: text "MELTAN CANDY:" line "@" - text_bcd wCandyJarCount, 2 | LEADING_ZEROES | LEFT_ALIGN + text_decimal wCandyJarCount, 1, 2 text "0" prompt \ No newline at end of file diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b0bfdff0..5af2f81b 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -846,15 +846,16 @@ FaintEnemyPokemon: cp $E7 ; Is it Meltan? jr nz, .skip ; Continue as normal if not. + ; Increment the Candy Jar count. + ld a, [wCandyJarCount] + inc a + ld [wCandyJarCount], a + ; For engine\overworld\clear_variables.asm ; Needed so the Mystery Box effect isn't cleared upon leaving battle. ld a, $01 ld [wDontSwitchOffMysteryBoxYet], a - ld a, [wCandyJarCount] - inc a - ld [wCandyJarCount], a - ld hl, MeltanIncrement ; Load text to show it's going up. call PrintText ; Yep text. call PrintEmptyString ; vs text likes this. diff --git a/engine/debug/debug_party.asm b/engine/debug/debug_party.asm index 15641325..cc81e102 100644 --- a/engine/debug/debug_party.asm +++ b/engine/debug/debug_party.asm @@ -44,6 +44,10 @@ IF DEF(_DEBUG) ld a, 1 ld [wPlayerSex], a + ; Test Candy Jar Evolution + ld a, 39 + ld [wCandyJarCount], a + ; Get all badges except Earth Badge. ld a, ~(1 << BIT_EARTHBADGE) ld [wObtainedBadges], a diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 59e333f6..752452f9 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -144,7 +144,7 @@ ItemUseCandyJar: and a jp nz, ItemUseNotTime - ld [wCandyJarCount], a ; Get the Candy count + ld a, [wCandyJarCount] ; 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...