Advertisement
KDLPro

Bug Catching Contest Encounter Code

Mar 6th, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. ChooseWildEncounter_BugContest::
  2. ; Pick a random mon out of ContestMons.
  3.  
  4. .loop
  5. call Random
  6. cp 100 << 1
  7. jr nc, .loop
  8. srl a
  9.  
  10. ld hl, ContestMons
  11. ld de, 4
  12. .CheckMon:
  13. sub [hl]
  14. jr c, .GotMon
  15. add hl, de
  16. jr .CheckMon
  17.  
  18. .GotMon:
  19. inc hl
  20.  
  21. ; Species
  22. ld a, [hli]
  23. ld [wTempWildMonSpecies], a
  24.  
  25. ; Min level
  26. ld a, [hli]
  27. ld d, a
  28.  
  29. ; Max level
  30. ld a, [hl]
  31.  
  32. sub d
  33. jr nz, .RandomLevel
  34.  
  35. ; If min and max are the same.
  36. ld a, d
  37. jr .GotLevel
  38.  
  39. .RandomLevel:
  40. ; Get a random level between the min and max.
  41. ld c, a
  42. inc c
  43. call Random
  44. ldh a, [hRandomAdd]
  45. call SimpleDivide
  46. add d
  47.  
  48. .GotLevel:
  49. ld [wCurPartyLevel], a
  50.  
  51. xor a
  52. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement