じ☆ve冰风 发表于 2026-8-5 15:18:32

Lune Ultimate Anti-Lag

Lune Ultimate Anti-Lag
 
Introduction
This script will improve the games performance and handle better against parallel programming, multiple events and graphical systems/scripts
 
Features
- Corrected the classical bug in Anti-lags when teleporting other events
- Handles smartly the FPS to adjust to the needs of each map and players PC
- The classical anti-lag also present, in which events out of the map are only updated at your will
- Increases the RPG Maker priority over other programs
 
Portuguese user? Access the portuguese script here
 
Screenshots
Not necessary
 
 
How to Use
Put it above main and configure the script as necessary
 
Script
 
 

Spoiler#=======================================================#         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=====># 12345678910 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 = .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)#============================================================================== #==============================================================================# ** 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.parameters.include?(':update:')  endend #==============================================================================# ** 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)  endend#==============================================================================# ** 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_Characteralias 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)  endend #==============================================================================# ** 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_Interpreteralias 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))  endend#==============================================================================# ** 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}  endend  $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.update  endend



 
 

 
 
 
FAQ
Does it bugs the event position?
Answer is in the topic
 
If the FPS drops isn't it the same to just let the program decide?
 No, example, if you let your FPS drop to 20 without the anti-lag, it will be very unconstant the graphics frames, and will appear really "laggy", with the anti-lag it will set to 30 about, and will be way smoother the game.
 
Credit and Thanks
- Raizen- TheoAllen - for helping in bug fixing
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7


本贴来自国际rpgmaker官方论坛作者:Raizen处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/lune-ultimate-anti-lag.9828/
页: [1]
查看完整版本: Lune Ultimate Anti-Lag