code:
;-------------------------------------------------
;天候管理システム本体
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM
#DIMS 低気圧位置
#DIMS 線状降水帯位置
#DIMS 積乱雲位置
#DIM 最新天候傾向

低気圧位置 = %GET_LOCATION_LOW()%
線状降水帯位置 = %GET_LOCATION_LINER_RAINBAND()%
積乱雲位置 = %GET_LOCATION_CUMULUS()%

IF 低気圧位置 == "台風接近強風域" || 低気圧位置 == "台風通過強風域"
	最新天候傾向 = 16
ELSEIF 低気圧位置 == "台風接近暴風域" || 低気圧位置 == "台風通過暴風域" || (IS_TYPHOON:2 != 2 && 低気圧位置 == "台風最接近")
	最新天候傾向 = 21
ELSEIF 低気圧位置 == "台風最接近"
	最新天候傾向 = 17
ELSEIF 線状降水帯位置 == "線状降水帯勢力圏"
	最新天候傾向 = 20
ELSEIF 低気圧位置 == "寒冷渦遠方" && DAY:2 == 4
	最新天候傾向 = 19
ELSEIF 低気圧位置 == "寒冷渦接近" && DAY:2 == 4
	最新天候傾向 = 13
ELSEIF 低気圧位置 == "寒冷渦接近" && (DAY:2 == 1 || DAY:2 == 3) && !IS_RAINY_SEASON1 && !IS_RAINY_SEASON2
	最新天候傾向 = 5
ELSEIF IS_RAINY_SEASON1:1 == 1 || (IS_RAINY_SEASON2 == 1 && 低気圧位置 == "台風勢力圏") || (IS_TYPHOON:3 == 1 && 低気圧位置 == "台風勢力圏")
	最新天候傾向 = 15
ELSEIF IS_RAINY_SEASON1:0 == 1 || IS_RAINY_SEASON2 == 1
	最新天候傾向 = 14
ELSEIF 低気圧位置 == "二つ玉低気圧接近" || 低気圧位置 == "日本海低気圧接近"
	最新天候傾向 = 10
ELSEIF 低気圧位置 == "二つ玉低気圧通過中" || 低気圧位置 == "日本海低気圧通過中"
	最新天候傾向 = 11
ELSEIF 低気圧位置 == "疑似好天"
	最新天候傾向 = 19
ELSEIF 低気圧位置 == "南岸低気圧接近"
	最新天候傾向 = 12
ELSEIF 低気圧位置 == "温暖前線接近"
	最新天候傾向 = 2
ELSEIF 低気圧位置 == "暖域"
	最新天候傾向 = 3
ELSEIF 低気圧位置 == "寒冷前線通過"
	最新天候傾向 = 4
ELSEIF TIME:0 >= 240 && TIME:0 <= 600 && CAN_STRATUS == 1
	最新天候傾向 = 18
ELSEIF DAY:2 == 1 || DAY:2 == 3
	最新天候傾向 = 1
ELSEIF DAY:2 == 4
	最新天候傾向 = 9
ELSEIF DAY:2 == 2 && 積乱雲位置 == "積乱雲接近"
	最新天候傾向 = 7
ELSEIF DAY:2 == 2 && 積乱雲位置 == "積乱雲直下"
	最新天候傾向 = 8
ELSE
	最新天候傾向 = 6
ENDIF

;天候が変わっていればその場で変更
IF NOW_WEATHER_CONTROL != 最新天候傾向
	NOW_WEATHER_CONTROL = 最新天候傾向
	;異常気象発生時は処理終了
	SIF FLAG:異常気象 >= 1 && FLAG:異常気象 <= 8
		RETURN
	;天候変更禁止ならば処理終了
	SIF FORBIDDEN_CHANGE_WEATHER == 1
		RETURN
	TRYCALLFORM CHANGE_WEATHER_SYSTEM_{最新天候傾向}
	;(天候パッチ)台風接近時・猛吹雪時にFLAG:異常気象を設定
	CALL SET_ABNORMAL_WEATHER
ENDIF

;-------------------------------------------------
;1 春・秋の天気(基本)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_1
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;晴天の時
		CASE 0
			;20%で晴天に移行
			IF RAND:5 == 0
				SETBIT TIME:5,0
			;20%で多雲に移行
			ELSEIF RAND:5 == 0
				SETBIT TIME:5,1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			;上記確率に引っかからなかったら晴天
			ELSE
				TIME:5 = 0
			ENDIF
		CASE 1
			;20%で晴天に移行
			IF RAND:5 == 0
				CLEARBIT TIME:5,0
			;20%で多雲に移行
			ELSEIF RAND:5 == 0
				TIME:5 = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			ENDIF
		;陰天の時
		CASE 2,3
			;50%で弱体化
			IF RAND:2 == 0
				TIME:5 = 2
			ELSE
				;晴天に移行
				TIME:5 = 0
				IF !CFLAG:MASTER:诶嘿嘿 && !地底
					IF TIME:2 >= 5 && TIME:2 <= 7
						PRINTW 可以看见星星了
					ELSE
						PRINTW 太阳出来了
					ENDIF
				ENDIF
			ENDIF
		;雨の時
		CASE 4,5,13,14,15
			;50%で弱体化
			IF RAND:2 == 0 && TIME:5 != 4
				TIME:5 = 4
				PRINTW 雨变小了
			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
					;念のため共用雨伞を解除
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雨なら10%で霧雨か雨雪交加に移行
				ELSEIF TIME:5 == 4 && RAND:10 == 0
					TIME:5 = 6
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨点变小了
				;晴天に移行
				ELSE
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						;かもしれないといいつつ確実に見えるのは気分をよくさせる魔法
						IF TIME:2 >= 5 && TIME:2 <= 7
							PRINTW 突然星空变的晴朗了！说不定能看到月虹呢
						ELSE
							PRINTW 突然太阳出来了！说不定能看到彩虹呢
						ENDIF
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雨→晴天を処理したら虹が出る
					TIME:7 = 1
					;市場が開かれる
					FLAG:市場の神 = 1
				ENDIF
			ENDIF
		;霧・霧雨の時
		CASE 6, 7
			TIME:5 = 0
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				IF TIME:2 >= 5 && TIME:2 <= 7
					PRINTW 可以看见星星了
				ELSE
					PRINTW 太阳出来了
				ENDIF
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		CASE IS >= 8
			;雪は冬以外降らない
			IF RAND:2
				;雨になる
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雪天好像变成了雨天的様子
			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;晴天に移行
				ELSE
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTFORMW \@ TIME:2 >= 5 && TIME:2 <= 7? 星空突然变得晴朗了！# 太阳突然出来了！\@ 说不定能看到钻石尘呢
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雪→晴天を処理したらダイヤモンドダストが出る
					TIME:7 = 2
				ENDIF
			ENDIF
		CASEELSE
			TIME:5 = RAND:4
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;強風である場合風がおさまる
IF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;春第2タームまでは降雪・雪崩判定
IF DAY:2 == 1 && NOW_TERM <= 2
	;連続降雪Counter
	SELECTCASE TIME:5
		CASE 0,1,2,3,7
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 5)
			ENDIF
		CASE 4,5,6,14
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 8)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 10)
			ENDIF
		CASE 8
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 1
			ELSE
				SNOW_COVERAGE += 1
			ENDIF
		CASE 9
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 3
			ELSE
				SNOW_COVERAGE += 3
			ENDIF
		CASEELSE
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
			ENDIF
	ENDSELECT

	;雪崩発生フラグ判定
	IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR >= 3 || TIME:5 <= 7 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR == 4 || TIME:5 == 4 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 7 && (POWER_WARM_AIR >= 5 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSE
		POSSIBLITY_AVALANCHE = 0
	ENDIF
ELSE
	CONTINUOUS_SNOWFALL = 0
	SNOW_COVERAGE = 0
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;2 春・秋の天気(温暖前線接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_2
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;晴朗の時
		CASE 1
			TIME:5 = 0
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 少量的雲出來了
		;晴天の時
		CASE 0
			;60%で多雲に移行
			IF RAND:2 == 0
				SETBIT TIME:5,1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			;10%で陰天に移行
			ELSEIF RAND:10 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 天空被雲層完全覆蓋了
			ENDIF
		;多雲の時
		CASE 2
			;60%で陰天に移行
			IF RAND:2 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 天空被雲層完全覆蓋了
			;10%で雨に移行
			ELSEIF RAND:10 == 0
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		;曇の時
		CASE 3
			;50%で雨に移行
			IF RAND:2 == 0
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		;降雨時
		CASE 4,5,13,14,15
			;熱雷発生フラグが立っているとき大雨に移行
			IF GET_HEAT_THUNDERSTORM() && TIME:5 == 4
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ENDIF
		CASEELSE
			TIME:5 = 2
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 变成多云天气了
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;春第2タームまでは降雪・雪崩判定
IF DAY:2 == 1 && NOW_TERM <= 2
	;連続降雪Counter
	SELECTCASE TIME:5
		CASE 0,1,2,3,7
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
			ENDIF
		CASE 4,5,6,14
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 8)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 10)
			ENDIF
		CASE 8
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 1
			ELSE
				SNOW_COVERAGE += 1
			ENDIF
		CASE 9
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 3
			ELSE
				SNOW_COVERAGE += 3
			ENDIF
		CASEELSE
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
			ENDIF
	ENDSELECT

	;雪崩発生フラグ判定
	IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR >= 3 || TIME:5 <= 7 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR == 4 || TIME:5 == 4 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 7 && (POWER_WARM_AIR >= 5 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSE
		POSSIBLITY_AVALANCHE = 0
	ENDIF
ELSE
	CONTINUOUS_SNOWFALL = 0
	SNOW_COVERAGE = 0
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;3 春・秋の天気(暖域時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_3
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF (TIME:5 != 0 || TIME:5 != 2) && CFLAG:MASTER:現在位置 != 天界
	IF RAND:2 == 1
		TIME:5 = 0
		IF !CFLAG:MASTER:诶嘿嘿 && !地底
			IF TIME:2 >= 5 && TIME:2 <= 7
				IF TIME:5 >= 4
					PRINTW 星空漫延了！说不定能看到月虹呢
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
					;雨→晴天を処理したら虹が出る
					TIME:7 = 1
					;市場が開かれる
					FLAG:市場の神 = 1
				ELSE
					PRINTW 可以看见星星了
				ENDIF
			ELSE
				IF TIME:5 >= 4
					PRINTW 太阳出来了！说不定能看到彩虹呢
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
					;雨→晴天を処理したら虹が出る
					TIME:7 = 1
					;市場が開かれる
					FLAG:市場の神 = 1
				ELSE
					PRINTW 太阳出来了
				ENDIF
			ENDIF
		ENDIF
	ELSE
		TIME:5 = 2
		IF !CFLAG:MASTER:诶嘿嘿 && !地底 && TIME:5 >= 4
			PRINTW 雨要停了的様子
		ENDIF
		;念のため共用雨伞を解除
		FOR LOCAL,0,CHARANUM
			SIF TEQUIP:LOCAL:201
				TEQUIP:LOCAL:201 = 0
		NEXT
	ENDIF
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;風速変化の確立
LOCAL:1 = RAND:10

;50%の確率で風速弱体化。暖気が強い場合20%の確率で風速強化
;但し春第1タームは確実に強風
IF DAY:2 == 1 && NOW_TERM == 1 && WIND_VELOCITY != 1 && CFLAG:MASTER:現在位置 != 天界
	WIND_VELOCITY = 1
	IF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了 春天來了！
		CALL ASK_DIARY("吹起了第一縷春風")
	ENDIF
ELSEIF POWER_WARM_AIR >= 4 && LOCAL:1 >= 8 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 0
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了
ELSEIF LOCAL:1 >= 5 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY > 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;春第2タームまでは降雪・雪崩判定
IF DAY:2 == 1 && NOW_TERM <= 2
	;連続降雪Counter
	SELECTCASE TIME:5
		CASE 0,1,2,3,7
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
			ENDIF
		CASE 4,5,6,14
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 8)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 10)
			ENDIF
		CASE 8
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 1
			ELSE
				SNOW_COVERAGE += 1
			ENDIF
		CASE 9
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 3
			ELSE
				SNOW_COVERAGE += 3
			ENDIF
		CASEELSE
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
			ENDIF
	ENDSELECT

	;雪崩発生フラグ判定
	IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR >= 3 || TIME:5 <= 7 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR == 4 || TIME:5 == 4 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 7 && (POWER_WARM_AIR >= 5 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSE
		POSSIBLITY_AVALANCHE = 0
	ENDIF
ELSE
	CONTINUOUS_SNOWFALL = 0
	SNOW_COVERAGE = 0
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;4 春・秋の天気(寒冷前線通過時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_4
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF TIME:5 == 15 && GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && CFLAG:MASTER:現在位置 != 天界
	TIME:5 = 14
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 下起了暴雨！
ELSEIF (TIME:5 == 13 || TIME:5 == 15) && CFLAG:MASTER:現在位置 != 天界
	TIME:5 = 5
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 变成了瓢泼大雨！
ELSEIF TIME:5 != 4 && TIME:5 != 5 && TIME:5 != 14 && CFLAG:MASTER:現在位置 != 天界
	IF RAND:3 == 0
		TIME:5 = 4
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 下雨了！
	ELSEIF RAND:3 == 1 && GET_FRONTAL_THUNDERSTORM() == 1
		SELECTCASE POWER_WARM_AIR
			CASE 5
				IF RAND:3 == 0
					TIME:5 = 15
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了冰雹！
				ELSE
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				ENDIF
			CASEELSE
				TIME:5 = 13
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 落冰雹了！
		ENDSELECT
	ELSE
		TIME:5 = 5
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 变成了瓢泼大雨！
	ENDIF
ELSEIF CFLAG:MASTER:現在位置 != 天界
	IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1
		IF TIME:5 != 14
			TIME:5 = 14
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下起了暴雨！
		ENDIF
	ELSE
		SELECTCASE TIME:5
			CASE 4
				IF RAND:3 == 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ENDIF
			CASE 5
				IF RAND:3 == 0
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨变小了
				ENDIF
			CASE 14
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨稍微小了一些
			CASEELSE
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
		ENDSELECT
	ENDIF
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;風速変化の確立
LOCAL:1 = RAND:4

;(天候パッチ)熱界雷時の処理　ダウンバースト発生
IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && ATMOSPHERIC_INSTABILITY <= -1 && CFLAG:MASTER:現在位置 != 天界
	IF ATMOSPHERIC_INSTABILITY <= -2
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 很強的風！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASE 1
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 而且風變強了！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASEELSE
				WIND_VELOCITY = 2
		ENDSELECT
	ELSE
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風變強了！
			CASE 1
				WIND_VELOCITY = 1
			CASEELSE
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風比剛才變弱了
		ENDSELECT
	ENDIF
;強風である場合25%で風がおさまる
ELSEIF LOCAL:1 == 0 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;春第2タームまでは降雪・雪崩判定
IF DAY:2 == 1 && NOW_TERM <= 2
	;連続降雪Counter
	SELECTCASE TIME:5
		CASE 0,1,2,3,7
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
			ENDIF
		CASE 4,5,6,14
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 8)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 10)
			ENDIF
		CASE 8
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 1
			ELSE
				SNOW_COVERAGE += 1
			ENDIF
		CASE 9
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 3
			ELSE
				SNOW_COVERAGE += 3
			ENDIF
		CASEELSE
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
			ENDIF
	ENDSELECT

	;雪崩発生フラグ判定
	IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR >= 3 || TIME:5 <= 7 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR == 4 || TIME:5 == 4 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 7 && (POWER_WARM_AIR >= 5 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSE
		POSSIBLITY_AVALANCHE = 0
	ENDIF
ELSE
	CONTINUOUS_SNOWFALL = 0
	SNOW_COVERAGE = 0
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;5 春・秋の天気(寒冷渦接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_5
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	;暖気が1の場合降雪の可能性
	IF POWER_WARM_AIR == 1
		SELECTCASE TIME:5
			;陰天
			CASE 3
				SELECTCASE RAND:5
					CASE 0
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					CASE 1, 2
						TIME:5 = 8
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下雪了！
					CASEELSE
						TIME:5 = 9
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下雪了！而且是大雪
				ENDSELECT
			;雪
			CASE 8
				SELECTCASE RAND:5
					CASE 0
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					CASE 1
						TIME:5 = 3
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW  雪好像停了的様子
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					CASEELSE
						TIME:5 = 9
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪越來越大了！
				ENDSELECT
			;大雪
			CASE 9
				SELECTCASE RAND:5
					CASE 0
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					CASE 1
						TIME:5 = 3
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW  雪好像停了的様子
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					CASEELSE
						TIME:5 = 8
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪好像變弱了
				ENDSELECT
			;冰雹
			CASE 13
				SELECTCASE RAND:4
					CASE 0
						TIME:5 = 8
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下雪了！
					CASEELSE
						TIME:5 = 9
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪越來越大了！
				ENDSELECT
			CASEELSE
				TIME:5 = 9
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雪了！而且是大雪
		ENDSELECT
	ELSE
		SELECTCASE TIME:5
			;陰天
			CASE 3
				IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && RAND:6 == 0
					SELECTCASE RAND:6
						CASE 0
							TIME:5 = 15
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了冰雹！
						CASE IS >= 2
							TIME:5 = 5
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 变成了瓢泼大雨！
						CASEELSE
							TIME:5 = 14
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了暴雨！
					ENDSELECT
				ELSE
					SELECTCASE RAND:6
						CASE 0
							TIME:5 = 13
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 落冰雹了！
						CASE 1
							TIME:5 = 12
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 雨夾雪降下來了！
						CASE 2
							TIME:5 = 4
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下雨了！
						CASEELSE
							TIME:5 = 5
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 变成了瓢泼大雨！
					ENDSELECT
				ENDIF
			;雨
			CASE 4
				IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && RAND:4 == 0
					SELECTCASE RAND:6
						CASE 0
							TIME:5 = 15
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了冰雹！
						CASE IS >= 2
							TIME:5 = 5
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 变成了瓢泼大雨！
						CASEELSE
							TIME:5 = 14
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了暴雨！
					ENDSELECT
				ELSE
					SELECTCASE RAND:6
						CASE 0
							TIME:5 = 13
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 落冰雹了！
						CASE 1
							TIME:5 = 12
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 雨夾雪降下來了！
						CASE 2
							TIME:5 = 3
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW  雨停了
							FOR LOCAL,0,CHARANUM
								SIF TEQUIP:LOCAL:201
									TEQUIP:LOCAL:201 = 0
							NEXT
						CASEELSE
							TIME:5 = 5
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 变成了瓢泼大雨！
					ENDSELECT
				ENDIF
			;大雨
			CASE 5,14
				SELECTCASE RAND:5
					CASE 0
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					CASE 1
						TIME:5 = 3
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW  雨停了
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					CASEELSE
						IF TIME:5 == 14
							TIME:5 = 5
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 雨稍微小了一点
						ELSEIF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && RAND:2 == 0
							TIME:5 = 14
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了暴雨！
						ELSE
							TIME:5 = 4
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 雨变小了
						ENDIF
				ENDSELECT
			;雨雪交加
			CASE 12
				SELECTCASE RAND:5
					CASE 0
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					CASE 1, 2
						TIME:5 = 3
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW  雨停了
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					CASEELSE
						TIME:5 = 4
				ENDSELECT
			;冰雹
			CASE 13
				SELECTCASE RAND:4
					CASE 0
						TIME:5 = 4
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下雨了！
					CASEELSE
						TIME:5 = 5
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 变成了瓢泼大雨！
				ENDSELECT
			;ひょう
			CASE 15
				SELECTCASE RAND:4
					CASE 0
						TIME:5 = 14
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下起了暴雨！
					CASEELSE
						TIME:5 = 5
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 变成了瓢泼大雨！
				ENDSELECT
			CASEELSE
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
		ENDSELECT
	ENDIF
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;風速変化の確立
LOCAL:1 = RAND:20

;(天候パッチ)熱界雷時の処理　ダウンバースト発生
IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && ATMOSPHERIC_INSTABILITY <= -1 && CFLAG:MASTER:現在位置 != 天界
	IF ATMOSPHERIC_INSTABILITY <= -2
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 很強的風！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASE 1
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 而且風變強了！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASEELSE
				WIND_VELOCITY = 2
		ENDSELECT
	ELSE
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風變強了！
			CASE 1
				WIND_VELOCITY = 1
			CASEELSE
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風比剛才變弱了
		ENDSELECT
	ENDIF
;10%の確率で暴風
ELSEIF LOCAL:1 == 0 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 1
	WIND_VELOCITY = 2
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風越來越強了！
;50%の確率で暴風から強風に弱体化
ELSEIF LOCAL:1 >= 10 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 2
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變小了一點
ELSEIF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 0
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了
ENDIF

;春第2タームまでは降雪・雪崩判定
IF DAY:2 == 1 && NOW_TERM <= 2
	;連続降雪Counter
	SELECTCASE TIME:5
		CASE 0,1,2,3,7
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
			ENDIF
		CASE 4,5,6,14
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 8)
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 10)
			ENDIF
		CASE 8
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 1
			ELSE
				SNOW_COVERAGE += 1
			ENDIF
		CASE 9
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
				SNOW_COVERAGE += 3
			ELSE
				SNOW_COVERAGE += 3
			ENDIF
		CASEELSE
			IF CONTINUOUS_SNOWFALL >= 1
				SNOW_COVERAGE = CONTINUOUS_SNOWFALL
				CONTINUOUS_SNOWFALL = 0
			ELSE
				SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
			ENDIF
	ENDSELECT

	;雪崩発生フラグ判定
	IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR >= 3 || TIME:5 <= 7 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR == 4 || TIME:5 == 4 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 7 && (POWER_WARM_AIR >= 5 || TIME:5 == 5 || TIME:5 == 14)
		POSSIBLITY_AVALANCHE = 2
	ELSE
		POSSIBLITY_AVALANCHE = 0
	ENDIF
