Guest User

Visor de combo MOG

a guest
Feb 21st, 2017
123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # +++ MOG - Combo Count (v1.7) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # Apresenta a quantidade de acertos no alvo e o dano maximo.
  8. #==============================================================================
  9. # É necessário ter os arquivos imagens na pasta Graphics/Systems.
  10. # Combo_Damage.png
  11. # Combo_Hud.png
  12. # Combo_Number.png
  13. #==============================================================================
  14.  
  15. #==============================================================================
  16. # ● Histórico (Version History)
  17. #==============================================================================
  18. # v1.7 - Correção de não apresentar o dano quando se usa sprites pequenos.
  19. #==============================================================================
  20.  
  21. $imported = {} if $imported.nil?
  22. $imported[:mog_combo_count] = true
  23.  
  24. module MOG_COMBO_COUNT
  25. #Ativar tempo para fazer combo.
  26. TIME_COUNT = true
  27. # Tempo para fazer um combo. (60 = 1s)
  28. COMBO_TIME = 60
  29. # Cancelar a contagem de Combo caso o inimigo acertar o herói.
  30. ENEMY_CANCEL_COMBO = true
  31. # Posição geral das imagens. X Y
  32. COMBO_POSITION = [20,85]
  33. # Posição do número de HITS. X Y
  34. HIT_POSITION = [25,23]
  35. # Posição do número de dano. X Y
  36. TOTAL_POSITION = [78,0]
  37. # Prioridade da HUD
  38. HUD_Z = 1
  39. end
  40.  
  41. #===============================================================================
  42. # ■ Game_Temp
  43. #===============================================================================
  44. class Game_Temp
  45. attr_accessor :combo_hit
  46. attr_accessor :cache_combo_hit
  47.  
  48. #--------------------------------------------------------------------------
  49. # ● initialize
  50. #--------------------------------------------------------------------------
  51. alias mog_combo_display_initialize initialize
  52. def initialize
  53. @combo_hit = [0,0,0] ; cache_cbhit
  54. mog_combo_display_initialize
  55. end
  56.  
  57. #--------------------------------------------------------------------------
  58. # ● Cache Cbhit
  59. #--------------------------------------------------------------------------
  60. def cache_cbhit
  61. @cache_combo_hit = []
  62. @cache_combo_hit.push(Cache.system("Combo_HUD"))
  63. @cache_combo_hit.push(Cache.system("Combo_Damage"))
  64. @cache_combo_hit.push(Cache.system("Combo_Number"))
  65. end
  66.  
  67. end
  68.  
  69. #===============================================================================
  70. # ■ Game_Battler
  71. #===============================================================================
  72. class Game_Battler
  73.  
  74. #--------------------------------------------------------------------------
  75. # ● Item Apply
  76. #--------------------------------------------------------------------------
  77. alias mog_combo_display_item_apply item_apply
  78. def item_apply(user, item)
  79. mog_combo_display_item_apply(user, item)
  80. set_combo_data_d(user, item) if @result.hp_damage > 0
  81. end
  82.  
  83. #--------------------------------------------------------------------------
  84. # ● Set Combo Data D
  85. #--------------------------------------------------------------------------
  86. def set_combo_data_d(user, item)
  87. if user.is_a?(Game_Actor)
  88. $game_temp.combo_hit[0] += 1
  89. $game_temp.combo_hit[1] += @result.hp_damage
  90. $game_temp.combo_hit[2] = MOG_COMBO_COUNT::COMBO_TIME
  91. else
  92. unless self.is_a?(Game_Enemy)
  93. $game_temp.combo_hit[2] = 0 if MOG_COMBO_COUNT::ENEMY_CANCEL_COMBO == true
  94. end
  95. end
  96. end
  97.  
  98. end
  99.  
  100. #===============================================================================
  101. # Spriteset Battle
  102. #===============================================================================
  103. class Spriteset_Battle
  104.  
  105. #--------------------------------------------------------------------------
  106. # ● Initialize
  107. #--------------------------------------------------------------------------
  108. alias mog_combo_initialize initialize
  109. def initialize
  110. create_cb_sprite
  111. mog_combo_initialize
  112. end
  113.  
  114. #--------------------------------------------------------------------------
  115. # ● create_cb_sprite
  116. #--------------------------------------------------------------------------
  117. def create_cb_sprite
  118. @combo_sprite = Combo_Sprite_Hud.new
  119. end
  120.  
  121. #--------------------------------------------------------------------------
  122. # ● Dispose
  123. #--------------------------------------------------------------------------
  124. alias mog_combo_dispose dispose
  125. def dispose
  126. mog_combo_dispose
  127. @combo_sprite.dispose
  128. end
  129.  
  130. #--------------------------------------------------------------------------
  131. # ● update
  132. #--------------------------------------------------------------------------
  133. alias mog_combo_update update
  134. def update
  135. mog_combo_update
  136. update_combo_hit
  137. end
  138.  
  139. #--------------------------------------------------------------------------
  140. # ● Update Combo Hit
  141. #--------------------------------------------------------------------------
  142. def update_combo_hit
  143. @combo_sprite.update
  144. @combo_sprite.combo_wait = (animation? or effect?) ? true : false
  145. end
  146.  
  147. end
  148.  
  149. #===============================================================================
  150. # ■ Combo_Sprite_Hud
  151. #===============================================================================
  152. class Combo_Sprite_Hud
  153. attr_accessor :combo_wait
  154. include MOG_COMBO_COUNT
  155.  
  156. #--------------------------------------------------------------------------
  157. # ● Initialize
  158. #--------------------------------------------------------------------------
  159. def initialize
  160. $game_temp.combo_hit = [0,0,0] ; @combo_wait = false ; @combo_hit_old = 0
  161. @animation_speed = 0 ; @pos_x = COMBO_POSITION[0] ; @pos_x_fix = 0
  162. @pos_y = COMBO_POSITION[1] ; create_hud_sprite ;create_combo_sprite
  163. create_total_damage_sprite
  164. end
  165.  
  166. #--------------------------------------------------------------------------
  167. # ● create_hud_sprite
  168. #--------------------------------------------------------------------------
  169. def create_hud_sprite
  170. @hud = Sprite.new ; @hud.bitmap = $game_temp.cache_combo_hit[0]
  171. @hud.z = HUD_Z ; @hud.x = COMBO_POSITION[0] ; @hud.y = COMBO_POSITION[1]
  172. @hud.opacity = 250 ; @hud.visible = false
  173. end
  174.  
  175. #--------------------------------------------------------------------------
  176. # ● create_total_damage_sprite
  177. #--------------------------------------------------------------------------
  178. def create_total_damage_sprite
  179. @total_image = $game_temp.cache_combo_hit[1] ; @total = Sprite.new
  180. @total.bitmap = Bitmap.new(@total_image.width,@total_image.height)
  181. @total_im_cw = @total_image.width / 10 ; @total_im_ch = @total_image.height
  182. @total.z = HUD_Z + 1 ; @total.visible = false
  183. @total_orig_x = COMBO_POSITION[0] + TOTAL_POSITION[0]
  184. @total_orig_y = COMBO_POSITION[1] + TOTAL_POSITION[1]
  185. @total.x = @total_orig_x ; @total.y = @total_orig_y
  186. @total.zoom_x = 1.00 ; @total.zoom_y = 1.00 ; @total.opacity = 250
  187. end
  188.  
  189. #--------------------------------------------------------------------------
  190. # ● create_combo_number
  191. #--------------------------------------------------------------------------
  192. def create_combo_sprite
  193. @combo_image = $game_temp.cache_combo_hit[2] ; @combo = Sprite.new
  194. @combo.bitmap = Bitmap.new(@combo_image.width,@combo_image.height)
  195. @combo_im_cw = @combo_image.width / 10 ; @combo_im_ch = @combo_image.height
  196. @combo.ox = @combo_im_cw / 2 ; @combo.oy = @combo_im_ch / 2
  197. @combo_orig_x = @combo.ox + COMBO_POSITION[0] + HIT_POSITION[0]
  198. @combo_orig_y = @combo.oy + COMBO_POSITION[1] + HIT_POSITION[1]
  199. @combo.zoom_x = 1.00 ; @combo.zoom_y = 1.00 ; @combo.opacity = 250
  200. @combo.z = HUD_Z + 2 ; @combo.visible = false
  201. end
  202.  
  203. #--------------------------------------------------------------------------
  204. # ● Dispose
  205. #--------------------------------------------------------------------------
  206. def dispose
  207. return if @hud == nil
  208. @hud.dispose ; @hud = nil ; @combo.bitmap.dispose ; @combo.dispose
  209. @total.bitmap.dispose ; @total.dispose
  210. end
  211.  
  212. #--------------------------------------------------------------------------
  213. # ● Refresh
  214. #--------------------------------------------------------------------------
  215. def refresh
  216. @combo_hit_old = $game_temp.combo_hit[0]
  217. @combo.bitmap.clear
  218. @combo_number_text = $game_temp.combo_hit[0].abs.to_s.split(//)
  219. for r in 0..@combo_number_text.size - 1
  220. @combo_number_abs = @combo_number_text[r].to_i
  221. @combo_src_rect = Rect.new(@combo_im_cw * @combo_number_abs, 0, @combo_im_cw, @combo_im_ch)
  222. @combo.bitmap.blt(@combo_im_cw * r, 0, @combo_image, @combo_src_rect)
  223. end
  224. @total.bitmap.clear
  225. @total_number_text = $game_temp.combo_hit[1].abs.to_s.split(//)
  226. for r in 0..@total_number_text.size - 1
  227. @total_number_abs = @total_number_text[r].to_i
  228. @total_src_rect = Rect.new(@total_im_cw * @total_number_abs, 0, @total_im_cw, @total_im_ch)
  229. @total.bitmap.blt(@total_im_cw * r, 0, @total_image, @total_src_rect)
  230. end
  231. #Combo Position
  232. @pos_x_fix = (@combo_im_cw / 2 * @combo_number_text.size)
  233. @combo.x = @combo_orig_x - @pos_x_fix ; @combo.y = @combo_orig_y
  234. @combo.zoom_x = 2 ; @combo.zoom_y = 2 ; @combo.opacity = 70
  235. @combo.visible = true
  236. #Total Position
  237. @total.x = @total_orig_x + 20 ; @total.y = @total_orig_y
  238. @total.opacity = 100 ; @total.visible = true
  239. #Hud Position
  240. @hud.x = COMBO_POSITION[0] ; @hud.y = COMBO_POSITION[1]
  241. @hud.opacity = 255 ; @hud.visible = true
  242. end
  243.  
  244. #--------------------------------------------------------------------------
  245. # ● Slide Update
  246. #--------------------------------------------------------------------------
  247. def slide_update
  248. return if !@combo.visible
  249. if $game_temp.combo_hit[2] > 0 and !@combo_wait
  250. $game_temp.combo_hit[2] -= 1 if TIME_COUNT
  251. end
  252. if $game_temp.combo_hit[2] > 0 and $game_temp.combo_hit[0] > 0
  253. #Total Damage
  254. if @total.x > @total_orig_x ; @total.x -= 1 ; @total.opacity += 8
  255. else ; @total.x = @total_orig_x ; @total.opacity = 255
  256. end
  257. #Combo
  258. if @combo.zoom_x > 1.00
  259. @combo.zoom_x -= 0.05 ; @combo.zoom_y -= 0.05 ; @combo.opacity += 8
  260. else
  261. @combo.zoom_x = 1 ; @combo.zoom_y = 1 ; @combo.opacity = 255
  262. @combo.x = @combo_orig_x - @pos_x_fix ; @combo.y = @combo_orig_y
  263. end
  264. elsif $game_temp.combo_hit[2] == 0 and @combo.visible
  265. @combo.x -= 5 ; @combo.opacity -= 10 ; @total.x -= 3
  266. @total.opacity -= 10 ; @hud.x += 5 ; @hud.opacity -= 10
  267. $game_temp.combo_hit[0] = 0 ; @combo_hit_old = $game_temp.combo_hit[0]
  268. $game_temp.combo_hit[1] = 0
  269. if @combo.opacity <= 0
  270. @combo.visible = false ; @total.visible = false ; @hud.visible = false
  271. end
  272. end
  273. end
  274.  
  275. #--------------------------------------------------------------------------
  276. # ● Cancel
  277. #--------------------------------------------------------------------------
  278. def cancel
  279. $game_temp.combo_hit = [0,0,0] ; @combo_hit_old = 0
  280. end
  281.  
  282. #--------------------------------------------------------------------------
  283. # ● Clear
  284. #--------------------------------------------------------------------------
  285. def clear
  286. $game_temp.combo_hit[2] = 0
  287. end
  288.  
  289. #--------------------------------------------------------------------------
  290. # ● Update
  291. #--------------------------------------------------------------------------
  292. def update
  293. return if @hud == nil
  294. refresh if $game_temp.combo_hit[0] != @combo_hit_old
  295. slide_update
  296. end
  297. end
  298.  
  299. #==============================================================================
  300. # ■ Spriteset Battle
  301. #==============================================================================
  302. class Scene_Battle < Scene_Base
  303.  
  304. #--------------------------------------------------------------------------
  305. # ● Dispose
  306. #--------------------------------------------------------------------------
  307. alias mog_combo_count_pre_terminate pre_terminate
  308. def pre_terminate
  309. $game_temp.combo_hit[2] = 0
  310. mog_combo_count_pre_terminate
  311. end
  312.  
  313. end
RAW Paste Data