Mystery Box functionality

It was a long shot, but I did it! I added the Mystery Box from Pokemon GO! Very happy with the results here.

So here's how it works: When used, the game will replace Pokemon encountered with Meltan until the player leaves the map. This is sort of how it works in GO, with the player unable to close it and naturally petering out as they play.

Now multiple Meltan can be obtained, and in abundance, just like GO. Technically, someone could use this as a pseudo-Repel to replace hard encounters with easy ones.

Oh, and I'm pretty sure this happens vs static encounters as well, but it's awkward to account for I think that's hilarious, so...
This commit is contained in:
Llinos Evans 2023-05-31 05:03:22 +01:00
parent 6d4b0f7a4e
commit 934f8adcac
15 changed files with 189 additions and 89 deletions

View file

@ -59,8 +59,10 @@ Naturally, these types get appropriate moves. They are currently distributed to
New Items: New Items:
==== ====
There are some new items here, with the aim of accomodating new Pokemon, adding features, and acting as methods of getting to new locations. There are some new items here, with the aim of accomodating new Pokemon, adding features, and acting as methods of getting to new locations.
- To accomodate Meltan, the Mystery Box from Pokemon GO is featured. When used, wild encounters are replaced with Meltan until one leaves the location.
- Melmetal is obtained by using a Candy Jar on Meltan, which is obtained as a special reward later!
- The Ice, Poison and Heart Stones have been added, the latter two being from the SpaceWorld '97 demo. - The Ice, Poison and Heart Stones have been added, the latter two being from the SpaceWorld '97 demo.
- Additional evolution items include the Protector, Black Augurite, Up-Grade, Dubious Disc, Metal Coat, and Candy Jar (for Melmetal). - Additional evolution items include the Protector, Black Augurite, Up-Grade, Dubious Disc, and the Metal Coat.
- The Bottle Cap has been added alongside a Hyper Training feature, acting as effectively a Gold Bottle Cap. - The Bottle Cap has been added alongside a Hyper Training feature, acting as effectively a Gold Bottle Cap.
- The Old Sea Map has been added, giving access to Faraway Island and Mew. - The Old Sea Map has been added, giving access to Faraway Island and Mew.
- The Citrine Pass has been added, allowing access to a new post-game area based on the unused "C" map. - The Citrine Pass has been added, allowing access to a new post-game area based on the unused "C" map.

View file

@ -101,6 +101,7 @@ DEF SAFARI_ROCK EQU $16 ; overload
const OLD_SEA_MAP ; $5A const OLD_SEA_MAP ; $5A
const UP_GRADE ; $5B const UP_GRADE ; $5B
const METAL_COAT ; $5C const METAL_COAT ; $5C
const MYSTERY_BOX ; $5D
DEF NUM_ITEMS EQU const_value - 1 DEF NUM_ITEMS EQU const_value - 1
; elevator floors use item IDs ; elevator floors use item IDs

View file

@ -92,6 +92,7 @@ KeyItemFlags:
dbit TRUE ; OLD_SEA_MAP dbit TRUE ; OLD_SEA_MAP
dbit FALSE ; UP_GRADE dbit FALSE ; UP_GRADE
dbit FALSE ; METAL_COAT dbit FALSE ; METAL_COAT
dbit TRUE ; MYSTERY_BOX
dbit TRUE ; FLOOR_B2F dbit TRUE ; FLOOR_B2F
dbit TRUE ; FLOOR_B1F dbit TRUE ; FLOOR_B1F
dbit TRUE ; FLOOR_1F dbit TRUE ; FLOOR_1F

View file

@ -92,6 +92,7 @@ ItemNames::
li "OLD SEA MAP" li "OLD SEA MAP"
li "UP-GRADE" li "UP-GRADE"
li "METAL COAT" li "METAL COAT"
li "MYSTERY BOX"
assert_list_length NUM_ITEMS assert_list_length NUM_ITEMS
li "B2F" li "B2F"
li "B1F" li "B1F"

View file

@ -92,6 +92,7 @@ ItemPrices::
bcd3 0 ; OLD_SEA_MAP bcd3 0 ; OLD_SEA_MAP
bcd3 3000 ; UP_GRADE bcd3 3000 ; UP_GRADE
bcd3 3000 ; METAL_COAT bcd3 3000 ; METAL_COAT
bcd3 0 ; MYSTERY_BOX
assert_table_length NUM_ITEMS assert_table_length NUM_ITEMS
bcd3 0 ; FLOOR_B2F bcd3 0 ; FLOOR_B2F
bcd3 0 ; FLOOR_B1F bcd3 0 ; FLOOR_B1F

View file

@ -348,6 +348,11 @@ _OldSeaMapDescription::
next "certain island." next "certain island."
prompt prompt
_MysteryBoxDescription:: ; GO Description: A mysterious old box. Opening it causes a certain Pokémon to appear for a limited time.
text "A mysterious old"
next "box."
prompt
_HM01Description:: _HM01Description::
text "Cuts using claws," text "Cuts using claws,"
next "scythes, etc." next "scythes, etc."

View file

@ -1824,3 +1824,13 @@ _BoyGirlText::
text "Firstly, are you a" text "Firstly, are you a"
line "boy or a girl?" line "boy or a girl?"
done done
_MysteryBoxText::
text "A mysterious mist"
line "billowed out!"
prompt
_MysteryBoxCloseText::
text "<PLAYER> closed"
line "the BOX!"
prompt

View file

@ -6191,6 +6191,23 @@ LoadEnemyMonData:
ld a, [wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
jp z, LoadEnemyMonFromParty jp z, LoadEnemyMonFromParty
; Upon initiating a 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, .cont ; 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!
.cont ; Standard loading.
ld a, [wEnemyMonSpecies2] ld a, [wEnemyMonSpecies2]
ld [wEnemyMonSpecies], a ld [wEnemyMonSpecies], a
ld [wd0b5], a ld [wd0b5], a

View file

@ -161,6 +161,7 @@ DebugSetPokedexEntries:
ret ret
DebugItemsList: DebugItemsList:
db MYSTERY_BOX, 1
db BICYCLE, 1 db BICYCLE, 1
db FULL_RESTORE, 99 db FULL_RESTORE, 99
db MAX_REPEL, 99 db MAX_REPEL, 99

View file

@ -64,7 +64,7 @@ ItemUsePtrTable:
dw UnusableItem ; BIKE_VOUCHER dw UnusableItem ; BIKE_VOUCHER
dw ItemUseXAccuracy ; X_ACCURACY dw ItemUseXAccuracy ; X_ACCURACY
dw ItemUseEvoStone ; LEAF_STONE dw ItemUseEvoStone ; LEAF_STONE
dw ItemUseCardKey ; CARD_KEY dw UnusableItem ; CARD_KEY
dw UnusableItem ; NUGGET dw UnusableItem ; NUGGET
dw UnusableItem ; WING_FOSSIL dw UnusableItem ; WING_FOSSIL
dw ItemUsePokedoll ; POKE_DOLL dw ItemUsePokedoll ; POKE_DOLL
@ -109,6 +109,7 @@ ItemUsePtrTable:
dw UnusableItem ; OLD_SEA_MAP dw UnusableItem ; OLD_SEA_MAP
dw ItemUseEvoStone ; UP_GRADE dw ItemUseEvoStone ; UP_GRADE
dw ItemUseEvoStone ; METAL_COAT dw ItemUseEvoStone ; METAL_COAT
dw ItemUseMysteryBox ; MYSTERY_BOX
dw UnusableItem ; FLOOR_B2F dw UnusableItem ; FLOOR_B2F
dw UnusableItem ; FLOOR_B1F dw UnusableItem ; FLOOR_B1F
dw UnusableItem ; FLOOR_1F dw UnusableItem ; FLOOR_1F
@ -124,6 +125,19 @@ ItemUsePtrTable:
dw UnusableItem ; FLOOR_11F dw UnusableItem ; FLOOR_11F
dw UnusableItem ; FLOOR_14F dw UnusableItem ; FLOOR_14F
ItemUseMysteryBox:
; Mystery Box can't be used in battle.
ld a, [wIsInBattle]
and a
jp nz, ItemUseNotTime
; Sets a variable in WRAM that'll trigger a Meltan wild encounter.
; Handled in engine\core.asm
ld a, $1
ld [wMysteryBoxActive], a
ld hl, MysteryBoxText ; Simple text is shown. Ambiguous to the user, identical to GO.
call PrintText
jp TextScriptEnd
ItemUseBall: ItemUseBall:
; Balls can't be used out of battle. ; Balls can't be used out of battle.
@ -1585,55 +1599,55 @@ ItemUseXAccuracy:
; This function is bugged and never works. It always jumps to ItemUseNotTime. ; This function is bugged and never works. It always jumps to ItemUseNotTime.
; The Card Key is handled in a different way. ; The Card Key is handled in a different way.
ItemUseCardKey: ;ItemUseCardKey:
xor a ; xor a
ld [wUnusedD71F], a ; ld [wUnusedD71F], a
call GetTileAndCoordsInFrontOfPlayer ; call GetTileAndCoordsInFrontOfPlayer
ld a, [GetTileAndCoordsInFrontOfPlayer] ; ld a, [GetTileAndCoordsInFrontOfPlayer]
cp $18 ; cp $18
jr nz, .next0 ; jr nz, .next0
ld hl, CardKeyTable1 ; ld hl, CardKeyTable1
jr .next1 ; jr .next1
.next0 ;.next0
cp $24 ; cp $24
jr nz, .next2 ; jr nz, .next2
ld hl, CardKeyTable2 ; ld hl, CardKeyTable2
jr .next1 ; jr .next1
.next2 ;.next2
cp $5e ; cp $5e
jp nz, ItemUseNotTime ; jp nz, ItemUseNotTime
ld hl, CardKeyTable3 ; ld hl, CardKeyTable3
.next1 ;.next1
ld a, [wCurMap] ; ld a, [wCurMap]
ld b, a ; ld b, a
.loop ;.loop
ld a, [hli] ; ld a, [hli]
cp -1 ; cp -1
jp z, ItemUseNotTime ; jp z, ItemUseNotTime
cp b ; cp b
jr nz, .nextEntry1 ; jr nz, .nextEntry1
ld a, [hli] ; ld a, [hli]
cp d ; cp d
jr nz, .nextEntry2 ; jr nz, .nextEntry2
ld a, [hli] ; ld a, [hli]
cp e ; cp e
jr nz, .nextEntry3 ; jr nz, .nextEntry3
ld a, [hl] ; ld a, [hl]
ld [wUnusedD71F], a ; ld [wUnusedD71F], a
jr .done ; jr .done
.nextEntry1 ;.nextEntry1
inc hl ; inc hl
.nextEntry2 ;.nextEntry2
inc hl ; inc hl
.nextEntry3 ;.nextEntry3
inc hl ; inc hl
jr .loop ; jr .loop
.done ;.done
ld hl, ItemUseText00 ; ld hl, ItemUseText00
call PrintText ; call PrintText
ld hl, wd728 ; ld hl, wd728
set 7, [hl] ; set 7, [hl]
ret ; ret
INCLUDE "data/events/card_key_coords.asm" INCLUDE "data/events/card_key_coords.asm"
@ -2980,3 +2994,7 @@ CheckMapForMon:
jr nz, .loop jr nz, .loop
dec hl dec hl
ret ret
MysteryBoxText:
text_far _MysteryBoxText
text_end

View file

@ -198,6 +198,8 @@ ItemDescriptionPointers:
text_end text_end
text_far _MetalCoatDescription text_far _MetalCoatDescription
text_end text_end
text_far _MysteryBoxDescription
text_end
text_far _HM01Description text_far _HM01Description
text_end text_end
text_far _HM02Description text_far _HM02Description

View file

@ -10,7 +10,7 @@ ClearVariablesOnEnterMap::
ldh [hJoyReleased], a ldh [hJoyReleased], a
ldh [hJoyHeld], a ldh [hJoyHeld], a
ld [wActionResultOrTookBattleTurn], a ld [wActionResultOrTookBattleTurn], a
ld [wUnusedD5A3], a ld [wMysteryBoxActive], a
ld hl, wCardKeyDoorY ld hl, wCardKeyDoorY
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a

View file

@ -1953,7 +1953,7 @@ wCurrentBoxNum:: db
; number of HOF teams ; number of HOF teams
wNumHoFTeams:: db wNumHoFTeams:: db
wUnusedD5A3:: db ds 1 ; was wUnusedD5A3, removed when putting the Mystery Box in.
wPlayerCoins:: ds 2 ; BCD wPlayerCoins:: ds 2 ; BCD
@ -2177,7 +2177,11 @@ wDungeonWarpDestinationMap:: db
; which dungeon warp within the source map was used ; which dungeon warp within the source map was used
wWhichDungeonWarp:: db wWhichDungeonWarp:: db
wUnusedD71F:: 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 ds 8

View file

@ -21,42 +21,43 @@ SafariZoneRestHouse3Text3:
text_end text_end
SafariZoneRestHouse3Meltan: SafariZoneRestHouse3Meltan:
; meltan guy ; Meltan Guy
; Originally, he was just going to give Meltan.
; But later on, we added the Mystery Box from GO for something more accurate, and for a possible Living Dex.
text_asm text_asm
ld a, [wd72e]
bit 0, a ; got meltan?
jr z, .giveMeltan
CheckEvent EVENT_GOT_MELTAN CheckEvent EVENT_GOT_MELTAN
jr nz, .MeltanInfo jr nz, .got_item
ld hl, .MeltanGuyText ld hl, MeltanGuyText
call PrintText call PrintText
jr .done lb bc, MYSTERY_BOX, 1
.giveMeltan call GiveItem
ld hl, .MeltanGuyText jr nc, .bag_full
ld hl, ReceivedBoxText
call PrintText call PrintText
lb bc, MELTAN, 5
SetEvent EVENT_GOT_MELTAN SetEvent EVENT_GOT_MELTAN
call GivePokemon
jr nc, .done
ld a, [wSimulatedJoypadStatesEnd]
and a
call z, WaitForTextScrollButtonPress
call EnableAutoTextBoxDrawing
ld hl, .MeltanInfoWithBlackjackAndHookers
call PrintText
ld hl, wd72e
set 0, [hl]
jr .done jr .done
.MeltanInfo .bag_full
ld hl, .MeltanInfoWithBlackjackAndHookers ld hl, BoxNoRoom
call PrintText
jr .done
.got_item
ld hl, MeltanInfo
call PrintText call PrintText
.done .done
jp TextScriptEnd jp TextScriptEnd
.MeltanInfoWithBlackjackAndHookers MeltanGuyText:
text_far _MeltanGuyText
text_end
MeltanInfo:
text_far _MeltanInfo text_far _MeltanInfo
text_end text_end
.MeltanGuyText ReceivedBoxText:
text_far _MeltanGuyText text_far _ReceivedBoxText
text_end
BoxNoRoom:
text_far _BoxNoRoom
text_end text_end

View file

@ -18,21 +18,57 @@ _SafariZoneRestHouse3Text3::
done done
_MeltanGuyText:: _MeltanGuyText::
text "I found a lost" text "Sheesh! This old"
line "#MON. It seems" line "BOX I found is"
cont "to be looking" cont "heavy."
cont "for its friends."
para "Could you take" para "Mind taking it"
line "care of it, kid?" line "off my hands,"
cont "kid?"
prompt prompt
_MeltanInfo:: _MeltanInfo::
text "My sources say it's" text "I saw a strange"
line "called MELTAN." line "#MON coming"
cont "out of that"
cont "thing."
para "It's never seen in" para "It's so creepy!"
line "KANTO..."
done done
_BoxNoRoom::
text "No room? Ugh,"
line "kids these"
cont "days..."
done
_ReceivedBoxText::
text "<PLAYER> received"
line "@"
text_ram wStringBuffer
text "!@"
text_end
; Old Meltan Guy text.
;_MeltanGuyText::
; text "I found a lost"
; line "#MON. It seems"
; cont "to be looking"
; cont "for its friends."
;
; para "Could you take"
; line "care of it, kid?"
; prompt
;_MeltanInfo::
; text "My sources say it's"
; line "called MELTAN."
; para "It's never seen in"
; line "KANTO..."
; done