Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GiveExperiencePoints:
- ; Give experience.
- ; Don't give experience if linked or in the Battle Tower.
- ...
- .no_pokerus_boost
- ; Make sure total EVs never surpass 512
- ld d, a
- push af
- push bc
- push hl
- ld e, 6
- ld bc, 0
- .count_evs
- ld a, [hli]
- add c
- ld c, a
- jr nc, .cont
- inc b
- .cont
- dec e
- jr nz, .count_evs
- ld a, d
- add c
- ld c, a
- adc b
- sub c
- ld b, a
- ld e, a
- .decrease_evs_gained
- call IsEvsGreaterThan512
- jr z, .check_ev_overflow
- jr c, .check_ev_overflow
- dec e
- dec bc
- jr .decrease_evs_gained
- .check_ev_overflow
- pop hl
- pop bc
- pop af
- ld a, e
- add [hl]
- cp MAX_EV
- jr nc, .ev_overflow
- cp MAX_EV + 1
- jr c, .got_ev
- .ev_overflow
- ld a, MAX_EV
- .got_ev
- ld [hli], a
- dec c
- jr z, .evs_done
- ; Use the second byte for Sp.Atk and Sp.Def
- ld a, c
- cp 2 ; two stats left, Sp.Atk and Sp.Def
- jr nz, .ev_loop
- ld a, [wBaseSpAtkSpDefEVs]
- ld b, a
- jr .ev_loop
- .evs_done
- xor a
- ldh [hMultiplicand + 0], a
- ldh [hMultiplicand + 1], a
- ld a, [wEnemyMonBaseExp]
- ldh [hMultiplicand + 2], a
- ld a, [wEnemyMonLevel]
- ldh [hMultiplier], a
- call Multiply
- ld a, 7
- ldh [hDivisor], a
- ld b, 4
- call Divide
- ...
- ldh a, [hQuotient + 3]
- ld [hli], a
- dec c
- jr nz, .base_stat_division_loop
- ret
- IsEvsGreaterThan512:
- ; EV total in bc
- ; Returns c if lower
- ld a, b
- cp HIGH(MAX_TOTAL_EV) ; 512
- ret nz
- ld a, c
- cp LOW(MAX_TOTAL_EV) ; 512
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement