Description: Reduces lag from events.
Script Name: Anti-Event Lag
Author: sandgolem
Version: 2.00
Number Of Scripts: 1
Description:
Reduces game lag from events. By default every single event (even the ones doing nothing) has to run through over 41 lines of code per frame. At 60 fps, that's 2460+ a second. Adds up pretty fast.This script chops that down mightily. Only events within a screen distance of your choice & active events/common events are updated.
Screenshots:
None
Instructions:
Create a new section above MAIN called Ant-Event Lag and copy the script below into it.
Frequently Asked Questions:
None
Script:
Spoiler
#========================================================================== # ** GameBaker Anti-Event Lag #========================================================================== # by sandgolem # Concept based on Near Fantastica's original RMXP script # # Version 2 [VX] - beta still # February 2nd, 2008 #========================================================================== module GameBaker AntiLagDisable = 0 AntiLagModifierX = 408 AntiLagModifierWidth = 272 AntiLagModifierY = 272 AntiLagModifierHeight = 408 AntiLagNeverEvent = '@' end #========================================================================== # # To check for updates or find more scripts, visit: # http://www.gamebaker.com/rmvx/scripts/ # Our RMXP scripts: http://www.gamebaker.com/rmxp/scripts/ # # This script is not exclusive to our site! # Feel free to pass around as long as you leave the links here. # A license is required for commercial use, see instructions below. # # Instructions: http://www.gamebaker.com/rmvx/scripts/e/anti-event-lag.php # Discussion/Help: http://forums.gamebaker.com/showthread.php?t=1242 # #========================================================================== 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 end #========================================================================== # End of file! You can find more of our scripts at http://www.gamebaker.com #==========================================================================


Help
Actions
Visit support topic
Bookmark



Tutorial/Script info
View members tutorials/scripts








