Anti-Lag Script
Publicado em 15 de setembro de 2011.Já postamos este mesmo script anteriormente no nosso site, nos comentários do Requiem ABS 9, um battle system para o RPG Maker VX, mas decidimos postar novamente, para encher linguiça deixar mais organizadinho e fácil para os visitantes acharem este código.
Ele é baseado num código anti lag para o RMXP, o Anti Event Lag Script, de Near Fantastica. Obviamente, este script pode ser útil nos casos de lag no seu jogo, evitando travamentos e demoras irritantes durante o gameplay, causados por fatores como scripts ou sistemas. Como os menos distraídos devem ter percebido, ele funciona para evitar lagging no Requiem ABS 9.
O Anti-Lag Script foi criado por Sandgolem e traduzido e divulgado por LegendsX. Ele deve ser inserido no seu projeto do RPG Maker VX logo acima do Main.
#==========================================================================
# Anti-Lag Script
#==========================================================================
# Criado por: Sandgolem
# Baseado no script de RMXP original de Near Fantastica's
# Versão Beta
# Tradução e Divulgação: LegendsX
#==========================================================================
module GameBaker
AntiLagDisable = 0
AntiLagModifierX = 408
AntiLagModifierWidth = 272
AntiLagModifierY = 272
AntiLagModifierHeight = 408
AntiLagNeverEvent = '@'
end
class Game_CommonEvent
alias gamebaker_antilag_commonrefresh refresh
def refresh
gamebaker_antilag_commonrefresh
#if self.trigger == 1
# gamebaker_antilag_add if $game_switches[common_event.switch_id]
# gamebaker_antilag_remove if !$game_switches[common_event.switch_id]
#else
gamebaker_antilag_add if @interpreter
gamebaker_antilag_remove if !@interpreter
#end
end
def gamebaker_antilag_remove
return if !$game_map.gb_antilagcommons.include?(@common_event_id)
$game_map.gb_antilagcommons -= [@common_event_id]
end
def gamebaker_antilag_add
return if $game_map.gb_antilagcommons.include?(@common_event_id)
$game_map.gb_antilagcommons += [@common_event_id]
end
end
class Game_Event
alias gamebaker_antilag_init initialize
def initialize(map_id, event)
gamebaker_antilag_init(map_id, event)
if event.name.include?(GameBaker::AntiLagNeverEvent)
$game_map.gb_antilagnever += [@id]
end
end
alias gamebaker_antilag_evsetup setup
def setup(new_page)
gamebaker_antilag_evsetup(new_page)
if @trigger == 3 or @trigger == 4
if !$game_map.gb_antilagevents.include?(@id)
$game_map.gb_antilagevents += [@id]
end
else
if $game_map.gb_antilagevents.include?(@id)
$game_map.gb_antilagevents -= [@id]
end
end
if @character_name == "" && @tile_id == 0
if !$game_map.gb_antilagnever2.include?(@id)
$game_map.gb_antilagnever2 += [@id]
end
else
if $game_map.gb_antilagnever2.include?(@id)
$game_map.gb_antilagnever2 -= [@id]
end
end
end
end
class Game_Map
attr_accessor :gb_antilagcommons, :gb_antilagevents,
:gb_antilagnever, :gb_antilagnever2
def gamebaker_antilag?(sg)
return false if sg.real_x < @gb_antilagscreen_x or
sg.real_x > @gb_antilagscreen_width or
sg.real_y < @gb_antilagscreen_y or
sg.real_y > @gb_antilagscreen_height
return true
end
def gamebaker_antilag2?(sg)
return @gb_antilagevents.include?(sg.id)
end
alias gamebaker_antilag_setupev setup_events
def setup_events
gamebaker_antilag_getscreen
@gb_antilagevents = []
@gb_antilagnever = []
@gb_antilagnever2 = []
@gb_antilagcommons = [] if !@gb_antilagcommons
gamebaker_antilag_setupev
end
def gamebaker_antilag_getscreen
@gb_antilagscreen_x = @display_x - GameBaker::AntiLagModifierX
@gb_antilagscreen_y = @display_y - GameBaker::AntiLagModifierY
@gb_antilagscreen_width =
@display_x + (Graphics.width * 8) + GameBaker::AntiLagModifierWidth
@gb_antilagscreen_height =
@display_y + (Graphics.height * 8) + GameBaker::AntiLagModifierHeight
end
alias gamebaker_antilag_ue update_events
def update_events
return gamebaker_antilag_ue if $game_switches[GameBaker::AntiLagDisable]
gamebaker_antilag_getscreen
if @gb_antilagnever != []
for i in @events.values
next if @gb_antilagnever.include?(i.id)
i.update if gamebaker_antilag?(i) or @gb_antilagevents.include?(i.id)
end
else
for i in @events.values
i.update if gamebaker_antilag?(i) or @gb_antilagevents.include?(i.id)
end
end
for i in 0...@gb_antilagcommons.size
@common_events[@gb_antilagcommons[i]].update
end
end
end
class Spriteset_Map
alias gamebaker_antilag_uc update_characters
def update_characters
return gamebaker_antilag_uc if $game_switches[GameBaker::AntiLagDisable]
sg = $game_map.gb_antilagnever2
for sprite in @character_sprites
next if sg.include?(sprite.character.id)
if $game_map.gamebaker_antilag?(sprite.character) or
$game_map.gamebaker_antilag2?(sprite.character)
sprite.update
end
end
end
endMais RPG Maker VX
Informações adicionais
- Categoria: Programação VX
- Tag: RPG Maker VX
- Adicionado por: LichKing
- Acessos: 1176
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!
