diff options
Diffstat (limited to 'engine/events/bug_contest')
-rwxr-xr-x | engine/events/bug_contest/contest_2.asm | 25 | ||||
-rwxr-xr-x | engine/events/bug_contest/judging.asm | 35 |
2 files changed, 25 insertions, 35 deletions
diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm index 20766185b..7ade44815 100755 --- a/engine/events/bug_contest/contest_2.asm +++ b/engine/events/bug_contest/contest_2.asm @@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8 ; Select five random people to participate in the current contest. ; First we have to make sure that any old data is cleared away. - ld c, 10 ; Number of people to choose from. + ld c, NUM_BUG_CONTESTANTS ld hl, BugCatchingContestantEventFlagTable .loop1 push bc @@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8 .next ; Choose a flag at uniform random to be set. call Random - cp 250 + cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS jr nc, .next - ld c, 25 + ld c, $ff / NUM_BUG_CONTESTANTS call SimpleDivide ld e, b ld d, 0 @@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8 Special_CheckBugContestContestantFlag: ; 139ed ; Checks the flag of the Bug Catching Contestant whose index is loaded in a. -; Bug: If a >= 10 when this is called, it will read beyond the table. +; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table. ld hl, BugCatchingContestantEventFlagTable ld e, a @@ -74,18 +74,7 @@ Special_CheckBugContestContestantFlag: ; 139ed ret ; 139fe -BugCatchingContestantEventFlagTable: ; 139fe - dw EVENT_BUG_CATCHING_CONTESTANT_1A - dw EVENT_BUG_CATCHING_CONTESTANT_2A - dw EVENT_BUG_CATCHING_CONTESTANT_3A - dw EVENT_BUG_CATCHING_CONTESTANT_4A - dw EVENT_BUG_CATCHING_CONTESTANT_5A - dw EVENT_BUG_CATCHING_CONTESTANT_6A - dw EVENT_BUG_CATCHING_CONTESTANT_7A - dw EVENT_BUG_CATCHING_CONTESTANT_8A - dw EVENT_BUG_CATCHING_CONTESTANT_9A - dw EVENT_BUG_CATCHING_CONTESTANT_10A -; 13a12 +INCLUDE "data/bug_contest_flags.asm" Special_ContestDropOffMons: ; 13a12 ld hl, PartyMon1HP @@ -101,7 +90,7 @@ Special_ContestDropOffMons: ; 13a12 ld a, [hl] ld [wBugContestSecondPartySpecies], a ; ... and replacing it with the terminator byte - ld [hl], $ff + ld [hl], -1 xor a ld [ScriptVar], a ret @@ -118,7 +107,7 @@ Special_ContestReturnMons: ; 13a31 ld a, [wBugContestSecondPartySpecies] ld [hl], a ; Restore the party count, which must be recomputed. - ld b, $1 + ld b, 1 .loop ld a, [hli] cp -1 diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm index 0dbd27024..8681feb8d 100755 --- a/engine/events/bug_contest/judging.asm +++ b/engine/events/bug_contest/judging.asm @@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b ; 0x13730 LoadContestantName: ; 13730 - -; If a = 0, get your name. - dec a +; If a = 1, get your name. + dec a ; BUG_CONTEST_PLAYER jr z, .player ; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a. ld c, a @@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm" BugContest_GetPlayersResult: ; 13807 ld hl, wBugContestThirdPlaceWinnerID - ld de, -4 - ld b, 3 + ld de, - BUG_CONTESTANT_SIZE + ld b, 3 ; 3rd, 2nd, or 1st .loop ld a, [hl] - cp 1 ; Player + cp BUG_CONTEST_PLAYER jr z, .done add hl, de dec b @@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819 call ClearContestResults call ComputeAIContestantScores ld hl, wBugContestTempWinnerID - ld a, 1 ; Player + ld a, BUG_CONTEST_PLAYER ld [hli], a ld a, [wContestMon] ld [hli], a @@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e jr c, .not_first_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestFirstPlaceWinnerID ld de, wBugContestSecondPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestFirstPlaceWinnerID call CopyTempContestant @@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e jr c, .not_second_place ld hl, wBugContestSecondPlaceWinnerID ld de, wBugContestThirdPlaceWinnerID - ld bc, 4 + ld bc, BUG_CONTESTANT_SIZE call CopyBytes ld hl, wBugContestSecondPlaceWinnerID call CopyTempContestant @@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e CopyTempContestant: ; 138a0 ; Could've just called CopyBytes. ld de, wBugContestTempWinnerID -rept 3 +rept BUG_CONTESTANT_SIZE +- 1 ld a, [de] inc de ld [hli], a @@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0 inc hl inc hl .loop2 + ; 0, 1, or 2 for 1st, 2nd, or 3rd call Random and 3 cp 3 @@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0 ld a, [hli] ld h, [hl] ld l, a + ; randomly perturb score call Random - and 7 + and %111 ld c, a ld b, 0 add hl, bc @@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0 .done inc e ld a, e - cp 10 + cp NUM_BUG_CONTESTANTS jr nz, .loop ret ; 13900 @@ -337,26 +338,26 @@ ContestScore: ; 13900 ; DVs ld a, [wContestMonDVs + 0] ld b, a - and 2 + and %0010 add a add a ld c, a swap b ld a, b - and 2 + and %0010 add a add c ld d, a ld a, [wContestMonDVs + 1] ld b, a - and 2 + and %0010 ld c, a swap b ld a, b - and 2 + and %0010 srl a add c add c |