Guest User

burning claw sim

a guest
Jun 15th, 2025
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. func (run *runner) rollAccuracy(attackRoll, defenceRoll float64) bool {
  2. var acc float64
  3. if attackRoll > defenceRoll {
  4. acc = 1 - ((defenceRoll + 2) / (2 * (attackRoll + 1)))
  5. } else {
  6. acc = attackRoll / (2 * (defenceRoll + 1))
  7. }
  8. return run.rnd.Float64() < acc
  9. }
  10.  
  11. func (run *runner) burningClawSpecBurn(maxHit int64, attackRoll float64, defenceRoll float64) int64 {
  12. // Helper to simulate 3 burn rolls with a given chance
  13. burnDamage := func(chance float64) int64 {
  14. var hits int
  15. for i := 0; i < 3; i++ {
  16. if run.rnd.Float64() < chance {
  17. hits++
  18. }
  19. }
  20.  
  21. switch hits {
  22. case 0:
  23. return 0
  24. case 1:
  25. return 10
  26. case 2:
  27. // 2/3 hits = 20 except in 1 of the 3 hit combinations it's 19
  28. // Pick one pattern randomly and treat it as the 19 case
  29. // There are 3 possible 2-hit combinations: 110, 101, 011
  30. if run.rnd.Intn(3) == 0 {
  31. return 19
  32. }
  33. return 20
  34. case 3:
  35. return 29
  36. default:
  37. panic("invalid burn hit count")
  38. }
  39. }
  40.  
  41. // First roll: 75-175% of maxHit
  42. if run.rollAccuracy(attackRoll, defenceRoll) {
  43. min := floor(0.75 * float64(maxHit))
  44. max := floor(1.75 * float64(maxHit))
  45. total := run.rnd.Int63n(max-min+1) + min
  46.  
  47. hit1 := floor(0.25 * float64(total))
  48. hit2 := floor(0.25 * float64(total))
  49. hit3 := floor(0.50 * float64(total))
  50. return hit1 + hit2 + hit3 + burnDamage(0.15)
  51. }
  52.  
  53. // Second roll: 50-150% of maxHit
  54. if run.rollAccuracy(attackRoll, defenceRoll) {
  55. min := floor(0.50 * float64(maxHit))
  56. max := floor(1.50 * float64(maxHit))
  57. total := run.rnd.Int63n(max-min+1) + min
  58.  
  59. base := floor(0.50 * float64(total))
  60. hit1 := base - 1
  61. hit2 := base - 1
  62. hit3 := int64(2)
  63. return hit1 + hit2 + hit3 + burnDamage(0.30)
  64. }
  65.  
  66. // Third roll: 25-125% of maxHit
  67. if run.rollAccuracy(attackRoll, defenceRoll) {
  68. min := floor(0.25 * float64(maxHit))
  69. max := floor(1.25 * float64(maxHit))
  70. total := run.rnd.Int63n(max-min+1) + min
  71.  
  72. hit3 := floor(1.00*float64(total)) - 2
  73. hit1 := int64(1)
  74. hit2 := int64(1)
  75. return hit1 + hit2 + hit3 + burnDamage(0.45)
  76. }
  77.  
  78. // All rolls failed: fixed fallback damage
  79. switch r := run.rnd.Float64(); {
  80. case r < 0.20:
  81. return 0
  82. case r < 0.60:
  83. return 1
  84. default:
  85. return 2
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment