Anti-lag script fix for edge case

This fix makes it such that even if a character sprite is offscreen it
will still update its camera position, to prevent issues when a
character sprite teleports offscreen (but their sprite does not because
it doesn't update).
This commit is contained in:
Michael Shirt 2016-09-20 20:52:23 -06:00
parent 31d90b8a66
commit 390cc74889
2 changed files with 24 additions and 13 deletions

View File

@ -94,6 +94,15 @@ class Sprite_Character
end end
end end
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# * Frame Update Fast (only position)
#--------------------------------------------------------------------------
def update_fast
# Set sprite coordinates
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
end
#--------------------------------------------------------------------------
# * Sprite attribute wrapper # * Sprite attribute wrapper
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
def self.sprite_attr(*args) def self.sprite_attr(*args)

View File

@ -242,21 +242,23 @@ class Spriteset_Map
@fog.tone = $game_map.fog_tone @fog.tone = $game_map.fog_tone
# Update character sprites # Update character sprites
@character_sprites.each do |sprite| @character_sprites.each do |sprite|
if !sprite.character.is_a?(Game_Event) if !sprite.character.is_a?(Game_Event)
sprite.update sprite.update
elsif elsif
# this is just a check to make sure the sprite is onscreen for game events # this is just a check to make sure the sprite is onscreen for game events
# based on its current width and height # based on its current width and height
# no point in updating the sprite if offscreen # no point in updating the sprite if offscreen
# this greatly increases performance on larger maps # this greatly increases performance on larger maps
((sprite.character.real_x + (sprite.ox*4) > $game_map.display_x - 128) && ((sprite.character.real_x + (sprite.ox*4) > $game_map.display_x - 128) &&
(sprite.character.real_x - (sprite.ox*4) < $game_map.display_x + (21 * 128)) && (sprite.character.real_x - (sprite.ox*4) < $game_map.display_x + (21 * 128)) &&
(sprite.character.real_y + (sprite.oy*4) > ($game_map.display_y) - 128) && (sprite.character.real_y + (sprite.oy*4) > ($game_map.display_y) - 128) &&
(sprite.character.real_y - (sprite.oy*4) < ($game_map.display_y) + (17 * 128))) (sprite.character.real_y - (sprite.oy*4) < ($game_map.display_y) + (17 * 128)))
sprite.update sprite.update
end else
sprite.update_fast
end
end end
# Update footprints # Update footprints
@footprint_sprites.delete_if do |sprite| @footprint_sprites.delete_if do |sprite|