SSTrihan

HorrorVale enemy animation extended

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