Add Trader to Celadon University

Includes fixes to allow trade evos to exist
This commit is contained in:
May Evans 2022-09-26 22:08:35 +01:00
parent 2d0cac3830
commit c243548fc4
8 changed files with 94 additions and 22 deletions

View file

@ -16,24 +16,8 @@ EvolveTradeMon:
; were used instead, where none can evolve.
; This was fixed in Yellow.
; KEP removes this quirk.
ld a, [wInGameTradeReceiveMonName]
; GRAVELER
cp "G"
jr z, .ok
; "SPECTRE" (HAUNTER)
cp "S"
ret nz
ld a, [wInGameTradeReceiveMonName + 1]
cp "P"
ret nz
.ok
ld a, [wPartyCount]
dec a
ld [wWhichPokemon], a
ld a, $1
ld [wForceEvolution], a
ld a, LINK_STATE_TRADING

View file

@ -57,6 +57,9 @@ DoInGameTradeDialogue:
jr nz, .printText
call InGameTrade_DoTrade
jr c, .printText
ld a, [wInGameTradeGiveMonSpecies]
cp NO_MON
jr z, .printText
ld hl, TradedForText
call PrintText
.printText
@ -98,22 +101,29 @@ InGameTrade_DoTrade:
ld a, $1
jp c, .tradeFailed ; jump if the player didn't select a pokemon
ld a, [wInGameTradeGiveMonSpecies]
cp NO_MON
jr z, .skip_mon_check
ld b, a
ld a, [wcf91]
cp b
ld a, $2
jr nz, .tradeFailed ; jump if the selected mon's species is not the required one
jp nz, .tradeFailed ; jump if the selected mon's species is not the required one
.skip_mon_check
ld a, [wWhichPokemon]
ld hl, wPartyMon1Level
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld a, [hl]
ld [wCurEnemyLVL], a
ld a, [wInGameTradeGiveMonSpecies]
cp NO_MON
jr z, .skip_flag_set
ld hl, wCompletedInGameTradeFlags
ld a, [wWhichTrade]
ld c, a
ld b, FLAG_SET
predef FlagActionPredef
.skip_flag_set
ld hl, ConnectCableText
call PrintText
ld a, [wWhichPokemon]
@ -121,7 +131,14 @@ InGameTrade_DoTrade:
ld a, [wCurEnemyLVL]
push af
call LoadHpBarAndStatusTilePatterns
ld a, [wInGameTradeGiveMonSpecies]
cp NO_MON
jr nz, .normal_in_game_trade_data
call TradeSelf_PrepareTradeData
jr .self_trade_data
.normal_in_game_trade_data
call InGameTrade_PrepareTradeData
.self_trade_data
predef InternalClockTradeAnim
pop af
ld [wCurEnemyLVL], a
@ -130,13 +147,21 @@ InGameTrade_DoTrade:
ld a, [wInGameTradeReceiveMonSpecies]
ld [wcf91], a
xor a
ld [wMonDataLocation], a ; not used
push af
ld a, [wInGameTradeGiveMonSpecies]
cp NO_MON
jr z, .skip_swap_mons
pop af
ld [wRemoveMonFromBox], a
call RemovePokemon
ld a, $80 ; prevent the player from naming the mon
ld [wMonDataLocation], a
call AddPartyMon
call InGameTrade_CopyDataToReceivedMon
ld a, [wPartyCount]
dec a
ld [wWhichPokemon], a
.skip_swap_mons
callfar EvolveTradeMon
call ClearScreen
call InGameTrade_RestoreScreen
@ -161,9 +186,22 @@ InGameTrade_RestoreScreen:
call DelayFrames
farjp LoadWildData
TradeSelf_PrepareTradeData:
ld a, [wWhichPokemon]
ld hl, wPartySpecies
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
ld [wTradedPlayerMonSpecies], a
ld [wInGameTradeReceiveMonSpecies], a
ld hl, wTradedPlayerMonSpecies
jr InGameTrade_PrepareTradeData.loaded_self_trade_instead
InGameTrade_PrepareTradeData:
ld hl, wTradedPlayerMonSpecies
ld a, [wInGameTradeGiveMonSpecies]
.loaded_self_trade_instead
ld [hli], a ; wTradedPlayerMonSpecies
ld a, [wInGameTradeReceiveMonSpecies]
ld [hl], a ; wTradedEnemyMonSpecies
@ -237,6 +275,7 @@ InGameTradeTextPointers:
dw TradeTextPointers1
dw TradeTextPointers2
dw TradeTextPointers3
dw TradeTextPointers4
TradeTextPointers1:
dw WannaTrade1Text
@ -258,6 +297,13 @@ TradeTextPointers3:
dw WrongMon3Text
dw Thanks3Text
dw AfterTrade3Text
TradeTextPointers4:
dw WannaTrade4Text
dw NoTrade4Text
dw WrongMon1Text
dw Thanks4Text
dw AfterTrade1Text
ConnectCableText:
text_far _ConnectCableText
@ -328,3 +374,15 @@ Thanks3Text:
AfterTrade3Text:
text_far _AfterTrade3Text
text_end
WannaTrade4Text:
text_far _WannaTrade4Text
text_end
NoTrade4Text:
text_far _NoTrade4Text
text_end
Thanks4Text:
text_far _Thanks4Text
text_end