@drei7717
Here's the script
CODE
#===============================================================================
# Zoom Script
# By Jet10985 (Jet)
# Original Code by: Zeriab
# Small fixes by: Piejamas
#===============================================================================
# This script will enable the user to zoom in and out of the map. It also allows
# them to have a classic looking map transfer if they want it.
# This script has: 15 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Spriteset_Map: initialize, dispose
# Game_Temp: initialize
# Scene_Map: update_transfer_player, call_battle, perform_battle_transition
#===============================================================================
=begin
How to zoom anywhere:
to zoom in a specific part, use the following script in an Event "Script..."
zoom_screen(duration, end_value, player, fade, fade_duration)
duration = time in frames for zoom to complete. 60 frames = 1 second
end_value = how far in the zoom goes, as in 10x size or 5x size. Use just number,
no x.
player = does the zoom zoom-in on the player? true or false. false will make
it so the zoom will zoom-in in the event that calls the zoom.
fade = true or false. true make the screen fade to black while zooming.
fade_duration = how long does it take to fade in frames? 60 frames = 1 second
You must specify duration AND end_value, but not always the rest.
If the others aren't specified, they will default like so:
player will be true
fade will be false
fade_duration will be 1
Ex. zoom_screen(120, 10)
This will zoom in on the player with a 10x zoom, and will last for 2 seconds
with no fading.
--------------------------------------------------------------------------------
How to end zoom:
to end the zoom, use the following script in an Event "Script..."
end_zoom_screen(zoom_out)
zoom_out = true or false. if true, it will end by zooming out.
if false, it will just revert back to regular map.
You can just put end_zoom_screen and it will assume that zoom_out is true
end_zoom_screen automatically detects if a fade occured during the zoom, and will
fade back in automatically.
--------------------------------------------------------------------------------
Notes:
While zoomed in, the player will not be able to move.
Pictures and message windows can still be displayed.
Pictures must have a Z value of 200+ in order to show above the zoom.
=end
module JetZoomScript
# When you transfer to a new map, do you want to have a cool zoom-in
# transfer? If false, you can skip down to ZOOM_BATTLE_TRANSFER.
ZOOM_TRANSFER = true
# With the zoom transfer, do you also want the screen to fade to black,
# then fade back normally when you're on the next map?
ZOOM_AND_FADE = false
# After the zoom transfer, you you want a zoom out effect instead of
# just the map?
ZOOM_OUT_AFTER_TRANSFER = false
# While transfering, do you want the previous map to slowly become
# intangible?
USE_OPACITY_CHANGE_ON_ZOOMSHOT = true
# What's the factor you want to zoom-in with on zoom transfers?
TRANSFER_ZOOM_AMOUNT = 10
# How long in frames does the transfer zoom take to zoom in?
# 60 frames = 1 second
TRANSFER_ZOOM_IN_TIME = 120
# This is the acceleration factor of the transfer zoom. The lower the factor,
# the higher it accelerates, so the higher the factor, the slower.
TRANSFER_ZOOM_FACTOR = 2.3
# How long in frames does the transfer zoom take to zoom out?
# Don't bother with this if ZOOM_OUT_AFTER_TRANSFER is false
# 60 frames = 1 second
TRANSFER_ZOOM_OUT_TIME = 120
# How long in frames does the transfer zoom take to fade to black?
# Don't bother with this if ZOOM_AND_FADE is false
# 60 frames = 1 second
TRANSFER_ZOOM_FADE_IN = 120
# How long in frames does the transfer zoom take to fade back into light?
# Don't bother with this if ZOOM_AND_FADE is false
# Also don't bother with this if ZOOM_OUT_AFTER_TRANSFER is false
# 60 frames = 1 second
TRANSFER_ZOOM_FADE_OUT = 120
# If this switch is on, then transfer zoom will be temporarily disabled.
NO_ZOOM_TRANSFER_SWITCH = 1
# Instead of the lame default battle enter sequence, do you want
# to zoom in on your character when entering into battle?
ZOOM_BATTLE_TRANSFER = false
# What's the factor you want to zoom-in with on zoom battle transfers?
BATTLE_TRANSFER_ZOOM_AMOUNT = 10
# How long in frames does the battle transfer zoom take to zoom in?
# 60 frames = 1 second
BATTLE_TRANSFER_ZOOM_IN_TIME = 100
# This is the acceleration factor of the battle transfer zoom. The lower the
# factor, the higher it accelerates, so the higher the factor, the slower.
BATTLE_TRANSFER_ZOOM_FACTOR = 2.3
end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Spriteset_Map
alias jet4762_initialize initialize unless $@
def initialize
jet4762_initialize
@disposed = false
end
alias jet7233_dispose dispose unless $@
def dispose
jet7233_dispose
@disposed = true
end
def disposed?
return @disposed
end
end
class Scene_Map
def spriteset
return @spriteset
end
end
class Game_Temp
attr_accessor :player_height, :display_x, :display_y
alias jet4672_initialize initialize unless $@
def initialize
jet4672_initialize
@player_height = 0
@display_x = 0
@display_y = 0
end
end
class Scene_Map < Scene_Base
include JetZoomScript
alias jet7833_update_transfer_player update_transfer_player unless $@
def update_transfer_player
if $game_switches[NO_ZOOM_TRANSFER_SWITCH] || !ZOOM_TRANSFER
jet7833_update_transfer_player
else
return unless $game_player.transfer?
zoom = (Graphics.brightness > 0 && $game_map.screen.brightness > 0)
fadeout = ZOOM_AND_FADE ? TRANSFER_ZOOM_FADE_OUT : -1
fadein = ZOOM_AND_FADE ? TRANSFER_ZOOM_FADE_IN : -1
zoom_screen(TRANSFER_ZOOM_IN_TIME, 1, TRANSFER_ZOOM_AMOUNT, fadeout) if zoom
if !USE_OPACITY_CHANGE_ON_ZOOMSHOT && ZOOM_OUT_AFTER_TRANSFER or
!USE_OPACITY_CHANGE_ON_ZOOMSHOT && ZOOM_AND_FADE &&
!ZOOM_OUT_AFTER_TRANSFER
@spriteset.dispose unless @spriteset.disposed?
$game_player.perform_transfer
$game_map.update
@spriteset = Spriteset_Map.new if @spriteset.disposed?
end
$game_map.autoplay
if ZOOM_OUT_AFTER_TRANSFER
zoom_screen(TRANSFER_ZOOM_OUT_TIME, TRANSFER_ZOOM_AMOUNT, 1, fadein) if zoom
end
if ZOOM_AND_FADE && !ZOOM_OUT_AFTER_TRANSFER
fadein(TRANSFER_ZOOM_FADE_IN)
end
end
end
def zoom_screen(duration, start_value, end_value, fade_duration)
$game_temp.player_height = @spriteset.player_height
$game_temp.display_x = $game_player.screen_x
$game_temp.display_y = $game_player.screen_y
Graphics.brightness = 255
@zoom_bitmap = Graphics.snap_to_bitmap
@zoom_sprite = Sprite.new
@zoom_sprite.z = 9999
@zoom_sprite.bitmap = @zoom_bitmap
if USE_OPACITY_CHANGE_ON_ZOOMSHOT && !ZOOM_OUT_AFTER_TRANSFER
@spriteset.dispose
$game_player.perform_transfer
$game_map.update
@spriteset = Spriteset_Map.new
end
do_zoom(duration, start_value, end_value, fade_duration)
@zoom_sprite.dispose
@zoom_bitmap.dispose
@zoom_sprite = nil
@zoom_bitmap = nil
end
def do_zoom(times, start_value, end_value, fade_duration)
value = start_value
if start_value > end_value && ZOOM_AND_FADE
Graphics.brightness = 0
end
for i in 0...times
percent = (i.to_f / times) ** TRANSFER_ZOOM_FACTOR
value = value + percent * (end_value - value)
if USE_OPACITY_CHANGE_ON_ZOOMSHOT and !(start_value > end_value)
@zoom_sprite.opacity -= 255 / TRANSFER_ZOOM_IN_TIME
@zoom_sprite.update
end
if ZOOM_AND_FADE
if start_value < end_value
Graphics.brightness -= 255 / fade_duration
elsif start_value > end_value
Graphics.brightness += 255 / fade_duration
end
end
zoom_sprite(@zoom_sprite, value)
Graphics.update
end
end
def zoom_sprite(sprite, amount)
sx = $game_temp.display_x
sy = $game_temp.display_y - $game_temp.player_height / 2
gw = Graphics.width
gh = Graphics.height
width = gw * amount
height = gh * amount
x = [sx * amount - (gw / 2), 0].max
x = [x, width - gw].min
y = [sy * amount - (gh / 2), 0].max
y = [y, height - gh].min
sprite.zoom_x = amount
sprite.zoom_y = amount
sprite.ox = x / amount
sprite.oy = y / amount
end
alias jet6592_call_battle call_battle unless $@
def call_battle
jet6592_call_battle
if ZOOM_BATTLE_TRANSFER
$game_temp.player_height = @spriteset.player_height
$game_temp.display_x = $game_player.screen_x
$game_temp.display_y = $game_player.screen_y
Graphics.brightness = 255
@zoom_bitmap = Graphics.snap_to_bitmap
@zoom_sprite = Sprite.new
@zoom_sprite.z = 199
@zoom_sprite.bitmap = @zoom_bitmap
value = 1
for i in 0...BATTLE_TRANSFER_ZOOM_IN_TIME
percent = (i.to_f / BATTLE_TRANSFER_ZOOM_IN_TIME) ** BATTLE_TRANSFER_ZOOM_FACTOR
value = value + percent * (BATTLE_TRANSFER_ZOOM_AMOUNT - value)
zoom_sprite(@zoom_sprite, value)
Graphics.update
end
end
end
alias jet4721_perform_battle_transition perform_battle_transition unless $@
def perform_battle_transition
if !ZOOM_BATTLE_TRANSFER
jet4721_perform_battle_transition
else
@zoom_sprite.dispose
@zoom_bitmap.dispose
@zoom_sprite = nil
@zoom_bitmap = nil
end
end
end
class Spriteset_Map
def player_height
@character_sprites[-1].height
end
end
class Game_Interpreter
def zoom_sprite(sprite, amount)
sx = $game_temp.display_x
sy = $game_temp.display_y - $game_temp.player_height / 2
gw = Graphics.width
gh = Graphics.height
width = gw * amount
height = gh * amount
x = [sx * amount - (gw / 2), 0].max
x = [x, width - gw].min
y = [sy * amount - (gh / 2), 0].max
y = [y, height - gh].min
sprite.zoom_x = amount
sprite.zoom_y = amount
sprite.ox = x / amount
sprite.oy = y / amount
end
def zoom_screen(times, end_value, player = true, fade = false,
fade_duration = 1)
$game_temp.player_height = $scene.spriteset.player_height
if player
$game_temp.display_x = $game_player.screen_x
$game_temp.display_y = $game_player.screen_y
else
$game_temp.display_x = $game_map.events[@original_event_id].screen_x
$game_temp.display_y = $game_map.events[@original_event_id].screen_y
end
Graphics.brightness = 255
@zoom_bitmap = Graphics.snap_to_bitmap
@zoom_sprite = Sprite.new
@zoom_sprite.z = 199
@zoom_sprite.bitmap = @zoom_bitmap
value = 1
@start_value = 1
@end_value = end_value
@fade = fade
@fade_duration = fade_duration
@times = times
if 1 > end_value && fade
Graphics.brightness = 0
end
for i in 0...times
percent = (i.to_f / times) ** 2.3
value = value + percent * (end_value - value)
if fade
if 1 < end_value
Graphics.brightness -= 255 / fade_duration
elsif 1 > end_value
Graphics.brightness += 255 / fade_duration
end
end
zoom_sprite(@zoom_sprite, value)
Graphics.update
end
end
def end_zoom_screen(zoom_out = true)
if zoom_out
value = @end_value
if @end_value > @start_value && @fade
Graphics.brightness = 0
end
for i in 0...@times
percent = (i.to_f / @times) ** 2.3
value = value + percent * (@start_value - value)
if @fade
if @start_value < @end_value
Graphics.brightness -= 255 / 60
elsif @start_value > @end_value
Graphics.brightness += 255 / 60
end
end
zoom_sprite(@zoom_sprite, value)
Graphics.update
end
end
@zoom_sprite.dispose
@zoom_bitmap.dispose
@zoom_sprite = nil
@zoom_bitmap = nil
end
end