From 390cc7488949d06532446fd87a3b68472f517bbf Mon Sep 17 00:00:00 2001 From: Michael Shirt Date: Tue, 20 Sep 2016 20:52:23 -0600 Subject: [PATCH] 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). --- scripts/Sprite_Character.rb | 9 +++++++++ scripts/Spriteset_Map.rb | 28 +++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/scripts/Sprite_Character.rb b/scripts/Sprite_Character.rb index 9334afc..b5aa42f 100644 --- a/scripts/Sprite_Character.rb +++ b/scripts/Sprite_Character.rb @@ -94,6 +94,15 @@ class Sprite_Character 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 #-------------------------------------------------------------------------- def self.sprite_attr(*args) diff --git a/scripts/Spriteset_Map.rb b/scripts/Spriteset_Map.rb index 9380ad6..0ea9141 100644 --- a/scripts/Spriteset_Map.rb +++ b/scripts/Spriteset_Map.rb @@ -242,21 +242,23 @@ class Spriteset_Map @fog.tone = $game_map.fog_tone # Update character sprites @character_sprites.each do |sprite| - if !sprite.character.is_a?(Game_Event) - sprite.update - elsif + if !sprite.character.is_a?(Game_Event) + sprite.update + elsif - # this is just a check to make sure the sprite is onscreen for game events - # based on its current width and height - # no point in updating the sprite if offscreen - # this greatly increases performance on larger maps + # this is just a check to make sure the sprite is onscreen for game events + # based on its current width and height + # no point in updating the sprite if offscreen + # 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 + (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) + (17 * 128))) - sprite.update - end + ((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_y + (sprite.oy*4) > ($game_map.display_y) - 128) && + (sprite.character.real_y - (sprite.oy*4) < ($game_map.display_y) + (17 * 128))) + sprite.update + else + sprite.update_fast + end end # Update footprints @footprint_sprites.delete_if do |sprite|