Scripted losses

Now the last issue is making this not crash when restoring the player's team. Very odd...
This commit is contained in:
Llinos Evans 2023-05-13 20:13:40 +01:00
parent 4de0a13543
commit 8e10d26336
4 changed files with 42 additions and 13 deletions

View file

@ -1167,7 +1167,27 @@ HandlePlayerBlackOut:
ld [wIsTrainerBattle], a ld [wIsTrainerBattle], a
ld a, [wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
jr z, .notRival1Battle jp z, .notRival1Battle
; This is a scripted loss mechanic from a pret tutorial, adapted to the Battle Tent.
; This is necessary so you don't get booted out of the tent and have your Pokemon de-levelled.
ld a, [wCurMap]
cp BATTLE_TENT
jr nz, .notThatTrainer
hlcoord 0, 0
lb bc, 8, 21
call ClearScreenArea
call ScrollTrainerPicAfterBattle
ld c, 40
call DelayFrames
ld hl, StupidBattleTentFix
call PrintText
ld a, [wCurMap]
cp BATTLE_TENT ; MAP ID can be found in constants\map_constants.asm
ret
.notThatTrainer
ld a, [wCurOpponent] ld a, [wCurOpponent]
cp OPP_RIVAL1 cp OPP_RIVAL1
jr nz, .notRival1Battle jr nz, .notRival1Battle
@ -7124,3 +7144,10 @@ LoadMonBackPic:
ldh a, [hLoadedROMBank] ldh a, [hLoadedROMBank]
ld b, a ld b, a
jp CopyVideoData jp CopyVideoData
; I struggled a lot in making this generate the text.
; This is the best compromise I can come up with right now.
StupidBattleTentFix:
text "Oops! Better"
line "luck next time!"
prompt

View file

@ -1,4 +1,5 @@
;btlibs ;btlibs
; afters are farcallable for core.asm
BTLib1: BTLib1:
db "ready@@@@" db "ready@@@@"
db "prepared@" db "prepared@"
@ -11,13 +12,13 @@ BTLib2:
db "battle@" db "battle@"
db "rock@@@" db "rock@@@"
BTLib3: BTLib3::
db "Oh no@@@@@" db "Oh no@@@@@"
db "Argh no@@@" db "Argh no@@@"
db "Oh well@@@" db "Oh well@@@"
db "My streak@" db "My streak@"
BTLib4: BTLib4::
db "game@@@" db "game@@@"
db "battle@" db "battle@"
db "play@@@" db "play@@@"
@ -33,7 +34,7 @@ BTBeforeBattlePtrTable:
dw BTBeforeBattleTemplate7 dw BTBeforeBattleTemplate7
dw BTBeforeBattleTemplate8 dw BTBeforeBattleTemplate8
BTAfterBattlePtrTable: BTAfterBattlePtrTable::
dw BTAfterBattleTemplate1 dw BTAfterBattleTemplate1
dw BTAfterBattleTemplate2 dw BTAfterBattleTemplate2
dw BTAfterBattleTemplate3 dw BTAfterBattleTemplate3
@ -107,7 +108,7 @@ BTBeforeBattleTemplate8:
text "." text "."
done done
BTAfterBattleTemplate1: BTAfterBattleTemplate1::
text "@" text "@"
text_ram wStringBuffer1 text_ram wStringBuffer1
text "!" text "!"
@ -115,13 +116,13 @@ BTAfterBattleTemplate1:
para "Oh man.." para "Oh man.."
prompt prompt
BTAfterBattleTemplate2: BTAfterBattleTemplate2::
text "@" text "@"
text_ram wStringBuffer1 text_ram wStringBuffer1
text "!" text "!"
prompt prompt
BTAfterBattleTemplate3: BTAfterBattleTemplate3::
text "@" text "@"
text_ram wStringBuffer1 text_ram wStringBuffer1
text "!" text "!"
@ -131,14 +132,14 @@ BTAfterBattleTemplate3:
text "!" text "!"
prompt prompt
BTAfterBattleTemplate4: BTAfterBattleTemplate4::
text "That was a nice" text "That was a nice"
line "@" line "@"
text_ram wStringBuffer2 text_ram wStringBuffer2
text "!" text "!"
prompt prompt
BTAfterBattleTemplate5: BTAfterBattleTemplate5::
text "I did the best" text "I did the best"
line "I could." line "I could."
@ -146,7 +147,7 @@ BTAfterBattleTemplate5:
line "regrets!" line "regrets!"
prompt prompt
BTAfterBattleTemplate6: BTAfterBattleTemplate6::
text "@" text "@"
text_ram wStringBuffer1 text_ram wStringBuffer1
text "!" text "!"
@ -156,7 +157,7 @@ BTAfterBattleTemplate6:
text "!" text "!"
prompt prompt
BTAfterBattleTemplate7: BTAfterBattleTemplate7::
text "That was a nice" text "That was a nice"
line "@" line "@"
text_ram wStringBuffer2 text_ram wStringBuffer2
@ -164,7 +165,7 @@ BTAfterBattleTemplate7:
cont "don't you think?" cont "don't you think?"
prompt prompt
BTAfterBattleTemplate8: BTAfterBattleTemplate8::
text "Awesome" text "Awesome"
line "@" line "@"
text_ram wStringBuffer2 text_ram wStringBuffer2

View file

@ -366,6 +366,8 @@ OverworldLoopLessDelay::
ld a, [wCurMap] ld a, [wCurMap]
cp OAKS_LAB cp OAKS_LAB
jp z, .noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab jp z, .noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
cp BATTLE_TENT
jp z, .noFaintCheck
callfar AnyPartyAlive callfar AnyPartyAlive
ld a, d ld a, d
and a and a

View file

@ -647,7 +647,6 @@ BattleTentTrainer:
ld hl, wd72d ld hl, wd72d
set 6, [hl] set 6, [hl]
set 7, [hl] set 7, [hl]
ld [wBTClass], a
ld a, 1 ld a, 1
ld [wIsTrainerBattle], a ld [wIsTrainerBattle], a