Допилил скрипт для смены количества кадров "на лету". Если у вас все ивенты из четырех кадров, а главный герой вдруг из восьми - просто вызовите:
$game_map.set_framecount 0,8
$game_map.set_framespeed 0,8
Собственно, допиленный скрипт:
# Скрипт для мультифреймовой анимации
# Game_Character.frames_count задает число кадров анимации (по умолчанию настроен на 8 кадров)
# Game_Character.frames_speed управляет скоростью анимации (по умолчанию настроен на адекватную скорость для frames_count == 8)
class Game_Character
attr_accessor :frames_count
attr_accessor :frames_speed
alias old_initialize initialize
def initialize
@frames_count=4
@frames_speed=4
old_initialize
end
def set_frames_count(count)
@frames_count=count
return
end
def set_frames_speed(speed)
@frames_speed=speed
return
end
alias old_update update
def update
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
if @anime_count > 18 - @move_speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % @frames_count
end
@anime_count = 0
end
if @wait_count > 0
@wait_count -= 1
return
end
if @move_route_forcing
move_type_custom
return
end
if @starting or lock?
return
end
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
case @move_type
when 1
move_type_random
when 2
move_type_toward_player
when 3
move_type_custom
end
end
end
alias old_update_move update_move
def update_move
distance = 2 ** @move_speed
if @y * 128 > @real_y
@real_y = [@real_y + distance, @y * 128].min
end
if @x * 128 < @real_x
@real_x = [@real_x - distance, @x * 128].max
end
if @x * 128 > @real_x
@real_x = [@real_x + distance, @x * 128].min
end
if @y * 128 < @real_y
@real_y = [@real_y - distance, @y * 128].max
end
if @walk_anime
@anime_count += (1 + @frames_speed*0.1) * (@frames_count / 4)
elsif @step_anime
@anime_count += (1 + @frames_speed/2*0.1)* (@frames_count / 4)
end
end
alias old_update_stop update_stop
def update_stop
if @step_anime
@anime_count += (1 + @frames_speed/2*0.1)* (@frames_count / 4)
elsif @pattern != @original_pattern
@anime_count += (1 + @frames_speed*0.1) * (@frames_count / 4)
end
unless @starting or lock?
@stop_count += 1
end
end
end
class Sprite_Character
def initialize(viewport, character = nil)
super(viewport)
@character = character
@old_frames_count = @character.frames_count
update
end
alias old_update update
def update
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / @character.frames_count
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
if @old_frames_count != @character.frames_count
refresh_frames
end
end
def refresh_frames
if @tile_id < 384
if self.bitmap!=nil
self.bitmap.dispose
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / @character.frames_count
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
@old_frames_count = @character.frames_count
end
end
end
class Game_Map
# задать framecount самому
def set_event_framecount(ev_id, count)
if ev_id>0
@events[ev_id].set_frames_count(count)
else
$game_player.set_frames_count(count)
end
end
# задать framespeed самому
def set_event_framespeed(ev_id, speed)
if ev_id>0
@events[ev_id].set_frames_speed(count)
else
$game_player.set_frames_speed(count)
end
end
end
Хотя можно было сделать и аккуратнее и "морозить" графику в какой-то момент, чтобы смена "на лету" не была заметна игроку, но меня все устраивает и ладно.