Advertisement
TheSixth

Timer Hud by Sixth

Sep 4th, 2015
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 25.53 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Timer HUD EX
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 10/07/2015
  7. # * Requires: Sixth's Picture Number Drawing
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (10/07/2015)
  12. #   - Initial release.
  13. # * Version 1.1 (10/07/2015)
  14. #   - Fixed the disposal of the timer pictures when changing scenes.
  15. #   - The animated picture's refresh rate setting is now properly implemented.
  16. #-------------------------------------------------------------------------------
  17. # * < Description >
  18. #-------------------------------------------------------------------------------
  19. # * This script changes the default timer class heavily!
  20. # * New functions:
  21. #   - Decreasing and increasing timer too!
  22. #   - Pause/resume the timer anytime you want!
  23. #   - Add/remove time from the counter anytime you want!
  24. #   - Automatically call a common event when the timer is stopped/expired!
  25. #   - Made the "Abort Battle" an optional thing only upon expire!
  26. #   - Hide the timer anytime with a switch or with a simple button press!
  27. # * Visual updates:
  28. #   - The numbers are displayed with pictures from now on!
  29. #     (This is why this requires my Picture Number Drawing script.)
  30. #   - Add a background for your timers!
  31. #   - Add a gauge for your timers!
  32. #   - Add an animated picture which follows the timer gauge automatically!
  33. #   - Change any visuals whenever you want during the game too!
  34. #-------------------------------------------------------------------------------
  35. # * < Usage Information >
  36. #-------------------------------------------------------------------------------
  37. # * This script uses a custom made folder setup to get the location of the
  38. #   pictures used. All images used must be in that folder!
  39. #   You can set the folder location with the 'ImgFolder' setting!
  40. #-------------------------------------------------------------------------------
  41. # * < Script Calls >
  42. #-------------------------------------------------------------------------------
  43. # * To change any visual properties of the timer (such as change the images used,
  44. #   their position, Z value or opacity), you can use the following script call:
  45. #
  46. #     timer_pic(img_sym,prop,val)
  47. #
  48. #   img_sym = The symbol of the image from the 'Pics' settings.
  49. #             Can be: :fill, :spark, :back, :nums
  50. #             Read more about what each of them does in the settings explanation!
  51. #   prop = The property symbol from the image's settings.
  52. #          You can use the same symbols used in the 'Pics' settings. These are
  53. #          image specific symbols, so not every symbol used works for all of the
  54. #          images (for example, the :nums "image" got no :img setting, so the
  55. #          :img symbol can not be used on that image in the script call)!
  56. #   val = The new value for the visual setting. This takes the same format as
  57. #         the property symbol you entered uses in their settings below!
  58. #
  59. #   Examples:
  60. #
  61. #     timer_pic(:fill,:img,"timerfillv3b")
  62. #   This would change the image used for the timer's gauge to the "timerfillv3b"
  63. #   image found in the timer HUD folder.
  64. #
  65. #     timer_pic(:spark,:frames,[0,1,2,3,2,1])
  66. #   This would change the animation frames for the animated picture.
  67. #
  68. #     timer_pic(:nums,:style,["timer_nums1",2])
  69. #   This would change the number drawing style of the timer.
  70. #
  71. #   NOTE:
  72. #   Any changes made will only be visible after the next timer is started if
  73. #   a timer is already running! The only exception is the number drawing style,
  74. #   which can be changed anytime, and will be visible immediately!
  75. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  76. # * To change the stop/expire effects of the timer, you can use the following
  77. #   script call:
  78. #
  79. #     timer_eff(eff,prop,val)
  80. #
  81. #   eff = The symbol of the effect to be changed.
  82. #         Can be :stop or :expire. It should be obvious what this does.
  83. #   prop = Just as for the visual settings, you can use any setting symbol here
  84. #          from the 'TimerEffects' settings.
  85. #   val = The new value for the setting. Takes the same format as the property
  86. #         symbol you entered uses in the 'TimerEffects' settings!
  87. #
  88. #   Examples:
  89. #
  90. #     timer_eff(:stop,:event,24)
  91. #   This would change the common event called when the timer is stopped.
  92. #
  93. #     timer_eff(:expire,:abort_battle,true)
  94. #   This would enable the "Abort_Battle" function, so whenever the timer expires,
  95. #   and the party is in a battle, the battle will be aborted automatically.
  96. #   I have set this to false by default in the settings below, since you can now
  97. #   event whatever you want in your common events, which is way more flexible
  98. #   than an auto-abort function. You can still enable it if you want thou.
  99. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  100. # * To change the type of the timer, use the following script call:
  101. #
  102. #     timer_type(type)
  103. #
  104. #   type = The type of the timer. Can be :dec or :inc.
  105. #          :dec is the default behaviour, so the timer will decrease due time,
  106. #          while :inc will make the timer increase due time.
  107. #          Note that you can change this even when a timer is already running!
  108. #
  109. #   Examples: timer_type(:dec) *or* timer_type(:inc)
  110. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  111. # * To pause/resume the timer at any time, you can use the following
  112. #   script calls:
  113. #
  114. #     timer_pause *or* timer_resume
  115. #
  116. #   Okay, this can't be more obvious, so I won't explain anything here. :P
  117. #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  118. # * To increase or decrease the timer's counter manually, you can use the
  119. #   following script call:
  120. #
  121. #     timer_count(val)
  122. #
  123. #   val = The value to be added for the counter.
  124. #         You can use any integer numbers.
  125. #         Use negative numbers to decrease the counter!
  126. #
  127. #   NOTE:
  128. #   Remember that the timer uses frames and NOT seconds, so if you add 120 to
  129. #   the timer, you will add 120 frames to it, which is 2 seconds!
  130. #   Keep this in mind when manipulating the timer!
  131. #          
  132. #   Examples:  timer_count(400),  timer_count(-360)
  133. #-------------------------------------------------------------------------------
  134. # * < Installation >
  135. #-------------------------------------------------------------------------------
  136. # * Place this script below Materials but above Main!
  137. #-------------------------------------------------------------------------------
  138. # * < Compatibility Info >
  139. #-------------------------------------------------------------------------------
  140. # * No known incompatibilities, but I suspect there can be some issues with
  141. #   other scripts changing the timer's functions/visuals.
  142. # * I heavily changed the Game_Timer and Sprite_Timer classes.
  143. # * Also removed the default initialization of the timer sprite completely,
  144. #   so from now on, the timer sprites are only initialized when they are really
  145. #   needed, and they are disposed correctly when they are not needed anymore!
  146. # * Overwritten methods:
  147. #   - In the Spriteset_Map/Spriteset_Battle classes:
  148. #     ~ create_timer, ~ dispose_timer, ~ update_timer
  149. #   - In the Game_Timer class:
  150. #     ~ start, ~ update
  151. #   - In the Sprite_Timer class:
  152. #     ~ initialize, ~ redraw, ~ update
  153. # * Aliased methods:
  154. #   - In the Game_Timer class:
  155. #     ~ initialize, ~ stop, ~ on_expire
  156. #-------------------------------------------------------------------------------
  157. # * < Known Issues >
  158. #-------------------------------------------------------------------------------
  159. # * No known issues.
  160. #-------------------------------------------------------------------------------
  161. # * < Terms of Use >
  162. #-------------------------------------------------------------------------------
  163. # * Free to use for whatever purposes you want.
  164. # * Credit me (Sixth) in your game, pretty please! :P
  165. # * Posting modified versions of this script is allowed as long as you notice me
  166. #   about it with a link to it!
  167. #===============================================================================
  168. $imported = {} if $imported.nil?
  169. $imported["SixthTimerHUD"] = true
  170. #===============================================================================
  171. # Settings:
  172. #===============================================================================
  173. module TimerHUD
  174.   #-----------------------------------------------------------------------------
  175.   # Image Folder Settings:
  176.   #-----------------------------------------------------------------------------
  177.   # Set up a custom folder where your timer HUD pictures will be read from.
  178.   # All pictures used must be in this folder!
  179.   #-----------------------------------------------------------------------------
  180.   ImgFolder = "Graphics/TimerHUD/"
  181.  
  182.   #-----------------------------------------------------------------------------
  183.   # Switch Settings:
  184.   #-----------------------------------------------------------------------------
  185.   # Set up a switch used to toggle the visibility of the timer HUD.
  186.   # Enter the ID of the switch used for this here.
  187.   # You can use this, in case you want to hide the HUD for a cut-scene, etc.
  188.   #-----------------------------------------------------------------------------
  189.   ToggleSw = 99
  190.  
  191.   #-----------------------------------------------------------------------------
  192.   # Button Settings:
  193.   #-----------------------------------------------------------------------------
  194.   # Set up a button to be used for toggling the timer HUD anytime during the
  195.   # game. Players can toggle the visibility with this button anytime they want,
  196.   # except when an event is running, so they can't turn the HUD on if you
  197.   # turned it off for a reason (like for a cut-scene).
  198.   # Set it to nil if you want to disable this function!
  199.   #-----------------------------------------------------------------------------
  200.   ToggleButton = :L
  201.    
  202.   #-----------------------------------------------------------------------------
  203.   # Visual Settings:
  204.   #-----------------------------------------------------------------------------
  205.   # Set up all of the visuals for the timer HUD here!
  206.   #
  207.   # Four images are used (well, one is not really a visible image):
  208.   #   :fill = This is the gauge which will be used for the timer.
  209.   #   :spark = This is the animated picture used which will follow the gauge
  210.   #            automatically. I named it this way, becaue I use this as an
  211.   #            animated spark for a burning rope, which is connected to a bomb.
  212.   #            Looks kinda cool! :D
  213.   #   :back = This is the background image used for the timer.
  214.   #   :nums = This is an invisible sprite for the numeric display of the timer.
  215.   #
  216.   # For all of these, some settings are the same, and these are:
  217.   #   :img = The image file name which will be used.
  218.   #          The :nums settings don't have this!
  219.   #          Setting this to nil will disable the image type!
  220.   #   :pos = The X and Y position of the image in an array.
  221.   #          Format: :pos => [x,y],
  222.   #          In the case of the :spark settings', depending on which gauge type
  223.   #          you have set for the :fill settings, either the X or the Y position
  224.   #          will not matter. If the gauge is horizontal, the X position will
  225.   #          be set automatically, if the gauge is vertical, the Y position will
  226.   #          be set automatically, so it will follow the gauge in both cases.
  227.   #          Also it is relative to the pictures' top left corner, except for
  228.   #          the :spark image! The :spark image's :pos settings are relative to
  229.   #          the image's center and NOT it's top left corner!
  230.   #   :opa = The opacity level of the image. Valid values: 0 - 255.
  231.   #   :z = The Z value of the image.
  232.   #
  233.   # The rest of the settings are image specific settings, so only one type got
  234.   # them!
  235.   #
  236.   # Gauge specific settings (for the :fill settings):
  237.   #   :type = The type of the gauge.
  238.   #           Can be :horz (horizontal) or :vert (vertical).
  239.   #
  240.   # Animated picture specific settings (for the :spark settings):
  241.   #   :frames = The animation frame sequence used for the animation.
  242.   #             The picture used must be a vertical image sheet.
  243.   #             It can be any sized, and can contain as many aniimation frames
  244.   #             as you want!
  245.   #             The top frame's index is 0, the one below is 1, and so on.
  246.   #             Use these indexes to make your animation sequence.
  247.   #             You can re-use any frames as many times as you want!
  248.   #             Once the sequence is finished, the animation starts from the
  249.   #             beginning.
  250.   #   :rows = The number of frame pictures (rows) on your image sheet.
  251.   #   :rate = The refresh rate of the animation. The lower the number, the
  252.   #           quicker the animation frames will change, resulting in a smoother
  253.   #           animation! Use only positive integer numbers!
  254.   #
  255.   # Number display specific settings (for the :nums settings):
  256.   #   :pos2 = The X and Y position of the numbers drawn inside of the sprite.
  257.   #           Format is the same as for the regular :pos settings!
  258.   #   :size = The size of the invisible sprite where the numbers are drawn.
  259.   #           Format: :size => [width,height],
  260.   #           Depending on your number drawing style used, you might need to set
  261.   #           this to bigger or smaller values, so that your numbers would fit
  262.   #           inside the sprite where they are drawn.
  263.   #   :style = The drawing style used for the numbers.
  264.   #            Format: :style => ["img_name",row],
  265.   #            Read more about setting number drawing styles in my
  266.   #            Picture Number Drawing script!
  267.   #   :align = The alignment used for the number drawing.
  268.   #            0 = left, 1 = middle, 2 = right.
  269.   #            Read more about setting number drawing alignment in my
  270.   #            Picture Number Drawing script!
  271.   #-----------------------------------------------------------------------------
  272.   Pics = { # <-- No touchy-touchy!
  273.     :fill => {
  274.       :img => "ropehorzv1a", :type => :horz, :pos => [321,16],
  275.       :opa => 240, :z => 30,
  276.     },
  277.     :spark => {
  278.       :img => "sparksv1a", :pos => [45,22], :opa => 240, :z => 50,
  279.       :frames => [0,1,2,1], :rows => 3,
  280.     },
  281.     :back => {
  282.       :img => "dinamite2va", :pos => [244,2], :opa => 240, :z => 10,
  283.     },
  284.     :nums => {
  285.       :pos => [196,13], :pos2 => [110,0], :size => [120,40], :opa => 240,
  286.       :z => 20, :style => ["hpnums1va",0], :align => 2,
  287.     },
  288.   } # <-- No touchy-touchy!
  289.  
  290.   #-----------------------------------------------------------------------------
  291.   # Effect Settings:
  292.   #-----------------------------------------------------------------------------
  293.   # Set up the effects to be triggered when the timer is stopped or expired here.
  294.   # These effects will be executed automatically every single time the timer
  295.   # stops/expires!
  296.   #
  297.   # Two kind of effects can be set up:
  298.   #   :stop = Effects set here are executed when the timer is stopped.
  299.   #   :expire = Effects set here are executed when the timer is expired.
  300.   #
  301.   # For both types, you can set a common event to be run automatically.
  302.   # The settings for these are:
  303.   #   :event = Enter the common event's ID here you want to be executed.
  304.   #            You can set this to nil if you don't want any auto-event to be
  305.   #            triggered.
  306.   #   :chance = You can randomize these auto-effects, so that they are not
  307.   #             executed every single time. Enter the percentage of the event
  308.   #             to be triggered here. 10 means 10%, 50 means 50%, and so on.
  309.   #
  310.   # The expire type got two additional settings:
  311.   #   :abort_battle = This is the default "Abourt Battle" function, which would
  312.   #                   be run every single time the timer expires in the battle,
  313.   #                   with no way to turn it off! Well, now you can turn it off
  314.   #                   or turn it on whenever you want!
  315.   #                   If this is turned ON, it will be executed, regardless of
  316.   #                   the :chance settings used!
  317.   #   :inc_effect = You can choose to disable the expire effect completely when
  318.   #                 the timer is set to the incrementing type. If this is set to
  319.   #                 false, the timer can't "expire" at all, so the expire
  320.   #                 effects can't be run either. If this is set to true, when the
  321.   #                 timer reaches the max amount, the expire effects will be
  322.   #                 triggered. If the timer is set to the incrementing type, the
  323.   #                 max amount is the amount you have set in the "Control Timer"
  324.   #                 event command, and the timer will always start on 0.
  325.   #
  326.   # NOTE:
  327.   # Any of these settings can be changed with the provided script calls during
  328.   # the game, even if the timer is running!
  329.   # The automatic common event function should be a giant help in timer
  330.   # related eventing! Yay! :D
  331.   #-----------------------------------------------------------------------------
  332.   TimerEffects = { # <-- No touchy-touchy!
  333.     :stop => {:event => 9, :chance => 100},
  334.     :expire => {
  335.       :event => 10, :chance => 100, :abort_battle => false, :inc_effect => false
  336.     },
  337.   } # <-- No touchy-touchy!
  338.  
  339. end # <-- No touchy-touchy!
  340. #===============================================================================
  341. # End of settings! O.o
  342. # Don't look below, someone may find out!
  343. #===============================================================================
  344.  
  345. module Cache
  346.  
  347.   def self.timerhud(filename)
  348.     load_bitmap(TimerHUD::ImgFolder, filename)
  349.   end
  350.  
  351. end
  352.  
  353. class Game_Interpreter
  354.  
  355.   def timer_pic(sym,prop,val)
  356.     $game_timer.data[sym][prop] = val
  357.   end
  358.  
  359.   def timer_eff(eff,prop,val)
  360.     $game_timer.effs[eff][prop] = val
  361.   end
  362.  
  363.   def timer_pause
  364.     $game_timer.pause = true
  365.   end
  366.  
  367.   def timer_resume
  368.     $game_timer.pause = false
  369.   end
  370.  
  371.   def timer_type(type)
  372.     $game_timer.type = type
  373.   end
  374.  
  375.   def timer_count(val)
  376.     $game_timer.count += val
  377.   end
  378.  
  379. end
  380.  
  381. class Spriteset_Map
  382.  
  383.   def create_timer
  384.     if $game_timer.working?
  385.       $game_timer.init_pics
  386.     end
  387.     # Removed! Well, almost! :D
  388.   end
  389.    
  390.   def dispose_timer
  391.     if $game_timer.working?
  392.       $game_timer.dispose_em_pics
  393.     end
  394.     # Removed! Well, almost! :D
  395.   end
  396.  
  397.   def update_timer
  398.     # Removed!
  399.   end
  400.  
  401. end
  402.  
  403. class Spriteset_Battle
  404.  
  405.   def create_timer
  406.     if $game_timer.working?
  407.       $game_timer.init_pics
  408.     end
  409.     # Removed! Well, almost! :D
  410.   end
  411.    
  412.   def dispose_timer
  413.     if $game_timer.working?
  414.       $game_timer.dispose_em_pics
  415.     end
  416.     # Removed! Well, almost! :D
  417.   end
  418.  
  419.   def update_timer
  420.     # Removed!
  421.   end
  422.  
  423. end
  424.  
  425. class Game_Timer
  426.  
  427.   attr_accessor  :data, :effs, :pause, :type, :count
  428.  
  429.   alias add_newhud6522 initialize
  430.   def initialize
  431.     @data = TimerHUD::Pics
  432.     @effs = TimerHUD::TimerEffects
  433.     @pics = {}
  434.     @pause = false
  435.     @type = :dec
  436.     add_newhud6522
  437.   end
  438.    
  439.   def init_pics
  440.     @data.each do |sym,data|
  441.       next if sym != :nums && data[:img].nil?
  442.       case sym
  443.       when :fill
  444.         rate = @count.to_f/@max
  445.         case data[:type]
  446.         when :vert
  447.           @pics[sym] = TimerBar1.new(data[:pos][0],data[:pos][1],Cache.timerhud(data[:img]),rate)
  448.         when :horz
  449.           @pics[sym] = TimerBar2.new(data[:pos][0],data[:pos][1],Cache.timerhud(data[:img]),rate)
  450.         end
  451.       when :nums
  452.         @pics[sym] = Sprite_Timer.new
  453.         @pics[sym].bitmap = Bitmap.new(data[:size][0],data[:size][1])
  454.         @pics[sym].update
  455.       else
  456.         @pics[sym] = Sprite.new
  457.         @pics[sym].bitmap = Cache.timerhud(data[:img])
  458.       end
  459.       if sym != :fill
  460.         if sym == :spark
  461.           @pics[sym].src_rect.height = @pics[sym].bitmap.height/data[:rows]
  462.           @pics[sym].ox = @pics[sym].bitmap.width/2
  463.           @pics[sym].oy = @pics[sym].src_rect.height/2
  464.           @prate = 0; @picid = 0
  465.           @pframes = @data[:spark][:frames]
  466.         end
  467.         @pics[sym].x = data[:pos][0]
  468.         @pics[sym].y = data[:pos][1]
  469.       end
  470.       @pics[sym].z = data[:z]
  471.       @pics[sym].opacity = data[:opa]
  472.       @pics[sym].visible = $game_switches[TimerHUD::ToggleSw]
  473.     end
  474.     if @pics != {} && !@pics[:spark].nil? && !@pics[:fill].nil?
  475.       case @data[:fill][:type]
  476.       when :vert
  477.         if @pics[:spark].y != @pics[:fill].y
  478.           @pics[:spark].y = @pics[:fill].y
  479.         end
  480.       when :horz
  481.         if @pics[:spark].x != @pics[:fill].x + @pics[:fill].src_rect.width
  482.           @pics[:spark].x = @pics[:fill].x + @pics[:fill].src_rect.width
  483.         end
  484.       end
  485.     end
  486.   end
  487.  
  488.   def start(count)
  489.     if @type == :dec
  490.       @count = count
  491.     elsif @type == :inc
  492.       @count = 0
  493.     end
  494.     @max = count
  495.     @working = true
  496.     @prate = 0
  497.     dispose_em_pics if @pics != {}
  498.     init_pics
  499.   end
  500.  
  501.   alias get_rid6533 stop
  502.   def stop
  503.     get_rid6533
  504.     dispose_em_pics if @pics != {}
  505.     do_stop_effects
  506.   end
  507.  
  508.   def fill_rate
  509.     return [@count.to_f/@max,1.0].min
  510.   end
  511.    
  512.   def update_pic_anim
  513.     if @prate % @data[:spark][:rate] == 0
  514.       @picid += 1
  515.       patt = @pframes[@picid % @pframes.size]
  516.       @pics[:spark].src_rect.y = patt*@pics[:spark].src_rect.height
  517.     end
  518.   end
  519.  
  520.   def pics_anim_update
  521.     if @working && ((@type == :dec && @count > 0) || @type == :inc)
  522.       @count -= 1 if !@pause && @type == :dec
  523.       @count += 1 if !@pause && @type == :inc
  524.       @prate += 1
  525.       @pics[:fill].update if @pics != {} && !@pics[:fill].nil?
  526.       @pics[:nums].update if @pics != {} && !@pics[:nums].nil?
  527.       if @pics != {} && !@pics[:spark].nil? && !@pics[:fill].nil?
  528.         case @data[:fill][:type]
  529.         when :vert
  530.           if @pics[:spark].y != @pics[:fill].y
  531.             @pics[:spark].y = @pics[:fill].y
  532.           end
  533.         when :horz
  534.           if @pics[:spark].x != @pics[:fill].x + @pics[:fill].src_rect.width
  535.             @pics[:spark].x = @pics[:fill].x + @pics[:fill].src_rect.width
  536.           end
  537.         end
  538.       end
  539.       update_pic_anim if @pics != {} && !@pics[:spark].nil?
  540.       on_expire if @count == 0 && @type == :dec
  541.       on_expire if @count == @max && @type == :inc && @effs[:expire][:inc_effect]
  542.     end
  543.   end
  544.    
  545.   def update_pic_visibility
  546.     @pics.each do |sym,sprite|
  547.       sprite.visible = $game_switches[TimerHUD::ToggleSw]
  548.     end
  549.   end
  550.  
  551.   def update
  552.     if Input.trigger?(TimerHUD::ToggleButton) &&
  553.        !$game_map.interpreter.running?
  554.       $game_switches[TimerHUD::ToggleSw] = !$game_switches[TimerHUD::ToggleSw]
  555.     end
  556.     if @pics != {} && @pics[:fill].visible != $game_switches[TimerHUD::ToggleSw]
  557.       update_pic_visibility
  558.     end
  559.     pics_anim_update
  560.   end
  561.  
  562.   def dispose_em_pics
  563.     @pics.each do |sym,sprite|
  564.       sprite.bitmap.dispose
  565.       sprite.dispose
  566.     end
  567.     @pics = {}
  568.   end
  569.  
  570.   alias get_rid_o_pics8643 on_expire
  571.   def on_expire
  572.     get_rid_o_pics8643 if @effs[:expire][:battle_abort]
  573.     dispose_em_pics if @pics != {}
  574.     do_expire_effects
  575.   end
  576.  
  577.   def do_expire_effects
  578.     if !@effs[:expire].nil? && !@effs[:expire][:event].nil? && @effs[:expire][:chance] >= rand(100)
  579.       $game_temp.reserve_common_event(@effs[:expire][:event])
  580.     end
  581.   end
  582.  
  583.   def do_stop_effects
  584.     if !@effs[:stop].nil? && !@effs[:stop][:event].nil? && @effs[:stop][:chance] >= rand(100)
  585.       $game_temp.reserve_common_event(@effs[:stop][:event])
  586.     end
  587.   end
  588.  
  589. end
  590.  
  591. class Sprite_Timer < Sprite
  592.  
  593.   def initialize(viewport=nil)
  594.     @data = $game_timer.data[:nums]
  595.     super(viewport)
  596.   end
  597.  
  598.   def redraw
  599.     self.bitmap.clear
  600.     self.bitmap.draw_numbers(@data[:pos2][0],@data[:pos2][1],timer_text,255,@data[:align])
  601.   end
  602.  
  603.   def update_num_data
  604.     if @data != $game_timer.data[:nums]
  605.       @data = $game_timer.data[:nums]
  606.       if self.bitmap.num_style != @data[:style]
  607.         self.bitmap.num_style = @data[:style]
  608.       end
  609.     end
  610.   end
  611.  
  612.   def update
  613.     super
  614.     update_num_data
  615.     update_bitmap
  616.   end
  617.  
  618. end
  619.  
  620. class TimerBar1 < Sprite_Base
  621.  
  622.   def initialize(x,y,pic,rate)
  623.     super(nil)
  624.     self.x = x; self.y = y
  625.     @ori_y = self.y
  626.     @rate = rate
  627.     self.bitmap = pic
  628.     src_rect.height = self.bitmap.height * @rate
  629.     src_rect.y = self.bitmap.height - src_rect.height
  630.     self.y = @ori_y + src_rect.y
  631.   end
  632.  
  633.   def update
  634.     super
  635.     update_rate
  636.   end
  637.  
  638.   def update_rate
  639.     if @rate != $game_timer.fill_rate
  640.       @rate = $game_timer.fill_rate
  641.       update_fill_rate
  642.     end
  643.   end
  644.  
  645.   def update_fill_rate
  646.     src_rect.height = self.bitmap.height * @rate
  647.     src_rect.y = self.bitmap.height - src_rect.height
  648.     self.y = @ori_y + src_rect.y
  649.   end
  650.  
  651. end
  652.  
  653. class TimerBar2 < Sprite_Base
  654.  
  655.   def initialize(x,y,pic,rate)
  656.     super(nil)
  657.     self.x = x; self.y = y
  658.     @rate = rate; @pic = pic
  659.     self.bitmap = pic
  660.     update_fill_rate
  661.   end
  662.  
  663.   def update
  664.     super
  665.     update_rate
  666.   end
  667.  
  668.   def update_rate
  669.     if @rate != $game_timer.fill_rate
  670.       @rate = $game_timer.fill_rate
  671.       update_fill_rate
  672.     end
  673.   end
  674.  
  675.   def update_fill_rate
  676.     src_rect.width = self.bitmap.width * @rate
  677.   end
  678.  
  679. end
  680. #==============================================================================
  681. # !!END OF SCRIPT - OHH, NOES!!
  682. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement