Balrogic

RPG Maker VX Ace Dice Module

Dec 25th, 2014
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.63 KB | None | 0 0
  1. # Dice module by Balrogic
  2. #
  3. # This is a fairly simple bit of code that adds full
  4. # d20 dice functionality to an RPG Maker project.
  5. #
  6. # How to use: Script calls
  7. # You may include the expression Dice::d6(4) in your
  8. # script call to roll 4d6 dice, as an example of how
  9. # this works. If you want to add that to a variable,
  10. # call the following.
  11. #
  12. # $game_variables[1] = Dice::d4(7)
  13. #
  14. # Ouch! That's a lot of magic missiles. To use in
  15. # skills and battle formulas uncomment the class at
  16. # the bottom of the script and include something like
  17. # a.d10(5) in the skill formula bar.
  18.  
  19. module Dice
  20.   def self.d2(x=1);      i = x; i.downto(1) {x += rand(2) + 1};  x - i; end
  21.   def self.d4(x=1);  i = x; i.downto(1) {x += rand(4) + 1};  x - i; end
  22.   def self.d6(x=1);      i = x; i.downto(1) {x += rand(6) + 1};  x - i; end
  23.   def self.d8(x=1);      i = x; i.downto(1) {x += rand(8) + 1};  x - i; end
  24.   def self.d10(x=1);     i = x; i.downto(1) {x += rand(10) + 1}; x - i; end
  25.   def self.d12(x=1);     i = x; i.downto(1) {x += rand(12) + 1}; x - i; end
  26.   def self.d20(x=1);     i = x; i.downto(1) {x += rand(20) + 1}; x - i; end
  27.   def d2(x=1);       i = x; i.downto(1) {x += rand(2) + 1};  x - i; end
  28.   def d4(x=1);       i = x; i.downto(1) {x += rand(4) + 1};  x - i; end
  29.   def d6(x=1);       i = x; i.downto(1) {x += rand(6) + 1};  x - i; end
  30.   def d8(x=1);       i = x; i.downto(1) {x += rand(8) + 1};  x - i; end
  31.   def d10(x=1);      i = x; i.downto(1) {x += rand(10) + 1}; x - i; end
  32.   def d12(x=1);      i = x; i.downto(1) {x += rand(12) + 1}; x - i; end
  33.   def d20(x=1);      i = x; i.downto(1) {x += rand(20) + 1}; x - i; end
  34. end
  35.  
  36. #class Game_BattlerBase
  37. #  include Dice
  38. #end
Advertisement
Add Comment
Please, Sign In to add comment