Guest Access
Go to page : 1, 2
EVENTALIST
EVENTALIST
EVENTALIST
profile
Allows for the concept of time passage in your game and a feel of more realism.
Demo 2.0 *Outdated*
Post any problems you may run into or suggestions for a future update here.
mr_wiggles
profile
Wiggles Dynamic Time System
Version: 2.1
Author: Mr Wiggles
Date: Feb. 4, 2012
Version History
Version: 2.1
Author: Mr Wiggles
Date: Feb. 4, 2012
Version History
- Version 2.0 (8/4/11) - Initial release
- Version 2.1 (2/4/12) - Fixed bug with pause [Thanks supercow and mely]
Planned Future Versions
- None that I can think of.
Description
Allows for the concept of time passage in your game and a feel of more realism.
Features
- Random Weather Creation
- Advanced Time Controls
- Forecasting Display System
Instructions
Paste above main and below the default scripts. Follow the instructions in the script header.
Script
Paste above main and below the default scripts. Follow the instructions in the script header.
Script
- Code:
#==============================================================================
# ** Wiggles Dynamic Time System **
#==============================================================================
# Created by: Mr_Wiggles
# Version 2.1
# 2/4/12
#==============================================================================
# Instructions:
#==============================================================================
# - To change the weather call script with the following:
# weather(type, power, transition)
#
# Weather Power: Weather Types:
# An integer from 0-50. 0 - clear
# 0 = no weather 1 - rain
# 50 = 500 sprites 2 - storm
# 3 - snow
# Transition: 4 - hail
# The number of frames to 5 - blizzard
# change the weather in. 6 - falling ash
#---------------------------------------------------------------------------
# - Show the forcast call script with the following:
# show_forcast
#---------------------------------------------------------------------------
# - Advance clock for sleeping time.
# inn_rest(wake_hour = 6)
#
# wake_hour = Hour to move the clock to.
#---------------------------------------------------------------------------
# inn_time = What time to wake the player.
#
# - Defign an outside map by using " [out] " in your map name.
#---------------------------------------------------------------------------
# - Change time with a script call with the following:
# set_time("key", amount)
#
# amount = 0 <=> inf key = Change code
# must not be < 0 "m" - Minutes
# "h" - Hours
# "d" - Days
#---------------------------------------------------------------------------
# - Pause and un-Pause time with a script call with the following:
# pause_time
#
# Will toggle when called: i.e.
# "pause_time" = time stoped
# "pause_time" = time started
#---------------------------------------------------------------------------
# - Check time by a script call with the following:
# check_time("string")
#
# stirng = Time or range or time as a string. ex.
# "10:30 - 5:00" or "5:30 - 20:45" or "17:00"
# am am am 8:45pm 5:00pm
#===============================================================================
USE_HUD = true # Show time on map.
TIMEPOS = [0, 0] # Location of the time HUD. [x pos, y pos]
WEATHER_SWITCH = 1 # Switch that enables weather.
MSG_WIN_PAUS = true # Pause time when showing text.
WEATHER = [2, 6, 15]
# [min days between weather, max days between weather, max hour run time]
#===============================================================================
class Game_Time
attr_accessor :manual_tone, :time_stoped
attr_reader :rand_weather
#===============================================================================
# ** CONFIG **
#===============================================================================
def initialize
start_hour, start_min = 10,24 # 10:24am | 20,24 = 10:24pm
#-------------------
@times = [[ 531, 730], # Morning 5:31am - 7:30am
[ 731,1730], # Day 7:31am - 5:30pm
[1731,1930], # Evening 5:31pm - 7:30pm
[1931, 530]] # Night 7:31pm - 5:30am
@colors = [[ 10, -25, -60, 130], # Morning [RRR, GGG, BBB, Grey]
[ 9 , 6, 3, 100], # Day RGB (-255 <=> 255)
[ -68, -136, -34, 115], # Evening Grey (0 - 255)
[-185, -120, -50, 175]] # Night
@duration = 100 # Transition time between tints.
#-------------------
@weather = [[ -92, -60, -25, 150], # rain Weather tints are set up
[-185, -120, -50, 150], # storm the same as time tints.
[ 65, 60, 70, 150], # snow
[ -92, -60, -25, 150], # hail Use nil for no tone used.
[ 100, 100, 100, 150], # blizzard
[ -60, -60, -60, 150]] # falling ash
#-------------------
@day_name = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"] # Weekday names; as many as you want.
#-------------------
# Variables used for time factors. Use nil for no variable tie.
@varids = [ 1 , 2 , 3 , 4 ]
# [day nam, clock hour, clock minute, total days]
# For use with time factored conditional branches. (shops, missions)
#===============================================================================
# ** END_CONFIG **
#-------------------------------------------------------------------------------
# Edditing anything bellow this point may cause an error with the script, it
# is advised that you don't edit anything past this point unless you are
# familar with script snipts.
#===============================================================================
@game_time_offset = (start_hour * 60) + start_min
@time_stoped, @manual_tone = false, false
@clock_minutes, @clock_hours, @total_days = 0, 0, 0
@fake_mins, @update_wait = 0, 0
@rand_weather = nil
#-------------------
@weather.unshift(nil)
end
#---------------------------------------------------------------------------
def update(instant = false)
return if $game_switches.nil?
# make random weather
if $game_switches[WEATHER_SWITCH]
@rand_weather = create_random if @rand_weather.nil?
if clock_time == @rand_weather[0]
w = @rand_weather[2]
$game_screen.weather(w[0], w[1], 150)
end
rdays, rhrs, rmins = @rand_weather[1]
if (clock_time[0] >= rdays and clock_time[1] >= rhrs and
clock_time[2] >= rmins)
$game_screen.weather(0, 0, 150)
@rand_weather = nil
end
elsif !@rand_weather.nil?
$game_screen.weather(0, 0, 150)
@rand_weather = nil
end
# time update
if @update_wait != 0 and !instant; @update_wait -= 1 ; return; end
@update_wait = 40
return if (MSG_WIN_PAUS and $game_temp.message_window_showing)
# update time
@fake_mins += 1 if !@time_stoped
# Calculate total number of seconds
total_min = @fake_mins + @game_time_offset
# Calculate seconds, minutes, hours and days
@clock_minutes, @clock_hours = total_min % 60, (total_min / 60) % 24
@total_days = total_min / 1440
# Makes Hours and Min together for more "random" tone changes.
@half_hours = (@clock_hours * 100) + (@clock_minutes % 60)
# Update Game Variables
$game_variables[@varids[0]] = today_name unless @varids[0].nil?
$game_variables[@varids[1]] = @clock_minutes unless @varids[1].nil?
$game_variables[@varids[2]] = @clock_hours unless @varids[2].nil?
$game_variables[@varids[3]] = @total_days unless @varids[3].nil?
# update screen tint
return if @manual_tone
set_tone(instant, $game_screen.weather_type)
end
#---------------------------------------------------------------------------
def set_tone(instant, wtone = 0)
if $data_map[$game_map.map_id].outside?
dur = instant ? 0 : @duration
if wtone.to_i > 0 and !@weather[wtone.to_i].nil?
c1, c2, c3, c4 = @weather[wtone]
$game_screen.start_tone_change(Tone.new(c1,c2,c3,c4), dur)
else
if @half_hours >= @times[3][0] or @half_hours <= @times[3][1]
c1, c2, c3, c4 = @colors[3]
elsif @half_hours >= @times[0][0] and @half_hours <= @times[0][1]
c1, c2, c3, c4 = @colors[0]
elsif @half_hours >= @times[1][0] and @half_hours <= @times[1][1]
c1, c2, c3, c4 = @colors[1]
elsif @half_hours >= @times[2][0] and @half_hours <= @times[2][1]
c1, c2, c3, c4 = @colors[2]
end
$game_screen.start_tone_change(Tone.new(c1,c2,c3,c4), dur)
end
end
end
#---------------------------------------------------------------------------
def today_name
return @day_name[@total_days % @day_name.size]
end
#---------------------------------------------------------------------------
def game_days
return @total_days.to_s
end
#---------------------------------------------------------------------------
def time
return if @clock_hours.nil?
tag = @clock_hours > 12 ? " PM" : " AM"
hour = @clock_hours > 12 ? @clock_hours - 12 : @clock_hours
hour += 1 if hour == 0
return sprintf("#{hour}:" + "%02d" + tag, @clock_minutes)
end
#---------------------------------------------------------------------------
def clock_time
return [@total_days, @clock_hours, @clock_minutes]
end
#---------------------------------------------------------------------------
def inn_rest(wake_hour)
if @clock_hours != wake_hour
total_mins = ((24 - @clock_hours) + wake_hour) * 60
else
total_mins = 1440
end
total_mins -= @clock_minutes if @clock_minutes > 0
@game_time_offset += total_mins
end
#---------------------------------------------------------------------------
def set_time(tag, val)
val = 0 if val < 0
case tag
when "m" then @game_time_offset += val
when "h" then @game_time_offset += val * 60
when "d" then @game_time_offset += val * 1440
end
end
#--------------------------------------------------------------------------
def create_random
time = $game_time.clock_time
min, max, mh = WEATHER
start_time = [time[0] + (rand(max) + min), rand(24), rand(60)]
weather = [(rand(3) + 1), rand(50)]
weather[0] += 1 if weather[0] == 3
mh = mh > 24 ? 24 : mh
stop_hour = start_time[1] + rand(mh)
stop_min = (start_time[2] + rand(60)) % 60
next_day = (stop_hour >= 24)
stop_day = next_day ? start_time[0] + 1 : start_time[0]
stop_hour %= 24
end_time = [stop_day, stop_hour, stop_min, next_day]
return [start_time, end_time, weather]
end
end
#==============================================================================
class Game_Map
alias :game_time_set :setup
def setup(*args)
game_time_set(*args)
return if $game_time.nil?
$game_time.update(true)
end
end
#==============================================================================
class Scene_Map
alias :gtime_main :main
def main
if USE_HUD
@gtime_hud = Window_PlayTime.new
@gtime_hud.x = TIMEPOS[0] - 16
@gtime_hud.y = TIMEPOS[1] - 16
@gtime_hud.opacity = 0
end
$game_time.update(true) unless $game_time.nil?
gtime_main
@gtime_hud.dispose if USE_HUD
end
#--------------------------------------------------------------------------
alias :game_time_up :update
def update
game_time_up
return if $game_time.nil?
$game_time.update
@gtime_hud.update if USE_HUD
end
end
#==============================================================================
class RPG::MapInfo
def name
return @name.gsub(/\[out\]/) {""}
end
def outside?
return @name.scan(/\[out\]/).size > 0
end
end
#===============================================================================
module RPG
class Weather
attr_reader :max
attr_reader :ox
attr_reader :oy
#--------------------------------------------------------------------------
def initialize(viewport = nil)
@type, @max, @ox, @oy, @count = 0, 0, 0, 0, 0
@current_pose, @info, @countarray, @sprites = [], [], [], []
make_bitmaps
for i in 1..500
sprite = Sprite.new(viewport)
sprite.z = 1000
sprite.visible = false
sprite.opacity = 0
@sprites.push(sprite)
@current_pose.push(0)
@info.push(rand(50))
@countarray.push(rand(15))
end
end
#--------------------------------------------------------------------------
def type
return @type
end
#--------------------------------------------------------------------------
def type=(type)
return if @type == type
@type = type
case @type
when 1 then bitmap = @rain_bitmap # rain
when 2 then bitmap = @storm_bitmap # storm
when 3 then bitmap = @snow_bitmap # snow
when 4 then bitmap = @hail_bitmap # hail
when 5 then bitmap = @snow_bitmap # blizzard
when 6 then bitmap = @ash_bitmaps[rand(@ash_bitmaps.size)] # falling ash
else
bitmap = nil
end
@thunder = (@type == 2)
for i in 1..500
sprite = @sprites[i]
if sprite != nil
sprite.visible = (i <= @max)
sprite.bitmap = bitmap
end
end
end
#--------------------------------------------------------------------------
def update
# update sprites
return if @type == 0
for i in 1..@max
sprite = @sprites[i]
break if sprite.nil?
# check if player is out side.
if $data_map[$game_map.map_id].outside?
case @type
#----------------------------------------------------
# rain
when 1
sprite.x -= 2
sprite.y += 16
sprite.opacity -= 8
#----------------------------------------------------
# storm
when 2
sprite.x -= 8
sprite.y += 16
sprite.opacity -= 12
if @thunder and (rand(50000 - @max) == 0)
$game_screen.start_flash(Color.new(255, 255, 255, 255), 5)
Audio.se_play("Audio/SE/061-Thunderclap01")
end
#----------------------------------------------------
# snow
when 3
sprite.x -= 2
sprite.y += 8
sprite.opacity -= 8
#----------------------------------------------------
# hail
when 4
sprite.x -= 1
sprite.y += 18
sprite.opacity -= 15
#----------------------------------------------------
# blowing snow
when 5
sprite.x -= 10
sprite.y += 6
sprite.opacity -= 4
#----------------------------------------------------
# ash
when 6
sprite.y += 2
case @countarray[i] % 3
when 0
sprite.x -= 1
when 1
sprite.x += 1
end
end
#----------------------------------------------------
# out side check
else
sprite.visible = false
end
x = sprite.x - @ox
y = sprite.y - @oy
if sprite.opacity < 64 or x < -50 or x > 750 or y < -300 or y > 500
sprite.x = rand(800) - 50 + @ox
sprite.y = rand(800) - 200 + @oy
sprite.opacity = 255
end
end
end
#--------------------------------------------------------------------------
def dispose
@sprites.each{|s| s.dispose}
@rain_bitmap.dispose
@storm_bitmap.dispose
@snow_bitmap.dispose
@hail_bitmap.dispose
@ash_bitmaps.each{|s| s.dispose}
end
#--------------------------------------------------------------------------
def ox=(ox)
return if @ox == ox
@ox = ox
@sprites.each{|s| s.ox = @ox}
end
#--------------------------------------------------------------------------
def oy=(oy)
return if @oy == oy
@oy = oy
@sprites.each{|s| s.oy = @oy}
end
#--------------------------------------------------------------------------
def max=(max)
return if @max == max
@max = [[max, 0].max, 500].min
for i in 1..500
sprite = @sprites[i]
if sprite != nil
sprite.visible = (i <= @max)
end
end
end
#--------------------------------------------------------------------------
def make_bitmaps
# Colors
blueGrey = Color.new(215, 227, 227, 150)
fade_white = Color.new(255, 255, 255, 128)
grey = Color.new(214, 217, 217, 150)
lightBlue = Color.new(222, 239, 243, 250)
lightGrey = Color.new(233, 233, 233, 250)
white = Color.new(255, 255, 255, 255)
#--------------------------------------------------
# Rain bitmap
@rain_bitmap = Bitmap.new(7, 56)
for i in 0..6
@rain_bitmap.fill_rect(6-i, i*8, 1, 8, white)
end
#--------------------------------------------------
# Storm bitmap
@storm_bitmap = Bitmap.new(34, 64)
for i in 0..31
@storm_bitmap.fill_rect(33-i, i*2, 1, 2, fade_white)
@storm_bitmap.fill_rect(32-i, i*2, 1, 2, white)
@storm_bitmap.fill_rect(31-i, i*2, 1, 2, fade_white)
end
#--------------------------------------------------
# Snow bitmap
@snow_bitmap = Bitmap.new(6, 6)
@snow_bitmap.fill_rect(0, 1, 6, 4, white)
@snow_bitmap.fill_rect(1, 0, 4, 6, fade_white)
@snow_bitmap.fill_rect(1, 2, 4, 2, white)
@snow_bitmap.fill_rect(2, 1, 2, 4, white)
#--------------------------------------------------
# Hail bitmap
@hail_bitmap = Bitmap.new(4, 4)
@hail_bitmap.fill_rect(1, 0, 2, 1, blueGrey)
@hail_bitmap.fill_rect(0, 1, 1, 2, blueGrey)
@hail_bitmap.fill_rect(3, 1, 1, 2, grey)
@hail_bitmap.fill_rect(1, 3, 2, 1, grey)
@hail_bitmap.fill_rect(1, 1, 2, 2, lightGrey)
@hail_bitmap.set_pixel(1, 1, lightBlue)
#--------------------------------------------------
# Ash bitmaps
@ash_bitmaps = []
@ash_bitmaps[0] = Bitmap.new(3, 3)
@ash_bitmaps[0].fill_rect(0, 1, 1, 3, lightGrey)
@ash_bitmaps[0].fill_rect(1, 0, 3, 1, lightGrey)
@ash_bitmaps[0].set_pixel(1, 1, white)
@ash_bitmaps[1] = Bitmap.new(3, 3)
@ash_bitmaps[1].fill_rect(0, 1, 1, 3, grey)
@ash_bitmaps[1].fill_rect(1, 0, 3, 1, grey)
@ash_bitmaps[1].set_pixel(1, 1, lightGrey)
end
end
end
#===============================================================================
class Interpreter
def command_236
$game_screen.weather(@parameters[0], @parameters[1] * 5, @parameters[2])
return true
end
#--------------------------------------------------
def command_223
tone = @parameters[0]
$game_time.manual_tone = (tone != Tone.new(0,0,0,0))
if $game_time.manual_tone or tone == Tone.new(0,0,0,0)
$game_screen.start_tone_change(tone, @parameters[1] * 2)
end
return true
end
#--------------------------------------------------
def show_forcast
forcast = $game_time.rand_weather
if forcast.nil?
string = "forcast was not made."
else
time = $game_time.clock_time
start = forcast[0]
endd = forcast[1]
weather = forcast[2]
sd = start[0] - time[0]
sm = start[2] > 10 ? start[2] : "0#{start[2]}"
wt = weather[0] == 1 ? "Rain" : weather[0] == 2 ? "Storm" : "Hail"
ws = weather[1] < 15 ? "Light" : weather[1] < 35 ? "Mild" : "Strong"
em = endd[2] > 10 ? endd[2] : "0#{endd[2]}"
st = start[1] > 12 ? "pm" : "am"
sh = start[1] > 12 ? start[1] - 12 : start[1] == 0 ? 12 : start[1]
et = endd[1] > 12 ? "pm" : "am"
eh = endd[1] > 12 ? endd[1] - 12 : endd[1] == 0 ? 12 : endd[1]
dt = sd > 1 ? "In #{sd} Days" : sd > 0 ? "In #{sd} Day" : "Today"
more = " the next day" if endd[3]
string = "#{dt} at #{sh}:#{sm}#{st}, #{ws} #{wt} " +
"which is \nexpected to end at #{eh}:#{em}#{et}#{more}."
end
@message_waiting = true
$game_temp.message_text = string
$game_temp.message_proc = Proc.new { @message_waiting = false }
end
#--------------------------------------------------
def weather(type, power, transition)
$game_screen.weather(type, power, transition)
end
#--------------------------------------------------
def set_time(tag, val)
$game_time.set_time(tag, val)
end
#--------------------------------------------------
def pause_time
$game_time.time_stoped = ($game_time.time_stoped ? false : true)
return true
end
#--------------------------------------------------
def check_time(string)
times = string.split(" - ")
dys, hrs, min = $game_time.clock_time
if times.size == 2
t1, t2 = times[0].split(":"), times[1].split(":")
if t1[0].to_i >= t2[0].to_i
return false if (t1[0].to_i < hrs and t2[0].to_i > hrs)
if hrs == t1[0].to_i
return (t1[1].to_i <= min)
elsif hrs == t2[0].to_i
return (t2[1].to_i >= min)
else
return true
end
else
return false if (t1[0].to_i > hrs and t2[0].to_i < hrs)
if hrs == t1[0].to_i
return (t1[1].to_i >= min)
elsif hrs == t2[0].to_i
return (t2[1].to_i <= min)
else
return true
end
end
else
t = times[0].split(":")
return (t[0].to_i == hrs and t[1].to_i == min)
end
return false
end
#--------------------------------------------------------------------------
def inn_rest(wake_hour = 6)
$game_time.inn_rest(wake_hour)
end
end
#===============================================================================
class Scene_Title
alias :gtime_main :main
def main
$data_map = load_data("Data/MapInfos.rxdata")
gtime_main
end
#--------------------------------------------------------------------------
alias :gtime_new :command_new_game
def command_new_game
gtime_new
$game_time = Game_Time.new
end
end
#===============================================================================
class Scene_Save < Scene_File
alias :gtime_save :write_save_data
def write_save_data(file)
gtime_save(file)
Marshal.dump($game_time, file)
end
end
#==============================================================================
class Scene_Load < Scene_File
alias :gtime_read :read_save_data
def read_save_data(file)
gtime_read(file)
$game_time = Marshal.load(file)
end
end
#==============================================================================
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, $game_time.today_name, 1)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_time.time, 2)
end
#--------------------------------------------------------------------------
def update
super
return if $game_time.time == @oldtime
@oldtime = $game_time.time
refresh
end
end
Demo 2.0 *Outdated*
Support
Post any problems you may run into or suggestions for a future update here.
Known Compatibility Issues
None that i know of.Restrictions
Do not post this on any other forum without my permission. EVENTALIST
Show Signature
EVENTALIST
Administrator
Administrator
Administrator
profile
G@MeF@Ce
profile
thanks for sharing wiggles!
this script packs a lot of punch!
time > day > light > dark
weather particles > (no graphics = script drawn)
even a forecast!? and a system for indoors and outdoors... wowzers!
+
this script packs a lot of punch!
time > day > light > dark
weather particles > (no graphics = script drawn)
even a forecast!? and a system for indoors and outdoors... wowzers!
+
Administrator
Show Signature
C.O.R.N.
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Wonderful again! Just an error, the line 530.
The pause return an error.
- Code:
def pause_time
$game_time.paused = !$game_time.paused
end
The pause return an error.
The only one
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
More specific, whats the error say?
EVENTALIST
Show Signature
EVENTALIST
The only one
Active Member
Active Member
Active Member
profile
I got this error when I entered the tent...
Plushmonkee
profile
I got this error when I entered the tent...
Active Member
Show Signature
Active Member
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
@plush- is this in your game? what kind of scripts do you have along with this one? I cant re create this error. :\
@supercow- Think its fixed now.
[edit]
@plush- I Think i fixed it in the update, what was happening is that Time class was being created after the Temp class. Might have fixed if not i'll need more details.
@supercow- Think its fixed now.
[edit]
@plush- I Think i fixed it in the update, what was happening is that Time class was being created after the Temp class. Might have fixed if not i'll need more details.
EVENTALIST
Show Signature
EVENTALIST
ACTIVATED
ACTIVATED
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
*updated*
Sorry, Been really busy lately.
[mely]- error that plush had or with the time.pause?
Sorry, Been really busy lately.
[mely]- error that plush had or with the time.pause?
EVENTALIST
Show Signature
EVENTALIST
Go to page : 1, 2