Advertisement
IdainTV

Soothe Bell implementation - StepHappiness

Sep 29th, 2021 (edited)
1,355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. StepHappiness::
  2. ; Raise the party's happiness by 1 point every 512 steps.
  3.  
  4.     ld hl, wHappinessStepCount
  5.     inc [hl]
  6.     ld a, [hl]
  7.     and 1
  8.     ret nz
  9.  
  10.     ld de, wPartyCount
  11.     ld a, [de]
  12.     and a
  13.     ret z
  14.  
  15.     ld c, a
  16.     ld hl, wPartyMon1Happiness
  17. .loop
  18.     inc de
  19.     ld a, [de]
  20.     cp EGG
  21.     jr z, .next
  22.     inc [hl] ; increase happiness
  23.     jr nz, .doIncrement
  24.     dec [hl]
  25.     jr .next
  26.    
  27. .doIncrement
  28.     push hl
  29.     push bc
  30.     ld bc, MON_ITEM - MON_HAPPINESS
  31.     add hl, bc
  32.     pop bc
  33.     ld a, [hl]
  34.     pop hl
  35.     cp SOOTHE_BELL
  36.     jr nz, .next
  37.    
  38.     inc [hl]
  39.     jr nz, .next
  40.     dec [hl]
  41. .next
  42.     push de
  43.     ld de, PARTYMON_STRUCT_LENGTH
  44.     add hl, de
  45.     pop de
  46.     dec c
  47.     jr nz, .loop
  48.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement