Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  2. #
  3. #  ★ Animate State for RGSS3 Ver1.00
  4. #      Display state icons based on order.
  5. #  Source: neomemo URL http://neomemo.web.fc2.com/top.html
  6. #
  7. #  【Notice】
  8. #  If the script doesn't work, don't contact the author.
  9. #
  10. #★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  11.  
  12. module StateAnime
  13.   # Icon number: represent by horizontal (0 to 16) + vertical (after 0) x 16
  14.   # ▼ Setting
  15.   NOR = 0             # Icon number when the state is normal
  16.   SPE = 50            # Animation speed (1 sec = 60)
  17. end
  18.  
  19. #==============================================================================
  20. # ■ StateIcons
  21. #==============================================================================
  22.  
  23. class StateIcons
  24.   #--------------------------------------------------------------------------
  25.   # ● Instance variables
  26.   #--------------------------------------------------------------------------
  27.   attr_reader   :x                        # X coordinate
  28.   attr_reader   :y                        # Y coordinate
  29.   attr_reader   :bitmap                   # Bitmap (back of icon)
  30.   #--------------------------------------------------------------------------
  31.   # ● Object initialization
  32.   #--------------------------------------------------------------------------
  33.   def initialize(icons, x, y, bitmap)
  34.     @icons  = icons
  35.     @x , @y = x , y
  36.     @bitmap = bitmap
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● Icon
  40.   #     index : Number of display
  41.   #--------------------------------------------------------------------------
  42.   def icon(index)
  43.     return @icons[index % @icons.size]
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● Dispose
  47.   #--------------------------------------------------------------------------
  48.   def dispose
  49.     @bitmap.dispose
  50.   end
  51. end
  52.  
  53. #==============================================================================
  54. # ■ Window_Base
  55. #==============================================================================
  56.  
  57. class Window_Base
  58.   #--------------------------------------------------------------------------
  59.   # ● Object initialization
  60.   #--------------------------------------------------------------------------
  61.   alias :stateanime_initialize :initialize
  62.   def initialize(x, y, width, height)
  63.     stateanime_initialize(x, y, width, height)
  64.     @stateanime_new   = true
  65.     @stateanime_set   = []
  66.     @stateanime_count = 0
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● State animation remove
  70.   #--------------------------------------------------------------------------
  71.   alias :stateanime_dispose :dispose
  72.   def dispose
  73.     stateanime_dispose
  74.     for state in @stateanime_set do state.dispose end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● Clear state animation
  78.   #--------------------------------------------------------------------------
  79.   def clear_stateanime
  80.     for state in @stateanime_set do state.dispose end
  81.     @stateanime_new   = false
  82.     @stateanime_set   = []
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● State animation drawing
  86.   #     obj: State icon class to draw
  87.   #--------------------------------------------------------------------------
  88.   def draw_stateanime(obj)
  89.     self.contents.clear_rect(obj.x, obj.y, 24, 24)
  90.     self.contents.blt(obj.x, obj.y, obj.bitmap, Rect.new(0, 0, 24, 24))
  91.     draw_icon(obj.icon(@stateanime_count / StateAnime::SPE), obj.x, obj.y)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● Update frame
  95.   #--------------------------------------------------------------------------
  96.   alias :stateanime_update :update
  97.   def update
  98.     stateanime_update
  99.     unless @stateanime_set.empty?
  100.       @stateanime_count += 1
  101.       if @stateanime_count % StateAnime::SPE == 0
  102.         @stateanime_new = true unless @stateanime_new
  103.         for obj in @stateanime_set do draw_stateanime(obj) end
  104.       end
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ☆ Draw state
  109.   #--------------------------------------------------------------------------
  110.   def draw_actor_icons(actor, x, y, dummy_width = 24)
  111.     clear_stateanime if @stateanime_new
  112.     icons = []
  113.     icons += actor.state_icons
  114.     icons += actor.buff_icons
  115.     icons.push(StateAnime::NOR) if icons.empty?
  116.     icons.uniq!
  117.     src_rect = Rect.new(x, y, 24, 24)
  118.     bitmap   = Bitmap.new(24, 24)
  119.     bitmap.blt(0, 0, self.contents, src_rect)
  120.     obj = StateIcons.new(icons, x, y, bitmap)
  121.     @stateanime_set.push(obj)
  122.     draw_stateanime(obj)
  123.   end
  124. end