diff --git a/ram/wram.asm b/ram/wram.asm index 74cce97a..48c81e70 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2125,7 +2125,7 @@ UNION ; Surely this position will not cause any issues at all. ;battle tent data wBTOrder:: dw -wBTStreakCnt:: db +wBTCont:: db wBTClass:: db wBTDataEnd:: wStringBuffer1:: ; cf5f @@ -2140,6 +2140,8 @@ NEXTU wChannel7:: channel_struct wChannel7 wChannel8:: channel_struct wChannel8 ENDU +wBTStreakCnt:: db +wBTRewards:: db wObtainedHiddenItemsFlags:: flag_array 112 @@ -2448,4 +2450,4 @@ SECTION "Stack", WRAM0 ; the stack grows downward ds $99 - 1 -wStack:: db \ No newline at end of file +wStack:: db diff --git a/scripts/BattleTent.asm b/scripts/BattleTent.asm index a3bc4649..a67bdca5 100644 --- a/scripts/BattleTent.asm +++ b/scripts/BattleTent.asm @@ -249,12 +249,17 @@ BattleTent_InitPhase: call DisplayTextID ld a, $ff ld [wJoyIgnore], a - ld a, [wBTStreakCnt] - cp 11 + ld a, [wBTCont] ; 0 = continue, 1 = lost, 2 = exit, FF = initial + cp 0 ; continue + jr z, .cont + cp $FF ; initial + jr z, .cont + ld a, 8 + jr .done +.cont ld a, 4 - jr nz, .skip - ld a, 8 ; TEH URN! -.skip + jr .done +.done ld [wBattleTentCurScript], a ret @@ -316,6 +321,9 @@ BattleTent_InitBattle: ld a, 6 ld [wBattleTentCurScript], a ret + +BTBattleReward: + db $00, $20, $00 BattleTent_AfterBattle: ld a, $ff @@ -324,6 +332,25 @@ BattleTent_AfterBattle: ld [$ff8c], a ld de, BattleTentMovement_3 call MoveSprite + ld a, [wBattleResult] + and a + jp nz, .skip ; if not zero, we lost / drew + xor a ; continue battle tent + ld [wBTCont], a + ld a, [wBTStreakCnt] + cp $FF + jr z, .max ; cap out at 255 wins + inc a + ld [wBTStreakCnt], a ; increment win counter +.max + jr .skip2 +.skip + ld a, 1 ; lost last match + ld [wBTCont], a + ld a, 8 + ld [wBattleTentCurScript], a + ret +.skip2 ld a, 7 ld [wBattleTentCurScript], a ret @@ -332,22 +359,12 @@ BattleTent_Heal: ld a, [wNPCNumScriptedSteps] and a ret nz - ld a, [wBattleResult] - cp 1 - jr nz, .stillTehUrn - ; rip - ld a, 8 - ld [wBattleTentCurScript], a - ret -.stillTehUrn - ld hl, wBTStreakCnt - inc [hl] + ld a, [wBTCont] + cp 1 ; lost, dont show healing dialogue + jr z, .skip ld a, 2 ld [wPlayerMovingDirection], a call Delay3 - ld a, [hl] - cp 11 - jr z, .skip ; No need to heal the party, let's just say that the player wins predef HealParty ld a, $fc ld [wJoyIgnore], a @@ -560,32 +577,64 @@ BattleTentGuy: call BattleTent_LoadTeam ld hl, BattleTentLetsGo call PrintText + ld a, $FF ; first battle + ld [wBTCont], a + xor a ; initialise counter + ld [wBTStreakCnt], a ld a, 1 ld [wBattleTentCurScript], a jp TextScriptEnd -BTReward: - db $03,$00,$00 - BattleTentGuy_After: db $8 - ld a, [wBTStreakCnt] - cp 11 + ld a, [wBTCont] + cp 2 ; voluntarily exited ld hl, BattleTentLost - jr nz, .skip ; Not Teh Urn BibleThump - ld a, $03 ; NO REVERTING THIS CODE PIGU IM SICK OF YOU BREAKING IT! - ldh [$9f], a - ld a, $00 - ldh [$a1], a - ld a, $00 - ldh [$a0], a - ld hl, $ffa1 - ld de, wPlayerMoney + 2 - ld c, $3 - predef AddBCDPredef - ld hl, BattleTentWon -.skip + jr nz, .skip + ld hl, BattleTentWon call PrintText + ; give reward + ; every ten battles gives a bottle cap + ; every five gives a rare candy + ld a, [wBTStreakCnt] + ld c, 0 ; fives count +.findFive: + cp 5 + jr nc, .hasFive + jr .done +.hasFive: + sub 5 + inc c + jr .findFive +.done: + ld a, c + and a + jr z, .skip ; skip if no rewards + ld [wBTRewards], a + ld hl, ReceivedRewardPreamble + call PrintText + ld a, [wBTRewards] + ld b, RARE_CANDY + call GiveItem + jr nc, .bag_full ; could use money instead here + ld hl, ReceivedRewardText + call PrintText + ld a, [wBTRewards] + srl a + and a + jr z, .skip + ld [wBTRewards], a + ;ld b, POWER_FEED + ld b, BOTTLE_CAP + call GiveItem + jr nc, .bag_full + ld hl, ReceivedRewardText + call PrintText + jr .skip +.bag_full: + ld hl, RewardNoRoomText + call PrintText +.skip: ld hl, BattleTentPleaseWait call PrintText call BattleTent_RestoreTeam @@ -605,23 +654,9 @@ BattleTentGuy_After: ; Arguably a better system, but I do wish the counter incremented... BattleTentGuy2: db $8 - ld a, [wBTStreakCnt] ; The streak counter is still used for message continuity. - and a - - ; Old System -; ld hl, BattleTentGuy2_Streak -; jr nz, .skip -; inc a -; ld [wBTStreakCnt], a -; ld hl, BattleTentGuy2_Init -; jr .skip2 -;.skip -; cp 11 -; jr nz, .skip2 - - ; New System - ld hl, BattleTentGuy2_Streak ; The message has been changed appropriately down below. - jr z, .skip2 + ld a, [wBTCont] ; The streak counter is still used for message continuity. + cp $FF ; very first initial battle + jr z, .init xor a ; The D-Pad is locked at this point, so blank out wJoyIgnore to allow manual option selection. ld [wJoyIgnore], a ld hl, BattleTentGuy2_Continue ; Continue prompt. @@ -630,18 +665,18 @@ BattleTentGuy2: ld a, [wCurrentMenuItem] and a jr nz, .refused ; If 0, move to refused. -.cont + ld hl, BattleTentGuy2_Streak ; The message has been changed appropriately down below. + call PrintText + jr .done +.init ld hl, BattleTentGuy2_Init ; Load the next battle. - ; fallthrough -.skip2 ; This handles BattleTentGuy2_Streak and BattleTentGuy2_Init at once. call PrintText jr .done .refused ld hl, BattleTentGuy2_Win call PrintText - ld a, 9 ; Load BattleTent_PlayerWalkBack, which takes it from here. - ld [wBattleTentCurScript], a ; For some reason, this isn't working properly, even if jp'd. - ; fallthrough + ld a, 2 ; 2 = quit + ld [wBTCont], a .done jp TextScriptEnd @@ -786,11 +821,10 @@ BattleTentWon: text "Wow! You finally" line "did it!" - para "Here is the" - line "reward!" - - para $52, " received" - line "¥30000!" + para "You beat" + line "@" + text_decimal wBTStreakCnt, 1, 3 + text " oppenont(s)!" prompt BattleTentLost: @@ -813,7 +847,7 @@ BattleTentGuy2_Init: ; Cut in favour of a different system. BattleTentGuy2_Streak: ; text "Opponent No.@" ; could be a №? -; text_decimal wBTStreakCnt, 1, 2 +; text_decimal wBTStreakCnt, 1, 3 ; text_start ; line "is up next." ; para "Good luck!" @@ -824,6 +858,11 @@ BattleTentGuy2_Streak: BattleTentGuy2_Continue: text "Congratulations!" + + para "You're at" + line "@" + text_decimal wBTStreakCnt, 1, 3 + text " win(s)!" para "Do you want to" line "continue?" @@ -833,8 +872,10 @@ BattleTentGuy2_Win: ;text "Congratulations!" text "Well done!" - ;para "You have defeated" - ;line "all 10 opponents!" + ;para "You defeated" + ;line "@" + ;text_decimal wBTStreakCnt, 1, 3 + ;text " opponent(s)!" para "Please go back to" line "the counter to" @@ -847,6 +888,27 @@ BattleTentGuy2_Heal: cont "full health." done +ReceivedRewardPreamble: + text "Take these" + line "on the house!" + prompt + text_end + +ReceivedRewardText: + text " received" + line "@" + text_decimal wBTRewards, 1, 2 + text "x @" + text_ram wStringBuffer + text "!" + prompt + text_end + +RewardNoRoomText: + text "You have no room!" + prompt + text_end + ; Battle Tent BattleTentMart:: script_mart FULL_RESTORE, MAX_REVIVE, FULL_HEAL, BOTTLE_CAP, POKE_DOLL, X_ATTACK, X_DEFEND, X_SPEED, X_SPECIAL, GUARD_SPEC