- Joined
- Oct 9, 2018
- Messages
- 362
- Reaction score
- 243
- First Language
- Greek
- Primarily Uses
- RMVXA
Hello everyone!
Fixed Pictures to Map by modern algebra works just fine by itself, but i need it to be compatible
with Zeus81's Map Effects Zoom. When i use the zoom effect, the pictures do not stay in place.. They still follow the player. Gladly Zeus81 posted a "fix" additional script around line 490 by adding "@viewport2" it looks like this:
This does fix the pictures from moving and in zoom mode, but it makes the pictures "lose" the priority they have to be above everything.. This is what i need to fix..
EDIT: i saw that with the default tint the picture does not lose the priority to be above everything
It loses priority when i use Vlue's Advanced Game Time + Night/Day tint.
so i'll add this script too to the thread.. i thought it didn't matter..
Here are the 3 scripts
Fixed Pictures to Map by modern algebra works just fine by itself, but i need it to be compatible
with Zeus81's Map Effects Zoom. When i use the zoom effect, the pictures do not stay in place.. They still follow the player. Gladly Zeus81 posted a "fix" additional script around line 490 by adding "@viewport2" it looks like this:
Ruby:
class Spriteset_Map
alias zeus_map_effects_update update
def update
zeus_map_effects_update
@map_effects ||= Spriteset_Map_Effects.new(@viewport1, @viewport2)
@map_effects.update(@tilemap.oy)
end
EDIT: i saw that with the default tint the picture does not lose the priority to be above everything
It loses priority when i use Vlue's Advanced Game Time + Night/Day tint.
so i'll add this script too to the thread.. i thought it didn't matter..
Here are the 3 scripts
Ruby:
# Map Effects v1.4.1 for VX and VXace by Zeus81
# 30€ for commercial use
# Licence : http://creativecommons.org/licenses/by-nc-nd/4.0/
# Contact : zeusex81@gmail.com
# (fr) Manuel d'utilisation : https://www.dropbox.com/s/lb1d3q9jmx53taf/Map%20Effects%20Doc%20Fr.txt
# (en) User Guide : https://www.dropbox.com/s/sk3uwq2bleoxr7s/Map%20Effects%20Doc%20En.txt
# Demo : https://www.dropbox.com/s/2ex6906dyehl7an/Map%20Effects.zip
$imported ||= {}
$imported[:Zeus_Map_Effects] = __FILE__
def xp?() false end ; def vx?() false end ; def vxace?() false end
RUBY_VERSION == '1.8.1' ? defined?(Hangup) ?
def xp?() true end : def vx?() true end : def vxace?() true end
class << Graphics
def snap_elements_to_bitmap(*elements)
if !@snap_elements_back or @snap_elements_back.disposed?
@snap_elements_back = Sprite.new
@snap_elements_back.bitmap = Bitmap.new(1, 1)
@snap_elements_back.bitmap.set_pixel(0, 0, Color.new(0, 0, 0))
@snap_elements_back.z = 0x0FFF_FFFF
end
@snap_elements_back.zoom_x = width
@snap_elements_back.zoom_y = height
@snap_elements_back.visible = true
elements.each {|element| element.z += 0x1FFF_FFFF}
bmp = snap_to_bitmap rescue retry
@snap_elements_back.visible = false
elements.each {|element| element.z -= 0x1FFF_FFFF}
return bmp
end
end
module Math
module_function
def min(x, y) x < y ? x : y end
def max(x, y) x < y ? y : x end
def middle(min, x, max) x < max ? x < min ? min : x : max end
end
module Zeus
module Animation
def animate(variable, target_value, duration=0, ext=nil)
@za_animations ||= {}
base_value = Marshal.load(Marshal.dump(instance_variable_get(variable)))
if duration < 1
update_animation_value(variable, base_value, target_value, 1, 1, ext)
@za_animations.delete(variable)
else
@za_animations[variable] = [base_value, target_value, 0, duration.to_i, ext]
end
end
def animating?
@za_animations and !@za_animations.empty?
end
def clear_animations
@za_animations and @za_animations.clear
end
def memorize_animations(variables = instance_variables)
data = {}
variables.each {|var| data[var.to_sym] = instance_variable_get(var)}
data.delete(:@za_memorize)
@za_memorize = Marshal.dump(data)
end
def restore_animations
return unless @za_memorize
Marshal.load(@za_memorize).each {|var,value| instance_variable_set(var,value)}
end
def update_animations
return unless @za_animations
@za_animations.delete_if do |variable, data|
data[2] += 1
update_animation_value(variable, *data)
data[2] == data[3]
end
end
private
def calculate_next_value(base_value, target_value, duration, duration_total)
base_value + (target_value - base_value) * duration / duration_total
end
def update_animation_value(variable, base_value, target_value, duration, duration_total, ext)
method_name = "update_animation_variable_#{variable.to_s[1..-1]}"
method_name = "update_animation_#{base_value.class}" unless respond_to?(method_name)
send(method_name, variable, base_value, target_value, duration, duration_total, ext)
end
def update_animation_Color(variable, base_value, target_value, duration, duration_total, ext)
value = instance_variable_get(variable)
value.red = calculate_next_value(base_value.red , target_value.red , duration, duration_total)
value.green = calculate_next_value(base_value.green, target_value.green, duration, duration_total)
value.blue = calculate_next_value(base_value.blue , target_value.blue , duration, duration_total)
value.alpha = calculate_next_value(base_value.alpha, target_value.alpha, duration, duration_total)
end
def update_animation_Tone(variable, base_value, target_value, duration, duration_total, ext)
value = instance_variable_get(variable)
value.red = calculate_next_value(base_value.red , target_value.red , duration, duration_total)
value.green = calculate_next_value(base_value.green, target_value.green, duration, duration_total)
value.blue = calculate_next_value(base_value.blue , target_value.blue , duration, duration_total)
value.gray = calculate_next_value(base_value.gray , target_value.gray , duration, duration_total)
end
def update_animation_Float(variable, base_value, target_value, duration, duration_total, ext)
value = calculate_next_value(base_value, target_value, duration, duration_total)
instance_variable_set(variable, value)
end
alias update_animation_Fixnum update_animation_Float
alias update_animation_Bignum update_animation_Float
end
end
class Game_Map_Effects
include Zeus::Animation
attr_accessor :active, :refresh_rate, :back, :x, :y, :ox, :oy, :angle,
:zoom_x, :zoom_y, :mirror, :opacity, :blend_type, :color, :tone,
:hue, :wave_amp, :wave_length, :wave_speed, :wave_phase,
:pixelize, :blur_division, :blur_fade, :blur_animation,
:gaussian_blur_length, :linear_blur_angle, :linear_blur_length,
:radial_blur_angle, :zoom_blur_length, :motion_blur_rate
def initialize
@active = true
@refresh_rate = 30.0
clear
end
def clear
@back = false
@x = @ox = Graphics.width / 2
@y = @oy = Graphics.height / 2
@zoom_x = 1.0
@zoom_y = 1.0
@zoom2 = Math.sqrt(100.0)
@angle = 0.0
@wave_amp = 0.0
@wave_length = 180
@wave_speed = 360
@wave_phase = 0.0
@mirror = false
@opacity = 255
@blend_type = 0
@color ||= Color.new(0, 0, 0, 0)
@color.set(0, 0, 0, 0)
@tone ||= Tone.new(0, 0, 0, 0)
@tone.set(0, 0, 0, 0)
@hue = 0
@pixelize = 1.0
@pixelize2 = Math.sqrt(100.0)
@blur_division = 4.0
@blur_fade = 1.0
@blur_animation = 0.0
@gaussian_blur_length = 0.0
@linear_blur_angle = 0.0
@linear_blur_length = 0.0
@radial_blur_angle = 0.0
@zoom_blur_length = 0.0
@motion_blur_rate = 0.0
clear_animations
end
alias memorize memorize_animations
alias restore restore_animations
alias update update_animations
def active?
return false unless @active
animating? or blur? or @mirror or @blend_type != 0 or
@zoom_x != 1 or @zoom_y != 1 or @pixelize > 1 or
@angle % 360 != 0 or @hue.to_i % 360 != 0 or @color.alpha != 0 or
@tone.red != 0 or @tone.green != 0 or @tone.blue != 0 or @tone.gray != 0 or
(@wave_amp * @zoom_x >= 1 and @wave_length * @zoom_y >= 1)
end
def blur?
return false if @blur_division < 1
@gaussian_blur_length != 0 or @linear_blur_length != 0 or
@radial_blur_angle != 0 or @zoom_blur_length != 0 or @motion_blur_rate != 0
end
def refresh_bitmap?
@refresh_rate > 0 and
Graphics.frame_count % (Graphics.frame_rate / @refresh_rate.to_f) < 1
end
def tilemap_wave_sync(tilemap_oy)
return 0 if @wave_length == 0
tilemap_oy * @wave_speed / @wave_length.to_f
end
def blur_animation_offset
return 0 if @blur_animation == 0
1 - @blur_animation * Graphics.frame_count / Graphics.frame_rate.to_f % 1
end
def refresh_motion_blur?
@blur_division >= 1 and @motion_blur_rate > 0 and
Graphics.frame_count % @motion_blur_rate < 1
end
def set_origin(x, y, duration=0)
x = x * Graphics.width / 100
y = y * Graphics.height / 100
animate(:@x , x, duration)
animate(:@y , y, duration)
animate(:@ox, x, duration)
animate(:@oy, y, duration)
end
def set_zoom(zoom, duration=0, center_on_player=true)
zoom = Math.sqrt(Math.max(1, zoom))
animate(:@zoom2, zoom, duration, center_on_player)
end
def update_animation_variable_zoom2(variable, base_value, target_value, duration, duration_total, center_on_player)
update_animation_Float(variable, base_value, target_value, duration, duration_total, nil)
@zoom_y = @zoom_x = @zoom2 ** 2 / 100.0
display_ratio = Game_Map::DisplayRatio.to_f
if center_on_player
x = $game_player.real_x / display_ratio
y = $game_player.real_y / display_ratio
else
x = $game_map.display_x / display_ratio + $game_map.screen_tile_x / 2
y = $game_map.display_y / display_ratio + $game_map.screen_tile_y / 2
end
$game_player.center(x, y)
end
def set_angle(angle, duration=0)
animate(:@angle, angle, duration)
end
def set_opacity(opacity, duration=0)
opacity = opacity * 255 / 100
animate(:@opacity, opacity, duration)
end
def set_color(red, green, blue, alpha, duration=0)
animate(:@color, Color.new(red, green, blue, alpha), duration)
end
def set_tone(red, green, blue, gray, duration=0)
animate(:@tone, Tone.new(red, green, blue, gray), duration)
end
def set_hue(hue, duration=0)
animate(:@hue, hue, duration)
end
def set_wave(amp, length, speed, duration=0)
animate(:@wave_amp , amp , duration)
animate(:@wave_length, length, duration)
animate(:@wave_speed , speed , duration)
end
def set_pixelize(pixelize, duration=0)
pixelize = Math.sqrt(Math.max(100, pixelize))
animate(:@pixelize2, pixelize, duration)
end
def update_animation_variable_pixelize2(variable, base_value, target_value, duration, duration_total, ext)
update_animation_Float(variable, base_value, target_value, duration, duration_total, ext)
@pixelize = @pixelize2 ** 2 / 100.0
end
def setup_blur(division, fade, animation, duration=0)
division = Math.middle(0, division, 16)
animate(:@blur_division , division , duration)
animate(:@blur_fade , fade , duration)
animate(:@blur_animation, animation, duration)
end
def set_gaussian_blur(length, duration=0)
animate(:@gaussian_blur_length, length, duration)
end
def set_linear_blur(angle, length, duration=0)
animate(:@linear_blur_angle , angle , duration)
animate(:@linear_blur_length, length, duration)
end
def set_radial_blur(angle, duration=0)
animate(:@radial_blur_angle, angle, duration)
end
def set_zoom_blur(zoom, duration=0)
length = Math.max(1, zoom) / 100.0 - 1
animate(:@zoom_blur_length, length, duration)
end
def set_motion_blur(rate, duration=0)
animate(:@motion_blur_rate, rate, duration)
end
end
class Spriteset_Map_Effects
Blur_Offset = [[0.7,0.7], [-0.7,-0.7], [-0.7,0.7], [0.7,-0.7],
[0,1], [0,-1], [1,0], [-1,0]]
def initialize(*viewports)
@map_viewports = viewports
@viewport = Viewport.new(viewports[0].rect)
@viewport.z = viewports[0].z
@viewport.visible = false
@effects_sprites = []
@effects_bitmaps = []
@data = $game_map.effects
end
def dispose(dispose_viewport=true)
@effects_sprites.each {|sprite| sprite.dispose}
@effects_sprites.clear
@effects_bitmaps.each {|bitmap| bitmap.dispose if bitmap}
@effects_bitmaps.clear
@pixelize_bitmap.dispose if @pixelize_bitmap
@pixelize_bitmap = nil
@back_sprite.dispose if @back_sprite
@back_sprite = nil
if dispose_viewport
@viewport.dispose
else
@viewport.visible = false
@map_viewports.each {|viewport| viewport.visible = true}
end
end
def update(tilemap_oy = 0)
unless @data.active?
dispose(false) if @viewport.visible
return
end
@viewport.visible = true
@motion_blur_refresh ||= @data.refresh_motion_blur?
refresh_sprites
if !@effects_bitmaps[0] or @data.refresh_bitmap?
refresh_bitmaps
refresh_pixelize
end
refresh_back
wave_sync = @data.tilemap_wave_sync(tilemap_oy)
blur_offset = @data.blur_animation_offset
@effects_sprites.each_with_index do |sprite, id|
update_effects(sprite, id, wave_sync)
update_pixelize(sprite) if @pixelize_bitmap
update_blur(sprite, id, blur_offset) if id > 0
end
@data.wave_phase = @effects_sprites[0].wave_phase - wave_sync
end
def refresh_sprites
n = (@data.blur? ? @data.blur_division.to_i+1 : 1) - @effects_sprites.size
n.times {@effects_sprites << Sprite.new(@viewport)}
(-n).times {@effects_sprites.pop.dispose}
end
def refresh_bitmaps
n = (@data.motion_blur_rate == 0 ? 1 : @effects_sprites.size) - @effects_bitmaps.size
n.times {@effects_bitmaps << nil}
(-n).times {bmp = @effects_bitmaps.pop and bmp.dispose}
@map_viewports.each {|viewport| viewport.visible = true}
@effects_bitmaps.unshift(@effects_bitmaps.pop) if @motion_blur_refresh
@effects_bitmaps[0].dispose if @effects_bitmaps[0]
@effects_bitmaps[0] = Graphics.snap_elements_to_bitmap(*@map_viewports)
@effects_bitmaps[0].hue_change(@data.hue % 360) if @data.hue.to_i % 360 != 0
@map_viewports.each {|viewport| viewport.visible = false}
@motion_blur_refresh = false
end
def refresh_pixelize
if @data.pixelize > 1
bmp = @effects_bitmaps[0]
@pixelize_rect ||= Rect.new(0, 0, 0, 0)
@pixelize_rect.width = Math.max(1, bmp.width / @data.pixelize)
@pixelize_rect.height = Math.max(1, bmp.height / @data.pixelize)
@pixelize_bitmap ||= Bitmap.new(bmp.width, bmp.height)
@pixelize_bitmap.clear
@pixelize_bitmap.stretch_blt(@pixelize_rect, bmp, bmp.rect)
elsif @pixelize_bitmap
@pixelize_bitmap.dispose
@pixelize_bitmap = nil
end
end
def refresh_back
if @data.back
@back_sprite ||= Sprite.new(@viewport)
@back_sprite.bitmap = @effects_bitmaps[0]
elsif @back_sprite
@back_sprite.dispose
@back_sprite = nil
end
end
def update_effects(sprite, id, wave_sync)
sprite.bitmap = @effects_bitmaps[id] || @effects_bitmaps[0]
sprite.x = @data.x
sprite.y = @data.y
sprite.z = id + 1
sprite.ox = @data.ox
sprite.oy = @data.oy
sprite.zoom_x = @data.zoom_x
sprite.zoom_y = @data.zoom_y
sprite.angle = @data.angle % 360
sprite.wave_amp = @data.wave_amp * @data.zoom_x
sprite.wave_length = @data.wave_length * @data.zoom_y
sprite.wave_speed = @data.wave_speed * @data.zoom_y
sprite.wave_phase = @data.wave_phase + wave_sync
sprite.mirror = @data.mirror
sprite.opacity = @data.opacity
sprite.blend_type = @data.blend_type
sprite.color = @data.color
sprite.tone = @data.tone
sprite.update
end
def update_pixelize(sprite)
pzx = @pixelize_bitmap.width / @pixelize_rect.width.to_f
pzy = @pixelize_bitmap.height / @pixelize_rect.height.to_f
sprite.bitmap = @pixelize_bitmap
sprite.src_rect = @pixelize_rect
sprite.x -= sprite.ox - (sprite.ox /= pzx).to_i * pzx
sprite.y -= sprite.oy - (sprite.oy /= pzy).to_i * pzy
sprite.zoom_x *= pzx
sprite.zoom_y *= pzy
end
def update_blur(sprite, id, blur_offset)
update_blur_opacity(sprite, id-blur_offset)
update_gaussian_blur(sprite, id) if @data.gaussian_blur_length != 0
update_linear_blur(sprite, id-blur_offset) if @data.linear_blur_length != 0
update_radial_blur(sprite, id-blur_offset) if @data.radial_blur_angle != 0
update_zoom_blur(sprite, id-blur_offset) if @data.zoom_blur_length != 0
end
def update_blur_opacity(sprite, id)
sprite.opacity /= (id < 1 ? 2 : id+1) **
(1 + @data.blur_fade / (@data.blur_division*20.0))
end
def update_gaussian_blur(sprite, id)
box, boy = *Blur_Offset[(id-1)%8]
offset = ((id+3)/4) / ((@data.blur_division.to_i+3)/4).to_f *
@data.gaussian_blur_length
sprite.x += (offset.ceil * box).round
sprite.y += (offset.ceil * boy).round
end
def update_linear_blur(sprite, id)
radian = @data.linear_blur_angle * Math::PI / 180
offset = id * @data.linear_blur_length / @data.blur_division.to_f
sprite.x += offset * Math.cos( radian)
sprite.y += offset * Math.sin(-radian)
end
def update_zoom_blur(sprite, id)
zoom = 1 + id * @data.zoom_blur_length / @data.blur_division.to_f
sprite.zoom_x *= zoom
sprite.zoom_y *= zoom
end
def update_radial_blur(sprite, id)
sprite.angle += id * @data.radial_blur_angle / @data.blur_division.to_f
sprite.angle %= 360
end
end
class Game_Map
if vx?
def screen_tile_x() Graphics.width / 32 end
def screen_tile_y() Graphics.height / 32 end
DisplayRatio = 256
else
DisplayRatio = 1
end
def zoom_ox
return 0 unless effects.active and effects.zoom_x > 1
(1 - 1 / effects.zoom_x) * screen_tile_x / 2
end
def zoom_oy
return 0 unless effects.active and effects.zoom_y > 1
(1 - 1 / effects.zoom_y) * screen_tile_y / 2
end
def limit_x(x)
ox = zoom_ox
min = DisplayRatio * -ox
max = DisplayRatio * (width - screen_tile_x + ox)
x < max ? x < min ? min : x : max
end
def limit_y(y)
oy = zoom_oy
min = DisplayRatio * -oy
max = DisplayRatio * (height - screen_tile_y + oy)
y < max ? y < min ? min : y : max
end
def set_display_x(x)
x = loop_horizontal? ? x % (width * DisplayRatio) : limit_x(x)
@parallax_x += x - @display_x if @parallax_loop_x or !loop_horizontal?
@display_x = x
end
def set_display_y(y)
y = loop_vertical? ? y % (height * DisplayRatio) : limit_y(y)
@parallax_y += y - @display_y if @parallax_loop_y or !loop_vertical?
@display_y = y
end
def set_display_pos(x, y) set_display_x(x); set_display_y(y) end
def scroll_down(distance) set_display_y(@display_y + distance) end
def scroll_left(distance) set_display_x(@display_x - distance) end
def scroll_right(distance) set_display_x(@display_x + distance) end
def scroll_up(distance) set_display_y(@display_y - distance) end
def effects() @effects ||= Game_Map_Effects.new end
alias zeus_map_effects_update update
def update(*args)
zeus_map_effects_update(*args)
effects.update
end
end
class Game_Interpreter
def map_effects
$game_map.effects
end
end
class Game_Player
def center(x, y)
$game_map.set_display_pos(x*256-CENTER_X, y*256-CENTER_Y)
end
end if vx?
class Spriteset_Map
alias zeus_map_effects_update update
def update
zeus_map_effects_update
@map_effects ||= Spriteset_Map_Effects.new(@viewport1, @viewport2)
@map_effects.update(@tilemap.oy)
end
alias zeus_map_effects_dispose dispose
def dispose
zeus_map_effects_dispose
@map_effects.dispose
end
end
$imported[:Zeus_Weather_Viewport] ||= __FILE__
if $imported[:Zeus_Weather_Viewport] == __FILE__
class Spriteset_Map
alias zeus_weather_viewport_create_weather create_weather
def create_weather
zeus_weather_viewport_create_weather
@weather.weather_viewport = @viewport1
end
end
class Spriteset_Weather
if vx?
def weather_viewport=(viewport)
for sprite in @sprites
sprite.viewport = viewport
sprite.z = 0x8000
end
end
else
attr_accessor :weather_viewport
alias zeus_weather_viewport_add_sprite add_sprite
def add_sprite
zeus_weather_viewport_add_sprite
@sprites[-1].viewport = @weather_viewport
@sprites[-1].z = 0x8000
end
end
end
end
Ruby:
#==============================================================================
# Fix Picture to Map
# Version: 1.0.2 [VXA]
# Author: modern algebra (rmrk.net)
# Date: 8 September, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This allows you to set the position of a picture by the X and Y position
# of the map, rather than the screen, so that the picture won't move with you
# when the screen scrolls. Additionally, the script lets you set the Z value
# to show below characters, or even below the tiles or below the parallax.
#
# This script has no effect in battle and pictures there behave normally.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials.
#
# To specify that a picture should be fixed to a map and not follow the
# screen, all you need to do is turn an in-game switch on before showing the
# picture. To specify which switch, all you need to do is change the value of
# SWITCH_ID at line 60. Alternatively, you can include the code [Fixed]
# somewhere in the name of the picture.
#
# For the fixed pictures, you also have the option of assigning it to grid
# coordinates instead of pixel coordinates. This means that if you wanted it
# to show up at (3, 5) in the map, you could set it to that directly instead
# of (96, 160). You can turn on this feature using another switch, again one
# which you choose by changing the value of COORDINATES_SWITCH_ID at line 63.
#
# To specify the layer of the tilemap (what shows above it and what shows
# below it), all you need to do is change the value of a variable. Which
# variable is also specifed by you by changing Z_VARIABLE_ID at line 69.
# The value to which that in-game variable is set at the time a picture is
# shown determines where the picture will show up. If the variable is set to
# 0 then it will be in its normal place; if set to -1, it will show below
# the tilemap but above the parallax; if set to -2, it will show below the
# parallax; if set to 1, it will show above all non-star tiles but star tiles
# and characters with normal priority; if set to 2, it will show above
# characters with normal priority but below characters with "Above
# Characters" priority. If set to any other value, the z value of the picture
# will be set to that directly.
#==============================================================================
$imported = {} unless $imported
$imported[:MA_FixPictureToMap] = true
#==============================================================================
# *** MA_FixPicture
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This module holds some relevant configuration Data
#==============================================================================
module MA_FixPicture
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# Editable Region
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# SWITCH_ID - set this to the ID of the in-game switch that you want to
# use to control whether pictures should be fixed.
SWITCH_ID = 50
# COORDINATES_SWITCH_ID - Set this to the ID of the in-game switch that you
# want to use to control how coordinates are set. If this switch is ON, then
# for fixed pictures, you can just use the grid x and y coordinates (ie: you
# would set (1, 4) instead of (32, 128). If you always want this feature to
# be on when the FPM Switch is on, you can set it to have the same ID.
COORDINATES_SWITCH_ID = 52
# Z_VARIABLE_ID - set this to the ID of the in-game variable that you
# want to use to control the z-value priority of the picture.
Z_VARIABLE_ID = 60
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# End Editable Region
#////////////////////////////////////////////////////////////////////////////
class << self
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :spriteset_vp1
attr_accessor :spriteset_vp2
end
end
#==============================================================================
# ** Game Picture
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new public instance variables - mafpm_vp_id; mafpm_fixed; mafpm_z
# aliased method - initialize; show; move
#==============================================================================
class Game_Picture
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :mafpm_vp_id
attr_accessor :mafpm_fixed
attr_accessor :mafpm_z
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_iniz_2fg6 initialize
def initialize(*args, &block)
@mafpm_fixed = false
@mafpm_vp_id = 2
mafpm_iniz_2fg6(*args, &block) # Call Original Method
@mafpm_z = self.number
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Show Picture
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_showpic_3jb7 show
def show(name, *args, &block)
# Only fix pictures if in Scene_Map
if SceneManager.scene_is?(Scene_Map)
@mafpm_fixed = (MA_FixPicture::SWITCH_ID == true ||
$game_switches[MA_FixPicture::SWITCH_ID] || !name[/\[FIXED\]/i].nil?)
z_var = $game_variables[MA_FixPicture::Z_VARIABLE_ID]
# If 0 or less than 300, then it should belong to the viewport1
@mafpm_vp_id = (z_var != 0 && z_var < 300) ? 1 : 2
# Set Z shortcuts
@mafpm_z = case z_var
when -1 then -50 # Below tilemap but above parallax
when -2 then -150 # Below parallax
when 0 then self.number # Normal position
when 1 then 50 # Above tilemap but below normal characters
when 2 then 150 # Above normal characters but below Above Characters
else
@mafpm_z = z_var < 300 ? z_var : z_var - 300 # Directly set to value
end
end
mafpm_showpic_3jb7(name, *args, &block) # Call Original Method
if @mafpm_fixed && (MA_FixPicture::COORDINATES_SWITCH_ID == true || $game_switches[MA_FixPicture::COORDINATES_SWITCH_ID])
@x *= 32
@y *= 32
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Move Picture
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_movepctr_2js1 move
def move(*args, &block)
mafpm_movepctr_2js1(*args, &block)
if @mafpm_fixed && (MA_FixPicture::COORDINATES_SWITCH_ID == true || $game_switches[MA_FixPicture::COORDINATES_SWITCH_ID])
@target_x *= 32
@target_y *= 32
end
end
end
#==============================================================================
# ** Sprite Picture
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - update
#==============================================================================
class Sprite_Picture
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_updt_5fw1 update
def update(*args, &block)
mafpm_updt_5fw1(*args, &block) # Call original method
# If picture is fixed to map
if @picture.mafpm_fixed
# Scroll the picture appropriately
self.x = @picture.x - ($game_map.display_x * 32)
self.y = @picture.y - ($game_map.display_y * 32)
end
self.z = @picture.mafpm_z # Update Z to the correct Z
# If the viewport has changed
if @mafpm_vp_id != @picture.mafpm_vp_id && MA_FixPicture.send(:"spriteset_vp#{@picture.mafpm_vp_id}")
@mafpm_vp_id = @picture.mafpm_vp_id
# Change viewport
self.viewport = MA_FixPicture.send(:"spriteset_vp#{@mafpm_vp_id}")
end
end
end
#==============================================================================
# ** Spriteset Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - create_viewports; dispose_viewports
#==============================================================================
class Spriteset_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Viewports
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_creatviewpor_3dk8 create_viewports
def create_viewports(*args, &block)
mafpm_creatviewpor_3dk8(*args, &block) # Call original method
# Set the viewports to be globally accessible
MA_FixPicture.spriteset_vp1 = @viewport1
MA_FixPicture.spriteset_vp2 = @viewport2
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose Viewports
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mafpm_disposevps_2nr5 dispose_viewports
def dispose_viewports(*args, &block)
# Nullify the variables in MA_FixPicture
MA_FixPicture.spriteset_vp1 = nil
MA_FixPicture.spriteset_vp2 = nil
mafpm_disposevps_2nr5(*args, &block) # Call original method
end
end
Ruby:
#Advanced Game Time + Night/Day v1.6e
#----------#
#Features: Provides a series of functions to set and recall current game time
# as well customizable tints based on current game time to give the
# appearance of night and day in an advanced and customizable way.
#
#Usage: Script calls:
# GameTime.sec? #current second
# GameTime.min? #current minute
# GameTime.hour? #current hour
# GameTime.hour_nom? #current hour (12-hour)
# GameTime.day? #current day of month
# GameTime.day_week? #current day of the week
# GameTime.day_year? #current day of the year
# GameTime.month? #current month
# GameTime.year? #current year
# GameTime.year_post("set") #changes the year post to set
# GameTime.pause_tint(true/false) #pauses/unpauses tint
# GameTime.notime(true/false) #stops time based on true/false
# GameTime.change(s,m,h,d,dw,mn,y) #manually set the time
# seconds,minutes,hours,days,weekday,months,years
# any can be nil to not be changed
# GameTime.set("handle",n) #increases a certain time portion
# valid arguments are:
# addsec,addmin,addhour,addday
# addmonth,addyear
# and:
# remsec,remmin,remhour,remday
# remmonth,remyear
# GameTime.clock?(true/false) #hides/shows the clock
# GameTime.save_time #saves the current time
# GameTime.load_time #loads the saved time
#
# Message Codes:
# GTSEC #Inputs the current second
# GTMIN #Inputs the current minute
# GTHOUR #Inputs the current hour
# GTMERI #Inputs AM/PM depending
# GTDAYN #Inputs the day of the month
# GTDAYF #Inputs the day of the week (full)
# GTDAYA #Inputs the day of the week (abbreviated)
# GTMONN #Inputs the month of the year
# GTMONF #Inputs the name of the month (full)
# GTMONA #Inputs the name of the month (abbreviated)
# GTYEAR #Inputs the current year
#
# Map Note Tags: (These go in the note box of Map Properties)
# Notint #These maps will not tint!
# Notime #Stops time from moving in that map
#
#Customization: Set below, in comments.
#
#Examples: GameTime.pause_tint(false)
# GameTime.change(nil,30,4,1,1,1,2012)
# GameTime.set("addyear",5)
# GameTime.clock?(true)
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
# given by email: sumptuaryspade@live.ca
# provided on facebook: http://www.facebook.com/DaimoniousTailsGames
# All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
#_# BEGIN_CUSTOMIZATION #_#
#What time a new game starts at: [sec, min, hour, day, month, year]
START_TIME = [0,0,11,0,0,1]
#Wether or not to set time to PC (Real) Time
$USE_REAL_TIME = false
#Time does not increase while the message window is visible:
NOTIMEMESSAGE = false
#Time does not increase unless you are on the map
PAUSE_IN_MENUS = true
#Time does not increase if you are in battle
NOBATTLETIME = false
#Clock is shown
USECLOCK = false
#Set to true to have the clock show up in the menu!
USECLOCK_MENU = false
#Set the format for the clock both in and out of menu
#1. hh:mm am/pm
#2. Sun dd hh:mm am/pm
#3. Custom clock, see below
CLOCK_FORMAT = 3
MENU_CLOCK_FORMAT = 2
#Set to true for a Twenty four hour clock
TF_HOUR_CLOCK = false
#Clock window background opacity
CLOCK_BACK = 75
#Whether to use a special image for the back of the clock or not (Picture folder)
CUSTOM_CLOCK_BACKGROUND = false
#The name of the special image to use
CUSTOM_CLOCK_BACKGROUND_IMAGE = ""
#The offset of the image on the x-axis
CUSTOM_CLOCK_BACKGROUND_X = 0
#The offset of the image on the y-axis
CUSTOM_CLOCK_BACKGROUND_Y = 0
#Button to be used to toggle the clock
CLOCK_TOGGLE = :ALT
#Toggle Options - :off, :hour12, :hour24
CLOCK_TOGGLE_OPTIONS = [:off, :hour24]
#X and Y position of clock
CLOCK_X = Graphics.width - 175
CLOCK_Y = Graphics.height - 48 - 24 - 12
#Finetune the width of the clock window here:
CLOCK_WIDTH = 175
#Whether or not those little dots on the clock blink
USE_BLINK = false
#The speed at which they blink
BLINK_SPEED = 120
#Here is where you would insert the array of commands for the custom clock:
CUSTOM_CLOCK = ["day","monthlong","year"]
CUSTOM_CLOCK2 = ["hourtog","blinky","min","meri"]
#Available commands for CUSTOM_CLOCK:
# "sec" - seconds "min" - minutes
# "hour" - hour (24) "hour12" - hour (12)
# "hourtog" - hour toggle (12, 24)
# "meri" - AM/PM "day" - day of the month
# "weekshort" - day of the week abbr
# "weeklong" - day of the week long
# "month" - month "monthshort" - month name abbr
# "monthlong" - month name
# "year" - year "yearp" - year post
# "blinky" - those blinky dots
#Using KHAS lighting effects script? Turn this on to use that tint
USE_KHAS = false
#Using Victor Engine Light effects? Turn this on to use that tint
USE_VICTOR = false
#Variables that count down each gametime second/minute
TIMER_VARIABLES = [11]
#Use Tint in the Battles
BATTLE_TINT = false
#Time it takes for a second (or minute) to pass, in frames by default
#(Frame rate is 60 frames per second)
DEFAULT_TIMELAPSE = 60
#Variable ID containing the current speed of time!
TIMELAPSE_VARIABLE = 12
#Whether to use seconds or not
NOSECONDS = true
#Number of seconds in a minute
SECONDSINMIN = 60
#Number of minutes in an hour
MINUTESINHOUR = 60
#Number of hours in a day
HOURSINDAY = 24
#Names of the days (As little or as many days in the week as you want)
DAYNAMES = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
#Day name abbreviations
DAYNAMESABBR = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
#Number of days in each month (Also represents number of months in a year)
MONTHS = [31,28,31,30,31,30,31,31,30,31,30,31]
#Names of the months
MONTHNAMES = ["January","February","March","April","May","June",
"July","August","September","October","November","December"]
#Abrreviated names of the months
MONTHNAMESABBR = ["Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"]
#The default letters to be posted before the year in dates
DEFAULT_YEAR_POST = ""
#NOT YET IMPLEMENTED *IGNORE*
USE_PERIODS = false
#Gradual tint effects! (The hardest part)
#It may look daunting, and it is, but here is where you put the tint
#to be shown at each hour (the actual tint is usually somewhere in between)
#The number of Color.new objects here must equal the number of hours in a day
#Starts from hour 0 (or 12am)
#A color object is -> Color.new(r,g,b,a)
# Where r is red,g is green,b is blue,and a is opacity and all are (0-255)
TINTS = [Color.new(30,0,70,155),
Color.new(30,0,40,155),
Color.new(20,0,30,135),
Color.new(10,0,30,135),
Color.new(10,0,20,125),
Color.new(0,0,20,125),
Color.new(80,20,20,125),
Color.new(130,40,10,105),
Color.new(80,20,10,85),
Color.new(0,0,0,65),
Color.new(0,0,0,35),
Color.new(0,0,0,15),
Color.new(0,0,0,0),
Color.new(0,0,0,0),
Color.new(0,0,0,5),
Color.new(0,0,0,15),
Color.new(0,0,0,25),
Color.new(0,0,10,55),
Color.new(0,0,10,55),
Color.new(0,0,10,55),
Color.new(130,40,30,105),
Color.new(80,20,40,125),
Color.new(10,0,50,135),
Color.new(20,0,60,135)]
#NOT YET IMPLEMENTED *IGNORE*
PERIODS = [["Night",0,5],
["Morning",6,12],
["Afternoon",13,19],
["Evening",20,23]]
$gametimeclockvisible = false
#_# END CUSTOMIZATION #_#
module GameTime
def self.run
$game_time = Current_Time.new
$game_time_tint = Sprite_TimeTint.new
end
def self.update
return if $game_message.busy? and NOTIMEMESSAGE
if !SceneManager.scene.is_a?(Scene_Map) and PAUSE_IN_MENUS
return $game_time_tint.update if SceneManager.scene.is_a?(Scene_Title)
return $game_time_tint.update if SceneManager.scene.is_a?(Scene_File)
return unless SceneManager.scene.is_a?(Scene_Battle) and !NOBATTLETIME
end
$game_time.update
$game_time_tint = Sprite_TimeTint.new if $game_time_tint.disposed?
update_tint
end
def self.update_tint
$game_time_tint.update unless @pause_tint
end
def self.sec?
return $game_time.sec
end
def self.min?
return $game_time.min
end
def self.mint?
return $game_time.min if $game_time.min > 9
return "0" + $game_time.min.to_s
end
def self.hour?
return $game_time.hour
end
def self.hour_nom?
hour = $game_time.hour
hour -= 12 if hour > 11
hour = 12 if hour == 0
return hour
end
def self.meri?
return "AM" if $game_time.hour < 12
return "PM"
end
def self.day?
return $game_time.day if $USE_REAL_TIME
return $game_time.day + 1
end
def self.day_week?
return $game_time.dayweek
end
def self.day_year?
month = month? - 1
day = day?
while month > 0
day += MONTHS[month]
month -= 1
end
day
end
def self.day_name
return DAYNAMES[$game_time.dayweek-1] if $USE_REAL_TIME
return DAYNAMES[$game_time.dayweek]
end
def self.day_name_abbr
return DAYNAMESABBR[$game_time.dayweek-1] if $USE_REAL_TIME
return DAYNAMESABBR[$game_time.dayweek]
end
def self.month_name_abbr
return MONTHNAMESABBR[$game_time.month-1] if $USE_REAL_TIME
return MONTHNAMESABBR[$game_time.month]
end
def self.month?
return $game_time.month if $USE_REAL_TIME
return $game_time.month + 1
end
def self.month_name
return MONTHNAMES[$game_time.month-1] if $USE_REAL_TIME
return MONTHNAMES[$game_time.month]
end
def self.year?
return $game_time.year
end
def self.pause_tint(set)
@pause_tint = set
$game_time_tint.visible = false if @pause_tint
$game_time_tint.force_update if !@pause_tint
end
def self.tint_paused?
@pause_tint
end
def self.change(s = nil,m = nil,h = nil,d = nil,dw = nil, mn = nil,y = nil)
$game_time.manual(s,m,h,d,dw,mn,y)
end
def self.set(handle,n)
$game_time.forward(handle,n)
end
def self.clock?(set)
SceneManager.scene.clock_visible?(set)
end
def self.year_post(set)
$game_time.year_post = set
end
def self.save_time
$saved_game_time = $game_time.dup
end
def self.load_time
$game_time = $saved_game_time.dup
end
def self.no_time_map
note = $game_map.map_note
/Notime/ =~ note
return false unless $~
return true
end
def self.notime(set)
$game_time.notime = set
end
class Current_Time
attr_reader :sec
attr_reader :min
attr_reader :hour
attr_reader :day
attr_reader :dayweek
attr_reader :month
attr_reader :year
attr_accessor :year_post
attr_accessor :notime
attr_accessor :toggle
attr_accessor :hour24
def initialize
reset_all_values
end
def reset_all_values
@sec = START_TIME[0]
@min = START_TIME[1]
@hour = START_TIME[2]
@day = START_TIME[3]
@dayweek = 0
@month = START_TIME[4]
@year = START_TIME[5]
@notime = false
@year_post = DEFAULT_YEAR_POST
@toggle = 0
end
def update
return realtime if $USE_REAL_TIME
return if GameTime.no_time_map or @notime
$game_variables[TIMELAPSE_VARIABLE] = DEFAULT_TIMELAPSE if $game_variables[TIMELAPSE_VARIABLE] <= 0
return unless Graphics.frame_count % $game_variables[TIMELAPSE_VARIABLE] == 0
NOSECONDS ? addmin(1) : addsec(1)
update_timers
end
def update_timers
return unless TIMER_VARIABLES.size > 0
for i in TIMER_VARIABLES
$game_variables[i] -= 1 unless $game_variables[i] == 0
end
end
def get_next_toggle
@toggle = 0 unless @toggle
@toggle += 1
@toggle = 0 if @toggle == CLOCK_TOGGLE_OPTIONS.size
return CLOCK_TOGGLE_OPTIONS[@toggle]
end
def set_hour24(value)
@hour24 = value
end
def realtime
@sec = Time.now.sec
@sec = 0 if @sec == 60
@min = Time.now.min
@hour = Time.now.hour
@day = Time.now.day
@dayweek = Time.now.wday
@month = Time.now.month
@year = Time.now.year
0
end
def addsec(s)
@sec += s
return unless @sec == SECONDSINMIN
@sec = 0
addmin(1)
end
def addmin(m)
@min += m
return unless @min == MINUTESINHOUR
@min = 0
addhour(1)
end
def addhour(h)
@hour += h
return unless @hour == HOURSINDAY
@hour = 0
addday(1)
end
def addday(d)
@day += d
@dayweek += d
@dayweek = 0 if @dayweek == DAYNAMES.size
return unless @day == MONTHS[@month]
@day = 0
addmonth(1)
end
def addmonth(mn)
@month += mn
return unless @month == MONTHS.size
@month = 0
addyear(1)
end
def addyear(y)
@year += y
end
def manual(s = nil,m = nil,h = nil,d = nil,dw = nil,mn = nil,y = nil)
@sec = s if !s.nil?
@sec = SECONDSINMIN - 1 if @sec >= SECONDSINMIN
@min = m if !m.nil?
@min = MINUTESINHOUR - 1 if @min >= MINUTESINHOUR
@hour = h if !h.nil?
@hour = HOURSINDAY - 1 if @hour >= HOURSINDAY
@day = d if !d.nil?
@day = MONTHS[@month] - 1 if @day >= MONTHS[@month]
@dayweek = dw if !dw.nil?
@dayweek = 0 if @dayweek >= DAYNAMES.size
@month = mn if !mn.nil?
@month = MONTHS.size - 1 if @month >= MONTHS.size
@year = y if !y.nil?
end
def forward(handle,n)
handle = handle.to_s + "(1)"
n.times do |s| eval(handle) end
end
def remsec(s)
@sec -= s
return unless @sec == -1
@sec = SECONDSINMIN
remmin(1)
end
def remmin(m)
@min -= m
return unless @min == -1
@min = MINUTESINHOUR
remhour(1)
end
def remhour(h)
@hour -= h
return unless @hour == -1
@hour = HOURSINDAY - 1
remday(1)
end
def remday(d)
@day -= d
@dayweek -= d
@dayweek = DAYNAMES.size - 1 if @dayweek == -1
return unless @day == -1
@day = MONTHS[@month] - 1
remmonth(1)
end
def remmonth(mn)
@month -= mn
return unless @month == -1
@month = MONTHS.size - 1
remyear(1)
end
def remyear(y)
@year -= y
end
end
class Sprite_TimeTint < Sprite_Base
def initialize(viewport = nil)
super(viewport)
self.z = 10
create_contents
update
@old_tint = [0,0,0,0]
@old_time = -1
end
def create_contents
self.bitmap = Bitmap.new(Graphics.width,Graphics.height)
self.visible = false
end
def force_update
@old_time = -1
@old_tint = [0,0,0,0]
update
end
def update
return true if GameTime.tint_paused?
return use_default if SceneManager.scene.is_a?(Scene_Battle) and BATTLE_TINT
return use_khas if USE_KHAS
return use_victor if USE_VICTOR
return use_default
end
def use_default
return if self.disposed?
create_contents if self.bitmap.height != Graphics.height
create_contents if self.bitmap.width != Graphics.width
self.visible = SceneManager.scene.is_a?(Scene_Map)
self.visible = true if SceneManager.scene.is_a?(Scene_Battle) and BATTLE_TINT
self.visible = false if SceneManager.scene.is_a?(Scene_Title)
self.visible = false if no_tint
return unless self.visible
min = $game_time.min
return if min == @old_time
@old_time = min
rgba = get_new_tint(min)
return if rgba == @old_tint
@old_tint = rgba
self.bitmap.clear
self.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(rgba[0],rgba[1],rgba[2],rgba[3]))
end
def use_khas
begin
temp = $game_map.light_surface.opacity
rescue
return
end
self.visible = false
if no_tint
$game_map.effect_surface.set_color(0,0,0)
$game_map.effect_surface.set_alpha(0)
end
return if no_tint
min = $game_time.min
return if min == @old_time
@old_time = min
rgba = get_new_tint(min)
return if rgba == @old_tint
@old_tint = rgba
$game_map.effect_surface.set_color(rgba[0],rgba[1],rgba[2])
$game_map.effect_surface.set_alpha(rgba[3])
end
def no_tint
return if $game_map.nil?
note = $game_map.map_note
/Notint/ =~ note
return false unless $~
return true
end
def use_victor
return if $game_map.nil?
self.visible = false
$game_map.screen.shade.change_color(0,0,0,0) if no_tint
$game_map.screen.shade.change_opacity(0) if no_tint
return if no_tint
$game_map.screen.shade.show if !$game_map.screen.shade.visible
min = $game_time.min
return if min == @old_time
@old_time = min
rgba = get_new_tint(min)
return if rgba == @old_tint
@old_tint = rgba
$game_map.screen.shade.change_color(rgba[0],rgba[1],rgba[2],0)
$game_map.screen.shade.change_opacity(rgba[3],0)
end
def get_new_tint(min)
ctint = TINTS[$game_time.hour]
ntint = TINTS[$game_time.hour + 1] unless $game_time.hour + 1 == HOURSINDAY
ntint = TINTS[0] if $game_time.hour + 1 == HOURSINDAY
r = ctint.red.to_f - ((ctint.red.to_f - ntint.red) * (min.to_f / MINUTESINHOUR))
g = ctint.green.to_f - ((ctint.green.to_f - ntint.green) * (min.to_f / MINUTESINHOUR))
b = ctint.blue.to_f - ((ctint.blue.to_f - ntint.blue) * (min.to_f / MINUTESINHOUR))
a = ctint.alpha.to_f - ((ctint.alpha.to_f - ntint.alpha) * (min.to_f / MINUTESINHOUR))
return [r,g,b,a]
end
end
class Window_GameClock < Window_Base
def initialize
super(CLOCK_X,CLOCK_Y,CLOCK_WIDTH,clock_height)
self.opacity = CLOCK_BACK unless SceneManager.scene.is_a?(Scene_Menu)
update
self.visible = $gametimeclockvisible unless SceneManager.scene.is_a?(Scene_Menu)
end
def clock_height
return 80 if !CUSTOM_CLOCK2.nil? and CLOCK_FORMAT == 3 and SceneManager.scene.is_a?(Scene_Map)
return 80 if !CUSTOM_CLOCK2.nil? and MENU_CLOCK_FORMAT == 3 and SceneManager.scene.is_a?(Scene_Menu)
return 56
end
def update
if NOSECONDS && @set_minute == $game_time.min
if Graphics.frame_count % BLINK_SPEED / 2 == 0 && USE_BLINK
return
end
end
contents.clear
@set_minute = $game_time.min if NOSECONDS
if SceneManager.scene.is_a?(Scene_Map)
v = CLOCK_FORMAT
else
v = MENU_CLOCK_FORMAT
end
bon = TF_HOUR_CLOCK ? 2 : 0
if $game_time.hour24
bon = $game_time.hour24 ? 2 : 0
end
string = normal_clock if v + bon == 1
string = dated_clock if v + bon == 2
string = military_clock if v + bon == 3
string = dated_military_clock if v + bon == 4
string = custom(CUSTOM_CLOCK) if v == 3
string2 = custom(CUSTOM_CLOCK2) if !CUSTOM_CLOCK2.nil? and v == 3
contents.draw_text(0,0,contents.width,24,string,1)
contents.draw_text(0,24,contents.width,24,string2,1) if !CUSTOM_CLOCK2.nil? and v == 3
end
def military_clock
hour = $game_time.hour
minute = $game_time.min
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
string = hour.to_s + blinky + minute.to_s
return string
end
def dated_military_clock
hour = $game_time.hour
minute = $game_time.min
dayweek = DAYNAMESABBR[$game_time.dayweek]
day = $game_time.day
day += 1 unless $USE_REAL_TIME
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
if day < 10 then day = " " + day.to_s end
string = dayweek.to_s + " " + day.to_s + " "
string += hour.to_s + blinky + minute.to_s
return string
end
def normal_clock
meri = "AM"
hour = $game_time.hour
minute = $game_time.min
if hour > 11 then meri = "PM" end
if hour == 0 then hour = 12; meri = "AM" end
if hour > 12 then hour -= 12 end
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
string = hour.to_s + blinky + minute.to_s + " " + meri
return string
end
def dated_clock
meri = "AM"
hour = $game_time.hour
minute = $game_time.min
dayweek = DAYNAMESABBR[$game_time.dayweek]
day = $game_time.day
day += 1 unless $USE_REAL_TIME
if hour > 11 then meri = "PM" end
if hour == 0 then hour = 12; meri = "AM" end
if hour > 12 then hour -= 12 end
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
if day < 10 then day = " " + day.to_s end
string = dayweek.to_s + " " + day.to_s + " "
string += hour.to_s + blinky + minute.to_s + " " + meri
return string
end
def blinky
return ":" unless USE_BLINK
return " " if Graphics.frame_count % BLINK_SPEED > (BLINK_SPEED / 2)
return ":"
end
def custom(array)
array = array.clone
if array.include?("hourtog")
bon = TF_HOUR_CLOCK
bon = $game_time.hour24 if $game_time.hour24
index = array.index("hourtog")
array[index] = bon ? "hour" : "hour12"
end
string = ""
for command in array
case command
when "sec"
sec = $game_time.sec
sec = "0" + sec.to_s if sec < 10
string += sec.to_s
when "min"
minute = $game_time.min
minute = "0" + minute.to_s if minute < 10
string += minute.to_s
when "hour"
hour = $game_time.hour
hour >= 12 ? meri = "PM" : meri = "AM"
hour = " " + hour.to_s if hour < 10
string += hour.to_s
when "hour12"
hour12 = $game_time.hour
hour12 -= 12 if hour12 > 12
hour12 = 12 if hour12 == 0
string += hour12.to_s
when "meri"
hour = $game_time.hour
hour >= 12 ? meri = "PM" : meri = "AM"
string += meri.to_s
when "weekshort"
dayweek = DAYNAMESABBR[$game_time.dayweek]
string += dayweek.to_s
when "weeklong"
dayweekn = DAYNAMES[$game_time.dayweek]
string += dayweekn.to_s
when "day"
day = $game_time.day
day += 1 unless $USE_REAL_TIME
string += day.to_s
when "month"
month = $game_time.month
month += 1 unless $USE_REAL_TIME
string += month.to_s
when "monthshort"
monthna = MONTHNAMESABBR[$game_time.month]
string += monthna.to_s
when "monthlong"
monthn = MONTHNAMES[$game_time.month]
string += monthn.to_s
when "year"
year = $game_time.year
string += year.to_s
when "yearp"
string += $game_time.year_post
when "blinky"
string += blinky
else
string += command.to_s
end
end
return string
end
end
end
GameTime.run
class Window_Base < Window
alias game_time_convert_escape_characters convert_escape_characters
def convert_escape_characters(text)
result = game_time_convert_escape_characters(text)
result.gsub!(/GTSEC/) { GameTime.sec? }
result.gsub!(/GTMIN/) { GameTime.mint? }
result.gsub!(/GTHOUR/) { GameTime.hour? }
result.gsub!(/GTMERI/) { GameTime.meri? }
result.gsub!(/GTDAYN/) { GameTime.day? }
result.gsub!(/GTDAYF/) { GameTime.day_name }
result.gsub!(/GTDAYA/) { GameTime.day_name_abbr }
result.gsub!(/GTMONF/) { GameTime.month? }
result.gsub!(/GTMONN/) { GameTime.month_name }
result.gsub!(/GTMONA/) { GameTime.month_name_abbr }
result.gsub!(/GTYEAR/) { GameTime.year? }
result
end
end
class Scene_Base
alias game_time_update update
def update
game_time_update
GameTime.update
end
def clock_visible?(set)
return
end
end
class Scene_Map
alias game_time_post_transfer post_transfer
alias game_time_init create_all_windows
alias game_time_map_update update
alias game_time_start start
def start
game_time_start
GameTime.update_tint
end
def create_all_windows
game_time_init
@gametimeclock = GameTime::Window_GameClock.new if USECLOCK
if CUSTOM_CLOCK_BACKGROUND
@clockbackground = Sprite.new(@gametimeclock.viewport)
@clockbackground.bitmap = Cache.picture(CUSTOM_CLOCK_BACKGROUND_IMAGE)
@clockbackground.x = @gametimeclock.x
@clockbackground.x += CUSTOM_CLOCK_BACKGROUND_X
@clockbackground.y = @gametimeclock.y
@clockbackground.y += CUSTOM_CLOCK_BACKGROUND_Y
@clockbackground.visible = @gametimeclock.visible
end
end
def post_transfer
$game_time_tint.force_update
game_time_post_transfer
end
def update
game_time_map_update
return unless USECLOCK
@gametimeclock.update unless SceneManager.scene != self
if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false
option = $game_time.get_next_toggle
if option == :off
@gametimeclock.visible = false
else
@gametimeclock.visible = true
end
if option == :hour12
$game_time.set_hour24(false)
elsif option == :hour24
$game_time.set_hour24(true)
end
$gametimeclockvisible = @gametimeclock.visible
@clockbackground.visible = @gametimeclock.visible if @clockbackground
end
end
def clock_visible?(set)
@gametimeclock.visible = set
@clockbackground.visible = @gametimeclock.visible if @clockbackground
$gametimeclockvisible = set
end
def update_encounter
if $game_player.encounter
$game_time_tint.use_default if BATTLE_TINT
SceneManager.call(Scene_Battle)
end
end
end
class Game_Map
def map_note
return @map.note unless @map.nil?
end
end
class Scene_Menu
alias gt_start start
alias gt_update update
def start
gt_start
@clock = GameTime::Window_GameClock.new if USECLOCK_MENU
return if @clock.nil?
@clock.x = 0
@clock.y = @gold_window.y - @clock.height
@clock.width = @gold_window.width
@clock.create_contents
end
def update
gt_update
@clock.update unless @clock.nil?
@clock.contents.clear if SceneManager.scene != self and !@clock.nil?
end
end
class Scene_Battle
alias gametime_pre_terminate pre_terminate
def pre_terminate
gametime_pre_terminate
$game_time_tint.update
end
end
module DataManager
class << self
alias gametime_msc make_save_contents
alias gametime_esc extract_save_contents
alias gametime_sng setup_new_game
end
def self.make_save_contents
contents = gametime_msc
contents[:gametime] = $game_time
contents
end
def self.extract_save_contents(contents)
gametime_esc(contents)
$game_time = contents[:gametime]
end
def self.setup_new_game
gametime_sng
$game_time = GameTime::Current_Time.new
end
end
Last edited: