Lune Ultimate Anti-Lag

SpacemanFive

Meteor Mage
Veteran
Joined
Jun 25, 2013
Messages
207
Reaction score
24
First Language
English
Primarily Uses
RMMZ
This looks incredibly useful, considering how some of my projects have been lagging during playtesting due to some things I've been doing with or adding to them.

Thank you very much!

I tested the script, and it works pretty well.

However, I ran into an issue when testing it for compatibility with Gab!'s Fullscreen & High Resolution script. The player character visually slides while moving, which is only reset when opening and closing the menu.

I read that you're working on a fix for issues with other resolutions. I hope it will be able to handle the variable, limit breaking options possible with Gab!'s script.
 

Raizen

Veteran
Veteran
Joined
Oct 24, 2012
Messages
381
Reaction score
660
First Language
Portuguese
Primarily Uses
RMMV
Actually I did correct the issue xD, but it was for max of 800x600, well for Gab!'s script I can make a correction that will work on his script, but the main feature that makes all anti-lag really work, is the fact that it ignores events and actions outside of the window, and his script will make almost the whole map be shown... so the anti-lag, actually any anti-lag will almost make no difference  :|

But you can use the other 2 features in my anti-lag, maybe it will help a little x)

Code:
#=======================================================#         Lune Ultimate Anti-Lag# Author: Raizen# Compatible with: RMVXAce# Comunity: centrorpg.com# This script allows a very well balanced anti-lag, in which# considers the own PC of the player, using a smart frame-skipper# to slow lags,#========================================================#To update constantly the event, put a commentary on the first# command of the script written :update:module Anti_conf#==============================================================================# ** Configurations#------------------------------------------------------------------------------#  Configure what is necessary for a better performance.#==============================================================================# Choose how the script will act.# <=====Quality============================Performance=====># 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20# Default = 10Fr = 10# Configure the FPS rate (default = 60)Fps = 60# Configure the minimum FPS rate (default = 25)Mini = 25# Quantity of frames the anti-lag will study,# the higher the time, the more precise the script, # but will take longer to load the anti-lagTime = 60end=beginFunctions on this Anti-Lag* Common event positioning bug fixed* Smart Frame Skipper* updates what is only necessary* helps to lower lags from visual system/scripts* Changes its behavior according to the players PC* Increases the RPG Maker priority over other programs=end#=================================================================##=================================================================##====================  Alias methods =============================## command_203          => Game_Interpreter# start                => Scene_Map# update               => Scene_Map# perform_transfer     => Scene_Map#=================================================================##====================  Rewrite methods ===========================## update_events        => Game_Map# update_one_event     => Spriteset_Map#=================================================================##========================  New methods ===========================## need_to_update?      => Game_Event# near_the_screen?     => Sprite_Character# call_position_event  => Scene_Map# skip_calculate       => Scene_Map# update_one_event     => Spriteset_Map#=================================================================##=================================================================# #==============================================================================#============================  Início do Script!  =============================#==============================================================================#==============================================================================# ** Scene_Map#------------------------------------------------------------------------------#  Esta classe executa o processamento da tela de mapa.#============================================================================== class Scene_Map < Scene_Basealias lune_skip_start startalias lune_skip_update updatealias lune_perform perform_transfer  #--------------------------------------------------------------------------  # * Inicialização do processo  #--------------------------------------------------------------------------  def start    Graphics.frame_rate = Anti_conf::Fps    @update_skip = false    @count_up = 0    lune_skip_start  end  #--------------------------------------------------------------------------  # * Execução da transferência  #--------------------------------------------------------------------------  def perform_transfer    $get_new_ids = Array.new    Graphics.frame_rate = Anti_conf::Fps    lune_perform    @count_up = 0    @update_skip = false  end  #--------------------------------------------------------------------------  # * Atualização da tela  #--------------------------------------------------------------------------  def update    @update_skip ? lune_skip_update : skip_calculate  end  #--------------------------------------------------------------------------  # * Atualização de um personagem especifico  #--------------------------------------------------------------------------  def call_position_event(id)    @spriteset.update_one_event(id)  end  #--------------------------------------------------------------------------  # * Calcula o tempo necessário para rodar o update do Scene_Map  #--------------------------------------------------------------------------    def skip_calculate    @count_up += 1    return unless @count_up >= Anti_conf::Time    auto_skip = Time.now    lune_skip_update    old_skip = Time.now    get_skip = old_skip - auto_skip    Graphics.frame_rate -= (get_skip * Graphics.frame_rate * 2 * Anti_conf::Fr - 1).to_i    Graphics.frame_rate = [Graphics.frame_rate, Anti_conf::Mini].max    @update_skip = true  endend  #==============================================================================# ** Scene_Base#------------------------------------------------------------------------------#  Esta é a superclasse de todas as cenas do jogo.#==============================================================================class Scene_Basealias skipper_main main  #--------------------------------------------------------------------------  # * Processamento principal  #--------------------------------------------------------------------------  def main    @fr_cont = 0    skipper_main  end  #--------------------------------------------------------------------------  # * Execução da transição  #--------------------------------------------------------------------------  def perform_transition    Graphics.transition(transition_speed * Graphics.frame_rate / 60)  end  #--------------------------------------------------------------------------  # * Atualização da tela (básico)  #--------------------------------------------------------------------------  def update_basic    if @fr_cont >= 60      Graphics.update             @fr_cont -= 60    end    @fr_cont += Graphics.frame_rate    update_all_windows    Input.update  endend #==============================================================================# ** Aumento da prioridade do rpg maker#------------------------------------------------------------------------------Lune_high = Win32API.new("kernel32", "SetPriorityClass", "pi", "i")Lune_high.call(-1, 0x90)#==============================================================================
 

SpacemanFive

Meteor Mage
Veteran
Joined
Jun 25, 2013
Messages
207
Reaction score
24
First Language
English
Primarily Uses
RMMZ
Actually I did correct the issue xD, but it was for max of 800x600, well for Gab!'s script I can make a correction that will work on his script, but the main feature that makes all anti-lag really work, is the fact that it ignores events and actions outside of the window, and his script will make almost the whole map be shown... so the anti-lag, actually any anti-lag will almost make no difference  :|

But you can use the other 2 features in my anti-lag, maybe it will help a little x)

#=======================================================# Lune Ultimate Anti-Lag# Author: Raizen# Compatible with: RMVXAce# Comunity: centrorpg.com# This script allows a very well balanced anti-lag, in which# considers the own PC of the player, using a smart frame-skipper# to slow lags,#========================================================#To update constantly the event, put a commentary on the first# command of the script written :update:module Anti_conf#==============================================================================# ** Configurations#------------------------------------------------------------------------------# Configure what is necessary for a better performance.#==============================================================================# Choose how the script will act.# <=====Quality============================Performance=====># 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20# Default = 10Fr = 10# Configure the FPS rate (default = 60)Fps = 60# Configure the minimum FPS rate (default = 25)Mini = 25# Quantity of frames the anti-lag will study,# the higher the time, the more precise the script, # but will take longer to load the anti-lagTime = 60end=beginFunctions on this Anti-Lag* Common event positioning bug fixed* Smart Frame Skipper* updates what is only necessary* helps to lower lags from visual system/scripts* Changes its behavior according to the players PC* Increases the RPG Maker priority over other programs=end#=================================================================##=================================================================##==================== Alias methods =============================## command_203 => Game_Interpreter# start => Scene_Map# update => Scene_Map# perform_transfer => Scene_Map#=================================================================##==================== Rewrite methods ===========================## update_events => Game_Map# update_one_event => Spriteset_Map#=================================================================##======================== New methods ===========================## need_to_update? => Game_Event# near_the_screen? => Sprite_Character# call_position_event => Scene_Map# skip_calculate => Scene_Map# update_one_event => Spriteset_Map#=================================================================##=================================================================# #==============================================================================#============================ Início do Script! =============================#==============================================================================#==============================================================================# ** Scene_Map#------------------------------------------------------------------------------# Esta classe executa o processamento da tela de mapa.#============================================================================== class Scene_Map < Scene_Basealias lune_skip_start startalias lune_skip_update updatealias lune_perform perform_transfer #-------------------------------------------------------------------------- # * Inicialização do processo #-------------------------------------------------------------------------- def start Graphics.frame_rate = Anti_conf::Fps @update_skip = false @count_up = 0 lune_skip_start end #-------------------------------------------------------------------------- # * Execução da transferência #-------------------------------------------------------------------------- def perform_transfer $get_new_ids = Array.new Graphics.frame_rate = Anti_conf::Fps lune_perform @count_up = 0 @update_skip = false end #-------------------------------------------------------------------------- # * Atualização da tela #-------------------------------------------------------------------------- def update @update_skip ? lune_skip_update : skip_calculate end #-------------------------------------------------------------------------- # * Atualização de um personagem especifico #-------------------------------------------------------------------------- def call_position_event(id) @spriteset.update_one_event(id) end #-------------------------------------------------------------------------- # * Calcula o tempo necessário para rodar o update do Scene_Map #-------------------------------------------------------------------------- def skip_calculate @count_up += 1 return unless @count_up >= Anti_conf::Time auto_skip = Time.now lune_skip_update old_skip = Time.now get_skip = old_skip - auto_skip Graphics.frame_rate -= (get_skip * Graphics.frame_rate * 2 * Anti_conf::Fr - 1).to_i Graphics.frame_rate = [Graphics.frame_rate, Anti_conf::Mini].max @update_skip = true endend #==============================================================================# ** Scene_Base#------------------------------------------------------------------------------# Esta é a superclasse de todas as cenas do jogo.#==============================================================================class Scene_Basealias skipper_main main #-------------------------------------------------------------------------- # * Processamento principal #-------------------------------------------------------------------------- def main @fr_cont = 0 skipper_main end #-------------------------------------------------------------------------- # * Execução da transição #-------------------------------------------------------------------------- def perform_transition Graphics.transition(transition_speed * Graphics.frame_rate / 60) end #-------------------------------------------------------------------------- # * Atualização da tela (básico) #-------------------------------------------------------------------------- def update_basic if @fr_cont >= 60 Graphics.update @fr_cont -= 60 end @fr_cont += Graphics.frame_rate update_all_windows Input.update endend #==============================================================================# ** Aumento da prioridade do rpg maker#------------------------------------------------------------------------------Lune_high = Win32API.new("kernel32", "SetPriorityClass", "pi", "i")Lune_high.call(-1, 0x90)#==============================================================================
Okay. Looks like my impression the first time I read the thread was correct, then. You did correct the original resolution issue. Sorry if I got it wrong, there.

