Fix issue #581 (random stuff ax6 noticed)

This commit is contained in:
Rangi 2018-12-23 03:45:41 -05:00
parent 83ff516c82
commit f6ecb681d5
2 changed files with 32 additions and 31 deletions

View File

@ -6986,7 +6986,7 @@ GiveExperiencePoints:
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
or [hl] or [hl]
jp z, .skip_stats ; fainted jp z, .next_mon ; fainted
push bc push bc
ld hl, wBattleParticipantsNotFainted ld hl, wBattleParticipantsNotFainted
@ -6998,7 +6998,7 @@ GiveExperiencePoints:
ld a, c ld a, c
and a and a
pop bc pop bc
jp z, .skip_stats jp z, .next_mon
; give stat exp ; give stat exp
ld hl, MON_STAT_EXP + 1 ld hl, MON_STAT_EXP + 1
@ -7008,20 +7008,20 @@ GiveExperiencePoints:
ld hl, wEnemyMonBaseStats - 1 ld hl, wEnemyMonBaseStats - 1
push bc push bc
ld c, NUM_EXP_STATS ld c, NUM_EXP_STATS
.loop1 .stat_exp_loop
inc hl inc hl
ld a, [de] ld a, [de]
add [hl] add [hl]
ld [de], a ld [de], a
jr nc, .okay1 jr nc, .no_carry_stat_exp
dec de dec de
ld a, [de] ld a, [de]
inc a inc a
jr z, .next jr z, .stat_exp_maxed_out
ld [de], a ld [de], a
inc de inc de
.okay1 .no_carry_stat_exp
push hl push hl
push bc push bc
ld a, MON_PKRUS ld a, MON_PKRUS
@ -7030,30 +7030,30 @@ GiveExperiencePoints:
and a and a
pop bc pop bc
pop hl pop hl
jr z, .skip jr z, .stat_exp_awarded
ld a, [de] ld a, [de]
add [hl] add [hl]
ld [de], a ld [de], a
jr nc, .skip jr nc, .stat_exp_awarded
dec de dec de
ld a, [de] ld a, [de]
inc a inc a
jr z, .next jr z, .stat_exp_maxed_out
ld [de], a ld [de], a
inc de inc de
jr .skip jr .stat_exp_awarded
.next .stat_exp_maxed_out
ld a, $ff ld a, $ff
ld [de], a ld [de], a
inc de inc de
ld [de], a ld [de], a
.skip .stat_exp_awarded
inc de inc de
inc de inc de
dec c dec c
jr nz, .loop1 jr nz, .stat_exp_loop
xor a xor a
ldh [hMultiplicand + 0], a ldh [hMultiplicand + 0], a
ldh [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
@ -7076,12 +7076,12 @@ GiveExperiencePoints:
inc hl inc hl
ld a, [wPlayerID + 1] ld a, [wPlayerID + 1]
cp [hl] cp [hl]
ld a, $0 ld a, 0
jr z, .no_boost jr z, .no_boost
.boosted .boosted
call BoostExp call BoostExp
ld a, $1 ld a, 1
.no_boost .no_boost
; Boost experience for a Trainer Battle ; Boost experience for a Trainer Battle
@ -7124,19 +7124,19 @@ GiveExperiencePoints:
ldh a, [hQuotient + 2] ldh a, [hQuotient + 2]
adc d adc d
ld [hl], a ld [hl], a
jr nc, .skip2 jr nc, .no_exp_overflow
dec hl dec hl
inc [hl] inc [hl]
jr nz, .skip2 jr nz, .no_exp_overflow
ld a, $ff ld a, $ff
ld [hli], a ld [hli], a
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
.skip2 .no_exp_overflow
ld a, [wCurPartyMon] ld a, [wCurPartyMon]
ld e, a ld e, a
ld d, $0 ld d, 0
ld hl, wPartySpecies ld hl, wPartySpecies
add hl, de add hl, de
ld a, [hl] ld a, [hl]
@ -7170,6 +7170,7 @@ GiveExperiencePoints:
ld [hld], a ld [hld], a
.not_max_exp .not_max_exp
; Check if the mon leveled up
xor a ; PARTYMON xor a ; PARTYMON
ld [wMonType], a ld [wMonType], a
predef CopyMonToTempMon predef CopyMonToTempMon
@ -7179,9 +7180,9 @@ GiveExperiencePoints:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp MAX_LEVEL cp MAX_LEVEL
jp nc, .skip_stats jp nc, .next_mon
cp d cp d
jp z, .skip_stats jp z, .next_mon
; <NICKNAME> grew to level ##! ; <NICKNAME> grew to level ##!
ld [wTempLevel], a ld [wTempLevel], a
ld a, [wCurPartyLevel] ld a, [wCurPartyLevel]
@ -7231,7 +7232,7 @@ GiveExperiencePoints:
ld d, a ld d, a
ld a, [wCurPartyMon] ld a, [wCurPartyMon]
cp d cp d
jr nz, .skip_animation jr nz, .skip_active_mon_update
ld de, wBattleMonHP ld de, wBattleMonHP
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a
@ -7268,13 +7269,13 @@ GiveExperiencePoints:
ld a, $1 ld a, $1
ldh [hBGMapMode], a ldh [hBGMapMode], a
.skip_animation .skip_active_mon_update
farcall LevelUpHappinessMod farcall LevelUpHappinessMod
ld a, [wCurBattleMon] ld a, [wCurBattleMon]
ld b, a ld b, a
ld a, [wCurPartyMon] ld a, [wCurPartyMon]
cp b cp b
jr z, .skip_animation2 jr z, .skip_exp_bar_animation
ld de, SFX_HIT_END_OF_EXP_BAR ld de, SFX_HIT_END_OF_EXP_BAR
call PlaySFX call PlaySFX
call WaitSFX call WaitSFX
@ -7282,7 +7283,7 @@ GiveExperiencePoints:
call StdBattleTextBox call StdBattleTextBox
call LoadTileMapToTempTileMap call LoadTileMapToTempTileMap
.skip_animation2 .skip_exp_bar_animation
xor a ; PARTYMON xor a ; PARTYMON
ld [wMonType], a ld [wMonType], a
predef CopyMonToTempMon predef CopyMonToTempMon
@ -7327,7 +7328,7 @@ GiveExperiencePoints:
pop af pop af
ld [wCurPartyLevel], a ld [wCurPartyLevel], a
.skip_stats .next_mon
ld a, [wPartyCount] ld a, [wPartyCount]
ld b, a ld b, a
ld a, [wCurPartyMon] ld a, [wCurPartyMon]
@ -7363,7 +7364,7 @@ GiveExperiencePoints:
ld [wTempByteValue], a ld [wTempByteValue], a
ld hl, wEnemyMonBaseStats ld hl, wEnemyMonBaseStats
ld c, wEnemyMonEnd - wEnemyMonBaseStats ld c, wEnemyMonEnd - wEnemyMonBaseStats
.count_loop2 .base_stat_division_loop
xor a xor a
ldh [hDividend + 0], a ldh [hDividend + 0], a
ld a, [hl] ld a, [hl]
@ -7375,7 +7376,7 @@ GiveExperiencePoints:
ldh a, [hQuotient + 3] ldh a, [hQuotient + 3]
ld [hli], a ld [hli], a
dec c dec c
jr nz, .count_loop2 jr nz, .base_stat_division_loop
ret ret
BoostExp: BoostExp:

View File

@ -11,17 +11,17 @@ EngineFlagAction::
; to know that the infrastructure is there. ; to know that the infrastructure is there.
ld a, d ld a, d
cp 0 cp HIGH(NUM_ENGINE_FLAGS)
jr z, .ceiling jr z, .ceiling
jr c, .read ; cp 0 can't set carry! jr c, .read ; cp 0 can't set carry!
jr .invalid jr .invalid
; There are only $a2 engine flags, so ; There are only NUM_ENGINE_FLAGS engine flags, so
; anything beyond that is invalid too. ; anything beyond that is invalid too.
.ceiling .ceiling
ld a, e ld a, e
cp NUM_ENGINE_FLAGS cp LOW(NUM_ENGINE_FLAGS)
jr c, .read jr c, .read
; Invalid flags are treated as flag 00. ; Invalid flags are treated as flag 00.