ELSE
	CONTINUOUS_SNOWFALL = 0
	SNOW_COVERAGE = 0
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;6 夏の天気(基本)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_6
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

;暖気が1のとき
IF POWER_WARM_AIR == 1 && CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		;晴天の時
		CASE 0
			;20%で晴天に移行
			IF RAND:5 == 0
				SETBIT TIME:5,0
			;20%で多雲に移行
			ELSEIF RAND:5 == 0
				SETBIT TIME:5,1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			;上記確率に引っかからなかったら晴天
			ELSE
				TIME:5 = 0
			ENDIF
		CASE 1
			;20%で晴天に移行
			IF RAND:5 == 0
				CLEARBIT TIME:5,0
			;20%で多雲に移行
			ELSEIF RAND:5 == 0
				TIME:5 = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			ENDIF
		;陰天の時
		CASE 2,3
			;25%で弱体化
			IF RAND:4 == 0
				TIME:5 = 2
			ELSE
				;20%で晴天に移行
				IF RAND:5 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						IF TIME:2 >= 5 && TIME:2 <= 7
							PRINTW 可以看见星星了
						ELSE
							PRINTW 太阳出来了
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		;雨の時
		CASE 4,5,14,15
			;25%で弱体化
			IF RAND:4 == 0 && TIME:5 != 4
				TIME:5 = 4
				PRINTW 雨变小了
			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
					;念のため共用雨伞を解除
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雨なら10%で霧雨に移行
				ELSEIF TIME:5 == 4 && RAND:10 == 0
					TIME:5 = 6
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨点变小了
				;10%で晴天に移行
				ELSEIF RAND:10 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						;かもしれないといいつつ確実に見えるのは気分をよくさせる魔法
						IF TIME:2 >= 5 && TIME:2 <= 7
							PRINTW 突然星空变的晴朗了！说不定能看到月虹呢
						ELSE
							PRINTW 突然太阳出来了！说不定能看到彩虹呢
						ENDIF
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雨→晴天を処理したら虹が出る
					TIME:7 = 1
					;市場が開かれる
					FLAG:市場の神 = 1
				ENDIF
			ENDIF
		;霧・霧雨の時
		CASE 6, 7
			TIME:5 = 0
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				IF TIME:2 >= 5 && TIME:2 <= 7
					PRINTW 可以看见星星了
				ELSE
					PRINTW 太阳出来了
				ENDIF
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		;雪の時
		CASE IS >= 8
			;雪は冬以外降らない
			IF TIME:5 == 8
				;雨になる
				CLEARBIT TIME:5,3
				SETBIT TIME:5,2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雪天好像变成了雨天的様子
			;50%の確率で弱体化
			ELSEIF GETBIT(TIME:5,0) && RAND:2
				CLEARBIT TIME:5,0
				PRINTW 雪好像變弱了

			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雪なら10%で細雪か雨雪交加に移行
				ELSEIF TIME:5 == 8 && RAND:10 == 0
					IF RAND:2
						TIME:5 = 10
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪花变小了
					ELSE
						TIME:5 = 12
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪中掺了一些雨点
					ENDIF
					;更に10%の確率で霧雪,冰雹に移行
					SIF RAND:10 == 0
						SETBIT TIME:5,0
				;10%で晴天に移行
				ELSEIF RAND:10 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTFORMW \@ TIME:2 >= 5 && TIME:2 <= 7? 星空突然变得晴朗了！# 太阳突然出来了！\@ 说不定能看到钻石尘呢
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雪→晴天を処理したらダイヤモンドダストが出る
					TIME:7 = 2
				ENDIF
			ENDIF
		CASEELSE
			TIME:5 = RAND:4
	ENDSELECT
;暖気が2以上
ELSEIF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		;晴天の時
		CASE 0
			TIME:5 = 1
		;陰天の時
		CASE 2,3
			TIME:5 = 1
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				IF TIME:2 >= 5 && TIME:2 <= 7
					PRINTW 可以看见星星了
				ELSE
					PRINTW 太阳出来了
				ENDIF
			ENDIF
		;雨の時
		CASE 4,5,6,7,13
			;25%で陰天に移行
			IF RAND:4 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨要停了的様子
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			;75%で晴天に移行
			ELSE
				TIME:5 = 0
				IF !CFLAG:MASTER:诶嘿嘿 && !地底
					;かもしれないといいつつ確実に見えるのは気分をよくさせる魔法
					IF TIME:2 >= 5 && TIME:2 <= 7
						PRINTW 突然星空变的晴朗了！说不定能看到月虹呢
					ELSE
						PRINTW 突然太阳出来了！说不定能看到彩虹呢
					ENDIF
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
				ENDIF
				;更に確率で晴朗
				SIF RAND:10 < 5
					TIME:5 = 1
				;雨→晴天を処理したら虹が出る
				TIME:7 = 1
				;市場が開かれる
				FLAG:市場の神 = 1
			ENDIF
		CASE 14,15
			TIME:5 = 5
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 雨稍微小了一些
		;雪の時
		CASE IS >= 8
			;雪は冬以外降らない
			IF TIME:5 == 8
				;雨になる
				CLEARBIT TIME:5,3
				SETBIT TIME:5,2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雪天好像变成了雨天的様子
			;50%の確率で弱体化
			ELSEIF GETBIT(TIME:5,0) && RAND:2
				CLEARBIT TIME:5,0
				PRINTW 雪好像變弱了

			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雪なら10%で細雪か雨雪交加に移行
				ELSEIF TIME:5 == 8 && RAND:10 == 0
					IF RAND:2
						TIME:5 = 10
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪花变小了
					ELSE
						TIME:5 = 12
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雪中掺了一些雨点
					ENDIF
					;更に10%の確率で霧雪,冰雹に移行
					SIF RAND:10 == 0
						SETBIT TIME:5,0
				;10%で晴天に移行
				ELSEIF RAND:10 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTFORMW \@ TIME:2 >= 5 && TIME:2 <= 7? 星空突然变得晴朗了！# 太阳突然出来了！\@ 说不定能看到钻石尘呢
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雪→晴天を処理したらダイヤモンドダストが出る
					TIME:7 = 2
				ENDIF
			ENDIF
		CASEELSE
			TIME:5 = 1
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;強風である場合風がおさまる
IF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;7 夏の天気(夕立接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_7
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE CAN_CUMULUS:0
		CASE 1
			TIME:5 = 0
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 綿雲出來了
		CASE 2, 3
			IF RAND:2 == 0
				TIME:5 = 0
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 綿雲出來了
			ELSE
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			ENDIF
		CASE 4
			IF RAND:2 == 0
				TIME:5 = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 卷雲正在蔓延
			ELSE
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 曇多起來了
			ENDIF
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 冷風吹起來了！
		CASE 5
			TIME:5 = 3
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 天暗下來了……
				PRINTW 冷風吹起來了！
			ENDIF
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;8 夏の天気(夕立通過後)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_8
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE CAN_CUMULUS:0
		CASE 1
			IF RAND:2 == 0 && TIME:5 <= 1
				TIME:5 = 0
			ELSEIF TIME:5 < 3
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 曇多起來了
			ENDIF
		CASE 2
			IF RAND:3 == 0 && TIME:5 < 4
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ELSEIF TIME:5 < 3
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 曇多起來了
			ENDIF
		CASE 3
			IF RAND:3 == 0 && TIME:5 < 4
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ELSEIF TIME:5 < 4
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		CASE 4
			IF RAND:3 == 0 && TIME:5 == 5
				TIME:5 = 13
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 落冰雹了！
			ELSEIF TIME:5 != 5
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ENDIF
		CASE 5
			IF RAND:3 == 0 && TIME:5 != 15
				TIME:5 = 15
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下起了冰雹！
			ELSEIF TIME:5 != 14
				TIME:5 = 14
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨下得很大！
			ENDIF
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;ダウンバースト発生
IF CAN_CUMULUS:2 == 2 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 2
	WIND_VELOCITY = 2
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 很強的風！
	;ダウンバーストによる作物への影響
	IF FLAG:地主 > 0
		FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
		IS_STORM_CROP_DAMAGE ++
	ENDIF
ELSEIF CAN_CUMULUS:2 == 1 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 1
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了！
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;9 冬の天気(基本)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_9
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;晴天の時
		CASE 0
			;20%で多雲に移行
			IF RAND:5 == 0
				SETBIT TIME:5,1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			;5%で陰天に移行
			ELSEIF RAND:20 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成陰天了
			;上記確率に引っかからなかったら晴天
			ELSE
				TIME:5 = 0
			ENDIF
		CASE 1
			;20%で多雲に移行
			IF RAND:5 == 0
				TIME:5 = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			ELSE
				TIME:5 = 0
			ENDIF
		;陰天の時
		CASE 2,3
			;25%で強化or弱体化
			IF RAND:4 == 0
				INVERTBIT TIME:5,0
			ELSE
				;20%で晴天に移行
				IF RAND:5 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						IF TIME:2 >= 5 && TIME:2 <= 7
							PRINTW 可以看见星星了
						ELSE
							PRINTW 太阳出来了
						ENDIF
					ENDIF
				;多雲なら10%で雨か雪に移行
				ELSEIF TIME:5 == 2 && RAND:10 == 0
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
					;更に10%の確率で霧雨,細雪に移行
					SIF RAND:10 == 0
						SETBIT TIME:5,1
				;陰天なら30%で雪に移行
				ELSEIF TIME:5 == 3 && RAND:10 < 3
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				ENDIF
			ENDIF
		;雨の時
		CASE 4,5,14,15
			TIME:5 = 8
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雪了！
		;霧・霧雨の時
		CASE 6, 7
			TIME:5 = 0
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				IF TIME:2 >= 5 && TIME:2 <= 7
					PRINTW 可以看见星星了
				ELSE
					PRINTW 太阳出来了
				ENDIF
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		;雪の時
		CASE IS >= 8
			;大雪は弱体化
			IF TIME:5 == 9
				TIME:5 = 8
				PRINTW 雪好像變弱了

			ELSE
				;50%で陰天に移行
				IF RAND:2 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雪なら10%で細雪か雨雪交加に移行
				ELSEIF TIME:5 == 8 && RAND:10 == 0
					TIME:5 = 10
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪花变小了
					;更に10%の確率で霧雪,冰雹に移行
					SIF RAND:10 == 0
						SETBIT TIME:5,0
				;25%で晴天に移行
				ELSEIF RAND:4 == 0
					TIME:5 = 0
					IF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTFORMW \@ TIME:2 >= 5 && TIME:2 <= 7? 星空突然变得晴朗了！# 太阳突然出来了！\@ 说不定能看到钻石尘呢
						FOR LOCAL,0,CHARANUM
							SIF TEQUIP:LOCAL:201
								TEQUIP:LOCAL:201 = 0
						NEXT
					ENDIF
					;更に低確率で晴朗
					SIF RAND:100 < 5
						TIME:5 = 1
					;雪→晴天を処理したらダイヤモンドダストが出る
					TIME:7 = 2
				ENDIF
			ENDIF
		CASEELSE
			TIME:5 = RAND:4
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;連続降雪Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
		ENDIF
	CASE 3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ENDIF
	CASE 4,5,6,14
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 6)
		ENDIF
	CASE 8
		CONTINUOUS_SNOWFALL += 1
	CASE 9
		CONTINUOUS_SNOWFALL += 3
ENDSELECT

;強風である場合風がおさまる
IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE WIND_VELOCITY
		CASE 1
			WIND_VELOCITY = 0
			SIF !地底
				PRINTW 風停了
		CASE 2
			WIND_VELOCITY = 1
			SIF !地底
				PRINTW 風變小了一點
		CASE IS >= 3
			WIND_VELOCITY = 2
			SIF !地底
				PRINTW 风比刚才小了一点儿
	ENDSELECT
ENDIF

;雪崩発生フラグ判定
IF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;10 冬の天気(日本海低気圧接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_10
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;晴朗の時
		CASE 1
			TIME:5 = 0
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 少量的雲出來了
		;晴天の時
		CASE 0
			;60%で多雲に移行
			IF RAND:2 == 0
				SETBIT TIME:5,1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成多云天气了
			;10%で陰天に移行
			ELSEIF RAND:10 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 天空被雲層完全覆蓋了
			ENDIF
		;多雲の時
		CASE 2
			;60%で陰天に移行
			IF RAND:2 == 0
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 天空被雲層完全覆蓋了
			;10%で雨・雪に移行
			ELSEIF RAND:10 == 0
				;暖気の強さによって雨か雪を区別
				IF POWER_WARM_AIR >= 3
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雨了！
				ELSE
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				ENDIF
			ENDIF
		;曇の時
		CASE 3
			;50%で雨・雪に移行
			IF RAND:2 == 0
				;暖気の強さによって雨か雪を区別
				IF POWER_WARM_AIR >= 3
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雨了！
				ELSE
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				ENDIF
			ENDIF
		;雨の時
		CASE 4
			;50%で大雨・大雪に移行
			IF RAND:2 == 0
				;暖気の強さによって雨か雪を区別
				IF POWER_WARM_AIR >= 3
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSE
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨變成雪了！
				ENDIF
			ENDIF
		;雪の時
		CASE 8
			;50%で大雨・大雪に移行
			IF RAND:2 == 0
				;暖気の強さによって雨か雪を区別
				IF POWER_WARM_AIR >= 3
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSE
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪越來越大了！
				ENDIF
			ENDIF
		CASE 6, 7, IS >= 10
			;暖気の強さによって雨か雪を区別
			IF POWER_WARM_AIR >= 3
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ELSE
				TIME:5 = 8
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雪了！
			ENDIF
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;連続降雪Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
		ENDIF
	CASE 3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ENDIF
	CASE 4,5,6,14
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 6)
		ENDIF
	CASE 8
		CONTINUOUS_SNOWFALL += 1
	CASE 9
		CONTINUOUS_SNOWFALL += 3
ENDSELECT

IF (POWER_WARM_AIR >= 4 || IS_SoJ_LOW ==2) && CFLAG:MASTER:現在位置 != 天界
	IF WIND_VELOCITY == 0
		WIND_VELOCITY = 1
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 風變強了
	ENDIF
ENDIF

;雪崩発生フラグ判定
IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR == 4 || TIME:5 == 4)
	POSSIBLITY_AVALANCHE = 2
ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR >= 5 || TIME:5 == 5)
	POSSIBLITY_AVALANCHE = 2
ELSEIF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;11 冬の天気(日本海低気圧通過時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_11
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF IS_SoJ_LOW == 2 && CFLAG:MASTER:現在位置 != 天界
	IF TIME:5 != 9 || WIND_VELOCITY < 2
		TIME:5 = 9
		IF POWER_COLD_AIR >= 4 && POWER_WARM_AIR >= 5
			WIND_VELOCITY = 3
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 突然下起了暴风雪！
				CALL ASK_DIARY("晴朗的天空突然天気急変")
			ENDIF
		ELSE
			WIND_VELOCITY = 2
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 突然下起了暴风雪！
				CALL ASK_DIARY("晴朗的天空突然天気急変")
			ENDIF
		ENDIF
	ENDIF
RETURN
ENDIF

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		CASE IS < 8
			IF POWER_COLD_AIR < 3
				TIME:5 = 8
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雪了！
			ELSE
				TIME:5 = 9
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下大雪了！
			ENDIF
		CASE 8
			IF POWER_COLD_AIR >= 3
				IF RAND:3 > 1
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪越來越大了！
				ELSEIF RAND:3 == 1
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				ENDIF
			ENDIF
		CASE 9
			IF RAND:3 == 0
				TIME:5 = 8
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雪變弱了
			ELSEIF RAND:3 == 1
				TIME:5 = 13
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 落冰雹了！
			ENDIF
		CASE 13
			IF POWER_COLD_AIR >= 3
				TIME:5 = 9
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雪越來越大了！
			ELSE
				TIME:5 = 8
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雪了！
			ENDIF
		CASEELSE
			TIME:5 = 8
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雪了！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;連続降雪Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
		ENDIF
	CASE 3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ENDIF
	CASE 4,5,6,14
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 6)
		ENDIF
	CASE 8
		CONTINUOUS_SNOWFALL += 1
	CASE 9
		CONTINUOUS_SNOWFALL += 3
ENDSELECT

;風速変化の確立
LOCAL:1 = RAND:20

;5%の確率で暴風
IF LOCAL:1 == 0 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 1 && POWER_COLD_AIR >= 4
	WIND_VELOCITY = 2
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風越來越強了！
;50%の確率で暴風から強風に弱体化
ELSEIF LOCAL:1 >= 10 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 2
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變小了一點
ELSEIF LOCAL:1 >= 10 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 0
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了
ENDIF

;雪崩発生フラグ判定
IF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;12 冬の天気(南岸低気圧接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_12
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;晴天の時
		CASE 0, 1
			TIME:5 = 3
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 变成陰天了
		;陰天の時
		CASE 2,3
			;25%で強化or弱体化
			IF RAND:4 == 0
				INVERTBIT TIME:5,0
			ELSE
				;多雲なら25%で雨か雪に移行
				IF TIME:5 == 2 && RAND:4 == 0
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				;陰天なら50%で雨に移行
				ELSEIF TIME:5 == 3 && RAND:2 == 0
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				ENDIF
			ENDIF
		;雨の時
		CASE 4,5,6,7,14,15
			TIME:5 = 8
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雪了！
		;雪の時
		CASE IS >= 8
			;10%で強化
			IF !GETBIT(TIME:5,0) && RAND:10 == 0
				SETBIT TIME:5,0
				PRINTW 雪越來越大了！
			;50%の確率で弱体化
			ELSEIF GETBIT(TIME:5,0) && RAND:2
				CLEARBIT TIME:5,0
				PRINTW 雪好像變弱了

			ELSE
				;25%で陰天に移行
				IF RAND:4 == 0
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				;雪なら10%で細雪か雨雪交加に移行
				ELSEIF TIME:5 == 8 && RAND:10 == 0
					TIME:5 = 10
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪花变小了
					;更に10%の確率で霧雪,冰雹に移行
					SIF RAND:10 == 0
						SETBIT TIME:5,0
				ENDIF
			ENDIF
		CASEELSE
			TIME:5 = 8
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雪了！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;連続降雪Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
		ENDIF
	CASE 3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ENDIF
	CASE 4,5,6,14
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 6)
		ENDIF
	CASE 8
		CONTINUOUS_SNOWFALL += 1
	CASE 9
		CONTINUOUS_SNOWFALL += 3
ENDSELECT

;雪崩発生フラグ判定
IF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 15 && (POWER_WARM_AIR == 4 || TIME:5 == 4)
	POSSIBLITY_AVALANCHE = 2
ELSEIF SNOW_COVERAGE + CONTINUOUS_SNOWFALL >= 10 && (POWER_WARM_AIR >= 5 || TIME:5 == 5)
	POSSIBLITY_AVALANCHE = 2
ELSEIF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;13 冬の天気(寒冷渦接近時)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_13
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
		;曇り
	CASE 3
			SELECTCASE RAND:5
				CASE 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				CASE 1, 2
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				CASEELSE
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！而且是大雪
			ENDSELECT
		;雪
		CASE 8
			SELECTCASE RAND:5
				CASE 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				CASE 1
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW  雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				CASEELSE
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪越來越大了！
			ENDSELECT
		;大雪
		CASE 9
			SELECTCASE RAND:5
				CASE 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				CASE 1
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW  雪好像停了的様子
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				CASEELSE
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪好像變弱了
			ENDSELECT
		;冰雹
		CASE 13
			SELECTCASE RAND:4
				CASE 0
					TIME:5 = 8
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雪了！
				CASEELSE
					TIME:5 = 9
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雪越來越大了！
			ENDSELECT
		CASEELSE
			TIME:5 = 9
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雪了！而且是大雪
		ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;連続降雪Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 3)
		ENDIF
	CASE 3
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 1)
		ENDIF
	CASE 4,5,6,14
		IF CONTINUOUS_SNOWFALL >= 1
			SNOW_COVERAGE = CONTINUOUS_SNOWFALL
			CONTINUOUS_SNOWFALL = 0
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 4)
		ELSE
			SNOW_COVERAGE = MAX(0, SNOW_COVERAGE - 6)
		ENDIF
	CASE 8
		CONTINUOUS_SNOWFALL += 1
	CASE 9
		CONTINUOUS_SNOWFALL += 3
ENDSELECT

;風速変化の確立
LOCAL:1 = RAND:20

;10%の確率で暴風
IF LOCAL:1 == 0 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 1
	WIND_VELOCITY = 2
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風越來越強了！
;50%の確率で暴風から強風に弱体化
ELSEIF LOCAL:1 >= 10 && CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 2
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變小了一點
ELSEIF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY == 0
	WIND_VELOCITY = 1
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風變強了
ENDIF

;雪崩発生フラグ判定
IF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;14 梅雨・秋雨の天気(基本)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_14
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
	CASE 1
			TIME:5 = 2
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 少量的雲出來了
		CASE 2
			IF RAND:4 == 0
				IF !CFLAG:MASTER:诶嘿嘿 && !地底
					IF TIME:2 >= 5 && TIME:2 <= 7
						PRINTW 可以看见星星了
					ELSE
						PRINTW 太阳出来了
					ENDIF
				ENDIF
			ELSE
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雲變厚了
			ENDIF
		CASE 3
			IF RAND:3 == 0
				TIME:5 = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雲變薄了
			ELSE
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		CASE 4,5,6,7,14,15
			IF GET_HEAT_THUNDERSTORM() == 1 && GET_FRONTAL_THUNDERSTORM() == 1 && (TIME:5 == 4 || TIME:5 == 5) && RAND:2 == 0 && TIME:5 != 14
				TIME:5 = 14
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下起了暴雨！
			ELSEIF (GET_HEAT_THUNDERSTORM() == 1 || GET_FRONTAL_THUNDERSTORM() == 1) && TIME:5 == 4
				IF RAND:4 == 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				ELSE
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ENDIF
			ELSEIF RAND:3 == 0
				TIME:5 = 0
				IF !CFLAG:MASTER:诶嘿嘿 && !地底
					;かもしれないといいつつ確実に見えるのは気分をよくさせる魔法
					IF TIME:2 >= 5 && TIME:2 <= 7
						PRINTW 突然星空变的晴朗了！说不定能看到月虹呢
					ELSE
						PRINTW 突然太阳出来了！说不定能看到彩虹呢
					ENDIF
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
				ENDIF
				;雨→晴天を処理したら虹が出る
				TIME:7 = 1
				;市場が開かれる
				FLAG:市場の神 = 1
			ELSE
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨要停了的様子
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		CASEELSE
			TIME:5 = 3
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 雲變厚了
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;強風である場合風がおさまる
IF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;15 梅雨・秋雨(梅雨末期・秋雨+台風接近)・先駆降雨帯発生時の天気
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_15
#DIM 地底
#DIM 活発化フラグ
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

活発化フラグ = 0
SIF POWER_WARM_AIR == 5 || GET_LOCATION_LOW() == "台風勢力圏" || GET_HEAT_THUNDERSTORM() == 1 || GET_FRONTAL_THUNDERSTORM() == 1
	活発化フラグ = 1

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		CASE 3
			IF 活発化フラグ == 1
				IF RAND:3 == 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSEIF RAND:2 == 0 && (GET_HEAT_THUNDERSTORM() == 1 || GET_FRONTAL_THUNDERSTORM() == 1)
					IF GET_HEAT_THUNDERSTORM() == 1 && GET_FRONTAL_THUNDERSTORM() == 1
						IF RAND:4 == 0
							TIME:5 = 15
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了冰雹！
						ELSE
							TIME:5 = 14
							SIF !CFLAG:MASTER:诶嘿嘿 && !地底
								PRINTW 下起了暴雨！
						ENDIF
					ELSE
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					ENDIF
				ELSE
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雨了！
				ENDIF
			ELSE
				IF RAND:4 == 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSE
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下雨了！
				ENDIF
			ENDIF
		CASE 4,6,7
			IF GET_HEAT_THUNDERSTORM() == 1 && GET_FRONTAL_THUNDERSTORM() == 1 && RAND:2
				IF RAND:4 == 0
					TIME:5 = 15
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了冰雹！
				ELSE
					TIME:5 = 14
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了暴雨！
				ENDIF
			ELSEIF 活発化フラグ == 1
				IF RAND:3 != 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSEIF RAND:2 == 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				ELSE
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
					;念のため共用雨伞を解除
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				ENDIF
			ELSE
				IF RAND:2 != 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 变成了瓢泼大雨！
				ELSE
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
					;念のため共用雨伞を解除
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				ENDIF
			ENDIF
		CASE 5,14,15
			IF GET_HEAT_THUNDERSTORM() == 1 && GET_FRONTAL_THUNDERSTORM() == 1
				IF RAND:4 == 0 && TIME:5 != 15
					TIME:5 = 15
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了冰雹！
				ELSEIF RAND:2 == 0 && TIME:5 != 14
					TIME:5 = 14
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了暴雨！
				ELSEIF TIME:5 == 14
					IF RAND:3
						TIME:5 = 4
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雨变小了
					ELSE
						TIME:5 = 5
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 雨稍微小了一点
					ENDIF
				ELSE
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
				ENDIF
			ELSEIF 活発化フラグ == 1
				IF RAND:2 != 0
					TIME:5 = 13
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 落冰雹了！
				ELSE
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨变小了
				ENDIF
			ELSE
				IF RAND:2 != 0
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨变小了
				ELSE
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
					;念のため共用雨伞を解除
					FOR LOCAL,0,CHARANUM
						SIF TEQUIP:LOCAL:201
							TEQUIP:LOCAL:201 = 0
					NEXT
				ENDIF
			ENDIF
		CASE 13
			IF GET_HEAT_THUNDERSTORM() == 1 && GET_FRONTAL_THUNDERSTORM() == 1
				TIME:5 = 14
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下起了暴雨！
			ELSE
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ENDIF
		CASEELSE
			TIME:5 = 4
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雨了！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		SIF CFLAG:MASTER:現在位置 != 天界
			CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;(天候パッチ)熱界雷時の処理　ダウンバースト発生
IF GET_FRONTAL_THUNDERSTORM() == 1 && GET_HEAT_THUNDERSTORM() == 1 && ATMOSPHERIC_INSTABILITY <= -1 && CFLAG:MASTER:現在位置 != 天界
	IF ATMOSPHERIC_INSTABILITY <= -2 && RAND:2 == 0
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 很強的風！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASE 1
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 而且風變強了！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASEELSE
				WIND_VELOCITY = 2
		ENDSELECT
	ELSE
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風變強了！
			CASE 1
				WIND_VELOCITY = 1
			CASEELSE
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風比剛才變弱了
		ENDSELECT
	ENDIF
;強風である場合風がおさまる
ELSEIF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;16 台風接近時の天気(強風域)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_16
#DIM 地底
#DIM 豪雨フラグ
#DIMS 低気圧位置
地底 = 0
低気圧位置 = %GET_LOCATION_LOW()%
豪雨フラグ = 0

;台風勢力5以上、台風の位置が西かつ暖気5のとき豪雨フラグオン
SIF IS_TYPHOON:1 >= 5 && IS_TYPHOON:2 == 3 && POWER_WARM_AIR >= 5
	豪雨フラグ = 1

IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
	CASE 3
			IF RAND:2 == 0
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ELSE
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		CASE 4,6,7
			IF RAND:2 != 0
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ELSEIF RAND:2 == 0 && 低気圧位置 == "台風通過強風域"
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨要停了的様子
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		CASE 5,14
			IF RAND:2 != 0 && 豪雨フラグ == 1 && TIME:5 != 14 && 低気圧位置 != "台風通過強風域"
				TIME:5 = 14
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下起了暴雨！
			ELSEIF RAND:2 != 0
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨变小了
			ENDIF
		CASE 13,15
			TIME:5 = 5
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 变成了瓢泼大雨！
		CASEELSE
			TIME:5 = 4
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雨了！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
ENDSELECT

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE WIND_VELOCITY
		CASE 0
			WIND_VELOCITY = 1
			IF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 風變強了！
				低気圧位置 = %GET_LOCATION_LOW()%
				IF 低気圧位置 == "台風接近強風域"
					PRINTL 台风好像袭来了
					CALL ASK_DIARY("台風が襲来した")
				ENDIF
			ENDIF
		CASE IS >= 2
			WIND_VELOCITY = 1
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 風比剛才變弱了
	ENDSELECT
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;21 台風接近時の天気(暴風域・最接近)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_21
#DIM 地底
#DIM 現在台風位置
#DIM 颶風フラグ
#DIM 豪雨フラグ
#DIMS 低気圧位置
地底 = 0
低気圧位置 = %GET_LOCATION_LOW()%
颶風フラグ = 0
豪雨フラグ = 0

;台風勢力5以上、台風の位置が西かつ暖気5のとき豪雨フラグオン
SIF IS_TYPHOON:1 >= 5 && IS_TYPHOON:2 == 3 && POWER_WARM_AIR >= 5
	豪雨フラグ = 1

SELECTCASE 低気圧位置
	CASE "台風接近暴風域", "台風最接近"
		現在台風位置 = 1
	CASE "台風通過暴風域"
		現在台風位置 = 2
ENDSELECT

IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
SELECTCASE TIME:5
	CASE 3
			IF RAND:2 == 0
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ELSE
				TIME:5 = 4
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下雨了！
			ENDIF
		CASE 4,6,7
			IF RAND:2 != 0
				TIME:5 = 5
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 变成了瓢泼大雨！
			ELSEIF RAND:2 == 0
				IF 豪雨フラグ == 1
					TIME:5 = 14
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了暴雨！
				ELSEIF 現在台風位置 == 2
					TIME:5 = 3
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨要停了的様子
				ENDIF
			ELSE
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨要停了的様子
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ENDIF
		CASE 5,14
			IF TIME:5 != 14 && 豪雨フラグ == 1
				TIME:5 = 14
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 下起了暴雨！
			ELSEIF RAND:2 != 0 && 現在台風位置 == 2
				TIME:5 = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 雨要停了的様子
			ELSEIF RAND:2 != 0
				IF TIME:5 == 14
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨稍微小了一些
				ELSE
					TIME:5 = 4
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨变小了
				ENDIF
			ENDIF
		CASE 13,15
			TIME:5 = 5
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 变成了瓢泼大雨！
		CASEELSE
			TIME:5 = 4
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下雨了！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
ENDSELECT

;台風勢力5以上、寒気1かつ暖気5のとき颶風フラグオン
SIF IS_TYPHOON:1 >= 5 && POWER_COLD_AIR == 1 && POWER_WARM_AIR >= 5
	颶風フラグ = 1

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE WIND_VELOCITY
		CASE 0
			IF 颶風フラグ == 1
				WIND_VELOCITY = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 骤然间刮起了猛烈的风！
			ELSE
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風突然就變強了！
			ENDIF
		CASE 1
			WIND_VELOCITY = 2
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 而且風變強了！
			;台風直撃による作物への影響
			IF FLAG:地主 > 0
				IF IS_TYPHOON:2 == 2
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			ENDIF
		CASE 2
			IF 颶風フラグ == 1 && 現在台風位置 == 1
				WIND_VELOCITY = 3
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 刮起了猛烈的风！
				;猛烈な風による作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			ENDIF
		CASE IS >= 3
			IF 現在台風位置 == 2
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 风比刚才小了一点儿
			ENDIF
	ENDSELECT
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;17 台風接近時の天気(台風の目)
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_17
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	IF IS_TYPHOON:1 < 3 && (TIME:5 != 2 || WIND_VELOCITY != 0)
		TIME:5 = 2
		WIND_VELOCITY = 0
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 風平靜下來了
		;念のため共用雨伞を解除
		FOR LOCAL,0,CHARANUM
			SIF TEQUIP:LOCAL:201
				TEQUIP:LOCAL:201 = 0
		NEXT
	ELSEIF TIME:5 != 0 || WIND_VELOCITY != 0
		TIME:5 = 0
		WIND_VELOCITY = 0
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 風平靜下來了
		;念のため共用雨伞を解除
		FOR LOCAL,0,CHARANUM
			SIF TEQUIP:LOCAL:201
				TEQUIP:LOCAL:201 = 0
		NEXT
	ENDIF
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0

;-------------------------------------------------
;18 霧の天気
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_18
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		CASE 6
			TIME:5 = 7
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 雨停了
			;念のため共用雨伞を解除
			FOR LOCAL,0,CHARANUM
				SIF TEQUIP:LOCAL:201
					TEQUIP:LOCAL:201 = 0
			NEXT
		CASE 10
			TIME:5 = 7
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 雪停了
			;念のため共用雨伞を解除
			FOR LOCAL,0,CHARANUM
				SIF TEQUIP:LOCAL:201
					TEQUIP:LOCAL:201 = 0
			NEXT
		CASE 7
			IF DAY:2 == 4
				TIME:5 = 10
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 變成細氷（钻石尘）了
			ELSE
				TIME:5 = 6
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 變成霧雨了
			ENDIF
		CASEELSE
			IF RAND:2 == 0
				TIME:5 = 7
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 起霧了
				;念のため共用雨伞を解除
				FOR LOCAL,0,CHARANUM
					SIF TEQUIP:LOCAL:201
						TEQUIP:LOCAL:201 = 0
				NEXT
			ELSEIF DAY:2 == 4
				TIME:5 = 10
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 變成細氷（钻石尘）了
			ELSE
				TIME:5 = 6
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 變成霧雨了
			ENDIF
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 0,1,2,3
		CONTINUOUS_RAINFALL = 0
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;-------------------------------------------------
;19 疑似好天
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_19
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	IF TIME:5 != 1 || WIND_VELOCITY != 0
		TIME:5 = 1
		WIND_VELOCITY = 0
		SIF !CFLAG:MASTER:诶嘿嘿 && !地底
			PRINTW 天空放晴了！！
		FOR LOCAL,0,CHARANUM
			SIF TEQUIP:LOCAL:201
				TEQUIP:LOCAL:201 = 0
		NEXT
	ENDIF
ENDIF

;雪崩発生フラグ判定
IF SNOW_COVERAGE >= 15 && CONTINUOUS_SNOWFALL >= 10
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 10 && CONTINUOUS_SNOWFALL >= 7 && WIND_VELOCITY >= 1
	POSSIBLITY_AVALANCHE = 1
ELSEIF SNOW_COVERAGE >= 5 && CONTINUOUS_SNOWFALL >= 5 && WIND_VELOCITY >= 2
	POSSIBLITY_AVALANCHE = 1
ELSE
	POSSIBLITY_AVALANCHE = 0
ENDIF

;-------------------------------------------------
;20 集中豪雨時の天気
;-------------------------------------------------
@CHANGE_WEATHER_SYSTEM_20
#DIM 地底
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0

IF CFLAG:MASTER:現在位置 != 天界
	SELECTCASE TIME:5
		CASE 5
			SELECTCASE RAND:3
				CASE 0,1
					TIME:5 = 14
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨下得更大了！
				CASE 2
					IF ATMOSPHERIC_INSTABILITY <= 0
						TIME:5 = 15
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下起了冰雹！
					ELSE
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					ENDIF
			ENDSELECT
		CASE 14
			SELECTCASE RAND:4
				CASE 0
					TIME:5 = 5
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 雨稍微小了一些
				CASE 1
					IF ATMOSPHERIC_INSTABILITY <= 0
						TIME:5 = 15
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 下起了冰雹！
					ELSE
						TIME:5 = 13
						SIF !CFLAG:MASTER:诶嘿嘿 && !地底
							PRINTW 落冰雹了！
					ENDIF
			ENDSELECT
		CASE 13,15
					TIME:5 = 14
					SIF !CFLAG:MASTER:诶嘿嘿 && !地底
						PRINTW 下起了暴雨！
		CASEELSE
			TIME:5 = 14
			SIF !CFLAG:MASTER:诶嘿嘿 && !地底
				PRINTW 下起了暴雨！
	ENDSELECT
ENDIF

;連続降水Counter
SELECTCASE TIME:5
	CASE 5
		CONTINUOUS_RAINFALL += 1
	CASE 14
		CONTINUOUS_RAINFALL += 3
	CASE 3,6,7,10,11
		CONTINUOUS_RAINFALL = MAX(0, CONTINUOUS_RAINFALL - 1)
ENDSELECT

;(天候パッチ)熱界雷時の処理　ダウンバースト発生
IF ATMOSPHERIC_INSTABILITY <= 0 && CFLAG:MASTER:現在位置 != 天界 && RAND:4 == 0
	IF ATMOSPHERIC_INSTABILITY <= -2 && RAND:2 == 0
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 很強的風！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASE 1
				WIND_VELOCITY = 2
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 而且風變強了！
				;ダウンバーストによる作物への影響
				IF FLAG:地主 > 0
					FLAG:田地工作的成果 = MAX(0, FLAG:田地工作的成果 - 30)
					IS_STORM_CROP_DAMAGE ++
				ENDIF
			CASEELSE
				WIND_VELOCITY = 2
		ENDSELECT
	ELSE
		SELECTCASE WIND_VELOCITY
			CASE 0
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風變強了！
			CASE 1
				WIND_VELOCITY = 1
			CASEELSE
				WIND_VELOCITY = 1
				SIF !CFLAG:MASTER:诶嘿嘿 && !地底
					PRINTW 風比剛才變弱了
		ENDSELECT
	ENDIF
;強風である場合風がおさまる
ELSEIF CFLAG:MASTER:現在位置 != 天界 && WIND_VELOCITY != 0
	WIND_VELOCITY = 0
	SIF !CFLAG:MASTER:诶嘿嘿 && !地底
		PRINTW 風停了
ENDIF

;降雪・雪崩判定を解除
CONTINUOUS_SNOWFALL = 0
SNOW_COVERAGE = 0
POSSIBLITY_AVALANCHE = 0


code:
;FileName_COMMON.ERB ------------------------------- Rev1.00
;季節管理
;CALL		USER
;ARG		VOID
;RETURN		VOID
;COMMENT
;-----------------------------------------------------------
@CHANGE_MONTH
#DIM 神簽代
;日期が月を跨いだら月変更
IF DAY:3 > 31
	DAY:3 = 1
	DAY:2 ++
	;冬の次は春
	IF DAY:2 > 4
		DAY:2 = 1
		FLAG:年始貸付金 = FLAG:地主貸付金
		;(天候パッチ)長期予報を行う
		CALL WEATHER_FORECAST_1YEAR
	ENDIF
	;夏になったらバレンタインフラグリセット
	SIF DAY:2 == 2
		CVARSET CFLAG, 383
	;徴収発生
	SIF FLAG:地主
		FLAG:年貢 = 1
	IF FLAG:澆水代行
		FLAG:澆水代行 = 0
		PRINTFORMW 澆水代理的期限到期了。
	ENDIF
	IF FLAG:新聞購読
		IF MONEY < 3000 && MONEY:2 < 10
			PRINTFORML 因爲缺錢所以文文。新聞的訂閱停止了。
		ELSE
			PRINTL
			PRINTFORML ★繼續訂閱文文。新聞嗎？（月額￥1500 or 5籌碼）
			CALL ASK_M("解約",1,"更新（￥1500）",MONEY >= 1500,"更新（5筹码）",MONEY:2 >= 5)
			SELECTCASE RESULT
				CASE 0
					PRINTFORML 停止了訂閱。
					FLAG:新聞購読 = 0
				CASE 1
					MONEY -= 1500
					PRINTFORML 本月繼續訂閱。
				CASE 2
					MONEY:2 -= 5
					PRINTFORML 本月繼續訂閱。
			ENDSELECT
		ENDIF
	ENDIF
	IF FLAG:神簽契約
		神簽代 = 50
		SIF !MAIN_MAP
			神簽代 = 30
		IF MONEY:2 < 神簽代
			PRINTFORML 因為籌碼不足、所以神签契約被中止了
			FLAG:神簽契約 = 0
		ELSE
			PRINTFORML 要繼續神签契約吗？
			CALL ASK_YN
			IF !RESULT
				PRINTFORML 更新了契約
				MONEY:2 -= 神簽代
			ELSE
				FLAG:神簽契約 = 0
				PRINTFORML 結束了契約
			ENDIF
		ENDIF
	ENDIF
	IF FLAG:蟲の採集サービス
		PRINTFORMDL
		PRINTFORMW 虫采集服务的合同到期了。
		PRINTFORMW 更新申请吗?
		PRINTFORML 所持金:%金額表示(MONEY)%
		LOCAL = CALCULATE_IFS_PRICE()
		CALL ASK_M("不更新",1,@"更新 (￥{LOCAL})",MONEY >= LOCAL)
		IF RESULT > 0
			MONEY -= LOCAL
			PRINTFORMW 契約更新
			PRINTFORMDL
			PRINTFORML 现在的素材收集地点是%GET_MAPNAME(FLAG:蟲の採集サービス - 1)%。
			PRINTFORMW 如果想要改变的话，就和%CALLNAME:[[莉格露]]%打招呼吧。
		ELSE
			FLAG:蟲の採集サービス = 0
		ENDIF
		PRINTFORMDL
	ENDIF
	SIF ENCOUNTDLC
		CALL SP_ENCOUNT
ENDIF
;異常値を固定修正
SIF DAY:3 < 1
	DAY:3 = 1
SIF DAY:2 < 1 || DAY:2 > 4
	DAY:2 = 1

;FileName_COMMON.ERB ------------------------------- Rev1.00
;時間帯管理
;CALL		USER
;ARG		VOID
;RETURN		VOID
;COMMENT
;-----------------------------------------------------------
@CHANGE_TIMEZONE
#DIM 現在時間帯

;SELECTCASE TIME
;	CASE 240 TO 599
;		LOCAL = 1
;	CASE 600 TO 1139
;		LOCAL = 2
;	CASE 1140 TO 1440 , 0 TO 239
;		LOCAL = 3
;ENDSELECT

SELECTCASE TIME
	;AM4~6　早朝
	CASE 240 TO 359
		LOCAL = 1
	;AM6~12　正午前
	CASE 360 TO 719
		LOCAL = 2
	;PM12~3　昼
	CASE 720 TO 899
		LOCAL = 3
	;PM3~6　昼下がり
	CASE 900 TO 1079
		LOCAL = 4
	;PM6~8　夕
	CASE 1080 TO 1199
		LOCAL = 5
	;PM8~11　夜
	CASE 1200 TO 1379
		LOCAL = 6
	;PM11~AM4　深夜
	CASE 0 TO 239, IS >= 1380
		LOCAL = 7
ENDSELECT

;(天候パッチ)天候システム上の時間帯管理
SELECTCASE TIME
	;AM0~3　未明
	CASE 0 TO 179
		現在時間帯 = 1
	;AM3~6　明け方
	CASE 180 TO 359
		現在時間帯 = 2
	;AM6~9　朝
	CASE 360 TO 539
		現在時間帯 = 3
	;AM9~12　昼前
	CASE 540 TO 719
		現在時間帯 = 4
	;PM0~3　昼過ぎ
	CASE 720 TO 899
		現在時間帯 = 5
	;PM3~6　夕方
	CASE 900 TO 1079
		現在時間帯 = 6
	;PM6~9　夜のはじめ頃
	CASE 1080 TO 1259
		現在時間帯 = 7
	;PM9~12　夜遅く
	CASE IS >= 1260
		現在時間帯 = 8
ENDSELECT

;(天候パッチ)現在的天候傾向を判定
CALL CHANGE_WEATHER_SYSTEM

IF LOCAL != TIME:2
	TIME:2 = LOCAL
	TRYCALLFORM MOB_PLACE_{MAIN_MAP}
	CALL TIMEZONE_MOVE
ENDIF

;(天候パッチ)天候システム上の時間帯変動・天候変化
IF WEATHER_TIMEZOME != 現在時間帯
	WEATHER_TIMEZOME = 現在時間帯
	CALL CHANGE_WEATHER
ENDIF
;(天候パッチ)時刻・天候に応じて背景色を変更
CALL SET_MAP_WEATHER_BGCOLOR

;FileName_COMMON.ERB ------------------------------- Rev1.00
;季節名取得
;CALL		USER
;ARG		引数がない場合DAY:2
;RETURN		VOID
;COMMENT
;-----------------------------------------------------------
@GET_MONTH(ARG)
#FUNCTIONS
SIF !ARG
	ARG = DAY:2
SIF !STRLENS(LOCALS)
	SPLIT "無之月/春之月/夏之月/秋之月/冬之月", "/", LOCALS
RETURNF LOCALS:(ARG)

;FileName_COMMON.ERB ------------------------------- Rev1.00
;天気名取得
;CALL		USER
;ARG		VOID
;RETURN		VOID
;COMMENT
;-----------------------------------------------------------
@GET_WEATHER
#FUNCTIONS
#DIMS 表示_異常気象,15
;(天候パッチ)台風・猛吹雪は表示しない
IF WEATHERDLC == 1
	IF FLAG:異常気象
		SPLIT " /Ｃ敏感/Ｖ敏感/Ａ敏感/Ｂ敏感/Ｍ敏感/裙子/胖次/桃色の風/台風/猛吹雪/钻石尘/黄沙/烈日/极光", "/", 表示_異常気象
		RETURNF 表示_異常気象:(FLAG:異常気象)
	ENDIF
	SIF !STRLENS(LOCALS)
		SPLIT "晴天/晴朗/多雲/陰天/雨/大雨/霧雨/霧/雪/吹雪/細雪/霧雪/雨雪交加/冰雹/豪雨/ひょう/太阳雨/疏雨/风雨/晴岚/川雾/无风/梅雨", "/", LOCALS
ELSE
	IF FLAG:異常気象 && FLAG:異常気象 != 9 && FLAG:異常気象 != 10
		SPLIT " /Ｃ敏感/Ｖ敏感/Ａ敏感/Ｂ敏感/Ｍ敏感/裙子/胖次/桃色の風/台風/猛吹雪", "/", 表示_異常気象
		RETURNF 表示_異常気象:(FLAG:異常気象)
	ENDIF
	;(天候パッチ)豪雨・ひょうを追加
	SIF !STRLENS(LOCALS)
		SPLIT "晴天/晴朗/多雲/陰天/雨/大雨/霧雨/霧/雪/大雪/細雪/霧雪/雨雪交加/冰雹/豪雨/ひょう", "/", LOCALS
ENDIF
RETURNF LOCALS:(TIME:5)

;-------------------------------------------------
;平日判定(ARG)
;DAYを渡して月～金曜日なら1
;-------------------------------------------------
@IS_WEEKDAY(ARG)
#FUNCTION
SIF !ARG
	ARG = DAY
RETURNF INRANGE(ARG % 7, 1, 5)

;-------------------------------------------------
;週末判定(ARG)
;DAYを渡して土日なら1
;-------------------------------------------------
@IS_WEEKEND(ARG)
#FUNCTION
SIF !ARG
	ARG = DAY
RETURNF !INRANGE(ARG % 7, 1, 5)

;-------------------------------------------------
;曜日一致判定(ARG)
;DAYと文字列を渡し、一致していれば1
;判定用文字列は日月火水木金土で各曜日を表す（＝複数指定可能）
;-------------------------------------------------
@YOUBI_MATCH(ARG, CHECK_STR)
#FUNCTION
#DIMS  CHECK_STR
SIF !ARG
	ARG = DAY
SIF STRCOUNT(CHECK_STR, GET_DAY(ARG))
	RETURNF 1
RETURNF 0

;-------------------------------------------------
;関数名:GET_DAY
;概　要:曜日を表す文字列を取得する関数
;引　数:引数がない場合DAY
;戻り値:曜日を表す文字列(日/月/火/水/木/金/土)
;備　考:文中関数
;-------------------------------------------------
@GET_DAY(ARG)
#FUNCTIONS
#DIMS CONST YOUBI = "日", "月", "火", "水", "木", "金", "土"
SIF !ARG
	ARG = DAY
RETURNF YOUBI:(ARG % 7)

;FileName_COMMON.ERB ------------------------------- Rev1.00
;天気管理
;CALL		USER
;ARG		VOID
;RETURN		VOID
;COMMENT
;-----------------------------------------------------------
@CHANGE_WEATHER
#DIM 地底
#DIM 入手胖次
#DIM 持ち主
#DIM ループ開始
#DIM ループ終了
#DIM ループ加算
DEBUGPRINTL 【CHANGE_WEATHER】CALL CHANGE_WATHER
;天候管理にメッセージ表示処理させてすみましぇん＞＜；
;诶嘿嘿中は読取周圍環境程度的能力
;天候変化しなくても虹は消える
地底 = 0
IF CFLAG:MASTER:约会中 == 9
	地底 = 1
ELSEIF CFLAG:MASTER:現在位置 == OMANEKIBEYA() && GROUPMATCH(CFLAG:MASTER:招待, 36, 37, 38, 49, 60, 64, 83, 84)
	地底 = 1
ENDIF
TIME:7 = 0
IF !地底
	SELECTCASE FLAG:異常気象
		CASE 7
			;こうでもしないとまた没穿内裤が飛んできてしまうと思うの
			DO
				CALL RAND_CHARASELECT("主人公以外的角色列表")
				持ち主 = RESULT
				入手胖次 = 今天穿的内裤(持ち主)
			LOOP !入手胖次
			SIF CFLAG:持ち主:(入手胖次 + 胖次管理) == 0
				SETCOLOR C_PINK
			PRINTFORML 强风把%CALLNAME:持ち主%的%PANTSNAME(入手胖次,持ち主)%吹过来了
			RESETCOLOR
			CALL ASK_YN("撿起","不撿")
			IF !RESULT
				PRINTFORMW %CALLNAME:MASTER%撿到了%CALLNAME:持ち主%的%PANTSNAME(入手胖次,持ち主)%
				CALL PANTS_GETTING(持ち主, 入手胖次)
			ELSE
				PRINTFORML %PANTSNAME(入手胖次,持ち主)%就这様飞到不知道哪里去了
			ENDIF
		CASE 8
			SETCOLOR 255,100,255
			FONTBOLD
			PRINTFORMW 幻想乡吹起了桃色之风！
			FOR LOCAL,1,CHARANUM
				IF !RAND:8 && !TALENT:LOCAL:妊娠
					PRINTFORML 沐浴在桃色之风的%CALLNAME:LOCAL%产生了奇怪的感觉
					CFLAG:LOCAL:积攒度 += LIMIT((10 + RAND:20 + RAND:20 + RAND:20) * ABL:LOCAL:欲望,200,1000)
					SIF !TALENT:LOCAL:人形
						TCVAR:LOCAL:発情 = 1
				ENDIF
			NEXT
			RESETCOLOR
			FONTREGULAR
	ENDSELECT
ENDIF

SIF FLAG:異常気象 >= 1 && FLAG:異常気象 <= 8
	RETURN

SIF TIME:5 > 15
	TIME:5 = 0

;(天候パッチ)天候変更禁止ならば処理終了
SIF FORBIDDEN_CHANGE_WEATHER == 1
	RETURN

;(天候パッチ)新しい天候管理システムへ
TRYCALLFORM CHANGE_WEATHER_SYSTEM_{NOW_WEATHER_CONTROL}

[SKIPSTART]
@現在気温設定
;高低差を５分割
SELECTCASE TIME
	;PM11~AM4
	CASE 0 TO 299, IS >= 1380
		LOCAL = FLAG:62
	;AM5~7
	CASE 300 TO 479
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5)
	;AM8~9
	CASE 480 TO 599
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5 * 2)
	;AM10~11
	CASE 600 TO 719
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5 * 3)
	;PM12~2
	CASE 720 TO 899
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5 * 4)
	;PM3~5
	CASE 900 TO 1079
		LOCAL = FLAG:61
	;PM6~7
	CASE 1080 TO 1199
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5 * 4)
	;PM8~9
	CASE 1200 TO 1259
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5 * 2)
	;PM9~10
	CASE 1260 TO 1379
		LOCAL = FLAG:62 + ((FLAG:61 - FLAG:62) / 5)
ENDSELECT
;日が出ていないと温度低下
SELECTCASE TIME
	;AM5~PM7
	CASE 300 TO 1199
		SIF TIME:5 > 1
			LOCAL -= ((FLAG:61 - FLAG:62) / 5)
ENDSELECT
;----------------------------------------------------------------
@年間基礎最高気温(ARG, ARG:1)
#FUNCTION
;ARG   指定の月
;ARG:1 指定の日
SELECTCASE ARG
	CASE 1
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 17
			CASE 4, 5
				RETURNF 18
			CASE 6 TO 8
				RETURNF 19
			CASE 9 TO 11
				RETURNF 20
			CASE 12 TO 14
				RETURNF 21
			CASE 15 TO 18
				RETURNF 22
			CASE 19 TO 22
				RETURNF 23
			CASE 23 TO 27
				RETURNF 24
			CASE 28 TO 30
				RETURNF 25
		ENDSELECT
	CASE 2
		SELECTCASE ARG:1
			CASE 1, 2
				RETURNF 25
			CASE 3 TO 7
				RETURNF 26
			CASE 8 TO 13
				RETURNF 27
			CASE 14 TO 17
				RETURNF 28
			CASE 18 TO 22
				RETURNF 29
			CASE 23 TO 28
				RETURNF 30
			CASE 29, 30
				RETURNF 31
		ENDSELECT
	CASE 3
		SELECTCASE ARG:1
			CASE 1, 2
				RETURNF 31
			CASE 3, 4
				RETURNF 30
			CASE 5 TO 7
				RETURNF 29
			CASE 8 TO 10
				RETURNF 28
			CASE 11, 12
				RETURNF 27
			CASE 13, 14
				RETURNF 26
			CASE 15, 16
				RETURNF 25
			CASE 17 TO 19
				RETURNF 24
			CASE 20 TO 22
				RETURNF 23
			CASE 23, 24
				RETURNF 22
			CASE 25 TO 27
				RETURNF 21
			CASE 28, 29
				RETURNF 20
			CASE 30
				RETURNF 19
		ENDSELECT
	CASE 4
		SELECTCASE ARG:1
			CASE 1 TO 4
				RETURNF 19
			CASE 5 TO 7
				RETURNF 18
			CASE 8 TO 10
				RETURNF 17
			CASE 11, 12
				RETURNF 16
			CASE 13, 14
				RETURNF 15
			CASE 15, 16
				RETURNF 14
			CASE 17, 18
				RETURNF 13
			CASE 19, 20
				RETURNF 12
			CASE 21, 22
				RETURNF 11
			CASE 23 TO 25
				RETURNF 10
			CASE 26, 27
				RETURNF 9
			CASE 28, 29
				RETURNF 8
			CASE 30
				RETURNF 7
		ENDSELECT
	CASE 5
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 7
			CASE 4 TO 9
				RETURNF 6
			CASE 10 TO 14
				RETURNF 5
			CASE 15 TO 21
				RETURNF 4
			CASE 22 TO 28
				RETURNF 5
			CASE 29, 30
				RETURNF 6
		ENDSELECT
	CASE 6
		SELECTCASE ARG:1
			CASE 1 TO 6
				RETURNF 6
			CASE 7 TO 12
				RETURNF 7
			CASE 13, 14
				RETURNF 8
			CASE 15, 16
				RETURNF 9
			CASE 17, 18
				RETURNF 10
			CASE 19, 20
				RETURNF 11
			CASE 21, 22
				RETURNF 12
			CASE 23, 24
				RETURNF 13
			CASE 25, 26
				RETURNF 14
			CASE 27, 28
				RETURNF 15
			CASE 29
				RETURNF 16
			CASE 30
				RETURNF 17
		ENDSELECT
ENDSELECT

;----------------------------------------------------------------
@年間基礎最低気温(ARG, ARG:1)
#FUNCTION
;ARG   指定の月
;ARG:1 指定の日
SELECTCASE ARG
	CASE 1
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 11
			CASE 4 TO 6
				RETURNF 12
			CASE 7, 8
				RETURNF 13
			CASE 9 TO 11
				RETURNF 14
			CASE 12 TO 14
				RETURNF 15
			CASE 15 TO 17
				RETURNF 16
			CASE 18 TO 20
				RETURNF 17
			CASE 21 TO 23
				RETURNF 18
			CASE 24 TO 27
				RETURNF 19
			CASE 28 TO 30
				RETURNF 20
		ENDSELECT
	CASE 2
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 20
			CASE 4 TO 7
				RETURNF 21
			CASE 8 TO 10
				RETURNF 22
			CASE 11 TO 14
				RETURNF 23
			CASE 15 TO 22
				RETURNF 24
			CASE 23 TO 30
				RETURNF 25
		ENDSELECT
	CASE 3
		SELECTCASE ARG:1
			CASE 1 TO 5
				RETURNF 25
			CASE 6 TO 9
				RETURNF 24
			CASE 10 TO 12
				RETURNF 23
			CASE 13, 14
				RETURNF 22
			CASE 15 TO 17
				RETURNF 21
			CASE 18 TO 20
				RETURNF 20
			CASE 21 TO 23
				RETURNF 19
			CASE 24, 25
				RETURNF 18
			CASE 26
				RETURNF 17
			CASE 27, 28
				RETURNF 16
			CASE 29
				RETURNF 15
			CASE 30
				RETURNF 14
		ENDSELECT
	CASE 4
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 14
			CASE 4, 5
				RETURNF 13
			CASE 6, 7
				RETURNF 12
			CASE 8, 9
				RETURNF 11
			CASE 10, 11
				RETURNF 10
			CASE 12 TO 14
				RETURNF 9
			CASE 15 TO 17
				RETURNF 8
			CASE 18 TO 20
				RETURNF 7
			CASE 21 TO 23
				RETURNF 6
			CASE 24 TO 26
				RETURNF 5
			CASE 27 TO 29
				RETURNF 4
			CASE 30
				RETURNF 3
		ENDSELECT
	CASE 5
		SELECTCASE ARG:1
			CASE 1, 2
				RETURNF 3
			CASE 3 TO 6
				RETURNF 2
			CASE 7 TO 10
				RETURNF 1
			CASE 11 TO 13
				RETURNF 0
			CASE 14 TO 21
				RETURNF -1
			CASE 22 TO 30
				RETURNF 0
		ENDSELECT
	CASE 6
		SELECTCASE ARG:1
			CASE 1 TO 3
				RETURNF 0
			CASE 4 TO 6
				RETURNF 1
			CASE 7, 8
				RETURNF 2
			CASE 9, 10
				RETURNF 3
			CASE 11 TO 14
				RETURNF 4
			CASE 15, 16
				RETURNF 5
			CASE 17, 18
				RETURNF 6
			CASE 19, 20
				RETURNF 7
			CASE 21 TO 23
				RETURNF 8
			CASE 24, 25
				RETURNF 9
			CASE 26 TO 28
				RETURNF 10
			CASE 29, 30
				RETURNF 11
		ENDSELECT
ENDSELECT
[SKIPEND]

;定時遭遇位置再設定
@TIMEZONE_MOVE
#DIMS 移動前
#DIMS 移動後
FOR LOCAL,1,CHARANUM
	SIF 出現状態(LOCAL) != 1
		CONTINUE
	SIF !CHARA_HOLIDAY(LOCAL)
		CONTINUE
	SIF CFLAG:LOCAL:招待
		CONTINUE
	SIF CFLAG:LOCAL:同行 || CHK_DATENOW(CFLAG:LOCAL:约会中)
		CONTINUE
	SIF !CFLAG:LOCAL:前一次的位置
		CONTINUE
	SIF CFLAG:LOCAL:睡眠
		CONTINUE
	;你と同じ場所にいるときは確率が下がる
	IF CFLAG:MASTER:現在位置 == CFLAG:LOCAL:現在位置
		IF TALENT:LOCAL:恋慕
			;恋慕は5分の1
			SIF RAND:5
				CONTINUE
		ELSEIF TALENT:LOCAL:思慕
			;思慕は4分の1
			SIF RAND:4
				CONTINUE
		ELSE
			;それ以外は3分の1
			SIF RAND:3
				CONTINUE
		ENDIF
	ELSE
		;見てない場所なら2分の1
		SIF RAND:2
			CONTINUE
	ENDIF
	CALL 遭遇フラグ決定(LOCAL)
NEXT
;全角色決定後、連動角色を設定する
FOR LOCAL, 1, CHARANUM
	VARSET RESULT
	CALLFORM CHARAMOVE_DATA_{LOCAL}(1)
	;依存連動
	IF RESULT
		CFLAG:LOCAL:遭遇位置 = CFLAG:RESULT:遭遇位置
	;対等連動
	ELSEIF RESULT:1
		;連動設定する
		CFLAG:LOCAL:遭遇位置 = CFLAG:連動角色設定(RESULT:1, RESULT:2, RESULT:3):遭遇位置
	ENDIF
NEXT

repo_name: akadiya/eratw

license: unknown