mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-09-16 18:30:50 +12:00
Mystery Box bugfixes and improvements
- Meltan is now loaded in engine/battle/wild_encounters.asm, allowing its level to be fixed at 5 and avoiding various glitches. This also fixed the "running from Meltan ends the Mystery Box game" bug. - Candy Jar now gives a message when it's full, more transparent to the player. - Fixed a bug where the increment text wouldn't load properly, it was very silly.
This commit is contained in:
parent
3866a69a25
commit
0aab4fb5e8
|
@ -328,3 +328,8 @@ _TradeCenterText1::
|
||||||
_ColosseumText1::
|
_ColosseumText1::
|
||||||
text "!"
|
text "!"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
_MeltanFullJar::
|
||||||
|
text "The CANDY JAR"
|
||||||
|
line "is full!"
|
||||||
|
prompt
|
||||||
|
|
|
@ -854,16 +854,16 @@ FaintEnemyPokemon:
|
||||||
; Increment the Candy Jar count.
|
; Increment the Candy Jar count.
|
||||||
ld a, [wCandyJarCount] ; Grab the jar.
|
ld a, [wCandyJarCount] ; Grab the jar.
|
||||||
cp 40 ; Do we have 40?
|
cp 40 ; Do we have 40?
|
||||||
jr z, .skip ; If yes, no more candies.
|
jr z, .skipFilling1 ; If yes, no more candies.
|
||||||
inc a ; Increment candy count.
|
inc a ; Increment candy count.
|
||||||
ld [wCandyJarCount], a ; Store candy count.
|
ld [wCandyJarCount], a ; Store candy count.
|
||||||
|
|
||||||
; For engine\overworld\clear_variables.asm
|
.skipFilling1
|
||||||
; Needed so the Mystery Box effect isn't cleared upon leaving battle.
|
ld hl, MeltanFullJar ; Special message for when the jar is full
|
||||||
ld a, $01
|
cp 40
|
||||||
ld [wDontSwitchOffMysteryBoxYet], a
|
jr z, .skipFilling2
|
||||||
|
ld hl, MeltanIncrement ; Load text to show it's going up.
|
||||||
ld hl, _MeltanIncrement ; Load text to show it's going up.
|
.skipFilling2
|
||||||
call PrintText ; Yep text.
|
call PrintText ; Yep text.
|
||||||
call PrintEmptyString ; vs text likes this.
|
call PrintEmptyString ; vs text likes this.
|
||||||
.skip
|
.skip
|
||||||
|
@ -6262,29 +6262,8 @@ LoadEnemyMonData:
|
||||||
cp LINK_STATE_BATTLING
|
cp LINK_STATE_BATTLING
|
||||||
jp z, LoadEnemyMonFromParty
|
jp z, LoadEnemyMonFromParty
|
||||||
|
|
||||||
; Mystery Box functionality.
|
; New Meltan encounter code in engine/battle/wild_encounters.asm
|
||||||
; First, we need to check if it's a trainer battle, or everyone will use Meltan.
|
; It's way less buggy and just works better
|
||||||
ld a, [wIsInBattle]
|
|
||||||
cp $2 ; is it a trainer battle?
|
|
||||||
jr z, .skip ; If so, skip.
|
|
||||||
|
|
||||||
; Upon initiating a battle, if not a trainer battle, check if the Mystery Box has been activated.
|
|
||||||
; ~50% of the time, Meltan will replace what you encounter.
|
|
||||||
ld a, [wMysteryBoxActive] ; Load the box.
|
|
||||||
cp $01 ; Check if it's active.
|
|
||||||
jr nz, .skip ; If not, load a normal Pokemon. I know this looks sort of weird, it's just how it panned out.
|
|
||||||
|
|
||||||
; This didn't work for some reason. It seems unnecessary, anyway...
|
|
||||||
;call Random
|
|
||||||
;and a
|
|
||||||
;cp 128 ; Compare Random (a) with 128 (b).
|
|
||||||
;jr z, .cont ; If not within range, normal Pokemon appears. 50% chance.
|
|
||||||
|
|
||||||
ld a, MELTAN ; Meltan is loaded...
|
|
||||||
ld [wEnemyMonSpecies2], a ; Here!
|
|
||||||
ld [wcf91], a
|
|
||||||
|
|
||||||
.skip ; Standard loading.
|
|
||||||
ld a, [wEnemyMonSpecies2]
|
ld a, [wEnemyMonSpecies2]
|
||||||
ld [wEnemyMonSpecies], a
|
ld [wEnemyMonSpecies], a
|
||||||
ld [wd0b5], a
|
ld [wd0b5], a
|
||||||
|
@ -7269,3 +7248,11 @@ VermilionBeautyCheck:
|
||||||
ld [wBeautyCounter], a ; and get the FUCK out of my office!!!
|
ld [wBeautyCounter], a ; and get the FUCK out of my office!!!
|
||||||
.skipCounting
|
.skipCounting
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
MeltanIncrement:
|
||||||
|
text_far _MeltanIncrement
|
||||||
|
text_end
|
||||||
|
|
||||||
|
MeltanFullJar:
|
||||||
|
text_far _MeltanFullJar
|
||||||
|
text_end
|
||||||
|
|
|
@ -20,7 +20,7 @@ TryDoWildEncounter:
|
||||||
and a
|
and a
|
||||||
jr z, .next
|
jr z, .next
|
||||||
dec a
|
dec a
|
||||||
jr z, .lastRepelStep
|
jp z, .lastRepelStep
|
||||||
ld [wRepelRemainingSteps], a
|
ld [wRepelRemainingSteps], a
|
||||||
.next
|
.next
|
||||||
; determine if wild pokemon can appear in the half-block we're standing in
|
; determine if wild pokemon can appear in the half-block we're standing in
|
||||||
|
@ -53,10 +53,10 @@ TryDoWildEncounter:
|
||||||
; ...as long as it's not Viridian Forest or Safari Zone.
|
; ...as long as it's not Viridian Forest or Safari Zone.
|
||||||
ld a, [wCurMap]
|
ld a, [wCurMap]
|
||||||
cp FIRST_INDOOR_MAP ; is this an indoor map?
|
cp FIRST_INDOOR_MAP ; is this an indoor map?
|
||||||
jr c, .CantEncounter2
|
jp c, .CantEncounter2
|
||||||
ld a, [wCurMapTileset]
|
ld a, [wCurMapTileset]
|
||||||
cp FOREST ; Viridian Forest/Safari Zone
|
cp FOREST ; Viridian Forest/Safari Zone
|
||||||
jr z, .CantEncounter2
|
jp z, .CantEncounter2
|
||||||
ld a, [wGrassRate]
|
ld a, [wGrassRate]
|
||||||
.CanEncounter
|
.CanEncounter
|
||||||
; compare encounter chance with a random number to determine if there will be an encounter
|
; compare encounter chance with a random number to determine if there will be an encounter
|
||||||
|
@ -84,6 +84,13 @@ TryDoWildEncounter:
|
||||||
; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not,
|
; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not,
|
||||||
; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters.
|
; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters.
|
||||||
.gotWildEncounterType
|
.gotWildEncounterType
|
||||||
|
; Meltan functionality.
|
||||||
|
; This used to be in engine/battle/core.asm.
|
||||||
|
; However, it was a bit buggy as the implementation was forced.
|
||||||
|
; So instead, we do this:
|
||||||
|
ld a, [wMysteryBoxActive] ; Load the box.
|
||||||
|
cp $01 ; Check if it's active.
|
||||||
|
jr z, .meltanEncounter ; If so, skip this.
|
||||||
ld b, 0
|
ld b, 0
|
||||||
add hl, bc
|
add hl, bc
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
|
@ -99,6 +106,25 @@ TryDoWildEncounter:
|
||||||
ld a, [wCurEnemyLVL]
|
ld a, [wCurEnemyLVL]
|
||||||
cp b
|
cp b
|
||||||
jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon
|
jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon
|
||||||
|
jp .willEncounter
|
||||||
|
.meltanEncounter ; needed this function as otherwise we really mess up regular processing for no reason
|
||||||
|
ld a, $01
|
||||||
|
ld [wDontSwitchOffMysteryBoxYet], a ; Using this variable here accounts for running from Meltan.
|
||||||
|
ld b, 0
|
||||||
|
add hl, bc
|
||||||
|
ld a, 5
|
||||||
|
ld [wCurEnemyLVL], a
|
||||||
|
ld a, MELTAN
|
||||||
|
ld [wcf91], a
|
||||||
|
ld [wEnemyMonSpecies2], a
|
||||||
|
ld a, [wRepelRemainingSteps]
|
||||||
|
and a
|
||||||
|
jr z, .willEncounter
|
||||||
|
ld a, [wPartyMon1Level]
|
||||||
|
ld b, a
|
||||||
|
ld a, [wCurEnemyLVL]
|
||||||
|
cp b
|
||||||
|
jr c, .CantEncounter2
|
||||||
jr .willEncounter
|
jr .willEncounter
|
||||||
.lastRepelStep
|
.lastRepelStep
|
||||||
ld [wRepelRemainingSteps], a
|
ld [wRepelRemainingSteps], a
|
||||||
|
|
Loading…
Reference in a new issue