Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Don't remove this header!
- #-------------------------------------------------------------------------------
- # Enemy Animation Extension Script
- # by Trihan
- #
- # Version : 1.1
- #
- # This script is commissioned by Batworks Software.
- #-------------------------------------------------------------------------------
- #-------------------------------------------------------------------------------
- # Version History
- #-------------------------------------------------------------------------------
- # 1.1 - Added <framename> and <anim_interval> notetags
- # 1.0 - Initial script.
- #-------------------------------------------------------------------------------
- #-------------------------------------------------------------------------------
- # To use a custom enemy animation, set the notetag to <motion standby = 3>.
- #
- # The script automatically sets up frames based on the original battler name,
- # which will not need to be changed. For example, if your battler is
- # "bigfootbattle" you can define an image as part of that animation simply by
- # calling it "bigfootbattle1" where 1 is any number. The numbers do not have
- # to be sequential, but frames will be added in folder order.
- #
- # You can also use the notetag <framename:x> to use x as the base battler
- # name instead.
- #
- # Set the Anim_Interval constant to the number of frames between cel changes.
- #
- # You can also use the notetag <anim_interval:x> on the enemy to set the
- # interval on a per-enemy basis.
- #
- # Note that for enemy transforms, you don't need the motion standby tag for
- # later forms; it'll take the motion type from the original enemy.
- #-------------------------------------------------------------------------------
- module TLBAnimExt
- #-------------------------------------------------------------------------------
- # Config
- Anim_Interval = 15
- Frame_Pattern = /<framename: ?(\w+)>/i
- Interval_Pattern = /<anim_interval: ?(\d+)/i
- # ** End Config **
- #
- # WARNING: Editing anything beyond this point may result in the script no
- # longer functioning as intended.
- #-------------------------------------------------------------------------------
- end
- class Game_Enemy < Game_Battler
- attr_accessor :current_cel
- attr_accessor :anim_interval
- attr_accessor :frame_count
- attr_accessor :arr_battlers
- alias :tlb_animext_game_enemy_initialize :initialize
- def initialize(index, enemy_id)
- tlb_animext_game_enemy_initialize(index, enemy_id)
- @current_cel = nil
- @frame_count = nil
- @arr_battlers = []
- setup_animation
- end
- def setup_animation
- if @motion_stand[0] == 3
- @arr_battlers = []
- @current_cel = 0
- if self.note =~ TLBAnimExt::Interval_Pattern
- @anim_interval = $1.to_i
- else
- @anim_interval = TLBAnimExt::Anim_Interval
- end
- if self.note =~ TLBAnimExt::Frame_Pattern
- battler = $1
- else
- battler = @battler_name
- end
- @frame_count = @anim_interval
- regexpattern = /#{battler}\d+/
- files = Dir.entries("Graphics/Battlers")
- .select { |file| file =~ regexpattern }
- files.each { |file|
- @arr_battlers.push(file)
- }
- @battler_name = @arr_battlers[0] if @arr_battlers.size > 0
- end
- end
- def set_battler(battler_name)
- @battler_name = battler_name
- end
- alias :tlb_animext_game_enemy_transform :transform
- def transform(enemy_id)
- tlb_animext_game_enemy_transform(enemy_id)
- setup_animation
- end
- end
- class Sprite_Battler < Sprite_Base
- def execute_motion_idle
- case @battler.motion_stand[0]
- when 0
- update_motion_breath
- when 1
- update_motion_float
- when 2
- update_motion_side
- when 3
- update_motion_anim
- end
- end
- def update_motion_anim
- @battler.frame_count -= 1
- return if @battler.frame_count > 0
- @battler.frame_count = @battler.anim_interval
- @battler.current_cel += 1
- @battler.current_cel = 0 if @battler.current_cel >= @battler.arr_battlers.size
- end
- alias :tlb_animext_sprite_battler_update_bitmap :update_bitmap
- def update_bitmap
- tlb_animext_sprite_battler_update_bitmap
- @battler.set_battler(@battler.arr_battlers[@battler.current_cel]) if @battler.arr_battlers.size > 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement