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

@ -30,6 +30,7 @@ DEF SLOTS_SOMEONESKEYS EQU $ff
const TRADE_FOR_DORIS
const TRADE_FOR_CRINKLES
const TRADE_FOR_SPOT
const TRADE_WITH_SELF
DEF NUM_NPC_TRADES EQU const_value
; in game trade dialog sets
@ -38,6 +39,7 @@ DEF NUM_NPC_TRADES EQU const_value
const TRADE_DIALOGSET_CASUAL
const TRADE_DIALOGSET_POLITE
const TRADE_DIALOGSET_HAPPY
const TRADE_DIALOGSET_SELF
; badges
; wObtainedBadges and wBeatGymFlags bits

View file

@ -12,4 +12,5 @@ TradeMons:
db KADABRA, GRAVELER, TRADE_DIALOGSET_POLITE, "SABURO@@@@@" ; From JP Blue
db VENONAT, TANGELA, TRADE_DIALOGSET_HAPPY, "CRINKLES@@@"
db NIDORAN_M, NIDORAN_F, TRADE_DIALOGSET_HAPPY, "SPOT@@@@@@@"
db NO_MON, NO_MON, TRADE_DIALOGSET_SELF, "Unseen@@@@@"
assert_table_length NUM_NPC_TRADES

View file

@ -8,6 +8,7 @@ CeladonUniversityInside_Object:
def_bg_events
def_object_events
object_event 8, 17, SPRITE_MIDDLE_AGED_MAN, STAY, ANY_DIR, 1 ; person
object_event 2, 3, SPRITE_MIDDLE_AGED_MAN, STAY, ANY_DIR, 1 ; person
object_event 4, 17, SPRITE_GAMEBOY_KID, STAY, DOWN, 2 ; person
def_warps_to CELADON_UNIVERSITY_INSIDE

View file

@ -198,3 +198,21 @@ _UsedCutText::
text " hacked"
line "away with CUT!"
prompt
_WannaTrade4Text::
text "I'm the TRADER!"
line "I love to help"
para "TRAINERs evolve"
line "their #MON!"
para "Wanna trade?"
done
_NoTrade4Text::
text "Ok, maybe next"
line "time then."
done
_Thanks4Text::
text "There we go!"
para "Hope I helped!"
done

View file

@ -31,7 +31,7 @@ ENDC
db DUGTRIO, 56
db ARTICUNO, 57
IF DEF(_DEBUG)
db PIKACHU, 5
db KADABRA, 16 ; to test trade evos @ celadon uni - PvK
ENDC
db -1 ; end
@ -86,7 +86,7 @@ IF DEF(_DEBUG)
ld a, 15
ld [hl], a
; Pikachu gets Flash.
; Kadabra gets Flash.
ld hl, wPartyMon6Moves + 2
ld a, FLASH
ld [hl], a

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
@ -259,6 +298,13 @@ TradeTextPointers3:
dw Thanks3Text
dw AfterTrade3Text
TradeTextPointers4:
dw WannaTrade4Text
dw NoTrade4Text
dw WrongMon1Text
dw Thanks4Text
dw AfterTrade1Text
ConnectCableText:
text_far _ConnectCableText
text_end
@ -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

View file

@ -3,9 +3,17 @@ CeladonUniversityInside_Script:
CeladonUniversityInside_TextPointers:
dw CeladonUniversityInsideText1
dw CeladonUniversityTrader
CeladonUniversityInsideText1:
text_far _CeladonUniversityInsideText1
text_end
CeladonUniversityTrader:
text_asm
ld a, TRADE_WITH_SELF
ld [wWhichTrade], a
predef DoInGameTradeDialogue
jp TextScriptEnd
text_end ; unused