CrowMakerVX

Dice Scene

Aug 5th, 2012
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 28.11 KB | None | 0 0
  1. #################################################################################
  2.  
  3. #################################################################################
  4. #                             IXFURU SCENE DICE
  5. ##################################################################################
  6. #   This script calls a scene which executes a dice roll at the given amount of
  7. # dice, specified in a variable.   It's bulky, and uses 5 game variables and
  8. # 7 game switches.  To use, you need to setup the constants in CONFIG1 section,
  9. # if you add or delete from the D6 constants section of CONFIG1, you'll have to
  10. # also modify CONFIG2 (line 667) to match it.   You'll also need to switch out iconsets in
  11. # the Graphics/System folder with the one in the demo, or just find some
  12. # icons of dice and change the images appropriately starting at line 99.
  13. # Once you've set it up how you want it, just call the scene by putting:
  14. #                   $scene = Scene_Dice.new
  15. #        in a script command (third page of the event commands)
  16. #
  17. #               SOME EXAMPLES:   (D6 means six-sided die)
  18. #                                  
  19. #                   3D6 + 4    Setup->  VROLL variable at 3, VADDR variable at 4,
  20. #                                         This will call for a roll of 3 dice,
  21. #                                               and add 4 to it for the total.
  22.  
  23. #
  24. #                 6D6 + 2D6    Setup->  VROLL variable at 6
  25. #                                      VADDR variable at 2
  26. #                                      Turn AIRSWITCH on
  27. #                                           This will call for a 6D6 roll,
  28. #                                           followed by a 2D6 roll, with the
  29. #                                           2D6 roll added to the initial.
  30. #
  31. #                 2D6 x 12     Setup-> VROLL variable at 2, VMULT variable at 12
  32. #                                     This will call a 2D6 roll, the value will
  33. #                                      will be multiplied by 12.
  34. #
  35. #         LIMITATIONS:  
  36. #      Though it is possible to do (4D6 x 2D6) + 3, it is not possible to do
  37. #         (7D6 + 4) x 7.  The multiplier MUST come before the adder and the
  38. #       bonus roll.  A fair replacement would be (7D6 + 4) + 7D6.
  39. #    Also, you cannot have more than 10D6 on a given roll.
  40. #
  41. # In closing, just remember to set up the roll prior to calling the scene by
  42. #  adjusting necessary switches and variables.  
  43. #################################################################################
  44. #
  45. #        Please credit me if you use this script.  Feel free to contact me in my
  46. #     subforum at RPGMakerVX.net, called "THE FINISH LINE".   You can also PM
  47. #       me with any questions regarding the script, or post in the script topic.
  48. #       If you want to use this commercially, credit MUST be given.  Also, please
  49. #      link me to your project so I can check it out.  Thanks and Enjoy!
  50. #
  51. #################################################################################
  52. ##################################################################################'
  53.  
  54. #                                    CONFIG1
  55.  
  56.  
  57. ###################################################################################
  58. module NQ
  59.  
  60.   #Window_Dice Constants
  61.  
  62.   # NOTE on the first 7 strings found here:
  63.   #  It is advised that if you change any of these, you make the string a short
  64.   # one.  As the size of these strings greatly effect how the dice are displayed
  65.   # on a given roll.  A string too long can cause some dice run out the side of
  66.   # the window.
  67.  
  68.   DRINSTRUCT = "ROLL THE DICE"  #string displayed at top of dice window
  69.  
  70.   DCOUNT = "ROLL"             #first string displayed on left margin; amount
  71.                                     # of dice to roll
  72.                                    
  73.   DMULTIPLIER = "ROLL X"      #second string on left margin; value count
  74.                                     # is multiplied by
  75.                                    
  76.   DADDER = "ROLL +"               #third string on left margin; value to be added
  77.                                    # to count
  78.                                    
  79.   DROLLBONUS = "BONUS"       #fourth string on left margin; conditional value
  80.                                       #to be added to count
  81.                                      
  82.   DTOTAL = "ROLL TOTAL"           #final string on left margin;  total of roll with
  83.                                     # all values added
  84.                                    
  85.   DBONUS = "ALL THE SAME BONUS"    #string at bottom of dice window, only appears
  86.                                       #if all dice are the same on rolls of 3 or
  87.                                       # more.  If these conditions are met, the
  88.                                       # total count is doubled.
  89.                                      
  90.   DRINSTRUCT_COLOR = 18   #must be integer above 0 and less than 31, changes color
  91.                           # of the DRINSTRUCT string above.
  92.                                      
  93.   USE_DOUBLER = true   ##SET THIS TO 'false' if you don't want the doubler active
  94.                         # this will make it so that DBONUS is never written.
  95.                        
  96.   MIN_DOUBLER = 3  #This number is the least amount of dice that can be rolled,
  97.                       #to enact doubler bonus.  This is only in effect if the
  98.                       #USE_DOUBLER is true.  This prevents doubling of rolls with
  99.                       #less than value given here.
  100.        
  101.   #Dice Variables;  You'll need to pass the variables VROLL, VMULT, VADDR and
  102.   #  VRBNS into the scene.  Set the variables pre scene call.
  103.  
  104.   VROLL = 11  #Variable that holds the amount of dice to roll
  105.   VMULT = 12   #Variable that holds the amount to multiply roll by
  106.   VADDR = 13    #Variable that holds the amount to add to the roll
  107.   VRBNS = 14    #Variable that holds any conditional value to add
  108.   VTRLL = 15    #Variable that holds total of the roll; this is the value you can
  109.                 # pass back to the scene or game you're creating.
  110. #-----------------------------------------------------------------------------------
  111.   MIRSWITCH = 16  #This is an in game switch which verifies if dice should be rolled
  112.                     # to determine the multiplier.  If switch is OFF, value of
  113.                     # multiplier is straight value; if ON a roll of the amount
  114.                     # of dice equal to the multiplier variable is required.
  115.                    
  116.   AIRSWITCH = 17 #This is an in game switch which is used to determine if a
  117.                   # roll is required for the adder.
  118.                  
  119.   BIRSWITCH = 18  #This is an in game switch which is used to determine if a
  120.                           # roll is required for the Roll Bonus.
  121.                          
  122. #----------------------------------------------------------------------------------
  123.  
  124.                 #These values make reference to the Iconset in Graphics/System
  125.                 # folder.   This is used in displaying the dice.  You need to
  126.                 # set these values to the icon from the iconset you wish to
  127.                 #  display the dice at each side.  DIE5 for example, will show
  128.                 # if the player rolls a 5.  DIESTILL is just which icon you
  129.                 # wish to display when the die is sitting still at the beginning
  130.                 # of the scene.
  131.  
  132.                      
  133.   DIESTILL = 3828 # still dice icon
  134.   DIE1 = 1410   #when 1 is rolled
  135.   DIE2 = 1411    #when 2 is rolled...
  136.   DIE3 = 1412
  137.   DIE4 = 1413
  138.   DIE5 = 1414
  139.   DIE6 = 1415
  140.  
  141.  
  142.   #These are the Sound Effects played during different parts of the scene.
  143.   ROLLING_SE = 'Earth9'
  144.   SET_DICE_SE = 'Battle2'
  145.   TALLY_LINES_SE = 'Saint5'
  146.   TOTAL_GIVEN_SE = 'Chime2'
  147.   DOUBLER_SE = 'Absorb2'
  148.  
  149.   INPUT_TO_ROLL = Input::C   #input button used to activate the roll
  150.   #=============================================================================
  151.  
  152.   #Window_D6 Constants;
  153.  
  154.  
  155.   #These are the strings which will show in the D6 Window.  
  156.   #Basically, they just explain why you're making the current roll.
  157.   #YOU SHOULD LIMIT THESE STRINGS TO 11 LETTERS!
  158.   RTYPE_1 = "SKILL"
  159.   RTYPE_2 = "PROFICIENCY"
  160.   RTYPE_3 = "ATTACKING"
  161.   RTYPE_4 = "EFFECTS"
  162.   RTYPE_5 = "FOR ITEM"
  163.   RTYPE_6 = "GAMBLING"
  164.   RTYPE_7 = "ROPE BREAK"
  165.   RTYPE_8 = "CHANCE"
  166.   RTYPE_9 = "SURPRISE"
  167.   RTYPE_10 = "HEALING"
  168.  
  169.   VRTYP = 16    #Variable which defines which of the 'RTYPE' string constants
  170.                       # to display. You'll need to set the CONFIG2 section up
  171.                       # if you plan on creating new ones, or subtracting from
  172.                       # those that already exist.  WARNING:  If you add or
  173.                       # subtract from the D6 Constants above, you must also,
  174.                       # add/subtract them from CONFIG2 section beginning at
  175.                       # line 667.
  176.                      
  177.   VSTAT = 17  #Variable that holds a relevant target value.  It will be displayed
  178.               # beneath the RTYPE string in parenteses, if it's used.
  179.              
  180.   VSTATSWITCH = 15   #Target Value Switch;  This is an in game switch which will be used to show/hide
  181.   #the value in VSTAT constant.  If turned on, it will display the stat, if
  182.   #turned off, it won't.
  183.  
  184. end
  185.  
  186. ###################################################################################
  187.  
  188. #                      END CONFIG1
  189. #      
  190. #        Please don't edit anything beyond here, unless you need to edit the
  191. #            CONFIG2 section explained above and found at line 697
  192. #
  193.  
  194.    
  195. ##################################################################################
  196.  
  197. class Window_Dice < Window_Base
  198.  
  199.  
  200.   #------------------------------------------------------------------------------
  201.   #     Public Instance Variables
  202.   #------------------------------------------------------------------------------
  203.   attr_accessor :rollbonus
  204.   attr_accessor :roll_complete
  205.   attr_accessor :multiroll_complete
  206.   attr_accessor :adderroll_complete
  207.   attr_accessor :bonusroll_complete
  208.   attr_accessor :roll_values
  209.   attr_accessor :multi_values
  210.   attr_accessor :adder_values
  211.   attr_accessor :bonus_values
  212.   attr_accessor :dieplacex
  213.   attr_accessor :dieplacey
  214.   attr_accessor :quickdraw
  215.   attr_accessor :rollbonus
  216.  
  217.   def initialize
  218.     super(160, 30, 375, 300)
  219.     @rollbonus = false
  220.     @roll_complete = false
  221.     @multiroll_complete = false
  222.     @adderroll_complete = false
  223.     @bonusroll_complete = false
  224.     @roll_values = []
  225.     @multi_values = []
  226.     @adder_values = []
  227.     @bonus_values = []
  228.     @multi_is_roll = $game_switches[NQ::MIRSWITCH]
  229.     @adder_is_roll = $game_switches[NQ::AIRSWITCH]
  230.     @bonus_is_roll = $game_switches[NQ::BIRSWITCH]
  231.     @roll = $game_variables[NQ::VROLL]
  232.     @multiplier = $game_variables[NQ::VMULT]
  233.     @adder = $game_variables[NQ::VADDR]
  234.     @roll_bonus = $game_variables[NQ::VRBNS]
  235.     @total_roll = $game_variables[NQ::VTRLL]
  236.     if @roll > 10  # if amount of dice to roll is greater than 10
  237.       @roll = 10    # set to 10, max
  238.     end
  239.     if @roll == 0  #if amount of dice to roll is set to zero
  240.       @roll = 1      #set to 1, minimum
  241.     end
  242.    
  243.    
  244.     x = 4         #create variable for x placement of still dice
  245.     for i in 1..@roll   #once for every die to be rolled
  246.       draw_still_dice((NQ::DCOUNT.length*13) + x, 50)
  247.       x += 26   #add 26 to x placement variable
  248.     end
  249.  
  250.     if @multiplier > 10
  251.       @multiplier = 10
  252.     end
  253.     if @multi_is_roll == true  #if multiplier requires an additional roll
  254.       x = 4               # x placement variable
  255.       for i in 1..@multiplier    #once for every die in the multiplier roll
  256.         draw_still_dice((NQ::DMULTIPLIER.length*13) + x, 90)
  257.         x += 26            # add 26 to x placement variable
  258.       end
  259.     end
  260.    
  261.  
  262.     if @adder > 10
  263.       @adder = 10
  264.     end
  265.     if @adder_is_roll == true    
  266.       x = 4
  267.       for i in 1..@adder
  268.         draw_still_dice((NQ::DADDER.length*13) + x, 130)
  269.         x += 26
  270.       end
  271.     end
  272.    
  273.     if @roll_bonus > 10
  274.       @roll_bonus = 10
  275.     end
  276.     if @bonus_is_roll == true
  277.       x = 4
  278.       for i in 1..@roll_bonus
  279.         draw_still_dice((NQ::DROLLBONUS.length*13) + x, 170)
  280.         x += 26
  281.       end
  282.     end
  283.    
  284.     refresh
  285.   end
  286.  
  287.   #------------------------------------------------------------------------------
  288.   #              Start processing, fill contents at beginning of scene
  289.   #------------------------------------------------------------------------------
  290.   def refresh
  291.      
  292.     self.contents.font.color = text_color(NQ::DRINSTRUCT_COLOR)
  293.     self.contents.draw_text(90, 4, self.width, WLH, NQ::DRINSTRUCT)
  294.     draw_roll_text
  295.     draw_multiplier_text
  296.     draw_adder_text
  297.     draw_bonusroll_text
  298.     self.contents.font.color = system_color
  299.     self.contents.draw_text(4, 210, self.width, WLH, NQ::DTOTAL)
  300.    
  301.   end
  302.  
  303.   #------------------------------------------------------------------------------
  304.   #                    Determine Roll text color and draw
  305.   #------------------------------------------------------------------------------
  306.   def draw_roll_text
  307.     if @roll_complete == true
  308.       self.contents.font.color = text_color(20)
  309.       self.contents.draw_text(4, 50, self.width, WLH, NQ::DCOUNT)
  310.     else
  311.       self.contents.font.color = system_color
  312.       self.contents.draw_text(4, 50, self.width, WLH, NQ::DCOUNT)
  313.     end
  314.   end
  315.  
  316.  
  317.   #-------------------------------------------------------------------------------
  318.   #                      Determine Multiplier text color and draw
  319.   #-------------------------------------------------------------------------------
  320.   def draw_multiplier_text
  321.     if @multiroll_complete == true   #has the multiplier roll been complete          
  322.       self.contents.font.color = text_color(20)  #change to active color
  323.       self.contents.draw_text(4, 90, self.width, WLH, NQ::DMULTIPLIER)
  324.     else
  325.       self.contents.font.color = system_color #change to system color
  326.       self.contents.draw_text(4, 90, self.width, WLH, NQ::DMULTIPLIER)
  327.     end
  328.   end
  329.  
  330.   #-----------------------------------------------------------------------------
  331.   #                  Determine Adder text color and draw
  332.   #-----------------------------------------------------------------------------
  333.   def draw_adder_text
  334.     if @adderroll_complete == true
  335.       self.contents.font.color = text_color(20)
  336.       self.contents.draw_text(4, 130, self.width, WLH, NQ::DADDER)
  337.     else
  338.       self.contents.font.color = system_color
  339.       self.contents.draw_text(4, 130, self.width, WLH, NQ::DADDER)
  340.     end
  341.   end
  342.  
  343.   #-------------------------------------------------------------------------------
  344.   #                  Determine Bonus Roll text color and draw
  345.   #-------------------------------------------------------------------------------
  346.   def draw_bonusroll_text
  347.     if @bonusroll_complete == true
  348.       self.contents.font.color = text_color(20)
  349.       self.contents.draw_text(4, 170, self.width, WLH, NQ::DROLLBONUS)
  350.     else
  351.       self.contents.font.color = system_color
  352.       self.contents.draw_text(4, 170, self.width, WLH, NQ::DROLLBONUS)
  353.     end
  354.   end
  355.  
  356. #--------------------------------------------------------------------------------
  357. #                 Drawing the Dice after roll
  358. #--------------------------------------------------------------------------------
  359.  
  360.   def draw_the_dice(value, x, y)
  361.     case value
  362.     when 1
  363.       draw_icon(NQ::DIE1, x, y)
  364.     when 2
  365.       draw_icon(NQ::DIE2, x, y)
  366.     when 3
  367.       draw_icon(NQ::DIE3, x, y)
  368.     when 4
  369.       draw_icon(NQ::DIE4, x, y)
  370.     when 5
  371.       draw_icon(NQ::DIE5, x, y)
  372.     when 6
  373.       draw_icon(NQ::DIE6, x, y)
  374.     end
  375.   end
  376.  
  377. #--------------------------------------------------------------------------------
  378. #              Drawing the Still Dice
  379. #--------------------------------------------------------------------------------
  380.  
  381.   def draw_still_dice(x, y)
  382.     draw_icon(NQ::DIESTILL, x, y)
  383.   end
  384.  
  385.  
  386. #--------------------------------------------------------------------------------
  387. #              Rolling the initial roll
  388. #--------------------------------------------------------------------------------
  389.  def roll_for_roll
  390.    
  391.    it = 0
  392.    rt = 0
  393.    @roll_values = []  # create the roll values array
  394.    for i in 1..@roll      # once for the number of dice in the roll
  395.      Audio.se_play('Audio/SE/' + NQ::ROLLING_SE, 80, 100) #plays Rolling SE
  396.      @roll_values.push(rand(5)+1)  #adds a random number 1 through 6 to the array
  397.      rt += @roll_values[it]
  398.      it += 1
  399.    end
  400.    
  401.    it = 0
  402.    x = 4  #create an x placement variable
  403.    for i in @roll_values  #once for every item in the array
  404.      value = @roll_values[it]  #create a value for the current element of the array
  405.      draw_the_dice(value, (NQ::DCOUNT.length*13) + x, 50) #call the draw dice method
  406.      x += 26  #adds 26 to x variable for spacing
  407.      it += 1
  408.    end
  409.    check_for_doubler(@roll, rt, @roll_values[0]) #passes number of dice, total of roll, first die roll
  410.    @roll_complete = true
  411.    Audio.se_play('Audio/SE/' + NQ::SET_DICE_SE, 80, 100)
  412.    if @multi_is_roll == false  #if multiplier does NOT require a roll
  413.      @multiroll_complete = true   #say the roll is complete
  414.      if @adder_is_roll == false
  415.        @adderroll_complete = true
  416.        if @bonus_is_roll == false
  417.          @bonusroll_complete = true
  418.          tally_lines              #if all conditions met, finish the roll
  419.        end
  420.      end
  421.    end
  422.    
  423.  end
  424.  
  425.  
  426.    
  427.   #-------------------------------------------------------------------------------
  428.   #                Rolling for the multiplier
  429.   #-------------------------------------------------------------------------------
  430.  
  431.   def roll_for_multiplier
  432.    
  433.     it = 0
  434.     rt = 0
  435.     @multi_values = []
  436.     for i in 1..@multiplier
  437.       Audio.se_play('Audio/SE/' + NQ::ROLLING_SE, 80, 100)
  438.       @multi_values.push(rand(5)+1)
  439.       rt += @multi_values[it]
  440.     end
  441.    
  442.     it = 0
  443.     x = 4
  444.     for i in @multi_values
  445.       value = @multi_values[it]
  446.       draw_the_dice(value, (NQ::DMULTIPLIER.length*13) + x, 90)
  447.       x += 26
  448.       it += 1
  449.     end
  450.    
  451.     check_for_doubler(@multiplier, rt, @multi_values[0])
  452.     @multiroll_complete = true
  453.     Audio.se_play('Audio/SE/' + NQ::SET_DICE_SE, 80, 100)
  454.     if @adder_is_roll == false
  455.       @adderroll_complete = true
  456.       if @bonus_is_roll == false
  457.         @bonusroll_complete = true
  458.         tally_lines
  459.       end
  460.     end
  461.   end
  462.  
  463.   #------------------------------------------------------------------------------
  464.   #                 Rolling for Adder
  465.   #-------------------------------------------------------------------------------
  466.  
  467.   def roll_for_adder
  468.    
  469.     it = 0
  470.     rt = 0
  471.     @adder_values = []
  472.     for i in 1..@adder
  473.       Audio.se_play('Audio/SE/' + NQ::ROLLING_SE, 80, 100)
  474.       @adder_values.push(rand(5)+1)
  475.       rt += @adder_values[it]
  476.       it += 1
  477.     end
  478.    
  479.     it = 0
  480.     x = 4
  481.     for v in @adder_values
  482.       value = @adder_values[it]
  483.       draw_the_dice(value, (NQ::DADDER.length*13) + x, 130)
  484.       x += 26
  485.       it += 1
  486.     end
  487.    
  488.     check_for_doubler(@adder, rt, @adder_values[0])
  489.     @adderroll_complete = true
  490.     Audio.se_play('Audio/SE/' + NQ::SET_DICE_SE, 80, 100)
  491.     if @bonus_is_roll == false
  492.       @bonusroll_complete = true
  493.       tally_lines
  494.     end
  495.   end
  496.  
  497.   #-------------------------------------------------------------------------------
  498.   #                     Rolling for Bonus
  499.   #------------------------------------------------------------------------------
  500.  
  501.   def roll_for_bonus
  502.    
  503.     it = 0
  504.     rt = 0
  505.     @bonus_values = []
  506.     for i in 1..@roll_bonus
  507.       Audio.se_play('Audio/SE/' + NQ::ROLLING_SE, 80, 100)
  508.       @bonus_values.push(rand(5)+1)
  509.       rt += @bonus_values[it]
  510.       it += 1
  511.     end
  512.    
  513.     it = 0
  514.     x = 4
  515.     for v in @bonus_values
  516.       value = @bonus_values[it]
  517.       draw_the_dice(value, (NQ::DROLLBONUS.length*13) + x, 170)
  518.       x += 26
  519.       it += 1
  520.     end
  521.    
  522.     check_for_doubler(@roll_bonus, rt, @bonus_values[0])
  523.     @bonusroll_complete = true
  524.     Audio.se_play('Audio/SE/' + NQ::SET_DICE_SE, 80, 100)
  525.     tally_lines
  526.   end
  527.  
  528.  
  529.  
  530.   #-------------------------------------------------------------------------------
  531.   #               Tally the lines (find total)
  532.   #-------------------------------------------------------------------------------
  533.   def tally_lines
  534.     @grand_total = 0  #create grand total
  535.     ri = 0
  536.     for i in @roll_values  #add the values of roll
  537.       @grand_total += @roll_values[ri]
  538.       ri += 1
  539.     end
  540.     Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  541.    
  542.     if @multi_is_roll == true
  543.        mi = 0
  544.        mt = 0                #create total multiplier value
  545.       for i in @multi_values  #add the multiplier values
  546.         mt += @multi_values[mi]
  547.         mi += 1
  548.       end
  549.       @grand_total *= mt         #multiply grand total by total multiplyer value
  550.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  551.     else
  552.       @grand_total *= @multiplier    #multiply grand total by multiplier instead
  553.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  554.       self.contents.font.color = normal_color
  555.       self.contents.draw_text(180, 90, self.width, WLH, @multiplier)  #draw the value of multiplier
  556.       self.contents.font.color = system_color
  557.     end
  558.    
  559.     if @adder_is_roll == true
  560.       ai = 0
  561.       for i in @adder_values       #add the adder values
  562.         @grand_total += @adder_values[ai]
  563.         ai += 1
  564.       end
  565.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  566.     else
  567.       @grand_total += @adder  #add adder to grand total instead
  568.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  569.       self.contents.font.color = normal_color
  570.       self.contents.draw_text(180, 130, self.width, WLH, @adder)
  571.       self.contents.font.color = system_color
  572.     end
  573.    
  574.     if @bonus_is_roll == true
  575.       bi = 0
  576.       for i in @bonus_values        #add the bonus values
  577.         @grand_total += @bonus_values[bi]
  578.         bi += 1
  579.       end
  580.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  581.     else
  582.       @grand_total += @roll_bonus
  583.       Audio.se_play('Audio/SE/' + NQ::TALLY_LINES_SE, 80, 100)
  584.       self.contents.font.color = normal_color
  585.       self.contents.draw_text(180, 170, self.width, WLH, @roll_bonus)
  586.       self.contents.font.color = system_color
  587.      
  588.     end
  589.    
  590.    
  591.    self.contents.font.color = power_up_color
  592.    self.contents.draw_text(180, 210, self.width, WLH, @grand_total)
  593.    $game_variables[NQ::VTRLL] = @grand_total
  594.    Audio.se_play('Audio/SE/' + NQ::TOTAL_GIVEN_SE, 80, 100)
  595.    refresh
  596.  
  597.  end
  598.  
  599.  
  600.   #------------------------------------------------------------------------------
  601.   #                Rolling the Dice
  602.   #------------------------------------------------------------------------------
  603.  
  604.   def roll_the_dice
  605.     if @bonusroll_complete == true
  606.       tally_lines
  607.     elsif @adderroll_complete == true
  608.       roll_for_bonus
  609.     elsif @multiroll_complete == true
  610.       roll_for_adder
  611.     elsif @roll_complete == true
  612.       roll_for_multiplier
  613.     elsif @roll_complete == false
  614.       roll_for_roll
  615.     end
  616.   end
  617.  
  618.      
  619.   #------------------------------------------------------------------------------
  620.   #                   check for doubler bonus
  621.   #------------------------------------------------------------------------------
  622.  
  623.   def check_for_doubler(dice, roll_total, first_value)
  624.     bonus_check = NQ::MIN_DOUBLER
  625.     use_doub = NQ::USE_DOUBLER
  626.     if use_doub == true   # if bonus doubler is being used
  627.       if dice >= bonus_check  #if number of dice to be rolled is greater than
  628.                                     # minimum required
  629.         @rollbonus = true         #turn flag on to compare values of dice
  630.       else
  631.         @rollbonus = false
  632.       end
  633.     end
  634.     if @rollbonus == true
  635.       d = dice             #number of dice rolled
  636.       rt = roll_total     #total of the given roll
  637.       fv = first_value    #value of first die in roll
  638.       fv *= d             #multiply first die by roll_total
  639.       if fv == rt      #if first value now equals roll_total
  640.         Audio.se_play('AUDIO/SE/' + NQ::DOUBLER_SE, 100, 85)
  641.         @total_roll *= 2
  642.         $game_variables[NQ::VTRLL] = @total_roll
  643.         self.contents.font.color = text_color(19)
  644.         self.contents.draw_text(4, 290, self.width, WLH, NQ::DBONUS)
  645.       end
  646.     end
  647.    
  648.    
  649.   end          #end of method
  650.  
  651. end             #end of class
  652.  
  653.  
  654. ##################################################################################
  655. class Window_D6 < Window_Base
  656.  
  657.   attr_accessor :vstat
  658.   attr_accessor :vstswitch
  659.  
  660.   def initialize
  661.     super(4, 30, 155, 140)
  662.     @vstat = $game_variables[NQ::VSTAT]
  663.     @vstswitch = $game_switches[NQ::VSTATSWITCH]
  664.     refresh
  665.   end
  666.  
  667.   def refresh
  668.     self.contents.font.color = power_up_color
  669.     self.contents.draw_text(3, 3, self.width, WLH, $game_variables[NQ::VROLL].to_s + "D6")
  670.     self.contents.font.color = system_color
  671.     case $game_variables[NQ::VRTYP]
  672. ##################################################################################
  673. #                         CONFIG2
  674. #
  675. #                      If you made any changes in the CONFIG1, by adding or
  676. # or subtracting roll types, you need to make this one match.  The set up is
  677. # simple, if you've deleted a roll type, you'll just delete the section
  678. #
  679. #                when x
  680. #                self.contents.draw_text(...
  681. #
  682. #         for the one you deleted, and if you added one, just follow the
  683. # same method and create the new ones below those listed here.
  684. #                  
  685. #                    when x
  686. #                   self.contents.draw_text(x, y, width, height, string)
  687. #
  688. # This will create a new possible string to display, based on what you pass into
  689. # the scene through in game variable found in VRTYP.
  690. #################################################################################
  691.     when 0
  692.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_1)
  693.     when 1
  694.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_2)
  695.     when 2
  696.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_3)
  697.     when 3
  698.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_4)
  699.     when 4
  700.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_5)
  701.     when 5
  702.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_6)
  703.     when 6
  704.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_7)
  705.     when 7
  706.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_8)
  707.     when 8
  708.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_9)
  709.     when 9
  710.       self.contents.draw_text(5, 40, self.width, WLH, NQ::RTYPE_10)
  711. ###################################################################################
  712. #                          END CONFIG2
  713. ##################################################################################
  714.     end
  715.     if @vstswitch == true
  716.       self.contents.draw_text(20, 70, self.width, WLH, "(" + @vstat.to_s + ")")
  717.     end
  718.    
  719.   end
  720.  
  721. end
  722.  
  723. ###################################################################################
  724.  
  725. class Scene_Dice < Scene_Base
  726.  
  727.   def initialize
  728.     create_menu_background
  729.     @dice_window = Window_Dice.new
  730.     @window_d6 = Window_D6.new
  731.   end
  732.  
  733.   def update
  734.     super
  735.     update_menu_background
  736.     @dice_window.refresh
  737.     @window_d6.refresh
  738.     if $game_variables[NQ::VTRLL] == 0
  739.       if Input.trigger?(NQ::INPUT_TO_ROLL)
  740.         @dice_window.roll_the_dice
  741.       end
  742.     elsif $game_variables[NQ::VTRLL] > 0
  743.       if Input.trigger?(NQ::INPUT_TO_ROLL)
  744.         Sound.play_decision
  745.         exit_the_scene
  746.       end
  747.     end
  748.    
  749.   end
  750.  
  751.   def exit_the_scene
  752.     $game_switches[NQ::VSTATSWITCH] = false
  753.     $game_switches[NQ::MIRSWITCH] = false
  754.     $game_switches[NQ::AIRSWITCH] = false
  755.     $game_switches[NQ::BIRSWITCH] = false
  756.     $game_variables[NQ::VTRLL] = 0
  757.     $scene = Scene_Map.new
  758.   end
  759.  
  760.  
  761.   def terminate
  762.     @dice_window.dispose
  763.     @window_d6.dispose
  764.     dispose_menu_background
  765.    
  766.   end
  767.  
  768. end
Advertisement
Add Comment
Please, Sign In to add comment