Advertisement
Demintika

Total Damage Popup Addon

Jun 12th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.36 KB | None | 0 0
  1. #==============================================================================
  2. # * Version 1.0: Release Script
  3. # * Version 1.1: Fixed Bug
  4. #==============================================================================
  5. module DMTK
  6.   module TOTAL_DAMAGE
  7.     #--------------------------------------------------------------------------
  8.     # *
  9.     #--------------------------------------------------------------------------
  10.     RULES = ["HP_DMG"]
  11.   end
  12. end
  13.  
  14. #==============================================================================
  15. # *
  16. #==============================================================================
  17. $imported = {} if $imported.nil?
  18. unless $imported["YEA-BattleEngine"]
  19.   msgbox("Please place DMTK Total Damage Addon below YEA Battle Engine")
  20.   exit
  21. end
  22. $imported["DMTK-TD-Addon"] = true
  23. #==============================================================================
  24. # *
  25. #==============================================================================
  26. module YEA
  27.   module BATTLE
  28.     #--------------------------------------------------------------------------
  29.     # *
  30.     #--------------------------------------------------------------------------
  31.     #                      [ Zoom1, Zoom2, Sz, Bold, Italic, Red, Grn, Blu, Font]
  32.     POPUP_RULES["TOTAL"] = [   1.0,   2.0, 32, true,  false, 255, 255,   0, DEFAULT]
  33.   end
  34. end
  35.  
  36. #==============================================================================
  37. # *
  38. #==============================================================================
  39. class Sprite_Battler < Sprite_Base
  40.  
  41.   #--------------------------------------------------------------------------
  42.   # *
  43.   #--------------------------------------------------------------------------
  44.   alias dmtk_td_create_new_popup create_new_popup
  45.   def create_new_popup(*array)
  46.     dmtk_td_create_new_popup(*array)
  47.     if DMTK::TOTAL_DAMAGE::RULES.include?(array[1])
  48.       psize = @popups.inject(0) {|r, p|
  49.       r += 1 if DMTK::TOTAL_DAMAGE::RULES.include?(p.rules)
  50.       r}
  51.       if psize == 1
  52.         @total_damage = array[0].to_i
  53.         @total_popup = nil
  54.       else
  55.         return if array[0].to_i.nil?
  56.         @total_damage += array[0].to_i
  57.         if @total_popup && !@total_popup.disposed?
  58.           @total_popup.value = @total_damage.to_s
  59.           @popups[-1].y -= 24
  60.         else
  61.           create_new_popup(@total_damage.to_s, "TOTAL", [])
  62.         end
  63.       end
  64.     elsif array[1] == "TOTAL"
  65.       @total_popup = @popups[-1]
  66.     end
  67.   end
  68. end
  69.  
  70. #==============================================================================
  71. # *
  72. #==============================================================================
  73. class Sprite_Popup < Sprite_Base
  74.  
  75.   #--------------------------------------------------------------------------
  76.   # *
  77.   #--------------------------------------------------------------------------
  78.   attr_reader :rules
  79.  
  80.   #--------------------------------------------------------------------------
  81.   # *
  82.   #--------------------------------------------------------------------------
  83.   def value=(new_value)
  84.     if @value != new_value
  85.       @value = new_value
  86.       refresh_popup_bitmap
  87.     end
  88.   end
  89.  
  90.   #--------------------------------------------------------------------------
  91.   # *
  92.   #--------------------------------------------------------------------------
  93.   def refresh_popup_bitmap
  94.     return create_popup_bitmap if self.bitmap.disposed?
  95.     rules_array = YEA::BATTLE::POPUP_RULES[@rules]
  96.     bw = Graphics.width
  97.     bh = self.bitmap.height
  98.     self.bitmap.clear
  99.     self.bitmap.font.color.set(rules_array[5], rules_array[6], rules_array[7])
  100.     self.bitmap.draw_text(0, 0, bw, bh, @value, 1)
  101.     #------------------------------------------------------------------------
  102.     self.x = @battler.screen_x
  103.     self.x += rand(4) - rand(4) if @battler.sprite.popups.size >= 1
  104.     self.x -= SceneManager.scene.spriteset.viewport1.ox
  105.     self.y = @battler.screen_y - @battler.sprite.oy/2
  106.     self.y -= @battler.sprite.oy/2 if @battler.actor?
  107.     self.y -= SceneManager.scene.spriteset.viewport1.oy
  108.     self.ox = bw/2; self.oy = bh/2
  109.     self.zoom_x = self.zoom_y = rules_array[0]
  110.     @target_zoom = rules_array[1]
  111.     self.z = 501
  112.   end
  113.  
  114. end
  115.  
  116. #==============================================================================
  117. # *
  118. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement