幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2020|回复: 13

[分享]日夜控制系統完美版!

[复制链接]

3

主题

20

帖子

222

积分

③业余

积分
222
发表于 2007-2-8 10:46:32 | 显示全部楼层 |阅读模式
日夜控制系統完美版!
[功能說明:]
時間為四個時段 晨、日、午、夜,每個時段有對應的自動開關,方便設計各時段特殊
事件的啟動。(比如時段為午,則會自動開啟開關2號。玩家可利用此開關設計特殊事
件)
日夜控制系統總開關 預設為開關6,可控制此系統是否運作。
自設起始時間預設為變數6,比如:當變數6設定為5,表示此系統由 5:00 開始計時。
屋內/洞穴亮度恢復開關 預設為開關5。即當玩家進入屋內/洞穴需要把亮度恢復,可
利用此開關控制。

請將下面腳本內容複製/插入到 main 上即可使用!
  1. #==========================================================================
  2. # ■ Window_Base
  3. #--------------------------------------------------------------------------
  4. #  遊戲中全部窗口的超級程式。
  5. #  由 Kevin Chang 製作,發佈請保留原作者訊息。
  6. #==========================================================================
  7. class Window_Base < Window
  8.   #------------------------------------------------------------------------
  9.   #●日夜控制系統初始控制設定
  10.   #------------------------------------------------------------------------
  11.   Ctrl_daylight_sys = 6 #日夜控制系統開關編號,預設 開關6
  12.   Ctrl_in_house = 5 #屋內/洞穴亮度恢復開關編號,預設 開關5
  13.   Ctrl_morning = 4 #晨間作息開關編號,預設 開關4
  14.   Ctrl_day = 1  #日間作息開關編號,預設 開關1
  15.   Ctrl_afternoon = 2 #午間作息開關編號,預設 開關2
  16.   Ctrl_night = 3 #夜間作息開關編號,預設 開關3
  17.   
  18.   $Ctrl_Set_hour = 6 #設定起始時間(小時)之變數編號,預設 變數6
  19.   $Day_sec = 5 #時間軸秒的進制 預設為 6 進制(0~5)
  20.   $Day_min = 5 #ㄧ小時幾分鐘的進制 預設為 6 進制(0~5)
  21.   $Day_hour = 11 #每天為幾小時的進制 預設為 12 小時1天(0~11)
  22.   #------------------------------------------------------------------------
  23.   # ● 初始化對像
  24.   #     x      : 窗口的 X 坐標
  25.   #     y      : 窗口的 Y 坐標
  26.   #     width  : 窗口的寬
  27.   #     height : 窗口的寬
  28.   #------------------------------------------------------------------------
  29.   def initialize(x, y, width, height)
  30.     super()
  31.     @windowskin_name = $game_system.windowskin_name
  32.     self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  33.     self.x = x
  34.     self.y = y
  35.     self.width = width
  36.     self.height = height
  37.     self.z = 100
  38.   end
  39.   #------------------------------------------------------------------------
  40.   #洞穴 屋內亮度正常化
  41.   #------------------------------------------------------------------------
  42.   def inside_normal
  43.     if $game_switches[Ctrl_in_house] == true
  44.       $game_screen.start_tone_change(Tone.new(0,0,0,0),5)
  45.     end
  46.   end
  47.   #------------------------------------------------------------------------
  48.   #---------------------------------------
  49.   #時段使用圖案代表
  50.   #---------------------------------------
  51.   def show_day #時段圖案函式
  52.     testname=$hour.to_s#將角色ID編號,轉成字串變數(to_s) 並存到testname
  53.     bitmap=Bitmap.new("Graphics/pictures/#{testname}")#取出路徑Graphics/pictures/下 testname 檔名的圖
  54.     src_rect=Rect.new(0,0,bitmap.width,bitmap.height)
  55.     self.contents.blt(20,4,bitmap,src_rect)
  56.   end
  57.   
  58.   #---------------------------------------
  59.   #-----------------------------------------
  60.   #天氣變化
  61.   #-----------------------------------------
  62.   def weather_decision
  63.     if $game_switches[Ctrl_in_house] == true
  64.       $game_screen.weather(0, 3, 1)
  65.     else      
  66.     w_d = rand(100)
  67.     if w_d >= 0 and w_d <= 80
  68.     $game_screen.weather(0, 3, 50) #正常(類型0正常1雨天2刮風3下雪,強度,時間/10)
  69.      else
  70.        if w_d > 80 and w_d <= 90
  71.         $game_screen.weather(1, 5, 50)#雨天
  72.         else
  73.         if w_d > 90 and w_d <= 100
  74.         $game_screen.weather(1, 10, 500)#刮風
  75.         end
  76.        end
  77.      end
  78.      end
  79.    end
  80.   #---------------------------------------
  81.   #------------各時間顏色變化---------------------
  82.     def the_time
  83.     case $hour
  84.     when 11
  85.       #self.contents.draw_text(0, 0, 120, 32, "『夜』")
  86.       $game_screen.start_tone_change(Tone.new(-136,-136,0,136),50)
  87.       inside_normal
  88.       #show_day  #設定時段圖案
  89.       weather_decision
  90.       $game_switches[Ctrl_morning] = false    #晨間作息開關
  91.       $game_switches[Ctrl_day] = false   #日間作息開關
  92.       $game_switches[Ctrl_afternoon] = false   #午間作息開關
  93.       $game_switches[Ctrl_night] = true    #夜間作息開關
  94.       
  95.     when 0
  96.       #self.contents.draw_text(0, 0, 120, 32, "『晨』")
  97.       $game_screen.start_tone_change(Tone.new(0,0,85,85),50)
  98.        inside_normal
  99.        #show_day  #設定時段圖案
  100.        weather_decision
  101.        $game_switches[Ctrl_morning] = true    #晨間作息開關
  102.        $game_switches[Ctrl_day] = false   #日間作息開關
  103.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  104.        $game_switches[Ctrl_night] = false    #夜間作息開關
  105.      
  106.     when 1
  107.       #self.contents.draw_text(0, 0, 120, 32, "『晨』")
  108.       $game_screen.start_tone_change(Tone.new(0,0,51,68),50)
  109.        inside_normal
  110.        #show_day  #設定時段圖案
  111.        weather_decision
  112.        $game_switches[Ctrl_morning] = true    #晨間作息開關
  113.        $game_switches[Ctrl_day] = false   #日間作息開關
  114.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  115.        $game_switches[Ctrl_night] = false    #夜間作息開關
  116.       
  117.     when 2
  118.       #self.contents.draw_text(0, 0, 120, 32, "『晨』")
  119.       $game_screen.start_tone_change(Tone.new(0,0,0,40),50)
  120.        inside_normal
  121.        #show_day  #設定時段圖案
  122.        weather_decision
  123.        $game_switches[Ctrl_morning] = true    #晨間作息開關
  124.        $game_switches[Ctrl_day] = false   #日間作息開關
  125.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  126.        $game_switches[Ctrl_night] = false    #夜間作息開關
  127.    
  128.     when 3
  129.       #self.contents.draw_text(0, 0, 120, 32, "『日』")
  130.       $game_screen.start_tone_change(Tone.new(0,0,0,0),50)
  131.        inside_normal
  132.        #show_day  #設定時段圖案
  133.        weather_decision
  134.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  135.        $game_switches[Ctrl_day] = true   #日間作息開關
  136.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  137.        $game_switches[Ctrl_night] = false    #夜間作息開關
  138.       
  139.     when 4
  140.       #self.contents.draw_text(0, 0, 120, 32, "『日』")
  141.       $game_screen.start_tone_change(Tone.new(50,0,0,0),50)
  142.        inside_normal
  143.       #show_day  #設定時段圖案
  144.        weather_decision
  145.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  146.        $game_switches[Ctrl_day] = true   #日間作息開關
  147.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  148.        $game_switches[Ctrl_night] = false    #夜間作息開關
  149.       
  150.     when 5
  151.       #self.contents.draw_text(0, 0, 120, 32, "『日』")
  152.       $game_screen.start_tone_change(Tone.new(100,34,51,0),50)
  153.        inside_normal
  154.        #show_day  #設定時段圖案
  155.        weather_decision
  156.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  157.        $game_switches[Ctrl_day] = true   #日間作息開關
  158.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  159.        $game_switches[Ctrl_night] = false    #夜間作息開關
  160.       
  161.     when 6
  162.       #self.contents.draw_text(0, 0, 120, 32, "『午』")
  163.       $game_screen.start_tone_change(Tone.new(100,34,-17,68),50)
  164.        inside_normal
  165.        #show_day  #設定時段圖案
  166.        weather_decision
  167.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  168.        $game_switches[Ctrl_day] = false   #日間作息開關
  169.        $game_switches[Ctrl_afternoon] = true   #午間作息開關
  170.        $game_switches[Ctrl_night] = false    #夜間作息開關
  171.       
  172.     when 7
  173.       #self.contents.draw_text(0, 0, 120, 32, "『午』")
  174.       $game_screen.start_tone_change(Tone.new(100,34,-20,170),50)
  175.        inside_normal
  176.        #show_day  #設定時段圖案
  177.        weather_decision
  178.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  179.        $game_switches[Ctrl_day] = false   #日間作息開關
  180.        $game_switches[Ctrl_afternoon] = true   #午間作息開關
  181.        $game_switches[Ctrl_night] = false    #夜間作息開關
  182.       
  183.     when 8
  184.       #self.contents.draw_text(0, 0, 120, 32, "『午』")
  185.       $game_screen.start_tone_change(Tone.new(68,0,-17,204),50)
  186.       inside_normal
  187.       #show_day  #設定時段圖案
  188.       weather_decision
  189.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  190.        $game_switches[Ctrl_day] = false   #日間作息開關
  191.        $game_switches[Ctrl_afternoon] = true   #午間作息開關
  192.        $game_switches[Ctrl_night] = false    #夜間作息開關
  193.      
  194.     when 9
  195.       #self.contents.draw_text(0, 0, 120, 32, "『夜』")
  196.       $game_screen.start_tone_change(Tone.new(0,0,0,204),50)
  197.       inside_normal
  198.       #show_day  #設定時段圖案
  199.       weather_decision
  200.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  201.        $game_switches[Ctrl_day] = false   #日間作息開關
  202.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  203.        $game_switches[Ctrl_night] = true    #夜間作息開關
  204.       
  205.     when 10
  206.       #self.contents.draw_text(0, 0, 120, 32, "『夜』")
  207.       $game_screen.start_tone_change(Tone.new(-51,-51,-51,170),50)
  208.       inside_normal
  209.       #show_day  #設定時段圖案
  210.       weather_decision
  211.        $game_switches[Ctrl_morning] = false    #晨間作息開關
  212.        $game_switches[Ctrl_day] = false   #日間作息開關
  213.        $game_switches[Ctrl_afternoon] = false   #午間作息開關
  214.        $game_switches[Ctrl_night] = true    #夜間作息開關
  215.       
  216.      end #end case
  217.      end
  218. end
  219. #==========================================================================
  220. #==========================================================================
  221. # ■ Window_DayLight
  222. #--------------------------------------------------------------------------
  223. #    顯示日夜/時間的窗口。
  224. #==========================================================================
  225. class Window_DayLight < Window_Base
  226.   #--------------------------------------------
  227.   #時間軸的進制
  228.   #--------------------------------------------
  229.     $sec_count = $Day_sec#5 #時間軸的進制 預設為 5 進制
  230.     $min_count = $Day_min#5 #ㄧ小時幾分鐘的進制 預設為5進制
  231.     $hour_count = $Day_hour#12 #每天為幾小時的進制 預設為12小時1天
  232.   #------------------------------------------------------------------------
  233.   # ● 初始化窗口
  234.   #------------------------------------------------------------------------
  235.   def initialize
  236.     super(0, 0, 160, 60) #(X,Y,寬,高)
  237.     self.contents = Bitmap.new(width - 32, height - 32)
  238.     $hour = 0
  239.     $set_hour = $game_variables[$Ctrl_Set_hour]
  240.     refresh
  241.   end
  242.   #------------------------------------------------------------------------
  243.   # ●  初始化對象
  244.   #------------------------------------------------------------------------
  245.   def refresh
  246.     self.contents.clear
  247.     self.back_opacity = 0 #背景透明
  248.     self.opacity = 0 #外框透明
  249.     if $hour > $hour_count #當計時時間超過實際時間
  250.       Graphics.frame_count = 0 #計時器歸零
  251.       $set_hour = 0
  252.     end
  253.      if $game_switches[Ctrl_daylight_sys] == false
  254.        @color = $game_variables[11] #設定變數11的值,來改變字時間體顏色
  255.       self.contents.font.color = text_color(@color)
  256.   @total_sec = Graphics.frame_count / Graphics.frame_rate
  257.     $hour =    (@total_sec / $sec_count /$sec_count %$hour_count) + $set_hour
  258.     $min = @total_sec / $sec_count % $min_count
  259.     $sec = @total_sec % $sec_count
  260.     text = sprintf("T:%02d:%02d", $hour, $min)
  261.     #self.contents.font.color = Color.new(255,255,255,255)#設定顏色(R,G,B,亮度)
  262.     self.contents.draw_text(25, 5, 100, 20, text, 2)#(x,y寬,高,變數,字型顏色)
  263.     the_time
  264.     end
  265. end
  266.   #------------------------------------------------------------------------
  267.   # ● 刷新
  268.   #------------------------------------------------------------------------
  269.   def update
  270.     super
  271.     if Graphics.frame_count / Graphics.frame_rate != @total_sec           
  272.     end
  273.   end
  274. end
  275. #--------------------------------------------------------------------------#==========================================================================
  276. # ■ Scene_Map
  277. #--------------------------------------------------------------------------
  278. #  處理地圖畫面的程式。
  279. #==========================================================================
  280. class Scene_Map
  281. def main
  282.       # 生成遊戲時間窗口
  283.     @daylight_window = Window_DayLight.new
  284.     @daylight_window.x = 450
  285.     @daylight_window.y = 0
  286.     # 生成活動塊
  287.     @spriteset = Spriteset_Map.new
  288.     # 生成訊息窗口
  289.     @message_window = Window_Message.new
  290.     # 執行過渡
  291.     Graphics.transition
  292.     # 主循環
  293.     loop do
  294.       # 刷新遊戲畫面
  295.       Graphics.update
  296.       # 刷新輸入訊息
  297.       Input.update
  298.       # 刷新畫面
  299.       update
  300.       # 如果畫面切換的話就中斷循環
  301.       if $scene != self
  302.         break
  303.       end
  304.     end
  305.     # 準備過渡
  306.     Graphics.freeze
  307.     # 釋放活動塊
  308.     @spriteset.dispose
  309.     @daylight_window.dispose #釋放時間窗口
  310.     # 釋放訊息窗口
  311.     @message_window.dispose
  312.     # 標題畫面切換中的情況下
  313.     if $scene.is_a?(Scene_Title)
  314.       # 淡入淡出畫面
  315.       Graphics.transition
  316.       Graphics.freeze
  317.     end
  318.   end
  319.   
  320.   alias daylight_sys_update update
  321.   def update
  322.       @daylight_window.refresh #刷新時間顯示
  323.       daylight_sys_update
  324.   end
  325. end
