#==========================================================================# * GameBaker Anti-Event Lag#==========================================================================# by sandgolem # Concept based on Near Fantastica's original RMXP script## Still a beta version, still the looping bug## Version 3 [VX]# February 22nd, 2008#==========================================================================module GameBaker AntiLagDisable = 0 AntiLagModifierX = 408 AntiLagModifierWidth = 272 AntiLagModifierY = 272 AntiLagModifierHeight = 408 AntiLagAlwaysMove = '&'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 gamebaker_antilag_add if @interpreter gamebaker_antilag_remove if !@interpreter 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] endendclass Game_Event def force_move_route(move_route) super(move_route) if $game_map.gb_antilagnonmove.include?(@id) $game_map.gb_antilagnonmove -= [@id] $game_map.gb_antilagmoveevents += [@id] end end alias gamebaker_antilag_init initialize def initialize(map_id, event) gamebaker_antilag_init(map_id, event) if event.name.include?(GameBaker::AntiLagAlwaysMove) $game_map.gb_antilagmove += [@id] end end alias gamebaker_antilag_evsetup setup def setup(new_page) gamebaker_antilag_evsetup(new_page) if @trigger == 3 or @trigger == 4 start if @trigger == 3 if !$game_map.gb_antilagprocess.include?(@id) $game_map.gb_antilagprocess += [@id] end elsif $game_map.gb_antilagprocess.include?(@id) $game_map.gb_antilagprocess -= [@id] end if @character_name == "" && @tile_id == 0 if !$game_map.gb_antilagnosprite.include?(@id) $game_map.gb_antilagnosprite += [@id] end elsif $game_map.gb_antilagnosprite.include?(@id) $game_map.gb_antilagnosprite -= [@id] end if @move_type == 0 && !@step_anime && !$game_map.gb_antilagnonmove.include?(@id) $game_map.gb_antilagnonmove += [@id] elsif $game_map.gb_antilagnonmove.include?(@id) $game_map.gb_antilagnonmove -= [@id] end end def gamebaker_antilag_interupdate if @interpreter != nil unless @interpreter.running? @interpreter.setup(@list, @event.id) end @interpreter.update end end def update super endendclass Game_Map attr_accessor :gb_antilagcommons, :gb_antilagnonmove, :gb_antilagnosprite, :gb_antilagmoveevents, :gb_antilagmove, :gb_antilagprocess, :gb_antilagspriteevents, :gb_antilag_spriteupdate 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 alias gamebaker_antilag_setupev setup_events def setup_events gamebaker_antilag_getscreen @gb_antilagnonmove = [] @gb_antilagmove = [] @gb_antilagnosprite = [] @gb_antilagprocess = [] @gb_antilagcommons = [] if !@gb_antilagcommons gamebaker_antilag_setupev gamebaker_antilag_refresh_events 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 def gamebaker_antilag_refresh_events @gb_antilagalwaysmove = [] @gb_antilagmoveevents = [] @gb_antilagspriteevents = [] for i in @events.values next if @gb_antilagnosprite.include?(i) @gb_antilagspriteevents += [i] end @gb_antilagspriteevents += [$game_player] for vehicle in $game_map.vehicles next if vehicle.map_id != @map_id @gb_antilagspriteevents += [vehicle] end for i in 0...@gb_antilagmove.size @gb_antilagalwaysmove += [@events[@gb_antilagmove[i]].id] end for i in @events.values next if @gb_antilagnonmove.include?(i.id) next if @gb_antilagmove.include?(i.id) @gb_antilagmoveevents += [i.id] end @gb_antilag_spriteupdate = true end alias gamebaker_antilag_ue update_events def update_events return gamebaker_antilag_ue if $game_switches[GameBaker::AntiLagDisable] gamebaker_antilag_getscreen for i in 0...@gb_antilagprocess.size @events[@gb_antilagprocess[i]].gamebaker_antilag_interupdate end for i in 0...@gb_antilagalwaysmove.size @events[@gb_antilagalwaysmove[i]].update end for i in 0...@gb_antilagmoveevents.size j = @gb_antilagmoveevents[i] @events[j].update if gamebaker_antilag?(@events[j]) end for i in 0...@gb_antilagcommons.size @common_events[@gb_antilagcommons[i]].update end end alias gamebaker_antilag_maprefresh refresh def refresh gamebaker_antilag_maprefresh gamebaker_antilag_refresh_events endendclass Game_Vehicle; attr_accessor :map_id; endclass Spriteset_Map def gamebaker_antilag_characters @gb_antilag_eventsprites = [] for sprite in @character_sprites next if !$game_map.gb_antilagspriteevents.include?(sprite.character) @gb_antilag_eventsprites += [sprite] end $game_map.gb_antilag_spriteupdate = nil end alias gamebaker_antilag_uc update_characters def update_characters return gamebaker_antilag_uc if $game_switches[GameBaker::AntiLagDisable] gamebaker_antilag_characters if $game_map.gb_antilag_spriteupdate for sprite in @gb_antilag_eventsprites sprite.update if $game_map.gamebaker_antilag?(sprite.character) end endend#==========================================================================# End of file! You can find more of our scripts at http://www.gamebaker.com#==========================================================================