Merge pull request #14 from PlagueVonKarma/candy-jar-rework

Candy jar rework
This commit is contained in:
Llinos Evans 2023-06-01 00:07:35 +01:00 committed by GitHub
commit 0161329d9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 16 deletions

View file

@ -75,7 +75,7 @@ KeyItemFlags:
dbit TRUE ; POKE_FLUTE
dbit TRUE ; LIFT_KEY
dbit FALSE ; EXP_ALL
dbit FALSE ; was TRUE for OLD_ROD, now CANDY_SACK
dbit TRUE ; was TRUE for OLD_ROD, now CANDY_JAR
dbit FALSE ; was GOOD_ROD & TRUE, now BOTTLE_CAP
dbit TRUE ; SUPER_ROD
dbit FALSE ; PP_UP

View file

@ -1834,3 +1834,10 @@ _MysteryBoxCloseText::
text "<PLAYER> closed"
line "the BOX!"
prompt
_CandyJarCount::
text "MELTAN CANDY:"
line "@"
text_decimal wCandyJarCount, 1, 2
text "0"
prompt

View file

@ -839,6 +839,27 @@ FaintEnemyPokemon:
call PrintText
call PrintEmptyString
call SaveScreenTilesToBuffer1
; Meltan Candy functionality.
; The way this is done looks like it conflates 8- and 16-bit integers, but it never goes above 256, so it'll be fine.
ld a, [wEnemyMonSpecies] ; Load species.
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 hl, MeltanIncrement ; Load text to show it's going up.
call PrintText ; Yep text.
call PrintEmptyString ; vs text likes this.
.skip
xor a
ld [wBattleResult], a
ld a, [wCurMap]
@ -7173,3 +7194,8 @@ StupidBattleTentFix:
text "Oops! Better"
line "luck next time!"
prompt
MeltanIncrement:
text "<PLAYER> found"
line "10 MELTAN CANDY!"
prompt

View file

@ -22,12 +22,11 @@ SetIshiharaTeam:
IshiharaTeam:
db EXEGGUTOR_A, 90
db PURAKKUSU, 90
db MELTAN, 90
db TRAMPEL, 90
IF DEF(_DEBUG)
db TAUROS_PB, 90
db SNORLAX, 50
db TANGROWTH, 50
ENDC
db -1 ; end
@ -45,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
@ -162,6 +165,7 @@ DebugSetPokedexEntries:
DebugItemsList:
db MYSTERY_BOX, 1
db CANDY_JAR, 1
db BICYCLE, 1
db FULL_RESTORE, 99
db MAX_REPEL, 99

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 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...
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

View file

@ -10,11 +10,20 @@ ClearVariablesOnEnterMap::
ldh [hJoyReleased], a
ldh [hJoyHeld], a
ld [wActionResultOrTookBattleTurn], a
ld [wMysteryBoxActive], a
ld hl, wCardKeyDoorY
ld [hli], a
ld [hl], a
ld hl, wWhichTrade
ld bc, wStandingOnWarpPadOrHole - wWhichTrade
call FillMemory
; The Mystery Box for Meltan gets switched off when leaving every map, but SPECIFICALLY not after a battle.
; Because leaving battle is map re-entry, this exception is included.
ld a, [wDontSwitchOffMysteryBoxYet] ; Load WRAM bit.
and a ; Did a battle just happen?
jr nz, .skip ; Yes? Off you go then.
ld a, $0 ; No? Let's zero both of these out then.
ld [wMysteryBoxActive], a ; This is now deactivated.
ld [wDontSwitchOffMysteryBoxYet], a ; To be activated when a Meltan is defeated later.
.skip
ret

View file

@ -2131,7 +2131,6 @@ wObtainedHiddenCoinsFlags:: flag_array 16
; $01 = biking
; $02 = surfing
wWalkBikeSurfState:: db
ds 10
wTownVisitedFlag:: flag_array NUM_CITY_MAPS
@ -2144,7 +2143,23 @@ wFossilItem:: db
; mon that will result from the item
wFossilMon:: db
ds 2
; Meltan WRAM entries.
; Meltan uses a 3 unique variables for its item functionality.
; This is for the Melmetal Evolution Item.
; If it reaches 40 (represented as 400), the player can evolve Meltan.
; Once used, the count will reset.
wCandyJarCount:: db
; Used for Meltan implementation. Replaced unused Card Key function.
; When byte is $01, Meltan has a chance to replace a Pokemon that appears.
; $00 - Not Active
; $01 - Active
wMysteryBoxActive:: db
; ClearVariablesOnEnterMap does everything I want, except when leaving battle, so this switches off that specific aspect.
; This is achieved through some jank in engine\core.asm and engine\overworld\clear_variables.asm.
wDontSwitchOffMysteryBoxYet:: db
; trainer classes start at OPP_ID_OFFSET
wEnemyMonOrTrainerClass:: db
@ -2152,9 +2167,7 @@ wEnemyMonOrTrainerClass:: db
wPlayerJumpingYScreenCoordsIndex:: db
wRivalStarter:: db
ds 1
ds 1
wPlayerStarter:: db
; sprite index of the boulder the player is trying to push
@ -2177,12 +2190,6 @@ wDungeonWarpDestinationMap:: db
; which dungeon warp within the source map was used
wWhichDungeonWarp:: db
; Used for Meltan implementation. Replaced unused Card Key function.
; When byte is $01, Meltan has a chance to replace a Pokemon that appears.
; $00 - Not Active
; $01 - Active
wMysteryBoxActive:: db
ds 8
; bit 0: using Strength outside of battle