复制代码
回复

使用道具 举报

845

主题

1万

帖子

214748万

积分

版主

脑残中……

Rank: 7Rank: 7Rank: 7

积分
2147483647

声命组金赏

发表于 2007-2-8 11:03:08 | 显示全部楼层
虽然用不到,还是支持一下好啦~
http://icv.cc声动音缘配音社
回复 支持 反对

使用道具 举报

14

主题

107

帖子

2307

积分

⑥精研

基拉里拉桑

积分
2307
发表于 2007-2-8 20:17:30 | 显示全部楼层
这好棒哦~~收下了~ [s:4]

回复 支持 反对

使用道具 举报

好人卡的 该用户已被删除
发表于 2007-2-8 20:26:22 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

14

主题

107

帖子

2307

积分

⑥精研

基拉里拉桑

积分
2307
发表于 2007-2-8 20:33:02 | 显示全部楼层
呃...我不懂脚本
我想问下把那个时间显示去掉要删掉哪些东西 [s:8]

回复 支持 反对

使用道具 举报

好人卡的 该用户已被删除
发表于 2007-2-8 20:42:13 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

14

主题

107

帖子

2307

积分

⑥精研

基拉里拉桑

积分
2307
发表于 2007-2-8 21:11:05 | 显示全部楼层
我测过了只有5有效 [s:6]

回复 支持 反对

使用道具 举报

3

主题

20

帖子

222

积分

③业余

积分
222
 楼主| 发表于 2007-2-8 21:51:50 | 显示全部楼层
基本上
開關只有 5 6有控制效果
1234 是自動會改變的,不是手動控制

比如你設計一個NPC事件 小偷,他必須在村莊內 並且 夜間 才會出現。玩家才能跟它互動產生劇情。
那就可以設計這NPC事件的啟動開關為 開關3號 = On 時才會啟動。

當日夜系統時段達到[夜間]時,會自動把 開關3 打開。同時你的NPC 就會被啟動了。
轉到晨間時,會把開關4 打開,開關3 Off。相對的NPC事件就會自動被關閉。
[s:1]
回复 支持 反对

使用道具 举报

3

主题

20

帖子

222

积分

③业余

积分
222
 楼主| 发表于 2007-2-8 21:58:30 | 显示全部楼层
引用第4楼GAME小子2007-02-08 20:33发表的:
呃...我不懂脚本
我想问下把那个时间显示去掉要删掉哪些东西 [s:8]
===================================================
請看到這段 Code:
  1. #------------------------------------------------------------------------
  2. # ● 初始化對象
  3. #------------------------------------------------------------------------
  4. def refresh
  5.   self.contents.clear
  6.   self.back_opacity = 0 #背景透明
  7.   self.opacity = 0 #外框透明
  8.   if $hour > $hour_count #當計時時間超過實際時間
  9.     Graphics.frame_count = 0 #計時器歸零
  10.     $set_hour = 0
  11.   end
  12.   if $game_switches[Ctrl_daylight_sys] == false
  13.     @color = $game_variables[11] #設定變數11的值,來改變字時間體顏色
  14.     self.contents.font.color = text_color(@color)
  15. @total_sec = Graphics.frame_count / Graphics.frame_rate
  16.   $hour =   (@total_sec / $sec_count /$sec_count %$hour_count) + $set_hour
  17.   $min = @total_sec / $sec_count % $min_count
  18.   $sec = @total_sec % $sec_count
  19.   text = sprintf("T:%02d:%02d", $hour, $min)
  20.   #self.contents.font.color = Color.new(255,255,255,255)#設定顏色(R,G,B,亮度)
  21.   self.contents.draw_text(25, 5, 100, 20, text, 2)#(x,y寬,高,變數,字型顏色)
  22.   the_time
  23.   end
  24. end
复制代码

主要把時間文字顯示在畫面上的控制是
  1. self.contents.draw_text(25, 5, 100, 20, text, 2)#(x,y寬,高,變數,字型顏色)
复制代码
把這句 Mark 起來就好了。變成如下:
  1. #self.contents.draw_text(25, 5, 100, 20, text, 2)#(x,y寬,高,變數,字型顏色)
复制代码
[s:1]
回复 支持 反对

使用道具 举报

14

主题

107

帖子

2307

积分

⑥精研

基拉里拉桑

积分
2307
发表于 2007-2-8 21:58:49 | 显示全部楼层
啊~~谢了~
如果1234能够受控制就好了
比如太阳被XX了   就只有晚上的话~

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-25 21:19 , Processed in 0.012642 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表