2016-06-12 00:24:04 +00:00
|
|
|
DoInGameTradeDialogue:
|
2014-05-22 22:13:20 +00:00
|
|
|
; trigger the trade offer/action specified by wWhichTrade
|
|
|
|
call SaveScreenTilesToBuffer2
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, TradeMons
|
|
|
|
ld a, [wWhichTrade]
|
|
|
|
ld b, a
|
2014-05-22 22:13:20 +00:00
|
|
|
swap a
|
|
|
|
sub b
|
|
|
|
sub b
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld [wInGameTradeGiveMonSpecies], a
|
|
|
|
ld a, [hli]
|
|
|
|
ld [wInGameTradeReceiveMonSpecies], a
|
|
|
|
ld a, [hli]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wInGameTradeMonNick
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
|
|
|
ld de, InGameTradeTextPointers
|
|
|
|
add hl, hl
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [wInGameTradeTextPointerTablePointer], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wInGameTradeTextPointerTablePointer + 1], a
|
|
|
|
ld a, [wInGameTradeGiveMonSpecies]
|
|
|
|
ld de, wInGameTradeGiveMonName
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_GetMonName
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wInGameTradeReceiveMonSpecies]
|
|
|
|
ld de, wInGameTradeReceiveMonName
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_GetMonName
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wCompletedInGameTradeFlags
|
|
|
|
ld a, [wWhichTrade]
|
|
|
|
ld c, a
|
|
|
|
ld b, FLAG_TEST
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, c
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $4
|
|
|
|
ld [wInGameTradeTextPointerTableIndex], a
|
|
|
|
jr nz, .printText
|
2015-02-07 10:43:08 +00:00
|
|
|
; if the trade hasn't been done yet
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wInGameTradeTextPointerTableIndex], a
|
2015-02-07 10:43:08 +00:00
|
|
|
call .printText
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $1
|
|
|
|
ld [wInGameTradeTextPointerTableIndex], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call YesNoChoice
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .printText
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_DoTrade
|
2017-12-30 00:54:27 +00:00
|
|
|
jr c, .printText
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, TradedForText
|
|
|
|
call PrintText
|
2015-02-07 10:43:08 +00:00
|
|
|
.printText
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wInGameTradeTextPointerTableIndex
|
|
|
|
ld a, [hld] ; wInGameTradeTextPointerTableIndex
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld a, [hld] ; wInGameTradeTextPointerTablePointer + 1
|
|
|
|
ld l, [hl] ; wInGameTradeTextPointerTablePointer
|
|
|
|
ld h, a
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
; copies name of species a to hl
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_GetMonName:
|
2014-05-22 22:13:20 +00:00
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
pop de
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
jp CopyData
|
|
|
|
|
|
|
|
INCLUDE "data/trades.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_DoTrade:
|
2015-07-13 22:40:33 +00:00
|
|
|
xor a ; NORMAL_PARTY_MENU
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wPartyMenuTypeOrMessageID], a
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wUpdateSpritesEnabled], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayPartyMenu
|
|
|
|
push af
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_RestoreScreen
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $1
|
|
|
|
jp c, .tradeFailed ; jump if the player didn't select a pokemon
|
|
|
|
ld a, [wInGameTradeGiveMonSpecies]
|
|
|
|
ld b, a
|
|
|
|
ld a, [wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $2
|
|
|
|
jr nz, .tradeFailed ; jump if the selected mon's species is not the required one
|
|
|
|
ld a, [wWhichPokemon]
|
|
|
|
ld hl, wPartyMon1Level
|
2015-08-05 21:20:29 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hl]
|
|
|
|
ld [wCurEnemyLVL], a
|
|
|
|
ld hl, wCompletedInGameTradeFlags
|
|
|
|
ld a, [wWhichTrade]
|
|
|
|
ld c, a
|
|
|
|
ld b, FLAG_SET
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, ConnectCableText
|
|
|
|
call PrintText
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wWhichPokemon]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurEnemyLVL]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
call LoadHpBarAndStatusTilePatterns
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_PrepareTradeData
|
2015-03-14 22:25:21 +00:00
|
|
|
predef InternalClockTradeAnim
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wCurEnemyLVL], a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wWhichPokemon], a
|
|
|
|
ld a, [wInGameTradeReceiveMonSpecies]
|
|
|
|
ld [wcf91], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wMonDataLocation], a ; not used
|
|
|
|
ld [wRemoveMonFromBox], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call RemovePokemon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $80 ; prevent the player from naming the mon
|
|
|
|
ld [wMonDataLocation], a
|
2014-06-16 20:03:05 +00:00
|
|
|
call AddPartyMon
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_CopyDataToReceivedMon
|
2014-05-22 22:13:20 +00:00
|
|
|
callab EvolveTradeMon
|
|
|
|
call ClearScreen
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_RestoreScreen
|
2014-09-14 18:29:18 +00:00
|
|
|
callba RedrawMapView
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, $3
|
2015-02-07 10:43:08 +00:00
|
|
|
jr .tradeSucceeded
|
|
|
|
.tradeFailed
|
2014-05-22 22:13:20 +00:00
|
|
|
scf
|
2015-02-07 10:43:08 +00:00
|
|
|
.tradeSucceeded
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wInGameTradeTextPointerTableIndex], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_RestoreScreen:
|
2014-05-22 22:13:20 +00:00
|
|
|
call GBPalWhiteOutWithDelay3
|
2014-09-10 03:55:19 +00:00
|
|
|
call RestoreScreenTilesAndReloadTilePatterns
|
2014-05-22 22:13:20 +00:00
|
|
|
call ReloadTilesetTilePatterns
|
|
|
|
call LoadScreenTilesFromBuffer2
|
|
|
|
call Delay3
|
|
|
|
call LoadGBPal
|
2015-02-07 10:43:08 +00:00
|
|
|
ld c, 10
|
2014-05-22 22:13:20 +00:00
|
|
|
call DelayFrames
|
2015-07-19 18:56:13 +00:00
|
|
|
jpba LoadWildData
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_PrepareTradeData:
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wTradedPlayerMonSpecies
|
|
|
|
ld a, [wInGameTradeGiveMonSpecies]
|
|
|
|
ld [hli], a ; wTradedPlayerMonSpecies
|
|
|
|
ld a, [wInGameTradeReceiveMonSpecies]
|
|
|
|
ld [hl], a ; wTradedEnemyMonSpecies
|
|
|
|
ld hl, wPartyMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wWhichPokemon]
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wTradedPlayerMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_CopyData
|
|
|
|
ld hl, InGameTrade_TrainerString
|
2015-07-14 21:32:49 +00:00
|
|
|
ld de, wTradedEnemyMonOT
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_CopyData
|
2015-07-14 21:32:49 +00:00
|
|
|
ld de, wLinkEnemyTrainerName
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_CopyData
|
|
|
|
ld hl, wPartyMon1OTID
|
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
|
|
|
ld a, [wWhichPokemon]
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wTradedPlayerMonOTID
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $2
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_CopyData
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
|
|
|
ld hl, hRandomAdd
|
2015-02-07 10:43:08 +00:00
|
|
|
ld de, wTradedEnemyMonOTID
|
2014-05-22 22:13:20 +00:00
|
|
|
jp CopyData
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_CopyData:
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
call CopyData
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_CopyDataToReceivedMon:
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wPartyMonNicks
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_GetReceivedMonPointer
|
|
|
|
ld hl, wInGameTradeMonNick
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wPartyMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2015-02-07 10:43:08 +00:00
|
|
|
call InGameTrade_GetReceivedMonPointer
|
|
|
|
ld hl, InGameTrade_TrainerString
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2015-02-07 10:43:08 +00:00
|
|
|
ld hl, wPartyMon1OTID
|
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
|
|
|
call InGameTrade_GetReceivedMonPointer
|
|
|
|
ld hl, wTradedEnemyMonOTID
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc, $2
|
|
|
|
jp CopyData
|
|
|
|
|
2015-02-07 10:43:08 +00:00
|
|
|
; the received mon's index is (partyCount - 1),
|
|
|
|
; so this adds bc to hl (partyCount - 1) times and moves the result to de
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_GetReceivedMonPointer:
|
2015-02-07 10:43:08 +00:00
|
|
|
ld a, [wPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTrade_TrainerString:
|
2014-05-22 22:13:20 +00:00
|
|
|
; "TRAINER@@@@@@@@@@"
|
|
|
|
db $5d, "@@@@@@@@@@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
InGameTradeTextPointers:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw TradeTextPointers1
|
|
|
|
dw TradeTextPointers2
|
|
|
|
dw TradeTextPointers3
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TradeTextPointers1:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw WannaTrade1Text
|
|
|
|
dw NoTrade1Text
|
|
|
|
dw WrongMon1Text
|
|
|
|
dw Thanks1Text
|
|
|
|
dw AfterTrade1Text
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TradeTextPointers2:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw WannaTrade2Text
|
|
|
|
dw NoTrade2Text
|
|
|
|
dw WrongMon2Text
|
|
|
|
dw Thanks2Text
|
|
|
|
dw AfterTrade2Text
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TradeTextPointers3:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw WannaTrade3Text
|
|
|
|
dw NoTrade3Text
|
|
|
|
dw WrongMon3Text
|
|
|
|
dw Thanks3Text
|
|
|
|
dw AfterTrade3Text
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ConnectCableText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ConnectCableText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TradedForText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _TradedForText
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_SFX_KEY_ITEM
|
|
|
|
TX_DELAY
|
|
|
|
db "@"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WannaTrade1Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WannaTrade1Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoTrade1Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _NoTrade1Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WrongMon1Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WrongMon1Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
Thanks1Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _Thanks1Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AfterTrade1Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _AfterTrade1Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WannaTrade2Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WannaTrade2Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoTrade2Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _NoTrade2Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WrongMon2Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WrongMon2Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
Thanks2Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _Thanks2Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AfterTrade2Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _AfterTrade2Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WannaTrade3Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WannaTrade3Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoTrade3Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _NoTrade3Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WrongMon3Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _WrongMon3Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
Thanks3Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _Thanks3Text
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
AfterTrade3Text:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _AfterTrade3Text
|
|
|
|
db "@"
|