Advertisement
KDLPro

Encounters

Mar 1st, 2021
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 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
  53.  
  54. TryWildEncounter_BugContest:
  55. ld a, [wPlayerStandingTile]
  56. call CheckSuperTallGrassTile
  57. ld b, 40 percent
  58. jr z, .ok
  59. ld b, 20 percent
  60.  
  61. .ok
  62. farcall ApplyMusicEffectOnEncounterRate
  63. farcall ApplyCleanseTagEffectOnEncounterRate
  64. call Random
  65. ldh a, [hRandomAdd]
  66. cp b
  67. ret c
  68. ld a, 1
  69. and a
  70. ret
  71.  
  72. INCLUDE "data/wild/bug_contest_mons.asm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement