This little script just makes it so you can have the fog shake around as you could the screen with the Screen Shake command. You have to establish that the map allows the fog to shake, and it only works with the default fog if any multiple fog scripts are in use. However, it allows you to set the intensity of the shake, and how long it can last.
Script
Shake n Bake
Code:
#==============================================================================
# ** Shaky Fog
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.0
# 03-03-2025 (mm/dd/yyyy)
# RGSS / RPGMaker XP
#==============================================================================
#
# INTRODUCTION:
#
# This little script just makes it so you can have the fog shake around as
# you could the screen with the Screen Shake command. You have to establish
# that the map allows the fog to shake, and it only works with the default
# fog if any multiple fog scripts are in use. However, it allows you to set
# the intensity of the shake, and how long it can last.
#
#
#------------------------------------------------------------------------------
#
# CONFIGURATION
#
# The Shaky_Map module just has one value, the MAP_IDs array. Fill it with
# the IDs of any map that is meant to have shaky fogs at start. It does not
# define any fogs FOR a map, but it does flag maps that can have shaky fogs.
#
# Maps must be defined as one that can have a shaking fog, otherwise they
# will assume the fogs are standard ones.
#
#
#------------------------------------------------------------------------------
#
# SCRIPT CALLS:
# =============
#
# * SHAKY FOG
# ---------
# Much like the [Screen Shake] event command, you can set the power, the
# speed, and the duration for a fog to shake. HOWEVER, you are able to
# use floating numbers (ie 1.5, 1.25... etc) in the calculations to more
# accurately handle the shake.
#
# SYNTAX: shaky_fog(power, speed, duration)
#
# - Power : How far left/right the fog slides
# - Speed : How fast the fog slides
# - Duration : (in frames) how long the effect lasts
# Set to 0 : Fog shake ends
# Set to -1: Shake has no duration except exiting the map
#
# NOTES: If the map is not defined as a shake-fog map, it does nothing
# until the map IS defined. The 'duration' begins counting down
# the moment it is called, so it is possible to wait too long.
#
#
# * SHAKY Map
# ---------
# This allows one to define maps that shake, or disable the shake effect
# from those already defined.
#
# SYNTAX: shaky_map(enable_bool [, map_id] )
#
# - enable_bool : (optional) True/False - Will a map have shaky fogs?
# - map_id : (optional) The ID of the map so affected
#
# NOTES: If the map_id is not supplied, it assumes the call is affecting
# the current map.
# If the enable_bool is nil, it assumes that the command is true
# and intends to set the map as a shaky map.
# Ergo, just using 'shaky_map' assumes you are setting the current
# map as a shaky map.
#
#==============================================================================
#
# TERMS OF USE:
#
# Free for use, even in commercial games. Only due credit is required.
#
#
#==============================================================================
#==============================================================================
# ** Shaky_Map
#------------------------------------------------------------------------------
# This module holds all configuration values for shaky map. Wowww----*
#==============================================================================
class Shaky_Map
MAP_IDs = [2] # IDs of maps already defined to allow shakes
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :shaky_map_ids # IDs of shakey maps
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias shakyfog_game_system_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#
# Perform the original method
shakyfog_game_system_initialize
#
# Populate the array with configuration defined IDs
@shaky_map_ids = Shaky_Map::MAP_IDs
#
end
end
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as change in color tone,
# flashing, etc. Refer to "$game_screen" for the instance of this class.
#==============================================================================
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias shakyfog_game_screen_initialize initialize
alias shakyfog_game_screen_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
#
# Perform the original method
shakyfog_game_screen_initialize
#
# Custom values for shaky fogs
@fog_shake_power = 0
@fog_shake_speed = 0
@fog_shake_timer = 0
@fog_shake_dir = 1
@fog_shake = 0
#
end
#--------------------------------------------------------------------------
# * Start Fog Shaking
# power : strength
# speed : speed
# duration : time
#--------------------------------------------------------------------------
def start_fog_shake(power, speed, duration)
#
@fog_shake_power = power
@fog_shake_speed = speed
@fog_shake_timer = duration
#
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
#
# Perform the original method
shakyfog_game_screen_update
#
# Determine if shake (duration or permanent)
effective = false
effective = true if @fog_shake_timer >= 1
effective = true if @fog_shake_timer == (-2)
#
# Execute shake system if shake
update_fog_shaker if effective or @fog_shake != 0
#
end
#--------------------------------------------------------------------------
# * Frame Update (when shaking the custom fog)
#--------------------------------------------------------------------------
def update_fog_shaker
#
# Determine if shake (duration or permanent)
duration = false
duration = true if @fog_shake_timer <= 1
duration = false if @fog_shake_timer == (-2)
#
# Calculate delta (x offset for fog on map) and shake the map
delta = (@fog_shake_power * @fog_shake_speed * @fog_shake_dir) / 10.0
if duration and @fog_shake * (@fog_shake + delta) < 0
@fog_shake = 0
else
@fog_shake += delta
end
#
# Change direction based on shake and shake power
@fog_shake_dir = -1 if @fog_shake > @fog_shake_power * 2
@fog_shake_dir = 1 if @fog_shake < - @fog_shake_power * 2
#
# Count down timer if shake has a temporary duration
return if @fog_shake_timer == (-2)
@fog_shake_timer -= 1 if @fog_shake_timer >= 1
#
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :shake_fog_name # fog file name
attr_accessor :shake_fog_hue # fog hue
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias shakyfog_game_map_setup setup
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
#
# Perform the original method
shakyfog_game_map_setup(map_id)
#
@shake_fog_name = ""
@shake_fog_hue = 0
#
# Execute change if a custom shaky fog
setup_shakey_map if $game_system.shaky_map_ids.include?(map_id)
#
end
#--------------------------------------------------------------------------
# * Setup (when entering a map with a custom shaking fog setting)
#--------------------------------------------------------------------------
def setup_shakey_map
#
# set tile set information in opening instance variables
tileset = $data_tilesets[@map.tileset_id]
#
@shake_fog_name = tileset.fog_name
@shake_fog_hue = tileset.fog_hue
@fog_name = ""
@fog_hue = 0
#
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias shakyfog_interpreter_command_204 command_204
#--------------------------------------------------------------------------
# * Shakey Fog
# power : strength
# speed : speed
# duration : time
#--------------------------------------------------------------------------
def shaky_fog(power, speed, duration)
#
# Set the current power levels
$game_screen.start_fog_shake(power, speed, duration * 2)
#
end
#--------------------------------------------------------------------------
# * Shaky Map
# enable : if enabling or disabling a map (by ID) as a shaky map
# map_id : Map ID
#--------------------------------------------------------------------------
def shaky_map(enable_bool=true, map_id=nil)
#
# If an invalid ID, assume the current Map
map_id = $game_map.map_id if map_id.nil?
map_id = $game_map.map_id if map_id == 0
#
# Add to the array if enable is true, else remove from the array
if enable_bool
unless $game_system.shaky_map_ids.include?(map_id)
$game_system.shaky_map_ids.push(map_id)
end
else
if $game_system.shaky_map_ids.include?(map_id)
$game_system.shaky_map_ids.delete(map_id)
end
end
#
# Go no further if not in the current map
return unless map_id == $game_map.map_id
#
# Remove the fog if not enabling, else add the fog based on the map
return shaky_map_disable unless enable_bool == true
shaky_map_enable
#
end
#--------------------------------------------------------------------------
# * Add default map fog setting to shaky fog settings and reset map's
#--------------------------------------------------------------------------
def shaky_map_enable
#
# If the current fog is assumed default
if $game_map.fog_name != "" and $game_map.shake_fog_name == ""
$game_map.shake_fog_name = $game_map.fog_name
$game_map.shake_fog_hue = $game_map.fog_hue
$game_map.fog_name = ""
$game_map.fog_hue = 0
end
#
end
#--------------------------------------------------------------------------
# * Restore default map fog setting from shaky fog and erase shaky fog's
#--------------------------------------------------------------------------
def shaky_map_disable
#
# If the current fog is a shaky fog, reset back to default
if $game_map.fog_name == "" and $game_map.shake_fog_name != ""
$game_map.fog_name = $game_map.shake_fog_name
$game_map.fog_hue = $game_map.shake_fog_hue
$game_map.shake_fog_name = ""
$game_map.shake_fog_hue = 0
end
#
end
#--------------------------------------------------------------------------
# * Change Map Settings
#--------------------------------------------------------------------------
def command_204
#
# Perform the original method
shakyfog_interpreter_command_204
#
# Get the current map ID
map_id = $game_map.map_id
#
# Go no further if in error OR if not a defined shaky map
return true if map_id.nil?
return true unless $game_system.shaky_map_ids.include?(map_id)
#
# Set values for shaky map
case @parameters[0]
when 1 # fog
$game_map.shake_fog_name = @parameters[1]
$game_map.shake_fog_hue = @parameters[2]
$game_map.fog_name = ""
$game_map.fog_hue = 0
end
# Continue
return true
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias shakyfog_spriteset_map_initialize initialize
alias shakyfog_spriteset_map_dispose dispose
alias shakyfog_spriteset_map_update update
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
#
# Perform the original method
shakyfog_spriteset_map_dispose
#
# Dispose of fog plane
@shake_fog.dispose
# Dispose of viewports
@viewport1a.dispose
#
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
#
# Perform the original method
shakyfog_spriteset_map_update
#
# Exit if no fog defined (first update performed prior to alias)
return if @shake_fog.nil?
#
# If shaky fog is different than current shaky fog
if @shake_fog_name != $game_map.shake_fog_name or
@shake_fog_hue != $game_map.shake_fog_hue
#
@shake_fog_name = $game_map.shake_fog_name
@shake_fog_hue = $game_map.shake_fog_hue
if @shake_fog.bitmap != nil
@shake_fog.bitmap.dispose
@shake_fog.bitmap = nil
end
if @shake_fog_name != ""
@shake_fog.bitmap = RPG::Cache.fog(@shake_fog_name, @shake_fog_hue)
end
#
Graphics.frame_reset
end
#
# Update fog plane
@shake_fog.zoom_x = $game_map.fog_zoom / 100.0
@shake_fog.zoom_y = $game_map.fog_zoom / 100.0
@shake_fog.opacity = $game_map.fog_opacity
@shake_fog.blend_type = $game_map.fog_blend_type
@shake_fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@shake_fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@shake_fog.tone = $game_map.fog_tone
#
# Set screen color tone and shake position
@viewport1a.tone = $game_screen.tone
@viewport1a.ox = $game_screen.fog_shake
#
# Update viewport
@viewport1a.update
#
end
end
Instructions
Its pretty basic. Set maps that lets the fog shake in an array, or use a script call to tag that map. Then use another script call to make the map shake, including intensity and duration.
FAQ
I think I made a variation months ago for Aveyond_Fan?
Compatibility
Designed for RPGMaker XP
Terms and Conditions
Free for use, even in commercial games. Only due credit is required.