Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LM² - Anim Overhaul + Idle Anim
- # Créditos:
- # - Victor Sant por criar vários dos métodos usados de base
- # Visitem o site dele https://victorenginescripts.wordpress.com/
- # - LeonM² por criar/adaptar
- module LMM
- IdleIndex = 0
- WalkIndex = 1
- IdleSpeed = 0.5
- WalkSpeed = 1
- end
- class Game_CharacterBase
- attr_reader :frames
- attr_reader :anim_max
- attr_reader :multiframe
- alias :initialize_multi_frames :initialize
- def initialize
- initialize_multi_frames
- @frames = 3
- @anim_max = 2
- @multiframe = false
- end
- def set_graphic(character_name, character_index)
- @tile_id = 0
- @character_name = character_name
- @character_index = character_index
- @frames = character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- @multiframe = @frames != 3
- @original_pattern = @multiframe ? 0 : 1
- @anim_max = character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- end
- alias :update_anime_pattern_multi_frames :update_anime_pattern
- def update_anime_pattern
- if @multiframe
- if !@step_anime && @stop_count > 0
- @pattern = @original_pattern
- else
- @pattern = (@pattern + 1) % @frames
- end
- else
- update_anime_pattern_multi_frames
- end
- end
- alias :straighten_anime_pattern_multi_frames :straighten
- def straighten
- if @multiframe
- @pattern = 0 if @walk_anime || @step_anime
- @anime_count = 0
- else
- straighten_anime_pattern_multi_frames
- end
- end
- end
- class Game_Character < Game_CharacterBase
- def animate_attack(ani_index)
- return if ani_index == 255 || @ani_time < Configs::ATTACK_ANIMATION_TIME
- @last_character_index = @character_index
- @last_pattern = @pattern
- @last_step_anime = @step_anime
- @character_index = ani_index
- @pattern = 0
- @step_anime = true
- @ani_time = 0
- @ani_attack = true
- end
- def update_animate_attack
- return if @ani_time == Configs::ATTACK_ANIMATION_TIME
- @ani_time += 1
- fpf = (Configs::ATTACK_ANIMATION_TIME / @frames ).to_i
- @pattern = (@ani_time / fpf).to_i
- if @ani_time == Configs::ATTACK_ANIMATION_TIME
- @character_index = @last_character_index
- @pattern = @last_pattern
- @step_anime = @last_step_anime
- @ani_attack = false
- end
- end
- #LM² - Idle Anim
- def update_anime_pattern
- return super unless (self.is_a?(Game_Player) || self.is_a?(Game_NetPlayer))
- @pattern = @multiframe ? (@pattern + 1) % @frames : (@pattern + 1) % 4
- end
- def update_anime_count
- return super unless (self.is_a?(Game_Player) || self.is_a?(Game_NetPlayer))
- @anime_count += moving? ? LMM::WalkSpeed : LMM::IdleSpeed
- end
- def update
- if (self.is_a?(Game_Player) || self.is_a?(Game_NetPlayer)) && !@ani_attack
- if moving? && @character_index == LMM::IdleIndex
- @character_index = LMM::WalkIndex
- elsif !moving? && @character_index == LMM::WalkIndex
- @character_index = LMM::IdleIndex
- end
- end
- super
- end
- #LM² - Idle Anim End
- end
- class Game_Player < Game_Character
- alias :refresh_multi_frames :refresh
- def refresh
- refresh_multi_frames
- @frames = @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- @multiframe = @frames != 3
- @original_pattern = @multiframe ? 0 : 1
- @anim_max = @character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- @original_pattern = @multiframe ? 0 : 1
- end
- end
- class Game_Event < Game_Character
- alias :setup_page_settings_multi_frames :setup_page_settings
- def setup_page_settings
- setup_page_settings_multi_frames
- @frames = @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- @multiframe = @frames != 3
- @anim_max = @character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- if (@move_type != 0 && @walk_anime) || @step_anime
- @original_pattern = @multiframe ? 0 : 1
- end
- end
- end
- class Game_NetPlayer < Game_Character
- alias :refresh_multi_frames :refresh
- def refresh
- refresh_multi_frames
- @frames = @character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- @multiframe = @frames != 3
- @original_pattern = @multiframe ? 0 : 1
- @anim_max = @character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- @original_pattern = @multiframe ? 0 : 1
- end
- end
- class Sprite_Character < Sprite_Base
- alias :init_sprites_multi_frames :init_sprites
- def init_sprites
- init_sprites_multi_frames
- @paperdoll_cw = []
- @paperdoll_ch = []
- @pd_frames = []
- @pd_anim = []
- end
- def set_character_bitmap
- self.bitmap = Cache.character(@character_name)
- sign = @character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- @cw = bitmap.width / @character.frames
- @ch = bitmap.height / 4
- else
- @cw = bitmap.width / (@character.frames * 4)
- @ch = bitmap.height / (@character.anim_max * 4)
- end
- self.ox = @cw / 2
- self.oy = @ch
- end
- def update_src_rect
- if @tile_id == 0
- if @character.multiframe
- index = @character.character_index
- sx = (index % 4 * @character.frames + @character.pattern) * @cw
- sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- else
- index = @character.character_index
- pattern = @character.pattern < 3 ? @character.pattern : 1
- sx = (index % 4 * 3 + pattern) * @cw
- sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- end
- end
- def update_paperdolls
- order_equips.each_with_index do |slot_id, index|
- if @character.actor.equips[slot_id] && @character.actor.equips[slot_id].paperdoll_name
- refresh_paperdoll(slot_id) unless @last_equips[slot_id] == @character.actor.equips[slot_id] && @last_sex == @character.actor.sex
- pattern = @pd_frames[slot_id] == 3 ? (@character.pattern < 3 ? @character.pattern : 1) : @character.pattern#@character.pattern
- paperdoll_index = @character.character_index #LM² - Idle Anim
- sx = (paperdoll_index % 4 * @pd_frames[slot_id] + pattern) * @paperdoll_cw[slot_id]
- sy = (paperdoll_index / 4 * 4 + (@character.direction - 2) / 2) * @paperdoll_ch[slot_id]
- @paperdoll_sprites[slot_id].src_rect.set(sx, sy, @paperdoll_cw[slot_id], @paperdoll_ch[slot_id])
- @paperdoll_sprites[slot_id].x = x
- @paperdoll_sprites[slot_id].y = y + index
- @paperdoll_sprites[slot_id].oy = @paperdoll_oy[slot_id] + index
- else
- dispose_paperdoll(slot_id)
- end
- end
- @last_sex = @character.actor.sex
- end
- def refresh_paperdoll(slot_id)
- @last_equips[slot_id] = @character.actor.equips[slot_id]
- puts @character.actor.equips[slot_id].paperdoll_name
- bitmap = Cache.paperdoll(@character.actor.equips[slot_id].paperdoll_name, @character.actor.sex)
- @paperdoll_sprites[slot_id] ? @paperdoll_sprites[slot_id].bitmap.clear : create_paperdoll(slot_id, bitmap)
- @paperdoll_sprites[slot_id].bitmap.blt(0, 0, bitmap, bitmap.rect)
- sign = @character.actor.equips[slot_id].paperdoll_name[/^[\!\$]./]
- frames = @character.actor.equips[slot_id].paperdoll_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- @pd_frames[slot_id] = frames
- anim_max = @character.actor.equips[slot_id].paperdoll_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- @pd_anim[slot_id] = anim_max
- if sign && sign.include?('$')
- @paperdoll_cw[slot_id] = bitmap.width / frames
- @paperdoll_ch[slot_id] = bitmap.height / 4
- else
- @paperdoll_cw[slot_id] = bitmap.width / (frames * 4)
- @paperdoll_ch[slot_id] = bitmap.height / (anim_max * 4)
- end
- @paperdoll_sprites[slot_id].ox = @paperdoll_cw[slot_id] / 2
- @paperdoll_sprites[slot_id].oy = @paperdoll_ch[slot_id]
- @paperdoll_oy[slot_id] = @paperdoll_ch[slot_id]
- end
- end
- class Window_Base < Window
- def draw_character(character_name, character_index, x, y)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- frames = character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- increase = frames == 3 ? 1 : 0
- anim_max = character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- if sign && sign.include?('$')
- cw = bitmap.width / frames
- ch = bitmap.height / 4
- else
- cw = bitmap.width / (frames * 4)
- ch = bitmap.height / (anim_max * 4)
- end
- n = character_index
- src_rect = Rect.new((n%4*frames+increase)*cw, (n/4*4)*ch, cw, ch)
- contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
- end
- def draw_paperdoll(paperdoll_name, paperdoll_index, sex, x, y)
- return unless paperdoll_name
- bitmap = Cache.paperdoll(paperdoll_name, sex)
- sign = paperdoll_name[/^[\!\$]./]
- frames = paperdoll_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- increase = frames == 3 ? 1 : 0
- anim_max = paperdoll_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- if sign && sign.include?('$')
- cw = bitmap.width / frames
- ch = bitmap.height / 4
- else
- cw = bitmap.width / (frames * 4)
- ch = bitmap.height / (anim_max * 4)
- end
- src_rect = Rect.new((paperdoll_index % 4 * frames + increase) * cw, (paperdoll_index / 4 * 4) * ch, cw, ch)
- contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
- end
- end
- class Sprite_Party < Sprite2
- def draw_character(index, member)
- self.bitmap.blt(0, 39 * index, @bitmap, @bitmap.rect, opacity(member.id))
- return unless member.actor.character_name
- bitmap = Cache.character(member.actor.character_name)
- sign = member.actor.character_name[/^[\!\$]./]
- frames = member.actor.character_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- increase = frames == 3 ? 1 : 0
- anim_max = member.actor.character_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- if sign && sign.include?('$')
- cw = bitmap.width / frames
- ch = bitmap.height / 4
- else
- cw = bitmap.width / (frames * 4)
- ch = bitmap.height / (anim_max * 4)
- end
- src_rect = Rect.new((member.actor.character_index % 4 * frames + increase) * cw, (member.actor.character_index / 4 * 4) * ch, cw, 24)
- self.bitmap.blt(10, 39 * index - 2, bitmap, src_rect, opacity(member.id))
- end
- def draw_paperdoll(index, equip, sex, opacity)
- return unless equip.paperdoll_name
- bitmap = Cache.paperdoll(equip.paperdoll_name, sex)
- sign = equip.paperdoll_name[/^[\!\$]./]
- frames = equip.paperdoll_name[/\[F(\d+)\]/i] ? $1.to_i : 3
- increase = frames == 3 ? 1 : 0
- anim_max = equip.paperdoll_name[/\[A(\d+)\]/i] ? $1.to_i : 2
- if sign && sign.include?('$')
- cw = bitmap.width / frames
- ch = bitmap.height / 4
- else
- cw = bitmap.width / (frames * 4)
- ch = bitmap.height / (anim_max * 4)
- end
- src_rect = Rect.new((equip.paperdoll_index % 4 * frames + increase) * cw, (equip.paperdoll_index / 4 * 4) * ch, cw, 24)
- self.bitmap.blt(10, 39 * index - 2, bitmap, src_rect, opacity)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement