Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (run *runner) rollAccuracy(attackRoll, defenceRoll float64) bool {
- var acc float64
- if attackRoll > defenceRoll {
- acc = 1 - ((defenceRoll + 2) / (2 * (attackRoll + 1)))
- } else {
- acc = attackRoll / (2 * (defenceRoll + 1))
- }
- return run.rnd.Float64() < acc
- }
- func (run *runner) burningClawSpecBurn(maxHit int64, attackRoll float64, defenceRoll float64) int64 {
- // Helper to simulate 3 burn rolls with a given chance
- burnDamage := func(chance float64) int64 {
- var hits int
- for i := 0; i < 3; i++ {
- if run.rnd.Float64() < chance {
- hits++
- }
- }
- switch hits {
- case 0:
- return 0
- case 1:
- return 10
- case 2:
- // 2/3 hits = 20 except in 1 of the 3 hit combinations it's 19
- // Pick one pattern randomly and treat it as the 19 case
- // There are 3 possible 2-hit combinations: 110, 101, 011
- if run.rnd.Intn(3) == 0 {
- return 19
- }
- return 20
- case 3:
- return 29
- default:
- panic("invalid burn hit count")
- }
- }
- // First roll: 75-175% of maxHit
- if run.rollAccuracy(attackRoll, defenceRoll) {
- min := floor(0.75 * float64(maxHit))
- max := floor(1.75 * float64(maxHit))
- total := run.rnd.Int63n(max-min+1) + min
- hit1 := floor(0.25 * float64(total))
- hit2 := floor(0.25 * float64(total))
- hit3 := floor(0.50 * float64(total))
- return hit1 + hit2 + hit3 + burnDamage(0.15)
- }
- // Second roll: 50-150% of maxHit
- if run.rollAccuracy(attackRoll, defenceRoll) {
- min := floor(0.50 * float64(maxHit))
- max := floor(1.50 * float64(maxHit))
- total := run.rnd.Int63n(max-min+1) + min
- base := floor(0.50 * float64(total))
- hit1 := base - 1
- hit2 := base - 1
- hit3 := int64(2)
- return hit1 + hit2 + hit3 + burnDamage(0.30)
- }
- // Third roll: 25-125% of maxHit
- if run.rollAccuracy(attackRoll, defenceRoll) {
- min := floor(0.25 * float64(maxHit))
- max := floor(1.25 * float64(maxHit))
- total := run.rnd.Int63n(max-min+1) + min
- hit3 := floor(1.00*float64(total)) - 2
- hit1 := int64(1)
- hit2 := int64(1)
- return hit1 + hit2 + hit3 + burnDamage(0.45)
- }
- // All rolls failed: fixed fallback damage
- switch r := run.rnd.Float64(); {
- case r < 0.20:
- return 0
- case r < 0.60:
- return 1
- default:
- return 2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment