Advertisement
Trihan

HorrorVale - Boss Animation

Jul 17th, 2023
1,766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.35 KB | Source Code | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Don't remove this header!
  3. #-------------------------------------------------------------------------------
  4. # Enemy Animation Extension Script
  5. # by Trihan
  6. #
  7. # Version : 1.1
  8. #
  9. # This script is commissioned by Batworks Software.
  10. #-------------------------------------------------------------------------------
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Version History
  14. #-------------------------------------------------------------------------------
  15. # 1.1 - Added <framename> and <anim_interval> notetags
  16. # 1.0 - Initial script.
  17. #-------------------------------------------------------------------------------
  18.  
  19. #-------------------------------------------------------------------------------
  20. # To use a custom enemy animation, set the notetag to <motion standby = 3>.
  21. #
  22. # The script automatically sets up frames based on the original battler name,
  23. # which will not need to be changed. For example, if your battler is
  24. # "bigfootbattle" you can define an image as part of that animation simply by
  25. # calling it "bigfootbattle1" where 1 is any number. The numbers do not have
  26. # to be sequential, but frames will be added in folder order.
  27. #
  28. # You can also use the notetag <framename:x> to use x as the base battler
  29. # name instead.
  30. #
  31. # Set the Anim_Interval constant to the number of frames between cel changes.
  32. #
  33. # You can also use the notetag <anim_interval:x> on the enemy to set the
  34. # interval on a per-enemy basis.
  35. #
  36. # Note that for enemy transforms, you don't need the motion standby tag for
  37. # later forms; it'll take the motion type from the original enemy.
  38. #-------------------------------------------------------------------------------
  39. module TLBAnimExt
  40. #-------------------------------------------------------------------------------
  41. #  Config
  42.  
  43.    Anim_Interval = 15
  44.    
  45.    Frame_Pattern = /<framename: ?(\w+)>/i
  46.    Interval_Pattern = /<anim_interval: ?(\d+)/i
  47.  
  48. #  ** End Config **
  49. #
  50. # WARNING: Editing anything beyond this point may result in the script no
  51. # longer functioning as intended.
  52. #-------------------------------------------------------------------------------
  53. end
  54.  
  55. class Game_Enemy < Game_Battler
  56.   attr_accessor :current_cel
  57.   attr_accessor :anim_interval
  58.   attr_accessor :frame_count
  59.   attr_accessor :arr_battlers
  60.  
  61.   alias :tlb_animext_game_enemy_initialize :initialize
  62.   def initialize(index, enemy_id)
  63.     tlb_animext_game_enemy_initialize(index, enemy_id)
  64.     @current_cel = nil
  65.     @frame_count = nil
  66.     @arr_battlers = []
  67.     setup_animation
  68.   end
  69.  
  70.   def setup_animation
  71.     if @motion_stand[0] == 3
  72.       @arr_battlers = []
  73.       @current_cel = 0
  74.       if self.note =~ TLBAnimExt::Interval_Pattern
  75.         @anim_interval = $1.to_i
  76.       else
  77.         @anim_interval = TLBAnimExt::Anim_Interval
  78.       end
  79.       if self.note =~ TLBAnimExt::Frame_Pattern
  80.         battler = $1
  81.       else
  82.         battler = @battler_name
  83.       end
  84.       @frame_count = @anim_interval
  85.       regexpattern = /#{battler}\d+/
  86.       files = Dir.entries("Graphics/Battlers")
  87.       .select { |file| file =~ regexpattern }
  88.       files.each { |file|
  89.         @arr_battlers.push(file)
  90.       }
  91.       @battler_name = @arr_battlers[0] if @arr_battlers.size > 0
  92.     end
  93.   end
  94.  
  95.   def set_battler(battler_name)
  96.     @battler_name = battler_name
  97.   end
  98.  
  99.   alias :tlb_animext_game_enemy_transform :transform
  100.   def transform(enemy_id)
  101.     tlb_animext_game_enemy_transform(enemy_id)
  102.     setup_animation
  103.   end
  104. end
  105.  
  106. class Sprite_Battler < Sprite_Base
  107.   def execute_motion_idle
  108.     case @battler.motion_stand[0]
  109.       when 0
  110.         update_motion_breath
  111.       when 1  
  112.         update_motion_float
  113.       when 2
  114.         update_motion_side
  115.       when 3
  116.         update_motion_anim
  117.     end        
  118.   end
  119.  
  120.   def update_motion_anim
  121.     @battler.frame_count -= 1
  122.     return if @battler.frame_count > 0
  123.     @battler.frame_count = @battler.anim_interval
  124.     @battler.current_cel += 1
  125.     @battler.current_cel = 0 if @battler.current_cel >= @battler.arr_battlers.size
  126.   end
  127.  
  128.   alias :tlb_animext_sprite_battler_update_bitmap :update_bitmap
  129.   def update_bitmap
  130.     tlb_animext_sprite_battler_update_bitmap
  131.     @battler.set_battler(@battler.arr_battlers[@battler.current_cel]) if @battler.arr_battlers.size > 0
  132.   end
  133. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement