Frozen time effect

Hello,

I'm looking for a way to freeze most of the map with a switch or similar effect, creating a "time stopped" effect, or even better a very highly slowed time effect.

My goal is to add this effect to one of my addon to TBS, when a reaction is suggested, the game slows down to reach a freezing point, only allowing the player/camera to move around and use menus while all units and decoration are frozen in time.

I think I just need to stop calling the updates of the events/characters on the map. And the tileset too (did not try it yet), and then some sprite effects like animations (did not try it either).
However I have a hard time with the weather since its sprites will disappear when changing scene (calling the menu) (edit: fixed by calling an update once when loading the scene) and moving the player out of the original screen will also reach the limits of the weather...
I'm also wondering if I'm not missing some things to freeze with my script.

So I was wondering if someone already investigated a similar effect? Otherwise, how would you make such script?

Here is a very basic WIP script to test the freeze effect on the map:
Ruby:
$imported ||= {}
module FREEZE_SCREEN
  FREEZE_SWITCH = 10
  def self.screen_frozen?
    $game_switches[FREEZE_SWITCH]
  end
end


class Sprite_Base < Sprite
  alias freeze_update_animation update_animation
  def update_animation
    freeze_update_animation unless FREEZE_SCREEN.screen_frozen?
  end
end

class Spriteset_Weather
  alias freeze_update update
  def update
    freeze_update
    @weather_done = true if FREEZE_SCREEN.screen_frozen? && !@weather_done
  end
 
  def freeze_weather?
    FREEZE_SCREEN.screen_frozen? && @weather_done
  end
  #--------------------------------------------------------------------------
  # * Update Sprite [Rain]
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_rain update_sprite_rain
  def update_sprite_rain(sprite)
    freeze_update_sprite_rain(sprite) unless freeze_weather?
  end
  #--------------------------------------------------------------------------
  # * Update Sprite [Storm]
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_storm update_sprite_storm
  def update_sprite_storm(sprite)
    freeze_update_sprite_storm(sprite) unless freeze_weather?
  end
  #--------------------------------------------------------------------------
  # * Update Sprite [Snow]
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_snow update_sprite_snow
  def update_sprite_snow(sprite)
    freeze_update_sprite_snow(sprite) unless freeze_weather?
  end
end

class Spriteset_Map
  alias freeze_update_tilemap update_tilemap
  #--------------------------------------------------------------------------
  # * Update Tilemap
  #--------------------------------------------------------------------------
  def update_tilemap
    return freeze_update_tilemap unless FREEZE_SCREEN.screen_frozen?
    @tilemap.map_data = $game_map.data
    @tilemap.ox = $game_map.display_x * 32
    @tilemap.oy = $game_map.display_y * 32
    #@tilemap.update
  end
end

class Game_Map
  alias freeze_update_events update_events
  def update_events
    freeze_update_events unless FREEZE_SCREEN.screen_frozen?
  end
 
  alias freeze_update_vehicles update_vehicles
  def update_vehicles
    freeze_update_vehicles unless FREEZE_SCREEN.screen_frozen?
  end
end

class Game_Interpreter
  def freeze_screen
    puts "freeze"
    $game_switches[FREEZE_SCREEN::FREEZE_SWITCH] = true
  end
 
  def unfreeze_screen
    puts "unfreeze"
    $game_switches[FREEZE_SCREEN::FREEZE_SWITCH] = false
  end
end

if $imported[:Zeus_Lights_Shadows]
class Game_Light_Shadow_Base
  alias freeze_update_pattern update_pattern
  def update_pattern
    freeze_update_pattern unless FREEZE_SCREEN.screen_frozen?
  end
end

class Game_Light < Game_Light_Shadow_Base
  alias freeze_update_flicker update_flicker
  def update_flicker
    freeze_update_flicker unless FREEZE_SCREEN.screen_frozen?
  end
end
end

Edit: I updated the script and added support to Zeus's light effects, now my only issue is regarding the weather when the camera moves :/

Edit: I went along with teleporting the particles whenever they are outside of the camera scope, it's not really pretty but it does the job.

Edit: Here is the final result
Ruby:
#==============================================================================
# Freeze Map Effect
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 10/11/2025
#==============================================================================

$imported ||= {}
$imported["TIM_FREEZE_SCREEN"] = true

#==============================================================================
# Description
#------------------------------------------------------------------------------
# Adds a time stop mechanisme to the game where everything is frozen in time
# except the player. This script is meant to be used with other script or
# game mechanism.
#
# to freeze the game, you can set the switch with id FREEZE_SWITCH to true.
#
# Alternatively, you can use script calls:
# FREEZE_SCREEN.freeze to have a freeze effect
# FREEZE_SCREEN.unfreeze to have an unfreeze effect
#==============================================================================
# Terms of use: free for free or commercial games, please give credit
#==============================================================================

#============================================================================
# FREEZE_SCREEN -> parameters for the freeze screen effect
#============================================================================
module FREEZE_SCREEN
  CHANGE_TONE = true
  FLASH_SCREEN = true
 
  #the game switch controlling the freeze effect, true to freeze the game,
  #false to let the gane run normally
  FREEZE_SWITCH = 10
  #screen tone used if CHANGE_TONE is true
  FROZEN_TONE = [34,17,-85,187]
  #flash color used if FLASH_SCREEN is true
  FLASH_COLOR = [255,255,136,255]
  FLASH_DURATION = 30
 
  #sounds played when using freeze ir unfreeze
  START_SOUND = RPG::SE.new("Down3",80,100)
  END_SOUND = RPG::SE.new("Darkness2",80,80)
  #--------------------------------------------------------------------------
  # new method: screen_frozen? -> the actual check by other classes
  #--------------------------------------------------------------------------
  def self.screen_frozen?
    $game_switches[FREEZE_SWITCH]
  end
  #--------------------------------------------------------------------------
  # new method: freeze= -> hides the fact that a switch controls the effect
  #--------------------------------------------------------------------------
  def self.freeze=(b)
    $game_switches[FREEZE_SWITCH] = b
  end
  #--------------------------------------------------------------------------
  # new method: freeze -> enable time freezing, t is transition time for
  # sound fade out and tone in seconds (default is instant)
  #--------------------------------------------------------------------------
  def self.freeze(t = 0)
    @frozen_bgm = RPG::BGM.last #save bgm
    @frozen_bgs = RPG::BGS.last #save bgs
    @frozen_screen_tone = $game_map.screen.tone #save screen tone
    #flash screen if option is true
    $game_map.screen.start_flash(Color.new(*FLASH_COLOR),FLASH_DURATION) if FLASH_SCREEN
    #change screen tone if option is true
    $game_map.screen.start_tone_change(Tone.new(*FROZEN_TONE), t * Graphics.frame_rate) if CHANGE_TONE
    RPG::BGM.fade(t * 1000) #stop bgm
    RPG::BGS.fade(t * 1000) #stop bgs
    #play sound effect
    START_SOUND.play
    #enable actual freeze effect
    self.freeze = true
  end
  #--------------------------------------------------------------------------
  # new method: unfreeze -> disable time freezing
  #--------------------------------------------------------------------------
  def self.unfreeze
    @frozen_bgm.play #restore bgm
    @frozen_bgs.play #restore bgs
    #flash screen if option is true
    $game_map.screen.start_flash(Color.new(*FLASH_COLOR),FLASH_DURATION) if FLASH_SCREEN
    #restore original screen tone if option is true
    $game_map.screen.start_tone_change(@frozen_screen_tone, 0) if CHANGE_TONE
    #play sound effect
    END_SOUND.play
    #disable actual freeze effect
    self.freeze = false
  end
end #FREEZE_SCREEN

#============================================================================
# Sprite_Base
#============================================================================
class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # alias method: update_animation -> freeze animations when frozen
  #--------------------------------------------------------------------------
  alias freeze_update_animation update_animation
  def update_animation
    freeze_update_animation unless FREEZE_SCREEN.screen_frozen?
  end
end #Sprite_Base

#============================================================================
# Spriteset_Weather
#============================================================================
class Spriteset_Weather
  #--------------------------------------------------------------------------
  # alias method: update -> if first update and screen must be frozen, then
  # do 1 normal update
  #--------------------------------------------------------------------------
  alias freeze_update update
  def update
    freeze_update
    @weather_done = true if FREEZE_SCREEN.screen_frozen? && !@weather_done
  end
  #--------------------------------------------------------------------------
  # new method: freeze_weather? -> allows to perform a first normal update
  # when the scene (and ths spriteset) is loaded
  #--------------------------------------------------------------------------
  def freeze_weather?
    FREEZE_SCREEN.screen_frozen? && @weather_done
  end
  #--------------------------------------------------------------------------
  # alias method: update_sprite
  #--------------------------------------------------------------------------
  alias freeze_update_sprite update_sprite
  def update_sprite(sprite)
    freeze_update_sprite(sprite)
    return unless freeze_weather?
    update_frozen_sprite(sprite)
  end
  #--------------------------------------------------------------------------
  # new method: update_frozen_sprite -> teleports the sprites when out of
  # sight
  #--------------------------------------------------------------------------
  def update_frozen_sprite(sprite)
    dx,dy = sprite_x_visibility(sprite), sprite_y_visibility(sprite)
    sprite.x += Graphics.width+100 if dx < 0
    sprite.x -= Graphics.width+100 if dx > 0
    sprite.y += Graphics.height+200 if dy < 0
    sprite.y -= Graphics.height+200 if dy > 0
  end
  #--------------------------------------------------------------------------
  # new method: sprite_x_visibility ->
  # 0 if on screen, -1 if x is too small, 1 if x is too big
  #--------------------------------------------------------------------------
  def sprite_x_visibility(sprite)
    return -1 if sprite.x + sprite.width < @ox
    return 1 if sprite.x >= @ox + Graphics.width
    return 0
  end
  #--------------------------------------------------------------------------
  # new method: sprite_y_visibility ->
  # 0 if on screen, -1 if y is too small, 1 if y is too big
  #--------------------------------------------------------------------------
  def sprite_y_visibility(sprite)
    return -1 if sprite.y + sprite.height < @oy
    return 1 if sprite.y >= @oy + Graphics.height
    return 0
  end
  #--------------------------------------------------------------------------
  # alias method: update_sprite_rain -> don't update opacity and position
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_rain update_sprite_rain
  def update_sprite_rain(sprite)
    freeze_update_sprite_rain(sprite) unless freeze_weather?
  end
  #--------------------------------------------------------------------------
  # alias method: update_sprite_storm -> don't update opacity and position
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_storm update_sprite_storm
  def update_sprite_storm(sprite)
    freeze_update_sprite_storm(sprite) unless freeze_weather?
  end
  #--------------------------------------------------------------------------
  # alias method: update_sprite_snow -> don't update opacity and position
  #--------------------------------------------------------------------------
  alias freeze_update_sprite_snow update_sprite_snow
  def update_sprite_snow(sprite)
    freeze_update_sprite_snow(sprite) unless freeze_weather?
  end
end #Spriteset_Weather

#============================================================================
# Spriteset_Map
#============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # alias method: update_tilemap -> don't update the tilemap if frozen
  #--------------------------------------------------------------------------
  alias freeze_update_tilemap update_tilemap
  def update_tilemap
    return freeze_update_tilemap unless FREEZE_SCREEN.screen_frozen?
    @tilemap.map_data = $game_map.data
    @tilemap.ox = $game_map.display_x * 32
    @tilemap.oy = $game_map.display_y * 32
    #@tilemap.update
  end
end #Spriteset_Map

#============================================================================
# Game_Map
#============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # alias method: update_events -> don't update the events if frozen
  #--------------------------------------------------------------------------
  alias freeze_update_events update_events
  def update_events
    freeze_update_events unless FREEZE_SCREEN.screen_frozen?
  end
  #--------------------------------------------------------------------------
  # alias method: update_vehicles -> don't update the vehicles if frozen
  # (not tested)
  #--------------------------------------------------------------------------
  alias freeze_update_vehicles update_vehicles
  def update_vehicles
    freeze_update_vehicles unless FREEZE_SCREEN.screen_frozen?
  end
end #Game_Map

#============================================================================
# Compatibility with Zeus's light and shadows script
#============================================================================
if $imported[:Zeus_Lights_Shadows]
class Game_Light_Shadow_Base
  #--------------------------------------------------------------------------
  # alias method: update_pattern -> probably useful to freeze too
  #--------------------------------------------------------------------------
  alias freeze_update_pattern update_pattern
  def update_pattern
    freeze_update_pattern unless FREEZE_SCREEN.screen_frozen?
  end
end #Game_Light_Shadow_Base

class Game_Light < Game_Light_Shadow_Base
  #--------------------------------------------------------------------------
  # alias method: update_flicker -> don't update the lights if frozen
  #--------------------------------------------------------------------------
  alias freeze_update_flicker update_flicker
  def update_flicker
    freeze_update_flicker unless FREEZE_SCREEN.screen_frozen?
  end
end #Game_Light
end #$imported[:Zeus_Lights_Shadows]

And the result:
timeswitch2-cut.gif

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/frozen-time-effect.180944/