RPG Maker Forums

So I'am using a script in my game that adds animated face sprites
it works great but in battles the game lags so much when there's more
than 1 character with an animated face. Also when you use an item the game
lags big time and it lasts through the entire battle. The item thing even
effects when there's only one party member. The game drops from 60 FPS down to 9 FPS in seconds

Can someone please fix this script?
I really need some help.
Thanks!
Code:
#===============================================================================
# )----------------------------------------------------------------------------(
# )--     AUTHOR:     Mr Trivel                                              --(
# )--     NAME:       Animated Faces                                         --(
# )--     CREATED:    2014-09-12                                             --(
# )--     VERSION:    1.2                                                    --(
#===============================================================================
# )----------------------------------------------------------------------------(
# )--                         VERSION HISTORY                                --(
# )--  1.0 - Initial script.                                                 --(
# )--  1.1 - Fixed bugs. Uses Frames per second instead of pure frames.      --(
# )--  1.2 - Fixed more bugs. Loops through drawn faces instead of party.    --(
#===============================================================================
# )----------------------------------------------------------------------------(
# )--                          DESCRIPTION                                   --(
# )--  Allows for actor faces to be animated.                                --(
#===============================================================================
# )----------------------------------------------------------------------------(
# )--                          INSTRUCTIONS                                  --(
# )--  Define animation files and frame sequence in ANIMATED_FACES module.   --(
#===============================================================================
# )----------------------------------------------------------------------------(
# )--                          LICENSE INFO                                  --(
# )--  Free for non-commercial & commercial games if credit was given to     --(
# )--  Mr Trivel.                                                            --(
# )----------------------------------------------------------------------------(
#===============================================================================

# )=======---------------------------------------------------------------------(
# )-- Module: ANIMATED_FACES                                                 --(
# )---------------------------------------------------------------------=======(
module ANIMATED_FACES
  # )--------------------------------------------------------------------------(
  # )-- Place your animated faces data here.                                 --(
  # )--------------------------------------------------------------------------(
  DATA = {
  # )-- ACTOR_ID    Filename      Frame Sequence                 
          1 => [ "Casey_Face.png", [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 6 ,5 ,4, 3, 2, 1, 1, 1, 1, 1,1] ],
          2 => [ "Actor2.png", [0, 1, 2, 3, 2, 0, 0, 0, 0, 0 ,0, 0] ]
 
  }
 
  # )--------------------------------------------------------------------------(
  # )-- How fast should frames change. Speed in milliseconds.                --(
  # )--------------------------------------------------------------------------(
  FRAME_SPEED = 20
end

# )=======---------------------------------------------------------------------(
# )-- class: Window_Base                                                     --(
# )---------------------------------------------------------------------=======(
class Window_Base < Window
  include ANIMATED_FACES

  alias :mrts_face_anims_update :update
  alias :mrts_face_anims_initialize :initialize
 
  # )--------------------------------------------------------------------------(
  # )-- Alias: initialize                                                    --(
  # )--------------------------------------------------------------------------(
  def initialize(x, y, width, height)
    mrts_face_anims_initialize(x, y, width, height)
    @time_now = Time.now
    @elapsed_time = 0.0
    @actor_hash = {}
    
  end
  # )--------------------------------------------------------------------------(
  # )-- Overwrite: draw_actor_face                                           --(
  # )--------------------------------------------------------------------------(
  def draw_actor_face(actor, x, y, enabled = true)
    data = DATA[actor.id]
    if data
      @animated_actors ||= true
      @actor_hash[actor.id] ||= 0
      face_name = data[0]
      face_index = data[1][@actor_hash[actor.id]]
      draw_face(face_name, face_index, x, y, enabled)
    else
      draw_face(actor.face_name, actor.face_index, x, y, enabled)
    end
  end
 
  # )--------------------------------------------------------------------------(
  # )-- Alias: update                                                        --(
  # )--------------------------------------------------------------------------(
  def update   
    finish = Time.now
    @elapsed_time += ms(@time_now, finish)
    mrts_face_anims_update
    if @animated_actors && @elapsed_time >= FRAME_SPEED && Time.now.to_f != @time_now
      @actor_hash.each { |k, v| 
        next unless @actor_hash[k]
        @actor_hash[k] += 1
        @actor_hash[k] = 0 if @actor_hash[k] > DATA[k][1].size-1
      }
      refresh
      @elapsed_time = 0
    end
    @time_now = Time.now
  end
 
  # )--------------------------------------------------------------------------(
  # )-- New Method: ms                                                       --(
  # )--------------------------------------------------------------------------(
  def ms(start, finish)
   (finish - start) * 1000.0
  end
end

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top