Advertisement
PikalaxALT

stick reduction

Mar 7th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BattleCommand_DamageVariation: ; 34cfd
  2. ; damagevariation
  3.  
  4. ; Modify the damage spread between 85% and 100%.
  5.  
  6. ; Because of the method of division the probability distribution
  7. ; is not consistent. This makes the highest damage multipliers
  8. ; rarer than normal.
  9.  
  10.  
  11. ; No point in reducing 1 or 0 damage.
  12.     ld hl, CurDamage
  13.     ld a, [hli]
  14.     and a
  15.     jr nz, .go
  16.     ld a, [hl]
  17.     cp 2
  18.     ret c
  19.  
  20. .go
  21. ; Start with the maximum damage.
  22.     xor a
  23.     ld [hMultiplicand + 0], a
  24.     dec hl
  25.     ld a, [hli]
  26.     ld [hMultiplicand + 1], a
  27.     ld a, [hl]
  28.     ld [hMultiplicand + 2], a
  29.  
  30. ; Multiply by 85-100%...
  31. .loop
  32.     call BattleRandom
  33.     rrca
  34.     cp $d9 ; 85%
  35.     jr c, .loop
  36.  
  37.     ld [hMultiplier], a
  38.     call Multiply
  39.  
  40. ; ...divide by 100%...
  41.     ld a, $ff ; 100%
  42.     ld [hDivisor], a
  43.     ld b, $4
  44.     call Divide
  45.  
  46. ; ...to get .85-1.00x damage.
  47.  
  48. ; wolfboyft
  49. ; If the target is holding a Stick...
  50.     ld a, [hBattleTurn]
  51.     and a
  52.     ld a, [EnemyMonItem]
  53.     jr z, .got_item
  54.     ld a, [BattleMonItem]
  55. .got_item
  56.     cp STICK
  57.     jr nz, .NoFurtherReduction
  58. ; Reduce damage by 17% (resulting damage is 83 percent after previous random reduction)
  59.     ld a, 83 percent
  60.     ld [hMultiplier], a
  61.     call Multiply
  62.     ld a, $ff
  63.     ld [hDivisor], a
  64.     ld b, $4
  65.     call Divide
  66. .NoFurtherReduction
  67.    
  68.     ld a, [hQuotient + 1]
  69.     ld hl, CurDamage
  70.     ld [hli], a
  71.     ld a, [hQuotient + 2]
  72.     ld [hl], a
  73.     ret
  74. ; 34d32401
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement