Project1
标题:
日历功能追加(已汉化)
[打印本页]
作者:
隐龙居士
时间:
2016-8-13 23:03
标题:
日历功能追加(已汉化)
最近在网上查找日历系统时发现了两个较好的脚本,这两个脚本不是出自同一位作者的。其中较新的是“BMSP日历系统”,较旧的是“日历功能追加”。不过这两个日历系统都不算完美,新的日历系统都是以相同天数为一个月,而旧的日历系统“时间暂停开关”只是虚设的。
两个日历系统脚本对比之下,还是决定先汉化“日历功能追加”并修正“时间暂停开关”。这样“日历功能追加”中的所有开关及变量指令就全了,其中包含隐藏日历窗口的开关、色调不变化的开关、天气效果无效化的开关、天气效果音暂停的开关等等。
以下便是汉化好的脚本,由于日文水平有限,翻译错误请谅解!
=begin =======================================================================
☆ 日历功能追加 原by 白雪レイカ
-------------------------------------------------------------------------------
在项目中加入「时间」的概念。
根据时间段切换背景音乐和画面色调,每个季节随机变化天气。
主要的数据都有赋予变量,可以使用它做事件分支。
-------------------------------------------------------------------------------
◆使用方法
基本的设定项目都可自定义写入,但是有一部分说明是必要的部分。
○关于时间段的情况。
3:00 ~ 5:59 => 凌晨 (:early_morning)
6:00 ~ 10:59 => 早晨 (:morning)
11:00 ~ 15:59 => 白天 (:noon)
16:00 ~ 18:59 => 傍晚 (:evening)
19:00 ~ 22:59 => 夜晚 (:night)
23:00 ~ 2:59 => 深夜 (:midnight)
○每个时间段的背景音乐切换
地图设置中的「自动切换背景音乐」开启时才有效。
在地图的备注栏上填写以下代码:<凌晨(或early)文件名, 音量, 音调>
以上是凌晨的背景音乐设定,其余可对应不同时间段设定背景音乐,
凌晨(或early)、早晨(或morning)、白天(或noon)、傍晚(或evening)、
夜晚(或night)、深夜(或mid),文件扩展名可以省略(例如 Town1)。
○在事件中设置时间
用事件指令「脚本」来实行
set_time(hour, min)
# 将时间设定为 hour:min 。
# 根据这一方法,天数不会推进。
set_date(month, date, day)
# 将日历设定为 month月 date日 day星期 。
# 因为会完全无视星期的推进,所以不建议使用。
# 星期用以下标志来设定。
# 星期日 => :Sun 星期一 => :Mon 星期二 => :Tue
# 星期三 => :Wed 星期四 => :Thr 星期五 => :Fri
# 星期六 => :Sat
set_year(year)
# 将日历设定为 year年 。
# 同上,不建议使用。
shift_date(date)
# 让日历按 date 日推进。
# 包含这星期也能好好的调整。
shift_month(month)
# 让日历按 month 月推进,向推进到月1日的设定。
shift_year(year)
# 让日历按指定 year 年数推进。
# 与 shift_month 不同的日期不会更改。
shift_date_to(month, date[, year])
# 让日历按指定的 year年 month月 date日 推进。
# 省略了 year 的场合当前的年份不变。
# 要设定的日期早于当前日期,将返回到那天为止的时间卷。
set_weather(weather)
# 设定天气。
# 用以下(weather)标志指定。
# 晴 => :fine 雨 => :rain 雪 => :snow
# 雷 => :thunder 暴风雨 => :storm 晴(夜) => :star
# 暴风雪 => :s_storm
◆使用条件
修改·重新发布等自由使用。
重新发布时请先向作者明示。
如果发现错误,请及时报告。
=end
#==============================================================================
# ■ 设定项目
#==============================================================================
module WhiteSnow
# ↓↓ 最初设定从此开始 ↓↓
INITAL_MIN = 30 # 游戏开始时的「分」的值
INITAL_HOUR = 6 # 游戏开始时的「時」的值
INITAL_DATE = 1 # 游戏开始时的「日」的值
INITAL_DAY = :Sun # 游戏开始时的「星期」的值
INITAL_MONTH = 7 # 游戏开始时的「月」的值
INITAL_YEAR = 2018 # 游戏开始时的「年」的值
# ↑↑ 最初设定到此为止 ↑↑
TIME_COUNT_FORBID_SID = 101 # 禁止时间流逝的开关ID
TONE_CHANGE_FORBID_SID = 102 # 禁止根据时间流逝更变画面色调的开关ID
WEATHER_EFFECT_FORBID_SID = 103 # 使天气效果无效化的开关ID
CALENDER_WINDOW_HIDE_SID = 104 # 隐藏日期窗口的开关ID
# 只会隐藏日期窗口,不会阻止时间的流逝
INSIDE_FLAG_SID = 105 # 位于室内标志的开关ID
# 色调变化和天气效果的影响皆无效化,但天气效果音依然存在
WEATHER_BGS_ENABLE = true # 确认是否启用天气效果音(true用、false不用)
INSIDE_BGS_TYPE = 1 # 室内标志或天气效果无效的开关打开时的天气效果音类型
# 使用天气效果音功能时才有效,其中0为静音、1为音量60%、2为逐步渐隐。
WEATHER_BGS_DISABLE = 106 # 天气效果音功能停止开关
# 这个开关ID为ON时,不播放天气效果音(只是暂时禁用天气效果音功能)。
# 但只有这个开关,不会停止当前播放的天气效果音,需与室内标志开关一起使用。
# 此外,这个开关为OFF状态时停止的天气效果音便能再次播放。
MIN_STORE_VID = 101 # 获取当前「分」值的变量ID
HOUR_STORE_VID = 102 # 获取当前「时」值的变量ID
TIME_ZONE_STORE_VID = 103 # 获取当前「时间段」值的变量ID
# 其中凌晨为0、早晨为1、白天为2、傍晚为3、夜晚为4、深夜为5。
DAY_STORE_VID = 104 # 获取当前「星期」值的变量ID
# 其中星期日为0、星期一为1、依此类推到星期六为6。
DATE_STORE_VID = 105 # 获取当前「日」值的变量ID
MONTH_STORE_VID = 106 # 获取当前「月」值的变量ID
YEAR_STORE_VID = 107 # 获取当前「年」值的变量ID
SEASON_STORE_VID = 108 # 获取当前「季节」的变量ID
# 其中春为0、夏为1、秋为2、冬为3。
WEATHER_STORE_VID = 109 # 获取当前「天气」的变量ID
# 其中晴为0、雨为1、雪为2、雷为3、暴风雨为4、晴(夜)为5、暴风雪为6。
# 按照R红, G绿, B蓝, Dark灰的顺序指定。
EARLY_MORNING_SCREEN_TONE = [15, 10, 0, 0] # 凌晨的画面色调
MORNING_SCREEN_TONE = [0, 0, 0, 0] # 早晨的画面色调
NOON_SCREEN_TONE = [15, 15, 15, 0] # 白天的画面色调
AFTERNOON_SCREEN_TONE = [32, -8, -32, 16] # 傍晚的画面色调
NIGHT_SCREEN_TONE = [-64, -64, -16, 32] # 夜晚的画面色调
MIDNIGHT_SCREEN_TONE = [-72, -72, -20, 48] # 深夜的画面色调
# 每月的天数表,基本不需要更改。
DAYS_TABLE = {0 => 31, 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30,
7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31}
# 以下天气列表,设定例:
# WEATHER = {:icon => 天气图标索引,
# :weather => [天气效果的种类,强度]},
# :bgs => ["文件名", 音量, 音调](nil为不设定),
# 天气效果的种类 :none表示「无」、:rain表示「雨」、
# :storm表示「暴风雨」、:snow表示「雪」。
FINE = {:icon => 12, :weather => [:none, 0], # 天气:晴
:bgs => nil}
RAIN = {:icon => 13, :weather => [:rain, 5], # 天气:雨
:bgs => ["Rain", 50, 90]}
SNOW = {:icon => 14, :weather => [:snow, 4], # 天气:雪
:bgs => nil}
THUNDER = {:icon => 15, :weather => [:storm, 4], # 天气:雷
:bgs => ["Storm", 60, 75],
:flash => [255, 255, 200, 180, 12],
:se => ["Thunder9", 80, 95]}
# 雷效果用的设定项目
# :flash => [(闪光颜色)R, G, B, Alpha, 闪光长度]
# :se => 闪光后响起的效果音
STORM = {:icon => 16, :weather => [:storm, 8], # 天气:暴风雨
:bgs => ["Storm", 70, 100]}
STAR = {:icon => 17, :weather => [:none, 0], # 天气:晴(夜)
:bgs => nil}
S_STORM = {:icon => 18, :weather => [:snow, 9], # 天气:暴风雪
:bgs => ["Wind", 70, 95]}
end
#==============================================================================
# ■ Calender
#------------------------------------------------------------------------------
# 日历类。
#==============================================================================
class Calender
#--------------------------------------------------------------------------
# ● 公共实例变量
#--------------------------------------------------------------------------
attr_accessor :count
attr_accessor :min
attr_accessor :hour
attr_accessor :date
attr_accessor :day
attr_accessor :month
attr_accessor :season
attr_accessor :year
attr_accessor :weather
attr_accessor :weather_count
attr_accessor :time_zone
attr_reader :interpreter
attr_accessor :thunder_count
#--------------------------------------------------------------------------
# ● 对象初始化
#--------------------------------------------------------------------------
def initialize
@count = 0
@weather = :fine
@interpreter = Game_Interpreter.new
init_calender
change_weather
end
#--------------------------------------------------------------------------
# ● 日历初始化
#--------------------------------------------------------------------------
def init_calender
[url=home.php?mod=space&uid=25749]@min[/url] = WhiteSnow::INITAL_MIN
@hour = WhiteSnow::INITAL_HOUR
@date = WhiteSnow::INITAL_DATE
[url=home.php?mod=space&uid=11519]@day[/url] = WhiteSnow::INITAL_DAY
[url=home.php?mod=space&uid=26122]@Month[/url] = WhiteSnow::INITAL_MONTH
@year = WhiteSnow::INITAL_YEAR
get_time_zone
$game_variables[WhiteSnow::MIN_STORE_VID] = @min
$game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
$game_variables[WhiteSnow::DATE_STORE_VID] = @date
case @month #月份
when 1..2
[url=home.php?mod=space&uid=31546]@season[/url] = :Winter #冬天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
when 3..5
@season = :Spring #春天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 0
when 6..8
@season = :Summer #夏天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 1
when 9..11
@season = :Autumn #秋天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 2
when 12
@season = :Winter #冬天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
end
case @day #星期
when :Sun #星期日
$game_variables[WhiteSnow::DAY_STORE_VID] = 0
when :Mon #星期一
$game_variables[WhiteSnow::DAY_STORE_VID] = 1
when :Tue #星期二
$game_variables[WhiteSnow::DAY_STORE_VID] = 2
when :Wed #星期三
$game_variables[WhiteSnow::DAY_STORE_VID] = 3
when :Thr #星期四
$game_variables[WhiteSnow::DAY_STORE_VID] = 4
when :Fri #星期五
$game_variables[WhiteSnow::DAY_STORE_VID] = 5
when :Sat #星期六
$game_variables[WhiteSnow::DAY_STORE_VID] = 6
end
$game_variables[WhiteSnow::MONTH_STORE_VID] = @month
$game_variables[WhiteSnow::YEAR_STORE_VID] = @year
change_tone_by_calender
end
#--------------------------------------------------------------------------
# ● 获得时间带
#--------------------------------------------------------------------------
def get_time_zone
case @hour
when 0..2
@time_zone = :midnight #深夜
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
when 3..5
@time_zone = :early_morning #凌晨
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 0
when 6..10
@time_zone = :morning #早晨
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 1
when 11..15
@time_zone = :noon #白天
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 2
when 16..18
@time_zone = :evening #傍晚
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 3
when 19..22
@time_zone = :night #夜晚
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 4
when 23..24
@time_zone = :midnight #深夜
$game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
end
end
#--------------------------------------------------------------------------
# ● 获取天气计数
#--------------------------------------------------------------------------
def randomize_weather_count
@weather_count = p_ex_rand(40, 100) + (109 - p_ex_rand(40, 110)) + 90
end
#--------------------------------------------------------------------------
# ● 更改画面色调
#--------------------------------------------------------------------------
def change_tone_by_calender(dur = 60)
return if $game_switches[WhiteSnow::TONE_CHANGE_FORBID_SID]
return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
case @time_zone
when :early_morning #凌晨
tone = WhiteSnow::EARLY_MORNING_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
when :morning #早晨
tone = WhiteSnow::MORNING_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
when :noon #白天
tone = WhiteSnow::NOON_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
when :evening #傍晚
tone = WhiteSnow::AFTERNOON_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
when :night #夜晚
tone = WhiteSnow::NIGHT_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
when :midnight #深夜
tone = WhiteSnow::MIDNIGHT_SCREEN_TONE
@interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
end
end
#--------------------------------------------------------------------------
# ● 更改天气
#--------------------------------------------------------------------------
def change_weather
srand
p_weather = @weather
case @month
when 1
case rand
when 0...0.2
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.2...0.8
@weather = :snow
when 0.8...1
@weather = :s_storm
end
when 2
case rand
when 0...0.3
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.3...0.8
@weather = :snow
when 0.8...0.9
@weather = :rain
when 0.9...1
@weather = :s_storm
end
when 3..4
case rand
when 0...0.8
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.8...0.9
@weather = :rain
when 0.9...1
@weather = :storm
end
when 5
case rand
when 0...0.7
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.7...0.8
@weather = :rain
when 0.8...0.9
@weather = :thunder
when 0.9...1
@weather = :storm
end
when 6
case rand
when 0...0.4
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.4...0.8
@weather = :rain
when 0.8...0.9
@weather = :thunder
when 0.9...1
@weather = :storm
end
when 7..8
case rand
when 0...0.6
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.6...0.7
@weather = :rain
when 0.7...0.9
@weather = :storm
when 0.9...1
@weather = :thunder
end
when 9..10
case rand
when 0...0.6
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.6...0.8
@weather = :storm
when 0.8...0.9
@weather = :rain
when 0.9...1
@weather = :thunder
end
when 11
if @date < 25
case rand
when 0...0.7
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.7...0.8
@weather = :storm
when 0.8...0.9
@weather = :rain
when 0.9...1
@weather = :thunder
end
else
case rand
when 0...0.6
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.6...0.7
@weather = :storm
when 0.7...0.8
@weather = :rain
when 0.8...0.9
@weather = :thunder
when 0.9...1
@weather = :snow
end
end
when 12
case rand
when 0...0.2
if @hour >= 3 and @hour < 18
@weather = :fine
else
@weather = :star
end
when 0.2...0.8
@weather = :snow
when 0.8...1
@weather = :s_storm
end
end
if @weather != p_weather
RPG::BGS.fade(10)
perform_weather_effect
end
randomize_weather_count
end
#--------------------------------------------------------------------------
# ● 天气效果
#--------------------------------------------------------------------------
def perform_weather_effect(dur = 30)
return unless SceneManager.scene_is?(Scene_Map)
return if $game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID]
return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
case @weather
when :fine
weather = WhiteSnow::FINE
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
when :rain
weather = WhiteSnow::RAIN
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
when :snow
weather = WhiteSnow::SNOW
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
when :thunder
weather = WhiteSnow::THUNDER
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
when :storm
weather = WhiteSnow::STORM
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
when :star
weather = WhiteSnow::STAR
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
when :s_storm
weather = WhiteSnow::S_STORM
@interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
bgs.play
end
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
end
end
#--------------------------------------------------------------------------
# ● 室内BGS的演奏
#--------------------------------------------------------------------------
def play_inside_bgs
case @weather
when :fine
weather = WhiteSnow::FINE
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.6, weather[:bgs][2])
bgs.play
end
when :rain
weather = WhiteSnow::RAIN
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
when :snow
weather = WhiteSnow::SNOW
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
when :thunder
weather = WhiteSnow::THUNDER
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
when :storm
weather = WhiteSnow::STORM
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
when :star
weather = WhiteSnow::STAR
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
when :s_storm
weather = WhiteSnow::S_STORM
if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
bgs.play
end
end
end
#--------------------------------------------------------------------------
# ● 天气「雷」效果的执行
#--------------------------------------------------------------------------
def perform_thunder_effect(r, g, b, alpha, dur)
@interpreter.perform_flash(r, g, b, alpha, dur)
end
#--------------------------------------------------------------------------
# ● 更新星期
#--------------------------------------------------------------------------
def shift_day
case @day
when :Sun #星期日
@day = :Mon
$game_variables[WhiteSnow::DAY_STORE_VID] = 1
when :Mon #星期一
@day = :Tue
$game_variables[WhiteSnow::DAY_STORE_VID] = 2
when :Tue #星期二
@day = :Wed
$game_variables[WhiteSnow::DAY_STORE_VID] = 3
when :Wed #星期三
@day = :Thr
$game_variables[WhiteSnow::DAY_STORE_VID] = 4
when :Thr #星期四
@day = :Fri
$game_variables[WhiteSnow::DAY_STORE_VID] = 5
when :Fri #星期五
@day = :Sat
$game_variables[WhiteSnow::DAY_STORE_VID] = 6
when :Sat #星期六
@day = :Sun
$game_variables[WhiteSnow::DAY_STORE_VID] = 0
end
end
#--------------------------------------------------------------------------
# ● 返回星期
#--------------------------------------------------------------------------
def back_day
case @day
when :Sun #星期日
@day = :Sat
$game_variables[WhiteSnow::DAY_STORE_VID] = 1
when :Sat #星期六
@day = :Fri
$game_variables[WhiteSnow::DAY_STORE_VID] = 2
when :Fri #星期五
@day = :Thr
$game_variables[WhiteSnow::DAY_STORE_VID] = 3
when :Thr #星期四
@day = :Wed
$game_variables[WhiteSnow::DAY_STORE_VID] = 4
when :Wed #星期三
@day = :Tue
$game_variables[WhiteSnow::DAY_STORE_VID] = 5
when :Tue #星期二
@day = :Mon
$game_variables[WhiteSnow::DAY_STORE_VID] = 6
when :Mon #星期一
@day = :Sun
$game_variables[WhiteSnow::DAY_STORE_VID] = 0
end
end
#--------------------------------------------------------------------------
# ● 更新月份
#--------------------------------------------------------------------------
def shift_month
case @month
when 1
return unless @date > 31
@month += 1
@date = 1
when 2
return unless @date > 28
@month += 1
@season = :Spring #春天
@date = 1
$game_variables[WhiteSnow::SEASON_STORE_VID] = 0
when 3
return unless @date > 31
@month += 1
@date = 1
when 4
return unless @date > 30
@month += 1
@date = 1
when 5
return unless @date > 31
@month += 1
@season = :Summer #夏天
@date = 1
$game_variables[WhiteSnow::SEASON_STORE_VID] = 1
when 6
return unless @date > 30
@month += 1
@date = 1
when 7
return unless @date > 31
@month += 1
@date = 1
when 8
return unless @date > 31
@month += 1
@season = :Autumn #秋天
@date = 1
$game_variables[WhiteSnow::SEASON_STORE_VID] = 2
when 9
return unless @date > 30
@month += 1
@date = 1
when 10
return unless @date > 31
@month += 1
@date = 1
when 11
return unless @date > 30
@month += 1
@season = :Winter #冬天
@date = 1
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
when 12
return unless @date > 31
@year += 1
@month = 1
@date = 1
$game_variables[WhiteSnow::YEAR_STORE_VID] = @year
end
$game_variables[WhiteSnow::DATE_STORE_VID] = @date
$game_variables[WhiteSnow::MONTH_STORE_VID] = @month
end
#--------------------------------------------------------------------------
# ● 返回月份
#--------------------------------------------------------------------------
def back_month
return unless @date < 1
case @month
when 1
@month = 12
@date = 31
@year -= 1
$game_variables[WhiteSnow::YEAR_STORE_VID] = @year
when 2
@month -= 1
@date = 31
when 3
@month -= 1
@date = 28
@season = :Winter #冬天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
when 4
@month -= 1
@date = 31
when 5
@month -= 1
@date = 30
when 6
@month -= 1
@date = 31
@season = :Spring #春天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 0
when 7
@month -= 1
@date = 30
when 8
@month -= 1
@date = 31
when 9
@month -= 1
@date = 31
@season = :Summer #夏天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 1
when 10
@month -= 1
@date = 30
when 11
@month -= 1
@date = 31
when 12
@month -= 1
@date = 30
@season = :Autumn #秋天
$game_variables[WhiteSnow::SEASON_STORE_VID] = 2
end
$game_variables[WhiteSnow::DATE_STORE_VID] = @date
$game_variables[WhiteSnow::MONTH_STORE_VID] = @month
end
#--------------------------------------------------------------------------
# ● 推进日期
#--------------------------------------------------------------------------
def shift_date
@date += 1
shift_day
shift_month
$game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
$game_variables[WhiteSnow::DATE_STORE_VID] = @date
end
#--------------------------------------------------------------------------
# ● 返回日期
#--------------------------------------------------------------------------
def back_date
@date += 1
back_day
back_month
$game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
$game_variables[WhiteSnow::DATE_STORE_VID] = @date
end
#--------------------------------------------------------------------------
# ● 查找指定日期和当前日期的时间之差
#--------------------------------------------------------------------------
def days_dif(y, m, d)
table = WhiteSnow::DAYS_TABLE
dy_n = (@year - 1) * 365
dy_s = (y - 1) * 365
dm_n = 0 ; 1.upto(@month - 1){|n| dm_n += table[n]} unless @month == 1
dm_s = 0 ; 1.upto(m - 1){|n| dm_s += table[n]} unless m == 1
d_n = @date - 1
d_s = d - 1
n = dy_n + dm_n + d_n
s = dy_s + dm_s + d_s
return s - n
end
end
#==============================================================================
# ■ Window_Calender
#------------------------------------------------------------------------------
# 显示日历内容的窗口。
#==============================================================================
class Window_Calender < Window_Base
#--------------------------------------------------------------------------
# ● 对象初始化 #改动过
#--------------------------------------------------------------------------
def initialize(x = Graphics.width - 240, y = 0, w = 240)
super(x, y, w, fitting_height(2))
refresh
end
#--------------------------------------------------------------------------
# ● 框架更新
#--------------------------------------------------------------------------
def update
self.visible = false if $game_switches[WhiteSnow::CALENDER_WINDOW_HIDE_SID]
self.visible = true if !$game_switches[WhiteSnow::CALENDER_WINDOW_HIDE_SID]
super
refresh if $calender.count == 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_year_date
draw_season_time
draw_weather_icon
end
#--------------------------------------------------------------------------
# ● 绘制年份·月份·日期
#--------------------------------------------------------------------------
def draw_year_date
w = contents_width
h = line_height
month = $calender.month
if (0..9).to_a.include?(month)
month = "0" + month.to_s
else
month = month.to_s
end
date = $calender.date
if (0..9).to_a.include?(date)
date = "0" + date.to_s
else
date = date.to_s
end
draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年" + month + "月" + date + "日")
end
#--------------------------------------------------------------------------
# ● 绘制季节·星期·時·分
#--------------------------------------------------------------------------
def draw_season_time
w = contents_width
h = line_height
season = $calender.season.to_s
season.gsub!("Spring"){"春"}
season.gsub!("Summer"){"夏"}
season.gsub!("Autumn"){"秋"}
season.gsub!("Winter"){"冬"}
day = $calender.day.to_s
day.gsub!("Sun"){"\\c[2]星期日\\c[0]"}
day.gsub!("Mon"){"星期一"}
day.gsub!("Tue"){"星期二"}
day.gsub!("Wed"){"星期三"}
day.gsub!("Thr"){"星期四"}
day.gsub!("Fri"){"星期五"}
day.gsub!("Sat"){"星期六"}
hour = "#{$calender.hour}"
min = $calender.min
if (0..9).to_a.include?(min)
min = "0" + min.to_s
else
min = min.to_s
end
draw_text(-80, h, contents_width , line_height , season, 1)
draw_text_ex(46, h, "(" + day + ")")
draw_text(-6, h, w, h, hour + ":" + min, 2)
end
#--------------------------------------------------------------------------
# ● 绘制天气图标
#--------------------------------------------------------------------------
def draw_weather_icon
case $calender.weather
when :fine
icon_index = WhiteSnow::FINE[:icon]
when :rain
icon_index = WhiteSnow::RAIN[:icon]
when :snow
icon_index = WhiteSnow::SNOW[:icon]
when :thunder
icon_index = WhiteSnow::THUNDER[:icon]
when :storm
icon_index = WhiteSnow::STORM[:icon]
when :star
icon_index = WhiteSnow::STAR[:icon]
when :s_storm
icon_index = WhiteSnow::S_STORM[:icon]
end
draw_icon(icon_index, contents_width - 30, 0)
end
end
#==============================================================================
# ■ Window_MenuCalender
#------------------------------------------------------------------------------
# 显示日历内容的窗口(菜单画面用)。
#==============================================================================
class Window_MenuCalender < Window_Base
#--------------------------------------------------------------------------
# ● 对象初始化
#--------------------------------------------------------------------------
def initialize(x = Graphics.width - 220, y = 0, w = 220)
super(x, y, w, fitting_height(3))
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_year_date
draw_season_time
draw_weather_icon
end
#--------------------------------------------------------------------------
# ● 绘制年份·月份·日期
#--------------------------------------------------------------------------
def draw_year_date
month = $calender.month
if (0..9).to_a.include?(month)
month = "0" + month.to_s
else
month = month.to_s
end
date = $calender.date
if (0..9).to_a.include?(date)
date = "0" + date.to_s
else
date = date.to_s
end
draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年" + month + "月" + date + "日")
end
#--------------------------------------------------------------------------
# ● 绘制季节·星期
#--------------------------------------------------------------------------
def draw_season_time
w = contents_width
h = line_height
season = $calender.season.to_s
season.gsub!("Spring"){"春"}
season.gsub!("Summer"){"夏"}
season.gsub!("Autumn"){"秋"}
season.gsub!("Winter"){"冬"}
day = $calender.day.to_s
day.gsub!("Sun"){"\\c[2]星期日\\c[0]"}
day.gsub!("Mon"){"星期一"}
day.gsub!("Tue"){"星期二"}
day.gsub!("Wed"){"星期三"}
day.gsub!("Thr"){"星期四"}
day.gsub!("Fri"){"星期五"}
day.gsub!("Sat"){"星期六"}
hour = "#{$calender.hour}"
min = $calender.min
if (0..9).to_a.include?(min)
min = "0" + min.to_s
else
min = min.to_s
end
draw_text(-80, h, contents_width + 12, line_height, season, 1)
draw_text_ex(46, h, "(" + day + ")")
draw_text(-12, h * 2, w, h, hour + ":" + min, 2)
end
#--------------------------------------------------------------------------
# ● 绘制天气图标
#--------------------------------------------------------------------------
def draw_weather_icon
case $calender.weather
when :fine
icon_index = WhiteSnow::FINE[:icon]
when :rain
icon_index = WhiteSnow::RAIN[:icon]
when :snow
icon_index = WhiteSnow::SNOW[:icon]
when :thunder
icon_index = WhiteSnow::THUNDER[:icon]
when :storm
icon_index = WhiteSnow::STORM[:icon]
when :star
icon_index = WhiteSnow::STAR[:icon]
when :s_storm
icon_index = WhiteSnow::S_STORM[:icon]
end
draw_icon(icon_index, contents_width - 30, 0)
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 进行地图画面处理的一个类。
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● 创建所有窗口
#--------------------------------------------------------------------------
alias calender_create_all_windows create_all_windows
def create_all_windows
calender_create_all_windows
create_calender_window
end
#--------------------------------------------------------------------------
# ● 创建日期显示窗口
#--------------------------------------------------------------------------
def create_calender_window
@calender_window = Window_Calender.new
end
end
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
# 游戏中所有 Scene 类(场景类)的父类。
#==============================================================================
class Scene_Base
#--------------------------------------------------------------------------
# ● 框架更新(基本)
#--------------------------------------------------------------------------
alias calender_update_basic update_basic
def update_basic
calender_update_basic
update_calender
end
#--------------------------------------------------------------------------
# ● 更新时间
#--------------------------------------------------------------------------
def update_calender
return if $game_switches[WhiteSnow::TIME_COUNT_FORBID_SID]
return unless SceneManager.scene_is?(Scene_Map)
return if $game_switches[10]
$calender.count += 1
if $calender.weather == :thunder and !($game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID] or $game_switches[WhiteSnow::INSIDE_FLAG_SID])
$calender.thunder_count ||= [Graphics.frame_rate * 5 + (rand * Graphics.frame_rate * 10).floor, false]
$calender.thunder_count[0] -= 1
if $calender.thunder_count[1]
if $calender.thunder_count[0] == 0
se = RPG::SE.new(WhiteSnow::THUNDER[:se][0], WhiteSnow::THUNDER[:se][1], WhiteSnow::THUNDER[:se][2])
se.play
$calender.thunder_count = nil
end
elsif $calender.thunder_count[0] < 12 + rand(43)
flash = WhiteSnow::THUNDER[:flash]
$calender.perform_thunder_effect(flash[0], flash[1], flash[2], flash[3], flash[4])
$calender.thunder_count[1] = true
end
else
$calender.thunder_count = nil
end
if $calender.count % Graphics.frame_rate == 0
$calender.min += 1
$calender.count = 0
$game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
$calender.weather_count -= 1
$calender.change_weather if $calender.weather_count <= 0
end
if $calender.min == 60
$calender.hour += 1
$calender.min = 0
if $calender.hour >= 3 and $calender.hour < 19
$calender.weather = :fine if $calender.weather == :star
else
$calender.weather = :star if $calender.weather == :fine
end
$calender.get_time_zone
$calender.change_tone_by_calender
$game_map.autoplay
$game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
$game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
end
if $calender.hour == 24
$calender.hour = 0
$calender.shift_date
end
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 进行菜单画面处理的场景类。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
alias calender_start start
def start
calender_start
create_calender_window
end
#--------------------------------------------------------------------------
# ● 日期窗口生成
#--------------------------------------------------------------------------
def create_calender_window
x = 0
w = @gold_window.width
@calender_window = Window_MenuCalender.new(x, 0, w)
@calender_window.y = Graphics.height - @gold_window.height - @calender_window.height
end
end
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# 数据库和游戏实例的管理器。所有在游戏中使用的全局变量都在这里初始化。
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# ● 别名用具体方法
#--------------------------------------------------------------------------
class << self
alias :calender_create_game_objects :create_game_objects
alias :calender_extract_save_contents :extract_save_contents
end
#--------------------------------------------------------------------------
# ● 创建各种游戏对象
#--------------------------------------------------------------------------
def self.create_game_objects
calender_create_game_objects
$calender = Calender.new
end
#--------------------------------------------------------------------------
# ● 存档内容生成(重新定义)
#--------------------------------------------------------------------------
def self.make_save_contents
contents = {}
contents[:system] = $game_system
contents[:timer] = $game_timer
contents[:message] = $game_message
contents[:switches] = $game_switches
contents[:variables] = $game_variables
contents[:self_switches] = $game_self_switches
contents[:actors] = $game_actors
contents[:party] = $game_party
contents[:troop] = $game_troop
contents[:map] = $game_map
contents[:player] = $game_player
contents[:calender] = $calender
contents
end
#--------------------------------------------------------------------------
# ● 存档内容生成
#--------------------------------------------------------------------------
def self.extract_save_contents(contents)
calender_extract_save_contents(contents)
$calender = contents[:calender]
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# 事件指令的解释器。本类在 Game_Map、Game_Troop、Game_Event 类的内部使用。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 更改画面色调(参数指定)
#--------------------------------------------------------------------------
def change_tone(r, g, b, gray = 0, dur = 60)
tone = Tone.new(r, g, b, gray)
screen.start_tone_change(tone, dur)
end
#--------------------------------------------------------------------------
# ● 更改天气(参数指定)
#--------------------------------------------------------------------------
def change_weather(type, power, dur = 30)
return if $game_party.in_battle
screen.change_weather(type, power, dur)
end
#--------------------------------------------------------------------------
# ● 设定时间
#--------------------------------------------------------------------------
def set_time(hour, min)
hour = 23 if hour > 23
hour = 0 if hour < 0
min = 59 if min > 59
min = 0 if min < 0
$calender.hour = hour
$calender.min = min
$calender.get_time_zone
$game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
$game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
$game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
$game_map.autoplay
$calender.change_weather
$calender.change_tone_by_calender
if $calender.hour >= 3 and $calender.hour < 19
$calender.weather = :fine if $calender.weather == :star
else
$calender.weather = :star if $calender.weather == :fine
end
end
#--------------------------------------------------------------------------
# ● 设定日期
#--------------------------------------------------------------------------
def set_date(month, date, day)
$calender.month = month
$calender.date = date
$calender.day = day
$game_variables[WhiteSnow::MIN_STORE_VID] = $calender.month
$game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
case $calender.day
when :Sun
$game_variables[WhiteSnow::DAY_STORE_VID] = 0
when :Mon
$game_variables[WhiteSnow::DAY_STORE_VID] = 1
when :Tue
$game_variables[WhiteSnow::DAY_STORE_VID] = 2
when :Wed
$game_variables[WhiteSnow::DAY_STORE_VID] = 3
when :Thr
$game_variables[WhiteSnow::DAY_STORE_VID] = 4
when :Fri
$game_variables[WhiteSnow::DAY_STORE_VID] = 5
when :Sat
$game_variables[WhiteSnow::DAY_STORE_VID] = 6
end
case $calender.month
when 1..2
$calender.season = :Winter
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
when 3..5
$calender.season = :Spring
$game_variables[WhiteSnow::SEASON_STORE_VID] = 0
when 6..8
$calender.season = :Summer
$game_variables[WhiteSnow::SEASON_STORE_VID] = 1
when 9..11
$calender.season = :Autumn
$game_variables[WhiteSnow::SEASON_STORE_VID] = 2
when 12
$calender.season = :Winter
$game_variables[WhiteSnow::SEASON_STORE_VID] = 3
end
$calender.change_weather
end
#--------------------------------------------------------------------------
# ● 设定年份
#--------------------------------------------------------------------------
def set_year(year)
$calender.year = year
$game_variables[WhiteSnow::YEAR_STORE_VID] = year
$calender.change_weather
end
#--------------------------------------------------------------------------
# ● 设定天气
#--------------------------------------------------------------------------
def set_weather(weather)
$calender.weather = weather
$calender.randomize_weather_count
$calender.perform_weather_effect
case weather
when :fine
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
when :rain
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
when :snow
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
when :thunder
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
when :storm
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
when :star
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
when :s_storm
$game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
end
end
#--------------------------------------------------------------------------
# ● 产生天气效果
#--------------------------------------------------------------------------
def perform_weather_effect
$calender.perform_weather_effect
end
#--------------------------------------------------------------------------
# ● 画面闪烁(参数指定)
#--------------------------------------------------------------------------
def perform_flash(r, g, b, alpha, dur = 12)
color = Color.new(r, g, b, alpha)
screen.start_flash(color, dur)
end
#--------------------------------------------------------------------------
# ● 推进日期
#--------------------------------------------------------------------------
def shift_date(num)
num.times{$calender.shift_date}
$calender.change_weather
end
#--------------------------------------------------------------------------
# ● 推进月份
#--------------------------------------------------------------------------
def shift_month(num)
table = WhiteSnow::DAYS_TABLE
days = table[$calender.month] - $calender.date + 1
for i in 1..num
days += table[($calender.month + i) % 12]
end
days.times{$calender.shift_date}
$calender.change_weather
end
#--------------------------------------------------------------------------
# ● 推进年份
#--------------------------------------------------------------------------
def shift_year(num)
(num * 365).times{$calender.shift_date}
$calender.change_weather
end
#--------------------------------------------------------------------------
# ● 推进到指定日期前日
#--------------------------------------------------------------------------
def shift_date_to(m, d, y = -1)
y = $calender.year if y == -1
if $calender.days_dif(y, m, d) > 0
$calender.days_dif(y, m, d).times{$calender.shift_date}
else
$calender.days_dif(y, m, d).abs.times{$calender.back_date}
end
$calender.change_weather
end
end
#==============================================================================
# ■ SceneManager
#------------------------------------------------------------------------------
# 场景切换的管理器。例如从主要菜单调用道具画面,还可以处理返回上一个场景。
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# ● 别名用具体方法
#--------------------------------------------------------------------------
class << self
alias :calender_goto :goto
alias :calender_call :call
alias :calender_return :return
end
#--------------------------------------------------------------------------
# ● 直接跳转
#--------------------------------------------------------------------------
def self.goto(scene_class)
calender_goto(scene_class)
if scene_class == Scene_Map
$calender.perform_weather_effect
$calender.change_tone_by_calender
end
end
#--------------------------------------------------------------------------
# ● 调用
#--------------------------------------------------------------------------
def self.call(scene_class)
calender_call(scene_class)
if scene_class == Scene_Map
$calender.perform_weather_effect
$calender.change_tone_by_calender
end
end
#--------------------------------------------------------------------------
# ● 返回到调用前
#--------------------------------------------------------------------------
def self.return
calender_return
if @scene.class == Scene_Map
$calender.perform_weather_effect
$calender.change_tone_by_calender
end
end
end
#==============================================================================
# ■ Game_Switches
#------------------------------------------------------------------------------
# 处理开关的类。本质上是套了个壳的 Array 。本类的实例请参考 $game_switches 。
#==============================================================================
class Game_Switches
#--------------------------------------------------------------------------
# ● 开关设置(重新定义)
# value : ON (true) / OFF (false)
#--------------------------------------------------------------------------
def []=(switch_id, value)
@data[switch_id] = value
on_change
if switch_id == WhiteSnow::TONE_CHANGE_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
case value
when true
$calender.interpreter.change_tone(0, 0, 0, 0, 0)
when false
$calender.change_tone_by_calender(0)
end
end
if switch_id == WhiteSnow::WEATHER_EFFECT_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
case value
when true
$calender.interpreter.change_weather(:none, 0, 0)
RPG::BGS.stop if (WhiteSnow::WEATHER_BGS_ENABLE and [0, 1].include?(WhiteSnow::INSIDE_BGS_TYPE)) or $game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
$calender.play_inside_bgs if WhiteSnow::WEATHER_BGS_ENABLE and WhiteSnow::INSIDE_BGS_TYPE == 1 and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
when false
$calender.perform_weather_effect(0)
end
end
end
end
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
# 本类的实例请参考 $game_player 。
#==============================================================================
class Game_Player
#--------------------------------------------------------------------------
# ● 场所移动的执行
#--------------------------------------------------------------------------
alias calender_perform_transfer perform_transfer
def perform_transfer
if transfer?
$calender.perform_weather_effect(0)
$calender.change_tone_by_calender(0)
end
calender_perform_transfer
end
end
#==============================================================================
# ■ RPG::Map
#------------------------------------------------------------------------------
# 地图的数据类。
#==============================================================================
class RPG::Map
#--------------------------------------------------------------------------
# ● 地图BGM
#--------------------------------------------------------------------------
def bgm
bgm = Hash.new(@bgm)
@note.each_line do |line|
case line
when /<(?:凌晨|early)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:early_morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
when /<(?:早晨|morning)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
when /<(?:白天|noon)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:noon] = RPG::BGM.new($1, $2.to_i, $3.to_i)
when /<(?:傍晚|evening)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:evening] = RPG::BGM.new($1, $2.to_i, $3.to_i)
when /<(?:夜晚|night)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:night] = RPG::BGM.new($1, $2.to_i, $3.to_i)
when /<(?:深夜|mid)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
bgm[:midnight] = RPG::BGM.new($1, $2.to_i, $3.to_i)
end
end
return bgm
end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
# 管理地图的类。拥有卷动地图以及判断通行度的功能。本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● BGM / BGS 自动切换(重新定义)
#--------------------------------------------------------------------------
def autoplay
case $calender.time_zone
when :early_morning #凌晨
@map.bgm[:early_morning].play if @map.autoplay_bgm
when :morning #早晨
@map.bgm[:morning].play if @map.autoplay_bgm
when :noon #白天
@map.bgm[:noon].play if @map.autoplay_bgm
when :evening #傍晚
@map.bgm[:evening].play if @map.autoplay_bgm
when :night #夜晚
@map.bgm[:night].play if @map.autoplay_bgm
when :midnight #深夜
@map.bgm[:midnight].play if @map.autoplay_bgm
end
@map.bgs.play if @map.autoplay_bgs
end
end
module Kernel
#--------------------------------------------------------------------------
# ● 生成平均随机数
#--------------------------------------------------------------------------
def p_ex_rand(rate, n = 0)
srand
rate = 99 if rate == 100
if n == 0
r = 1 - rand ** (1 - rate * 0.01)
if r == 1
return 0
else
return r
end
else
num = n.truncate
r = 1 - rand ** (1 - rate * 0.01)
r = 0 if r == 1
return (r * num).floor
end
end
end
复制代码
让“时间暂停开关”生效的方法只是在 class Scene_Base → def update_calender(更新时间) 下增加了一行
return if $game_switches[WhiteSnow::TIME_COUNT_FORBID_SID]
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1