The project I'm working on will have some very big maps. Due to this, I've also decided to add some non-event stuff on the outside of building internals to fill in empty space. (So there's a visual bonus in higher resolutions.) I'll try to not clutter things up too much, however. Don't want to make using the script pointless...

One of the main reasons I thought of using your script was because of lag I was noticing in my project with various other scripts I was using. Your script does a pretty good job fixing that. Thank you very much!
 
Last edited by a moderator:

GalanDun

Villager
Member
Joined
Dec 23, 2014
Messages
13
Reaction score
0
First Language
English
Primarily Uses
Question, how much of the code-box do I have to copy to make the script work?
 

dioarcangel

Villager
Member
Joined
Aug 13, 2015
Messages
16
Reaction score
0
First Language
Español
Primarily Uses
Hello ! let me say this is a nice nice script good job =D 

I can see the difference with this script at the begining !!! 

 

But i have a problem when i place this script my events goes wrong , some dont start... why ?
 

Raizen

Veteran
Veteran
Joined
Oct 24, 2012
Messages
381
Reaction score
660
First Language
Portuguese
Primarily Uses
RMMV
They don't update outside the screen, unless you put a comment :update: :)
 

TriWop

Warper
Member
Joined
Jul 8, 2015
Messages
1
Reaction score
0
First Language
English
Primarily Uses
You are now credited and loved by myself and many. <3  :rock-left:   :D   :rock-right:
 

lonequeso

Warper
Member
Joined
Mar 29, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
I'm having an issue come up when I transfer the player on certain maps.
To allow events to move while off screen I changed this:

def need_to_update? return false unless @list ax = $game_map.adjust_x(@real_x) - 8 ay = $game_map.adjust_y(@real_y) - 6 ax.between?(-9, 9) && ay.between?(-7, 7) || @list[0].parameters.include?(':update:') endendto

def need_to_update? return false unless @list ax = $game_map.adjust_x(@real_x) - 8 ay = $game_map.adjust_y(@real_y) - 6 ax.between?(-40, 40) && ay.between?(-40, 40) || @list[0].parameters.include?(':update:') endendOne one map in particular crashes when I  try to transfer the player. The message is:

No implicit conversion from nil to integer

I've tried several ranges. What could be causing this?
 
Last edited by a moderator:

tale

Volunteer
Veteran
Joined
Dec 16, 2016
Messages
711
Reaction score
1,196
First Language
English
Primarily Uses
N/A
Fixed script format, credit Raizen and TheoAllen - for helping in bug fixing
For more details- see thread
Code:
#=======================================================
#         Lune Ultimate Anti-Lag
# Author: Raizen
# Compatible with: RMVXAce
# Comunity: centrorpg.com
# This script allows a very well balanced anti-lag, in which
# considers the own PC of the player, using a smart frame-skipper
# to slow lags,
#========================================================

#To update constantly the event, put a commentary on the first
# command of the script written :update:

module Anti_conf
#==============================================================================
# ** Configurations
#------------------------------------------------------------------------------
#  Configure what is necessary for a better performance.
#==============================================================================
# Choose how the script will act.
# <=====Quality============================Performance=====>
# 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20
# Default = 10
Fr = 10

# Configure the FPS rate (default = 60)
Fps = 60
# Configure the minimum FPS rate (default = 25)
Mini = 25
# Quantity of frames the anti-lag will study,
# the higher the time, the more precise the script,
# but will take longer to load the anti-lag
Time = 60

end
=begin




Functions on this Anti-Lag

* Common event positioning bug fixed
* Smart Frame Skipper
* updates what is only necessary
* helps to lower lags from visual system/scripts
* Changes its behavior according to the players PC
* Increases the RPG Maker priority over other programs


=end

#=================================================================#
#=================================================================#
#====================  Alias methods =============================#
# command_203          => Game_Interpreter
# start                => Scene_Map
# update               => Scene_Map
# perform_transfer     => Scene_Map
#=================================================================#
#====================  Rewrite methods ===========================#
# update_events        => Game_Map
# update_one_event     => Spriteset_Map
#=================================================================#
#========================  New methods ===========================#
# need_to_update?      => Game_Event
# near_the_screen?     => Sprite_Character
# call_position_event  => Scene_Map
# skip_calculate       => Scene_Map
# update_one_event     => Spriteset_Map
#=================================================================#
#=================================================================#
 
#==============================================================================
#============================  Início do Script!  =============================
#==============================================================================
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Esta classe executa o processamento da tela de mapa.
#==============================================================================
 
class Scene_Map < Scene_Base
alias lune_skip_start start
alias lune_skip_update update
alias lune_perform perform_transfer
  #--------------------------------------------------------------------------
  # * Inicialização do processo
  #--------------------------------------------------------------------------
  def start
    Graphics.frame_rate = Anti_conf::Fps
    @update_skip = false
    @count_up = 0
    lune_skip_start
  end
  #--------------------------------------------------------------------------
  # * Execução da transferência
  #--------------------------------------------------------------------------
  def perform_transfer
    $get_new_ids = Array.new
    Graphics.frame_rate = Anti_conf::Fps
    lune_perform
    @count_up = 0
    @update_skip = false
  end
  #--------------------------------------------------------------------------
  # * Atualização da tela
  #--------------------------------------------------------------------------
  def update
    @update_skip ? lune_skip_update : skip_calculate
  end
  #--------------------------------------------------------------------------
  # * Atualização de um personagem especifico
  #--------------------------------------------------------------------------
  def call_position_event(id)
    @spriteset.update_one_event(id)
  end
  #--------------------------------------------------------------------------
  # * Calcula o tempo necessário para rodar o update do Scene_Map
  #-------------------------------------------------------------------------- 
  def skip_calculate
    @count_up += 1
    return unless @count_up >= Anti_conf::Time
    auto_skip = Time.now
    lune_skip_update
    old_skip = Time.now
    get_skip = old_skip - auto_skip
    Graphics.frame_rate -= (get_skip * Graphics.frame_rate * 2 * Anti_conf::Fr - 1).to_i
    Graphics.frame_rate = [Graphics.frame_rate, Anti_conf::Mini].max
    @update_skip = true
  end
end
 
 
#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  Esta é a superclasse de todas as cenas do jogo.
#==============================================================================
class Scene_Base
alias skipper_main main
  #--------------------------------------------------------------------------
  # * Processamento principal
  #--------------------------------------------------------------------------
  def main
    @fr_cont = 0
    skipper_main
  end
  #--------------------------------------------------------------------------
  # * Execução da transição
  #--------------------------------------------------------------------------
  def perform_transition
    Graphics.transition(transition_speed * Graphics.frame_rate / 60)
  end
  #--------------------------------------------------------------------------
  # * Atualização da tela (básico)
  #--------------------------------------------------------------------------
  def update_basic
    if @fr_cont >= 60
      Graphics.update       
      @fr_cont -= 60
    end
    @fr_cont += Graphics.frame_rate
    update_all_windows
    Input.update
  end
end
 
#==============================================================================
# ** Aumento da prioridade do rpg maker
#------------------------------------------------------------------------------
Lune_high = Win32API.new("kernel32", "SetPriorityClass", "pi", "i")
Lune_high.call(-1, 0x90)
#==============================================================================
 
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  Esta classe gerencia os eventos. Ela controla funções incluindo a mudança
# de páginas de event por condições determinadas, e processos paralelos.
# Esta classe é usada internamente pela classe Game_Map.
#==============================================================================
 
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * necessário atualizar?
  #--------------------------------------------------------------------------
  def need_to_update?
    return false unless @list
    ax = $game_map.adjust_x(@real_x) - 8
    ay = $game_map.adjust_y(@real_y) - 6
    ax.between?(-9, 9) && ay.between?(-7, 7) || @list[0].parameters.include?(':update:')
  end
end
 
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  Este sprite é usado para mostrar personagens. Ele observa uma instância
# da classe Game_Character e automaticamente muda as condições do sprite.
#==============================================================================
 
class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # * Evento próximo a tela?
  #--------------------------------------------------------------------------
  def near_the_screen?
    ax = $game_map.adjust_x(@character.x) - 8
    ay = $game_map.adjust_y(@character.y) - 6
    ax.between?(-11, 11) && ay.between?(-8, 8)
  end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  Esta classe gerencia os eventos. Ela controla funções incluindo a mudança
# de páginas de event por condições determinadas, e processos paralelos.
# Esta classe é usada internamente pela classe Game_Map.
#==============================================================================
 
class Game_Event < Game_Character
alias lune_ant_initialize initialize
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #     event : RPG::Event
  #--------------------------------------------------------------------------
  def initialize(*args, &block)
    lune_ant_initialize(*args, &block)
    $get_new_ids.push(@event.id)
  end
end
 
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  Um interpretador para executar os comandos de evento. Esta classe é usada
# internamente pelas classes Game_Map, Game_Troop e Game_Event.
#==============================================================================
 
class Game_Interpreter
alias lune_lag_command_203 command_203
  #--------------------------------------------------------------------------
  # Definir posição do evento
  #--------------------------------------------------------------------------
  def command_203
    lune_lag_command_203
    SceneManager.scene.call_position_event($get_new_ids.index(@event_id))
  end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  Esta classe gerencia o mapa. Inclui funções de rolagem e definição de
# passagens. A instância desta classe é referenciada por $game_map.
#==============================================================================
 
class Game_Map
  #--------------------------------------------------------------------------
  # * Atualização dos comandos dos eventos
  #--------------------------------------------------------------------------
  def update_events
    @events.each_value {|event| event.update if event.need_to_update?}
    @common_events.each {|event| event.update}
  end
end
 
 
$get_new_ids = Array.new
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  Esta classe reune os sprites da tela de mapa e tilesets. Esta classe é
# usada internamente pela classe Scene_Map.
#==============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Atualização dos personagens
  #--------------------------------------------------------------------------
  def update_characters
    refresh_characters if @map_id != $game_map.map_id
    @character_sprites.each {|sprite| sprite.update if sprite.near_the_screen? }
  end
  #--------------------------------------------------------------------------
  # * Atualização de algum personagem remoto
  #--------------------------------------------------------------------------
  def update_one_event(id)
    @character_sprites[id].update
  end
end
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games? And, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top