Advertisement
Guest User

Untitled

a guest
May 13th, 2009
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.90 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. puts "Int:"
  4. int = gets.to_i
  5. puts "Spellcasting:"
  6. spc = gets.to_i
  7. puts "Avg of spell schools:"
  8. sch = gets.to_i
  9. puts "Number of enhancers (possibly negative):"
  10. enh = gets.to_i
  11. puts "Mons MR:"
  12. mr = gets.to_i
  13.  
  14. rawpower = (int / 10) * (spc/2 + sch*2) * (1.5**enh)
  15.  
  16. puts "Raw spellpower: #{rawpower}"
  17.  
  18. def adjust(x,a,b,c,d)
  19.   return x if x <= a
  20.   r = a
  21.   a.step(c,b) do |i|
  22.     if r > i
  23.       r = (r-i)/2 + i
  24.     else
  25.       break
  26.     end
  27.   end
  28.   r = d if r > d
  29.   r
  30. end
  31.  
  32. adjustedpower = adjust(rawpower, 50, 50, 150, 200)
  33.  
  34. puts "Adjusted spellpower: #{adjustedpower}"
  35.  
  36. enchpower = adjust(adjustedpower, 30, 40, 100, 120)
  37.  
  38. mrchance = 100+mr - enchpower
  39.  
  40. props = []
  41. 20.times do
  42.   succ = 0
  43.   1000.times { succ += 1 if mrchance < (1+rand(100) + 1+rand(101)) }
  44.   props <<  (succ.to_f / 10).to_i
  45. end
  46. props.sort!
  47.  
  48. puts "Ench success: (#{props[1]}, #{props[18]}) %"
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement