Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ChangeHappiness:
- ; Perform happiness action c on wCurPartyMon
- ld a, [wCurPartyMon]
- inc a
- ld e, a
- ld d, 0
- ld hl, wPartySpecies - 1
- add hl, de
- ld a, [hl]
- cp EGG
- ret z
- ld a, MON_HAPPINESS
- call GetPartyParamLocation
- ld d, h
- ld e, l
- push de
- ld a, [de]
- cp HAPPINESS_THRESHOLD_1
- ld e, 0
- jr c, .ok
- inc e
- cp HAPPINESS_THRESHOLD_2
- jr c, .ok
- inc e
- .ok
- dec c
- ld b, 0
- ld hl, HappinessChanges
- add hl, bc
- add hl, bc
- add hl, bc
- ld d, 0
- add hl, de
- pop de
- ; If happiness change is 0, don't modify anything.
- ld a, [hl]
- and a
- jr z, .done2
- ld b, a
- add a
- jr c, .negative
- ld a, MON_ITEM
- call GetPartyParamLocation
- ld a, [hl]
- cp SOOTHE_BELL
- jr nz, .continue
- ld a, b
- inc a
- srl a
- add b
- ld b, a
- ; fallthrough
- .continue
- ld a, [de]
- add b
- jr nc, .done
- ld a, $ff
- jr .done
- .negative
- ld a, [de]
- add b
- jr c, .done
- xor a
- ; fallthrough
- .done
- ld [de], a
- .done2
- ld a, [wBattleMode]
- and a
- ret z
- ld a, [wCurPartyMon]
- ld b, a
- ld a, [wPartyMenuCursor]
- cp b
- ret nz
- ld a, [de]
- ld [wBattleMonHappiness], a
- ret
- INCLUDE "data/events/happiness_changes.asm"
Add Comment
Please, Sign In to add comment