Advertisement
DaxSoft

Event Bar 3.5 [USA]

Sep 13th, 2014
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. #==============================================================================
  2. # • Event Bar
  3. #==============================================================================
  4. # Actor: Dax
  5. # Version: 3.5
  6. # Site: www.dax-soft.weebly.com
  7. # Requered: Dax Core
  8. #==============================================================================
  9. # • Description:
  10. #------------------------------------------------------------------------------
  11. # Possible to make/create bars who stay in the head of the events..
  12. # Helpful to make bars of life..To system of battle.
  13. #==============================================================================
  14. # • How to use: IN COMMAND 'CALL SCRIPT'
  15. #------------------------------------------------------------------------------
  16. # ebar(eID, vID, m, vm, x, y, w, h, color2, color)
  17. #------------------------------------------------------------------------------
  18. # ► Requered.
  19. # eID : ID of the event of the map. If case nil's the id of the local event.
  20. # vID : ID of the variable who will show the value actual of the bar.
  21. # m : Value max of the bar.
  22. #------------------------------------------------------------------------------
  23. # ► Optional.
  24. # vm : Want control the max value of the bar through of a variable? So,
  25. # set the ID of the variable. Case no, set nil.
  26. # x : Position X add. Case no, set nil.
  27. # y : Position Y add. Case no, set nil.
  28. # w : Modify the width of the size of the HUD.. Case no, set nil.
  29. # The default value is defined.
  30. # h : Modify the height of the size of the HUD.. Case no, set nil.
  31. # The default value is defined.
  32. # i : Modify the first color of the bar. Case no, set nil.
  33. # j : Modify the second color of the bar. Case no, set nil.
  34. #------------------------------------------------------------------------------
  35. # ► Tip:
  36. # Set nil(nothing), is equal the put: nil
  37. #------------------------------------------------------------------------------
  38. # Example:
  39. # ebar(1,1,100,nil,0,0,25,5,"f2e341".color, "fdef57".color)
  40. # ebar(1,2,100,nil,0,-5,32)
  41. #==============================================================================
  42. Dax.register(:event_bar, "Dax", 3.5, "12/09/14")
  43. #==============================================================================
  44. # • Module of configuration.
  45. #==============================================================================
  46. module EventBar
  47. extend self
  48. #----------------------------------------------------------------------------
  49. # • Configuration.
  50. #----------------------------------------------------------------------------
  51. Z = 199 # ► Priority in the map.
  52. COLOR_DEFAULT_BAR2 = "920120".color # ► Default color of the bar 2.
  53. COLOR_DEFAULT_BAR = "d3002d".color # ► Default color of the bar.
  54. COLOR_BACKGROUND = "000000".color # ► Back color.
  55. WIDTH = 24 # ► Default width of the bar.
  56. HEIGHT = 5 # ► Default height of the bar.
  57. @data = []
  58. #----------------------------------------------------------------------------
  59. # • Criar uma barra.
  60. #----------------------------------------------------------------------------
  61. def do(*args)
  62. return unless @data[rand(9999)].nil?
  63. @data[rand(9999)] = Sprite_Event_Bar.new(*args)
  64. end
  65. #----------------------------------------------------------------------------
  66. # • Esconder.
  67. #----------------------------------------------------------------------------
  68. def hide
  69. @data.each { |each| each.opacity = 0 unless each.nil? }
  70. end
  71. #----------------------------------------------------------------------------
  72. # • Dispose
  73. #----------------------------------------------------------------------------
  74. def dispose
  75. return if @data.nil?
  76. @data.each_with_index { |bar, index|
  77. unless bar.nil?
  78. bar.dispose
  79. @data.delete_at(index)
  80. end
  81. }
  82. end
  83. #----------------------------------------------------------------------------
  84. # • Atualizar.
  85. #----------------------------------------------------------------------------
  86. def update
  87. return if @data.nil?
  88. @data.each_with_index { |bar, index|
  89. unless bar.nil?
  90. bar.update
  91. bar.opacity = 255 if bar.opacity == 0
  92. unless bar.visible
  93. bar.dispose
  94. @data.delete_at(index)
  95. end
  96. end
  97. }
  98. end
  99. end
  100. #==============================================================================
  101. # • Sprite_Event_Bar
  102. #==============================================================================
  103. class Sprite_Event_Bar < Sprite
  104. include EventBar
  105. #----------------------------------------------------------------------------
  106. # • Inicialização dos objetos.
  107. #----------------------------------------------------------------------------
  108. def initialize(eID, vID, m, vm=nil, x=nil, y=nil, w=nil, h=nil, color2=nil, color=nil)
  109. @x, @y = x || 0, y || 0
  110. @eID = eID
  111. @m, @vm, @vID = m, vm || 0, vID
  112. super([w || WIDTH, h || HEIGHT])
  113. self.x = $game_map.events[@eID].screen_x - (self.width / 2) + @x
  114. self.y = $game_map.events[@eID].screen_y - (33+self.height) + @y
  115. self.z = Z
  116. @color2, @color = color2 || COLOR_DEFAULT_BAR2, color || COLOR_DEFAULT_BAR
  117. end
  118. #----------------------------------------------------------------------------
  119. # • Renovação dos objetos.
  120. #----------------------------------------------------------------------------
  121. def dispose
  122. self.bitmap.dispose
  123. super
  124. end
  125. #----------------------------------------------------------------------------
  126. # • Atualização dos objetos.
  127. #----------------------------------------------------------------------------
  128. def update
  129. return if self.bitmap.nil?
  130. self.x = $game_map.events[@eID].screen_x - (self.width / 2) + @x
  131. self.y = $game_map.events[@eID].screen_y - (33+self.height) + @y
  132. self.bitmap.clear
  133. @actual = $game_variables[@vID] = $game_variables[@vID] == 0 ? 1 : $game_variables[@vID]
  134. @max = @vm.nil? ? @m : $game_variables[@vm] == 0 ? ($game_variables[@vm] = @m) : $game_variables[@vm]
  135. self.bitmap.fill_rect(self.rect, COLOR_BACKGROUND)
  136. self.bitmap.gradient_bar([@color, @color2], @actual, @max, 1)
  137. self.visible = false if @actual <= 1
  138. end
  139. end
  140. #==============================================================================
  141. # • Spriteset_Map
  142. #==============================================================================
  143. class Spriteset_Map
  144. alias :event_bar_dispose :dispose
  145. def dispose
  146. EventBar.hide
  147. event_bar_dispose
  148. end
  149. alias :event_bar_update :update
  150. def update
  151. event_bar_update
  152. EventBar.update
  153. end
  154. end
  155. #==============================================================================
  156. # • Game_Player
  157. #==============================================================================
  158. class Game_Player < Game_Character
  159. alias :eb_perform_transfer :perform_transfer
  160. def perform_transfer
  161. eb_perform_transfer
  162. EventBar.dispose
  163. end
  164. end
  165. #==============================================================================
  166. # • Interpretador;
  167. #==============================================================================
  168. class Game_Interpreter
  169. #----------------------------------------------------------------------------
  170. # • Barra no evento.
  171. #----------------------------------------------------------------------------
  172. def ebar(*args)
  173. EventBar.do(*args)
  174. end
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement