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

View file

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

View file

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

View file

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

View file

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

View file

@ -348,6 +348,11 @@ _OldSeaMapDescription::
next "certain island."
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::
text "Cuts using claws,"
next "scythes, etc."

View file

@ -1824,3 +1824,13 @@ _BoyGirlText::
text "Firstly, are you a"
line "boy or a girl?"
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]
cp LINK_STATE_BATTLING
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 [wEnemyMonSpecies], a
ld [wd0b5], a

View file

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

View file

@ -64,7 +64,7 @@ ItemUsePtrTable:
dw UnusableItem ; BIKE_VOUCHER
dw ItemUseXAccuracy ; X_ACCURACY
dw ItemUseEvoStone ; LEAF_STONE
dw ItemUseCardKey ; CARD_KEY
dw UnusableItem ; CARD_KEY
dw UnusableItem ; NUGGET
dw UnusableItem ; WING_FOSSIL
dw ItemUsePokedoll ; POKE_DOLL
@ -109,6 +109,7 @@ ItemUsePtrTable:
dw UnusableItem ; OLD_SEA_MAP
dw ItemUseEvoStone ; UP_GRADE
dw ItemUseEvoStone ; METAL_COAT
dw ItemUseMysteryBox ; MYSTERY_BOX
dw UnusableItem ; FLOOR_B2F
dw UnusableItem ; FLOOR_B1F
dw UnusableItem ; FLOOR_1F
@ -124,6 +125,19 @@ ItemUsePtrTable:
dw UnusableItem ; FLOOR_11F
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:
; 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.
; The Card Key is handled in a different way.
ItemUseCardKey:
xor a
ld [wUnusedD71F], a
call GetTileAndCoordsInFrontOfPlayer
ld a, [GetTileAndCoordsInFrontOfPlayer]
cp $18
jr nz, .next0
ld hl, CardKeyTable1
jr .next1
.next0
cp $24
jr nz, .next2
ld hl, CardKeyTable2
jr .next1
.next2
cp $5e
jp nz, ItemUseNotTime
ld hl, CardKeyTable3
.next1
ld a, [wCurMap]
ld b, a
.loop
ld a, [hli]
cp -1
jp z, ItemUseNotTime
cp b
jr nz, .nextEntry1
ld a, [hli]
cp d
jr nz, .nextEntry2
ld a, [hli]
cp e
jr nz, .nextEntry3
ld a, [hl]
ld [wUnusedD71F], a
jr .done
.nextEntry1
inc hl
.nextEntry2
inc hl
.nextEntry3
inc hl
jr .loop
.done
ld hl, ItemUseText00
call PrintText
ld hl, wd728
set 7, [hl]
ret
;ItemUseCardKey:
; xor a
; ld [wUnusedD71F], a
; call GetTileAndCoordsInFrontOfPlayer
; ld a, [GetTileAndCoordsInFrontOfPlayer]
; cp $18
; jr nz, .next0
; ld hl, CardKeyTable1
; jr .next1
;.next0
; cp $24
; jr nz, .next2
; ld hl, CardKeyTable2
; jr .next1
;.next2
; cp $5e
; jp nz, ItemUseNotTime
; ld hl, CardKeyTable3
;.next1
; ld a, [wCurMap]
; ld b, a
;.loop
; ld a, [hli]
; cp -1
; jp z, ItemUseNotTime
; cp b
; jr nz, .nextEntry1
; ld a, [hli]
; cp d
; jr nz, .nextEntry2
; ld a, [hli]
; cp e
; jr nz, .nextEntry3
; ld a, [hl]
; ld [wUnusedD71F], a
; jr .done
;.nextEntry1
; inc hl
;.nextEntry2
; inc hl
;.nextEntry3
; inc hl
; jr .loop
;.done
; ld hl, ItemUseText00
; call PrintText
; ld hl, wd728
; set 7, [hl]
; ret
INCLUDE "data/events/card_key_coords.asm"
@ -2980,3 +2994,7 @@ CheckMapForMon:
jr nz, .loop
dec hl
ret
MysteryBoxText:
text_far _MysteryBoxText
text_end

View file

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

View file

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

View file

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

View file

@ -21,42 +21,43 @@ SafariZoneRestHouse3Text3:
text_end
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
ld a, [wd72e]
bit 0, a ; got meltan?
jr z, .giveMeltan
CheckEvent EVENT_GOT_MELTAN
jr nz, .MeltanInfo
ld hl, .MeltanGuyText
jr nz, .got_item
ld hl, MeltanGuyText
call PrintText
jr .done
.giveMeltan
ld hl, .MeltanGuyText
lb bc, MYSTERY_BOX, 1
call GiveItem
jr nc, .bag_full
ld hl, ReceivedBoxText
call PrintText
lb bc, MELTAN, 5
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
.MeltanInfo
ld hl, .MeltanInfoWithBlackjackAndHookers
.bag_full
ld hl, BoxNoRoom
call PrintText
jr .done
.got_item
ld hl, MeltanInfo
call PrintText
.done
jp TextScriptEnd
.MeltanInfoWithBlackjackAndHookers
MeltanGuyText:
text_far _MeltanGuyText
text_end
MeltanInfo:
text_far _MeltanInfo
text_end
.MeltanGuyText
text_far _MeltanGuyText
ReceivedBoxText:
text_far _ReceivedBoxText
text_end
BoxNoRoom:
text_far _BoxNoRoom
text_end

View file

@ -18,21 +18,57 @@ _SafariZoneRestHouse3Text3::
done
_MeltanGuyText::
text "I found a lost"
line "#MON. It seems"
cont "to be looking"
cont "for its friends."
text "Sheesh! This old"
line "BOX I found is"
cont "heavy."
para "Could you take"
line "care of it, kid?"
para "Mind taking it"
line "off my hands,"
cont "kid?"
prompt
_MeltanInfo::
text "My sources say it's"
line "called MELTAN."
text "I saw a strange"
line "#MON coming"
cont "out of that"
cont "thing."
para "It's never seen in"
line "KANTO..."
para "It's so creepy!"
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