Advertisement
KDLPro

Classic Wild Encounters

Mar 2nd, 2021
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. ChooseWildEncounter:
  2. call LoadWildMonDataPointer
  3. jp nc, .nowildbattle
  4. call CheckEncounterRoamMon
  5. jp c, .startwildbattle
  6.  
  7. inc hl
  8. inc hl
  9. inc hl
  10. call CheckOnWater
  11. ld de, WaterMonProbTable
  12. jr z, .watermon
  13. inc hl
  14. inc hl
  15. ld a, [wTimeOfDay]
  16. ld bc, NUM_GRASSMON * 2
  17. call AddNTimes
  18. ld de, GrassMonProbTable
  19.  
  20. .watermon
  21. ; hl contains the pointer to the wild mon data, let's save that to the stack
  22. push hl
  23. .randomloop
  24. call Random
  25. cp 100
  26. jr nc, .randomloop
  27. inc a ; 1 <= a <= 100
  28. ld b, a
  29. ld h, d
  30. ld l, e
  31. ; This next loop chooses which mon to load up.
  32. .prob_bracket_loop
  33. ld a, [hli]
  34. cp b
  35. jr nc, .got_it
  36. inc hl
  37. jr .prob_bracket_loop
  38.  
  39. .got_it
  40. ld c, [hl]
  41. ld b, 0
  42. pop hl
  43. add hl, bc ; this selects our mon
  44. ld a, [hli]
  45. ld b, a
  46. ; If the Pokemon is encountered by surfing, we need to give the levels some variety.
  47. call CheckOnWater
  48. jr nz, .ok
  49. ; Check if we buff the wild mon, and by how much.
  50. call Random
  51. cp 35 percent
  52. jr c, .ok
  53. inc b
  54. cp 65 percent
  55. jr c, .ok
  56. inc b
  57. cp 85 percent
  58. jr c, .ok
  59. inc b
  60. cp 95 percent
  61. jr c, .ok
  62. inc b
  63. ; Store the level
  64. .ok
  65. ld a, b
  66. ld [wCurPartyLevel], a
  67. ld b, [hl]
  68. ; ld a, b
  69. call ValidateTempWildMonSpecies
  70. jr c, .nowildbattle
  71.  
  72. ld a, b ; This is in the wrong place.
  73. cp UNOWN
  74. jr nz, .done
  75.  
  76. ld a, [wUnlockedUnowns]
  77. and a
  78. jr z, .nowildbattle
  79.  
  80. .done
  81. jr .loadwildmon
  82.  
  83. .nowildbattle
  84. ld a, 1
  85. and a
  86. ret
  87.  
  88. .loadwildmon
  89. ld a, b
  90. ld [wTempWildMonSpecies], a
  91.  
  92. .startwildbattle
  93. xor a
  94. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement