查看: 4229|回复: 4

[已经解决] 如何获取游戏进行时间,作事件发生?

[复制链接]
梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
发表于 2013-2-19 16:28:55 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 xixifilm 于 2013-2-22 15:36 编辑

已经插入一日夜脚本,如何提取指定时间,作为事件开关?
脚本转自66论坛内

[pre lang="ruby" line="1"]#Basic Game Time + Night/Day
#----------#
#Features: Provides a series of functions to set and recall current game time
#   as well customizable tints based on current game time to give the
#   appearance of night and day.
#
#Usage:   Script calls:
#       GameTime::minute?   - returns the current minute返回当前分钟
#       GameTime::hour?  - returns the current hour返回当前小时
#       GameTime::set(time) - sets the game time to time, in frames设置游戏时,以每秒帧(max:1440)
#       例子GameTime::set(360)是早上6点
#       GameTime::change(time) - increments the game time! (can be negative)增加游戏时间可以负数
#       GameTime::pause_time(set) - stops time for events and stuff, true or false真或假停止时间
#       GameTime::pause_tint(set) - time runs, but tints do not update时间的运行,但色彩不更新
#       GameTime::clock(set) - sets whether clock is visible or not设置时钟是否可见
#
#Customization: Set below, in comments.
#
#Examples: GameTime::set(360)
#
#----------#
#-- Script by: V.M of D.T
#--- Free to use in any project with credit given

#---Game Clock---#
#USE_CLOCK to true to display game time clock
#CLOCK_POSITION for position of clock
#  1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
#CLOCK_TOGGLE is any input button available, see the INPUT help file for options
#------#
USE_CLOCK       = true   #时钟显示,默认true,不显示为false
CLOCK_POSITION  = 4      #时钟位置
CLOCK_TOGGLE = :SHIFT

module GameTime
  #---Game Time Details---#
  #Number of frames in a game minute, 60 frames = 1 second 游戏分钟60帧为1秒
  TIME_COUNT   = 6     # 6的倍数时间较为慢
  #Sets whether to tint screen based on game time 色彩是否跟随时间
  USE_TINT = true

  #True to pause time while not in map or while during a message
  #真正的暂停时间,而不是在地图或同时在消息
  PAUSE_IN_COMBAT  = false
  PAUSE_NOT_IN_MAP = true
  PAUSE_IN_MESSAGE = true

  #Sets time frames of tints by minute count, one day is 1440 minutes
  # 0 = 12am, 360 = 6am, 720 = 12pm, 1080 = 6pm  etc...
  PRESUNRISE_TIME = 240
  SUNRISE_TIME = 360
  NOONSTART_TIME  = 660
  NOONEND_TIME = 900
  PRESUNSET_TIME  = 1080
  SUNSET_TIME  = 1260
  MIDNIGHT_TIME   = 60  #Must be greater than 0

  #Sets custome tints
  PRESUNRISE_TONE = Tone.new(-75,-75,0,50)
  SUNRISE_TONE = Tone.new(0,0,0,0)
  NOONSTART_TONE  = Tone.new(45,45,0,-25)
  NOONEND_TONE = Tone.new(0,0,0,0)
  PRESUNSET_TONE  = Tone.new(-50,-50,0,25)
  SUNSET_TONE  = Tone.new(-75,-100,0,75)
  MIDNIGHT_TONE   = Tone.new(-125,-125,0,125)

  #Include the ids of any maps not to be tinted based on time
  #包括基于时间的ID不被着色的任何地图
  # Usually reserved for indoor maps
  # 通常是保留给室内地图
  NOTINTMAPS = [2]
  #---END---#

  def self.init
$game_time = 0
$game_time_pause_time = false
$game_time_pause_tint = false
  end
  def self.update
if $game_time_pause_time then return else end
case SceneManager::scene_is?(Scene_Map)
when true
if $game_message.visible == true && PAUSE_IN_MESSAGE then else
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
when false
if SceneManager::scene_is?(Scene_Battle) && PAUSE_IN_COMBAT != true
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
end
if $game_time == 1440 then $game_time = 0 end
GameTime::tint if $game_time_pause_tint != true
  end
  def self.hour?
return $game_time / 60
  end
  def self.minute?
return $game_time % 60
  end
  def self.time?
meri = "AM"
hour = GameTime::hour?
minute = GameTime::minute?
if hour > 11 then meri = "PM" end
if hour == 0 then hour = 12; meri = "AM" end
if hour > 12 then hour -= 12 end
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
return hour.to_s + ":" + minute.to_s + " " + meri
  end
  def self.set(number)
$game_time = number if number < 1440
GameTime::tint(0)
  end
  def self.change(number)
$game_time += number
$game_time -= 1440 if $game_time > 1440
$game_time += 1440 if $game_time < 0
GameTime::tint(0)
  end
  def self.tint(tint = 60)
if USE_TINT != true then return end
for i in NOTINTMAPS
if $game_map.map_id == i
$game_map.screen.start_tone_change(Tone.new(0,0,0,0),0)
return
end
end
if SceneManager::scene_is?(Scene_Map) then else return end
case $game_time
when PRESUNRISE_TIME .. SUNRISE_TIME
$game_map.screen.start_tone_change(PRESUNRISE_TONE, tint)
when SUNRISE_TIME .. NOONSTART_TIME
$game_map.screen.start_tone_change(SUNRISE_TONE, tint)
when NOONSTART_TIME .. NOONEND_TIME
$game_map.screen.start_tone_change(NOONSTART_TONE, tint)
when NOONEND_TIME .. PRESUNSET_TIME
$game_map.screen.start_tone_change(NOONEND_TONE, tint)
when PRESUNSET_TIME .. SUNSET_TIME
$game_map.screen.start_tone_change(PRESUNSET_TONE, tint)
when SUNSET_TIME .. 1440
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when 0 .. MIDNIGHT_TIME
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when MIDNIGHT_TIME .. PRESUNRISE_TIME
$game_map.screen.start_tone_change(MIDNIGHT_TONE, tint)
end
  end
  def self.pause_time(set)
$game_time_pause_time = set
  end
  def self.pause_tint(set)
$game_time_pause_tint = set
  end
  def self.clock(set)
SceneManager.scene.clock_visible?(set)
  end

  class Window_Clock < Window_Base
def initialize
case CLOCK_POSITION
when 1
super(0,0,115,56)
when 2
super(429,0,115,56)
when 3
super(0,360,115,56)
when 4
super(429,360,115,56)
end
end
def update
self.contents.clear
self.contents.draw_text(0,0,100,24,GameTime::time?)
end
  end

end

module DataManager
  class << self
  alias gametime_msc make_save_contents
  alias gametime_esc extract_save_contents
  end
  def self.make_save_contents
contents = gametime_msc
contents[:gametime] = $game_time
contents
  end
  def self.extract_save_contents(contents)
gametime_esc(contents)
$game_time = contents[:gametime]
  end
end


class Scene_Map < Scene_Base
  alias gametime_post_transfer post_transfer
  alias gametime_create_all_windows create_all_windows
  alias gametime_update_map update
  def post_transfer
GameTime::tint(0)
gametime_post_transfer
  end
  def create_all_windows
gametime_create_all_windows
@gametimeclock = GameTime::Window_Clock.new if USE_CLOCK
  end
  def update
gametime_update_map
@gametimeclock.update if @gametimeclock.nil? == false
if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false
@gametimeclock.visible ? @gametimeclock.visible = false : @gametimeclock.visible = true
end
  end
  def clock_visible?(set)
@gametimeclock.visible = set
  end
end

class Scene_Base
  alias gametime_update update
  def update
gametime_update
GameTime::update
  end
end

GameTime::init[/pre]
梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
 楼主| 发表于 2013-2-19 16:56:44 | 显示全部楼层
我是脚本小白, 只知道$game_time赋值于变量,后,再用变量控制发生 , 试了无数次,在地图中建一个空的自动事件执行赋值变量,跟着变量的事件是可以自动跟随时间发生了,但主角动不了(不能控制),是RMVA不能用这样操作吗
回复

使用道具 举报

梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
 楼主| 发表于 2013-2-19 17:11:23 | 显示全部楼层
又试了几次,为何$game_time赋值于变量事件时需要 “并行处理”,否则角色不能动(不能操作游戏)? 真不明白
回复

使用道具 举报

梦石
0
星屑
50
在线时间
687 小时
注册时间
2012-10-29
回帖
1526
发表于 2013-2-19 22:08:29 | 显示全部楼层
设成自动如果在最后没有暂时取消事件,它是会不断重覆自动重新执行的,但这重覆不是与其它事件并行,所以角色动不了,自动的工作没有结束,角色还在等它结束呢,设成并行就不影响了,

您可以这么理解,就像显示图片后的移动图片,不是有个等待到移动结束的勾选项吗?如果勾选了,除非一张图移动完毕,后面的图不会有动作,但不勾选就可以同时几张图一起动作,这就和自动与并行的意思一样。
修改劇本中,仔細審查原來的劇情大綱,覺得有點不太滿意,嘗試編寫不同主角不同主線的劇情,希望能寫得出來。
回复

使用道具 举报

梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
 楼主| 发表于 2013-2-20 09:33:37 | 显示全部楼层
j433463 发表于 2013-2-19 22:08
设成自动如果在最后没有暂时取消事件,它是会不断重覆自动重新执行的,但这重覆不是与其它事件并行,所以角 ...

感谢感谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部