Okay so this is going off my previous thread with the Rhyme animated battlers (based on holders format), which I got working with my own custom edits/formatting. However since all poses loop, it does not seem to have a "no-loop" function, and I need the dead-pose (@epose = 2) to not loop. (or a way to set '@battler_visible = false' after the dead-pose (@epose = 2) happens once)
Actually i'm not sure if this belongs on this section, or the support section, since it is a modify request after all.
Actually i'm not sure if this belongs on this section, or the support section, since it is a modify request after all.
Code:
#==============================================================================# ■ Animated Enemy Sprites# Merry Christmas and happy holidays!#==============================================================================# Notebox Tag:# Enemy: !Flip#==============================================================================# Spritesheet Data for referencing## 0. Idle# 1. Action# 2. Dead# 3. Damaged#-------------------------------# 4. Attack# 5. Item# 6. Skill# 7. Magic# 8. Advance (n/a)# 9. Retreat (n/a)# 10. Victory (n/a)# 11. Enter# 12. Dead# 13. Credits and/or etc (n/a)#==============================================================================# ~rhyme#==============================================================================module Animated_Enemy_Sprites Delay = 8 FrameSize = [7, 4] DefaultBlink = falseend#==============================================================================# ■ Game_Battler#==============================================================================class Game_Battler < Game_BattlerBase attr_accessor :epose #-------------------------------------------------------------------------- # ● Flip #-------------------------------------------------------------------------- def flip_sprite return false end #-------------------------------------------------------------------------- # ● Reset Pose #-------------------------------------------------------------------------- def reset_pose @epose = 0 #@pose = 2 if @hp < mhp / 4 #if @states != nil # @pose = 2 if @states.size > 0 #end #@epose = 1 if guard? @epose = 2 if dead? end #-------------------------------------------------------------------------- # ● Use Item #-------------------------------------------------------------------------- alias use_item_ani use_item def use_item(item) if item.is_a?(RPG::Item) @epose = 1 else if item.is_a?(RPG::Skill) if item.id == attack_skill_id @pose = 1 elsif item.physical? @pose = 1 elsif item.magical? @pose = 1 end end end use_item_ani(item) end #-------------------------------------------------------------------------- # ● Perform Damage #-------------------------------------------------------------------------- alias perform_map_damage_effect_ani perform_map_damage_effect def perform_map_damage_effect perform_map_damage_effect_ani @epose = 3 unless @guarding end #-------------------------------------------------------------------------- # ● Upon Damage #-------------------------------------------------------------------------- alias on_damage_ani on_damage def on_damage(value) @epose = 3 unless @guarding on_damage_ani(value) endend#==============================================================================# ■ Game_Enemy#==============================================================================class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● Flip #-------------------------------------------------------------------------- def flip_sprite return true if Scan::string($data_enemies[@enemy_id].note, "!Flip") return super endend#==============================================================================# ■ Sprite_Battler#==============================================================================class Sprite_Battler < Sprite_Base attr_accessor :battler #-------------------------------------------------------------------------- # ● Initialize #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @effect_type = nil @effect_duration = 0 @spritesheet = true @epose = 0 @counter = 0 @delay = Animated_Enemy_Sprites::Delay @frame_size = Animated_Enemy_Sprites::FrameSize end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if @battler @battler.reset_pose if @battler.epose == nil self.mirror = @battler.flip_sprite @use_sprite = @battler.use_sprite? if @spritesheet update_pose if @epose != 11 end if Graphics.frame_count % @delay == 0 @counter += 1 if @counter >= @frame_size[0] @counter = 0 if @epose == 11 update_pose else @battler.reset_pose end end end if @use_sprite update_bitmap update_origin update_position end setup_new_effect setup_new_animation update_effect else @effect_type = nil end self.opacity = 255 self.visible = true end #-------------------------------------------------------------------------- # ● Update bitmap #-------------------------------------------------------------------------- def update_bitmap if @spritesheet @spritesheet_bitmap = Cache.battler(@battler.battler_name + " Sheet", @battler.battler_hue) ss_size = [@spritesheet_bitmap.width, @spritesheet_bitmap.height] new_bitmap = Bitmap.new(ss_size[0] / @frame_size[0], ss_size[1] / @frame_size[1]) cx = @counter * (ss_size[0] / @frame_size[0]) cby = @epose * (ss_size[1] / @frame_size[1]) crop_rect = Rect.new(cx, cby, ss_size[0], ss_size[1]) new_bitmap.blt(0, 0, @spritesheet_bitmap, crop_rect) else new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue) end if bitmap != new_bitmap self.bitmap = new_bitmap init_visibility end end #-------------------------------------------------------------------------- # ● Update Pose #-------------------------------------------------------------------------- def update_pose oldpose = @epose newpose = @battler.epose if newpose != oldpose @counter = 0 @epose = newpose end end #-------------------------------------------------------------------------- # ● Blink #-------------------------------------------------------------------------- def update_blink self.opacity = (@effect_duration % 10 < 5) ? 255 : 0 if Animated_Enemy_Sprites::DefaultBlink endend#============================================================================# ▼ Scan#============================================================================module Scan #-------------------------------------------------------------------------- # ● Scan.string(object, string) #-------------------------------------------------------------------------- def self.string(object, string) if object[/#{Regexp.quote string}/] return true end return false endend