Advertisement
LiTTleDRAgo

[RGSS] Blizz-ABS Animated Combo Hud

Oct 21st, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.84 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Blizz ABS Animated Combo Hud
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. #==============================================================================#
  7. #
  8. # Explanation :
  9. # Displays the amount of hits and total damage caused to an enemy.      
  10. #                                                                            
  11. # Graphics required:                                                        
  12. #                                                                            
  13. # Combo_Damage                                                              
  14. # Combo_Hud                                                                  
  15. # Combo_Number                                                              
  16. #                                                                          
  17. # All images must be in the Windowskin folder.                              
  18. #                                                                            
  19. # Special Thanks :
  20. # Moghunter for XAS Combo Hit
  21. #
  22. #==============================================================================#
  23.  
  24. module LiTTleDRAgo
  25.  
  26.   BLIZZ_ABS_COMBO_TIME = 1   # Time displayed on-screen
  27.   BLIZZ_ABS_COMBO_X = 450    # Position of the Combo HUD
  28.   BLIZZ_ABS_COMBO_Y = 30
  29.  
  30. end
  31.  
  32. #===============================================================================
  33. # Map_Battler
  34. #===============================================================================
  35. class Map_Battler < Game_Character
  36.   if BlizzABS::VERSION >= 2.7
  37.   #--------------------------------------------------------------------------
  38.   # Action Effect
  39.   #--------------------------------------------------------------------------
  40.    alias action_effect_earlier action_effect
  41.    def action_effect(object)
  42.       action_effect_earlier(object)
  43.       combo_displayer
  44.     end
  45.   #--------------------------------------------------------------------------
  46.   # Combo Displayer
  47.   #--------------------------------------------------------------------------
  48.     def combo_displayer
  49.       if self.damage_done?
  50.         if @battler.is_a?(Game_Actor)
  51.           $game_temp.xvtr_max_damage = 0
  52.           $game_temp.xvtrcombo = 0
  53.         else
  54.           $game_temp.xvtr_max_damage += @battler.hpdamage.to_i.abs
  55.           $game_temp.xvtrcombo += 1
  56.           $game_temp.xvtrcombotime = 3
  57.           $game_temp.xvtrcombotime2 = 40 * LiTTleDRAgo::BLIZZ_ABS_COMBO_TIME
  58.         end
  59.       end
  60.     end
  61.   end
  62. end
  63. #===============================================================================
  64. # Combo_Hud
  65. #===============================================================================
  66. class Combo_Hud < Sprite
  67. #--------------------------------------------------------------------------
  68. # Initialize
  69. #--------------------------------------------------------------------------
  70.   def initialize
  71.     @viewport = Viewport.new(0, 0, 640, 480)
  72.     @viewport.z = 9999  
  73.     super(@viewport)
  74.     @combo_hit = $game_temp.xvtrcombo
  75.     @combo, @total, @hud = Sprite.new, Sprite.new, Sprite.new
  76.     @combo_image = RPG::Cache.windowskin("Combo_Number")
  77.     @total_image = RPG::Cache.windowskin("Combo_damage")
  78.     @hud.bitmap = RPG::Cache.windowskin("Combo_HUD")
  79.     @combo_bitmap = Bitmap.new(@combo_image.width,@combo_image.height)
  80.     @total_bitmap = Bitmap.new(@combo_image.width,@combo_image.height)
  81.     @combo.bitmap = @combo_bitmap
  82.     @total.bitmap = @total_bitmap
  83.     @combo_im_cw = @combo_image.width / 10
  84.     @combo_im_ch = @combo_image.height  
  85.     @total_im_cw = @total_image.width / 10
  86.     @total_im_ch = @total_image.height  
  87.     @combo_number_text = @combo_hit.abs.to_s.split(//)
  88.     @total_number_text = $game_temp.xvtr_max_damage.abs.to_s.split(//)
  89.     for r in 0..@combo_number_text.size - 1
  90.       @combo_number_abs = @combo_number_text[r].to_i
  91.       @combo_src_rect = Rect.new (@combo_im_cw *
  92.       @combo_number_abs, 0, @combo_im_cw, @combo_im_ch)
  93.       @combo_bitmap.blt(40 + ((@combo_im_cw - 12) *  r),
  94.       0, @combo_image, @combo_src_rect)    
  95.     end  
  96.     for r in 0..@total_number_text.size - 1
  97.       @total_number_abs = @total_number_text[r].to_i
  98.       @total_src_rect = Rect.new(@total_im_cw *
  99.       @total_number_abs, 0, @total_im_cw, @total_im_ch)
  100.       @total_bitmap.blt(40 + ((@total_im_cw - 12) *  r),
  101.       0, @total_image, @total_src_rect)    
  102.     end
  103.     @combo.z, @total.z, @hud.z = 5009, 5009, 5008
  104.     @combo.ox = $game_temp.xvtrhitwin_x
  105.     @combo.oy = $game_temp.xvtrhitwin_y
  106.     @total.ox = $game_temp.xvtrdamwin_x
  107.     @total.oy = $game_temp.xvtrdamwin_y
  108.     @hud.ox = $game_temp.xvtrhudwin_x
  109.     @hud.oy = $game_temp.xvtrhudwin_y
  110.     @combo.zoom_x = $game_temp.xvtrhitwin_zoom_x
  111.     @combo.zoom_y = $game_temp.xvtrhitwin_zoom_y
  112.     @total.zoom_x = $game_temp.xvtrdamwin_zoom_x
  113.     @total.zoom_y = $game_temp.xvtrdamwin_zoom_y
  114.     @combo.opacity = $game_temp.xvtrhitwin_opa
  115.     @total.opacity = $game_temp.xvtrdamwin_opa
  116.     @hud.opacity = $game_temp.xvtrhudwin_opa
  117.  
  118.     @combo.x = LiTTleDRAgo::BLIZZ_ABS_COMBO_X
  119.     @combo.y = LiTTleDRAgo::BLIZZ_ABS_COMBO_Y
  120.     @total.x = LiTTleDRAgo::BLIZZ_ABS_COMBO_X
  121.     @total.y = LiTTleDRAgo::BLIZZ_ABS_COMBO_Y
  122.     @hud.x   = LiTTleDRAgo::BLIZZ_ABS_COMBO_X
  123.     @hud.y   = LiTTleDRAgo::BLIZZ_ABS_COMBO_Y
  124.  
  125.     if @combo_hit <= 0
  126.       @combo.opacity = 0
  127.       @combo.visible = @hud.visible = @total.visible = false
  128.     else
  129.       @combo.visible = @hud.visible = @total.visible = true
  130.     end
  131.    end  
  132.  
  133. #--------------------------------------------------------------------------
  134. # Dispose
  135. #--------------------------------------------------------------------------
  136.   def dispose
  137.     [@combo_bitmap, @combo.bitmap, @combo, @hud.bitmap, @hud, @total_bitmap,
  138.     @total, @viewport].each {|s| s.dispose if s != nil}
  139.     [@combo_bitmap, @combo.bitmap, @combo, @hud.bitmap, @hud, @total_bitmap,
  140.     @total, @viewport].each {|s| s = nil if s != nil}
  141.   end
  142.  
  143. #--------------------------------------------------------------------------
  144. # Refresh
  145. #--------------------------------------------------------------------------
  146.    def refresh
  147.      @combo_hit = $game_temp.xvtrcombo
  148.      combo_strike_valor = 0.1 *@combo_hit / 10
  149.      $game_temp.xvtrhitwin_zoom_x = 2;   $game_temp.xvtrhitwin_zoom_y = 2
  150.      $game_temp.xvtrhitwin_opa = 70;     $game_temp.xvtrhitwin_x = 15
  151.      $game_temp.xvtrhitwin_y = -10  ;    $game_temp.xvtrhudwin_x = 0
  152.      $game_temp.xvtrhudwin_y = -100;     $game_temp.xvtrhudwin_opa = 255
  153.      $game_temp.xvtrdamwin_zoom_x = 1;   $game_temp.xvtrdamwin_zoom_y = 1
  154.      $game_temp.xvtrdamwin_opa = 100;    $game_temp.xvtrdamwin_x = -85
  155.      $game_temp.xvtrdamwin_y = -80;      @combo.bitmap.clear  
  156.      @combo_number_text = @combo_hit.abs.to_s.split(//)
  157.      for r in 0..@combo_number_text.size - 1
  158.        @combo_number_abs = @combo_number_text[r].to_i
  159.        @combo_src_rect = Rect.new(@combo_im_cw *
  160.        @combo_number_abs, 0, @combo_im_cw, @combo_im_ch)
  161.        @combo_bitmap.blt(40 + ((@combo_im_cw - 12) *  r),
  162.        0, @combo_image, @combo_src_rect)  
  163.      end      
  164.      @total.bitmap.clear
  165.      @total_number_text = $game_temp.xvtr_max_damage.abs.to_s.split(//)
  166.      for r in 0..@total_number_text.size - 1
  167.        @total_number_abs = @total_number_text[r].to_i
  168.        @total_src_rect = Rect.new(@total_im_cw *
  169.        @total_number_abs, 0, @total_im_cw, @total_im_ch)
  170.        @total_bitmap.blt(40 + ((@total_im_cw - 12) *  r),
  171.        20, @total_image, @total_src_rect)  
  172.      end        
  173.      hud_pos_update
  174.      @combo.visible = @hud.visible = @total.visible = true  
  175.   end
  176.    
  177. #--------------------------------------------------------------------------
  178. # Hud Pos Update
  179. #--------------------------------------------------------------------------
  180.   def hud_pos_update  
  181.      @combo.ox = $game_temp.xvtrhitwin_x
  182.      @combo.oy = $game_temp.xvtrhitwin_y
  183.      @combo.zoom_x = $game_temp.xvtrhitwin_zoom_x
  184.      @combo.zoom_y = $game_temp.xvtrhitwin_zoom_y
  185.      @combo.opacity = $game_temp.xvtrhitwin_opa
  186.      @hud.ox = $game_temp.xvtrhudwin_x
  187.      @hud.oy = $game_temp.xvtrhudwin_y
  188.      @hud.opacity = $game_temp.xvtrhudwin_opa
  189.      @total.ox = $game_temp.xvtrdamwin_x
  190.      @total.oy = $game_temp.xvtrdamwin_y
  191.      @total.zoom_x = $game_temp.xvtrdamwin_zoom_x
  192.      @total.zoom_y = $game_temp.xvtrdamwin_zoom_y
  193.      @total.opacity = $game_temp.xvtrdamwin_opa
  194.   end
  195.  
  196. #--------------------------------------------------------------------------
  197. # Slide Update
  198. #--------------------------------------------------------------------------
  199.   def slide_update
  200.     if $game_temp.xvtrcombotime > 0 && $game_temp.xvtrcombo > 0  
  201.       if $game_temp.xvtrdamwin_x < -65
  202.         $game_temp.xvtrdamwin_x += 1;  $game_temp.xvtrdamwin_opa += 8  
  203.       elsif $game_temp.xvtrdamwin_x <= -65
  204.         $game_temp.xvtrdamwin_x, $game_temp.xvtrdamwin_opa = -65, 255
  205.       end      
  206.       if $game_temp.xvtrcombotime > 0.1
  207.         $game_temp.xvtrhitwin_zoom_x -= 0.05;$game_temp.xvtrhitwin_zoom_y -= 0.05    
  208.         $game_temp.xvtrhitwin_opa += 8
  209.       elsif $game_temp.xvtrcombotime <= 0.1 && $game_temp.xvtrcombo > 0
  210.         $game_temp.xvtrhitwin_zoom_x = $game_temp.xvtrhitwin_zoom_y = 1
  211.         $game_temp.xvtrhitwin_opa = 255;  $game_temp.xvtrhitwin_x = 10
  212.         $game_temp.xvtrhitwin_y = -115
  213.       end    
  214.       $game_temp.xvtrhitwin_x -= 5 if $game_temp.xvtrhitwin_x > 25
  215.       $game_temp.xvtrhitwin_y -= 5 if $game_temp.xvtrhitwin_y > -105
  216.     elsif @combo.visible == true &&  $game_temp.xvtrcombotime2 < 80
  217.       $game_temp.xvtrhitwin_x -= 5;   $game_temp.xvtrhitwin_opa -= 10
  218.       $game_temp.xvtrdamwin_x -= 3;   $game_temp.xvtrdamwin_opa -= 10
  219.       $game_temp.xvtrhudwin_x += 5;   $game_temp.xvtrhudwin_opa -= 10  
  220.       $game_temp.xvtrcombo = $game_temp.xvtr_max_damage = 0
  221.       @combo_hit = $game_temp.xvtrcombo
  222.     end  
  223.   end
  224.  
  225. #--------------------------------------------------------------------------
  226. # Update
  227. #--------------------------------------------------------------------------
  228.   def update
  229.    @combo.visible = @hud.visible = @total.visible = false if @combo.opacity <= 0  
  230.    hud_pos_update; @combo_hit = $game_temp.xvtrcombo if $game_temp.xvtrcombo == 0
  231.    slide_update; refresh if @combo_hit != $game_temp.xvtrcombo && $game_temp.xvtrcombo != 0  
  232.   end  
  233. end
  234.  
  235. #===============================================================================
  236. # Scene_Map
  237. #===============================================================================
  238. class Scene_Map
  239.  
  240. #--------------------------------------------------------------------------
  241. # Main
  242. #--------------------------------------------------------------------------
  243.   alias xvtrcombo_main main
  244.   def main
  245.     @combosprite_hud = Combo_Hud.new
  246.     xvtrcombo_main
  247.     @combosprite_hud.dispose
  248.     @combosprite_hud = nil
  249.   end
  250.  
  251. #--------------------------------------------------------------------------
  252. # Update
  253. #--------------------------------------------------------------------------
  254.   alias xvtrcombo_update update
  255.   def update
  256.     xvtrcombo_update  
  257.     $game_temp.xvtrcombotime -= 0.15
  258.     $game_temp.xvtrcombotime2 -= 1
  259.     @combosprite_hud.update
  260.   end
  261. end
  262.  
  263. #==============================================================================
  264. # Game_Temp
  265. #==============================================================================
  266. class Game_Temp
  267.     attr_accessor :xvtrcombo  
  268.     attr_accessor :xvtrcombotime
  269.     attr_accessor :xvtrcombotime2
  270.     attr_accessor :xvtrcombowin_x
  271.     attr_accessor :xvtrcombowin_y
  272.     attr_accessor :xvtrcomboopa
  273.     attr_accessor :xvtr_hit
  274.     attr_accessor :xvtr_max_damage
  275.     attr_accessor :xvtrhitwin_x
  276.     attr_accessor :xvtrhitwin_y
  277.     attr_accessor :xvtrhitwin_opa
  278.     attr_accessor :xvtrhitwin_zoom_x
  279.     attr_accessor :xvtrhitwin_zoom_y
  280.     attr_accessor :xvtrdamwin_x
  281.     attr_accessor :xvtrdamwin_y
  282.     attr_accessor :xvtrdamwin_opa
  283.     attr_accessor :xvtrdamwin_zoom_x
  284.     attr_accessor :xvtrdamwin_zoom_y
  285.     attr_accessor :xvtrhudwin_x
  286.     attr_accessor :xvtrhudwin_y
  287.     attr_accessor :xvtrhudwin_opa  
  288.  
  289. #--------------------------------------------------------------------------
  290. # Initialize
  291. #--------------------------------------------------------------------------
  292.   alias drago_xvtrcombo_initialize initialize
  293.   def initialize
  294.     drago_xvtrcombo_initialize
  295.     @xvtrcombo = @xvtrcombotime = @xvtrcombotime2 = 0
  296.     @xvtrcombowin_x = -200;    @xvtrhudwin_x = 0
  297.     @xvtrcombowin_y = 0;       @xvtrhudwin_y = 0
  298.     @xvtrhitwin_x = 0;         @xvtrdamwin_x = 0
  299.     @xvtrhitwin_y = 0;         @xvtrdamwin_y = 0
  300.     @xvtrcomboopa = @xvtr_hit = @xvtr_max_damage =  0
  301.     @xvtrhitwin_zoom_x = @xvtrdamwin_zoom_x = 1
  302.     @xvtrhitwin_zoom_y = @xvtrdamwin_zoom_y = 1
  303.     @xvtrhitwin_opa = @xvtrhudwin_opa = @xvtrdamwin_opa = 0
  304.   end
  305. end
  306.  
  307. $drago_xvtr_animated_combo_hit = true
  308.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement