Advertisement
Guest User

scriptamtilag

a guest
Nov 28th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.52 KB | None | 0 0
  1. #======================================================= # 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? � � 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement