查看: 2424|回复: 2

[已经解决] 这个时间系统在战斗中如何不显示

[复制链接]
梦石
0
星屑
1554
在线时间
523 小时
注册时间
2015-8-23
回帖
83
发表于 2021-10-17 18:04:11 | 显示全部楼层 |阅读模式

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

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

×
时间#==============================================================================
# ** 虚拟日历
#  作者:影月千秋
#  适用:VA
#  要求:Smomo脚本核心 1.0+
#------------------------------------------------------------------------------
# * 简介:
#  模拟时间流逝,并在地图(菜单)进行显示
#  可以自定义计时规则和显示效果
#  请为本脚本准备变量和开关,在下方进行设定
#  本脚本需要Smomo脚本核心,请到此下载:http://tinyurl.com/l9kvg2p
#  如果链接失效,请到rm.66rpg.com,@余烬之中 或 @影月千秋
#------------------------------------------------------------------------------
# * 使用方法:
#  将此脚本插入到其他脚本以下,Main以上,在下面给出的设定区进行设定后即可
#  在事件中操作指定的变量和开关,便可以获取和改变时间
#  也可以通过事件脚本进行操作
#  允许的脚本呼叫:
#    Smomo.calendar(type) 取得日历的内部数据
#   参数说明:type 想要获得的数据名
#       【:all】 获取所有数据的数组 依次为:时段 色调 刷新标志 周期历时 周期序号
#       【:zone】获取当前时段的名称(如:"早晨")
#       【:tone】不常用,获取当前色调(Tone色调类的实例)
#       【:need_change】没有任何实用意义,不常用,可以获取需要刷新的标志
#       【:period】当前周期经过的时间(如:1366)
#       【:prd】当前周期的序号,对应在周期名字(如:3)
#       【:pname】当前周期的名字,与prd是对应的(如:周三)
#   例:【Smomo.calendar(:zone)】获取时段名
#------------------------------------------------------------------------------
# * 版本:
#   V 3.1 2014.09.07 优化了室内地图的标记方式 修正了暂停计时时色调的转换问题
#   V 3.0 2014.07.31 修正了2.7以为成功实际上未修正成功的问题 并做了一些其他调整
#   V 2.9 2014.07.28 修正了Map不能为:none从2.3版延续过来的睿智错误
#   V 2.8 2014.07.26 对2.7的小修正 并修改了自定义提示语
#   V 2.7 2014.07.24 修正了事件推进时不刷新周期的问题
#   V 2.6 2014.05.24 修正了日期出现0的BUG
#   V 2.5 2014.04.06 规范化脚本 消除冗余 重建逻辑结构 需要依赖Smomo脚本核心
#   V 2.4 2014.01.31 修正读档时报错的BUG
#   V 2.3 2014.01.29 可以自定义地图窗体的位置
#   V 2.2 2013.12.27 修正Window_MoVMe的错误
#   V 2.1 2013.12.15 修正过卡的BUG
#   V 2.0 2013.10.04 基本重写
#   V 1.0 2013.08.31 公开
#------------------------------------------------------------------------------
# * 声明:
#   本脚本由来自【影月千秋】,使用和转载请保留此信息
#==============================================================================

if $smomo["Core"].nil? || $smomo["Core"] < 1.0
  msgbox "请先安装Smomo脚本核心!"; %x!start http://tinyurl.com/l9kvg2p!
elsif $smomo["Calendar"].nil?
$smomo["Calendar"] = true

#==============================================================================
# ** Smomo::Calendar
#==============================================================================
module Smomo::Calendar
  Menu = true
  # 是否在菜单内显示日历
   # true 使用  false 不使用
   # 如果预设不能满足要求 请自行在下方自定义区更改
  
  Map = :bottom
  # 是否在地图上显示日历
   # :top 顶部  :bottom 底部  :none 不使用
   # 如果预设不能满足要求 请自行在下方自定义区更改
  
  Use = 16
  # 设定占用开关,只有当此开关打开时,才会计时
   # !打开开关前 请确保下方Speed对应的变量不为0!
  
  Var = 81
  # 设定占用变量的起始编号 会占用以这个号码为开端的连续几个号码对应的游戏变量
  
  # 继续设置需要了解的事实:
  #  脚本内部用一个数字累加计时 然后依次推进到下一单位 把最开始的数字叫计时变量
  
  Speed = 100
  # 设定游戏时间进行速度占用变量,代表经过多少帧后游戏内部计时变量增加一
   # 一般情况下 1秒60帧
   # 再打开Use对应的开关前 请确保这个常量不为0
   # 请确保这个常量不与上面Var的常量(及其包括的范围内的变量)重合

  System = [
    # ["单位", 满多少进一(比最大值大一), 是否以零起始(true/false)],
    ["分", 60, true],
    ["时", 24, true],
    ["日", 30],
    ["月", 12],
    ["年", 9999],
  ]
  # 设定计时制,最后一个数据的单位与计时变量的单位统一
   # 可以突破公元历法的限制
    # 比如:636号时间线3145纪6887年6月4日 21:39:44:03
   # !这里有几项 上面的Var就会占用几个变量!
   # !从上往下! 单位由小到大 如:分-->时-->日-->月-->年
   # 有的单位允许以0为值 比如 3:00 有的不行 比如 3月1日
    # 默认不允许0值 如果需要允许 请将“以零起始”填为【true】
  
  Start = [50, 4, 4, 5, 0001]
  # 设置游戏起始时间 与上面的单位从上到下依次对应
  
  PeriodName = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
  # 日期的别名 每经过一个周期都会自动推进并显示下一个名字
   # 别名列表长度不固定 可以自行添加或缩短
   
  Start_PeriodName = 6
  # 确定游戏起始时的那个周期的别名是什么 0为第一个别名
   # 一定要用数字来指代 不要用"字符串"
  
  TimeZone = true
  # 是否启用时段功能, 即一个周期内是否有各时段的区分(如:凌晨-中午-黄昏-黑夜)
  
  Zone = [
  # [时段长度, Tone.new(红, 绿, 蓝, 灰), "名称"],
    [120, Tone.new( 0,0,   0,  0), "深夜"], # 0...120
    [240, Tone.new(0,0, 0, 0), "凌晨"], # 120...240
    [60, Tone.new( 0,0,   0,  0), "黎明"], # 240...360
    [240, Tone.new(   0,   0,   0,   0), "上午"], # 360...660
    [240, Tone.new(  0,  0,  0, 0), "中午"], # 660...900
    [120, Tone.new(   0,   0,   0,   0), "下午"], # 900...1020
    [120, Tone.new(  0, 0, 0, 0), "黄昏"], # 1020...1140
    [300, Tone.new( 0,0,   0,  0), "夜晚"], # 1140...1440 则1440为周期长度
  ]
  # 设置时段周期内各时段的长度、色调及名称
   # 时段长度以计时变量的单位为单位
  # 到达对应时段时 会自动改变画面的色调
   # 【所有时段的长度加起来就是周期长度!】
   # 【所以,就算不需要使用时段功能,也一定要保证时段长度之和是一个合适的值!】
  # 当一次时段轮回完毕 就会推移到下一个周期(如:周三-->周四)
  
  IndoorMap = /<IndoorMap>/i
  # 用于匹配室内地图备注的正则式
   # 默认为/<IndoorMap>/i
   # 在地图的备注上写【<IndoorMap>】就可以标记其为室内地图
   # 不区分大小写
  # 处于室内地图时,不会受到时段色调的影响
  
  Format = {
    # 菜单用的格式
    #menu: %W!
     #       <4年>.<2月>.<2日>
      #      \\I[280]___<Period>
       #     <2时>:<2分>_<Zone>
#          !,
    # 地图用的格式
    map:  %W!
               \\I[280]蓝月<4年>年<2月>月<2日>日___<Period>___<Zone>_<2时>:<2分>
          !
  }
  # 输出格式 此处写多少行 游戏内就会依次对应输出多少行
   # 每一行的内部不要使用空格( ),空格用下划线(_)代替
   # 尽量不要使用英文感叹号(!),如果一定要用请在之前加上反斜杠(\!)
   # 使用【<符号>】的形式来代替指定的数据 其他的文字用于修饰
   # 可用的符号
    # 在上面计时制中设定的单位 可以加上一个数字来代表格式化位数
     # 如:<2时>:<2分> 显示 09:33 <时>:<分> 显示 9:33
    # <Period> 当前周期的名字(如:星期三)
    # <Zone>   当前时段的名字(如:早晨)
   # 两个符号必须用两对<>分别括起来 不能写在同一对<>内
    # 允许使用转义字符 但是必须有两个反斜杠
     # 如 显示图标 \I[3] 应写成 \\I[3]
end

#==============================================================================
# 如果你懂脚本,可以在下面调整时间窗口的显示方式
#==============================================================================

#==============================================================================
# ** Scene_Menu 建立菜单场景的窗口
#==============================================================================
class Scene_Menu
  _def_ :start do |*args|
    return unless Smomo::Calendar::Menu
    # 在下面添加自定义内容
#    @mocalendar_window = Window_MoMenuCalendar.new(@gold_window)
  end
end
#==============================================================================
# ** Scene_Map 建立地图场景的窗口
#==============================================================================
class Scene_Map
  _def_ :create_all_windows do |*args|
    return if Smomo::Calendar::Map == :none
    # 在下面添加自定义内容
    @mocalendar_window = Window_MoMapCalendar.new
  end
  _def_ :call_menu do |*args|
    return if Smomo::Calendar::Map == :none
    # 在下面添加自定义内容
    @mocalendar_window.contents.clear
  end
end
#============================================================================
# ** Window_MoMenuCalendar 菜单画面中,显示当前游戏内部虚拟日历的窗口
#============================================================================
class Window_MoMenuCalendar < Window_Base
  include Smomo::Calendar

  def initialize(gold_window)
    unless $game_switches[Use]
      super(0, 0, 1, 1)
      self.opacity = 0
      return
    end
   Smomo::Calendar.ensure_time_legal
    Smomo::Calendar.check_period_and_zone
    height = Format[:menu].size * 30 + 20
    super(0, gold_window.y - height, gold_window.width, height)
    format = Smomo.deep_clone(Format[:menu])
    format.each_with_index do |t, l|
      t.gsub!(/_/){" "}
      System.each_with_index do |(u, m), i|
        t.gsub!(/<(\d*)#{u}>/){
          format("%0#{$1 ? $1.to_i : nil}d", $game_variables[Var + i])
        }
      end
      t.gsub!(/<Period>/){"#{PeriodName[Smomo::Calendar.prd]}"}
      t.gsub!(/<Zone>/){"#{Smomo::Calendar.zone}"}
      draw_text_ex(0, l * 30, t)
    end
  end
end
#============================================================================
# ** Window_MoMapCalendar 地图画面中,显示当前游戏内部虚拟日历的窗口
#                         但本质上是一个精灵
#============================================================================
class Window_MoMapCalendar < Window_Base
  include Smomo::Calendar
  
  def initialize
    height = Format[:map].size * 30 + 10
    @sprite = Sprite.new
    @sprite.y = Smomo::Calendar::Map == :top ? 0 : Graphics.height - height
    @sprite.bitmap = Bitmap.new(Graphics.width, height)
    @use = true
    update
    refresh
  end
  
  def update
    unless @use == $game_switches[Use]
      @use = $game_switches[Use]
      @sprite.x = @use ? 0 : Graphics.width
      refresh
    else
      refresh if @use && Graphics.frame_count % $game_variables[Speed] == 0 ||
      $game_map.need_refresh
    end
  end
  
  def refresh
    Smomo::Calendar.ensure_time_legal
    Smomo::Calendar.check_period_and_zone
    contents.clear
    contents.gradient_fill_rect(0, 0, @sprite.width, @sprite.height,
    Color.new(30, 30, 30), Color.new(0, 0, 0, 0))
    format = Smomo.deep_clone(Format[:map])
    format.each_with_index do |t, l|
      t.gsub!(/_/){" "}
      System.each_with_index do |(u, m), i|
        t.gsub!(/<(\d*)#{u}>/){
          format("%0#{$1 ? $1.to_i : nil}d", $game_variables[Var + i])
        }
      end
      t.gsub!(/<Period>/){"#{PeriodName[Smomo::Calendar.prd]}"}
      t.gsub!(/<Zone>/){"#{Smomo::Calendar.zone}"}
      draw_text_ex(0, l * 30 + 5, t)
    end
  end
  #------------------------------------------------------------------------
  # * 偷梁换柱 如果不明白这段的意义 请勿随意删除
  #------------------------------------------------------------------------
  def contents
    @sprite.bitmap
  end
  def windowskin
    Cache.system("Window")
  end
end
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+#
#------------------------------------------------------------------------------#
                               "请勿跨过这块区域"
#------------------------------------------------------------------------------#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=#

#==============================================================================
# ** Smomo::Calendar
#==============================================================================
module Smomo::Calendar
  # 预处理
  PeriodSize = Zone.inject(0){|s, (l)| s + l}
  Zone.each_with_index{|z, i| z[0] += i == 0 ? 0 : Zone[i - 1][0]}
  _ = Smomo.deep_clone(Zone)
  _.each_with_index{|z, i| Zone[0] = (i == 0 ? 0 : _[i - 1][0])...z[0]}
  class << self
    attr_reader :zone, :prd, :ticking
    attr_accessor :period
    define_method(:data){[@zone, @tone, @need_change, @period, @prd]}
    define_method(:data=){|d| @zone, @tone, @need_change, @period, @prd = d}
    define_method(:function){|type| type == :all ? data : eval(type.to_s)}
    # 获知周期名
    def pname
      PeriodName[@prd]
    end
    # 初始化
    def ini
      @ticking = true
      System.each_index{|i| $game_variables[Var + i] = Start}
      @ticking = false
      @zone = ""
      @tone = Tone.new(0, 0, 0, 0)
      @need_change = false
      @period = init_period
      @prd = Start_PeriodName
      check_period_and_zone
    end
    # 初始化周期
    def init_period
      sta = Start.reverse
      sta.each_with_index do |n, i|
        next if i == sta.size - 1
        sta[i + 1] += n * System.reverse[i + 1][1]
      end
      sta.reverse[0] % PeriodSize
    end
    # 计时
    def i_look_into_the_sky_as_time_passes_by
      return unless $game_switches[Use]
      return if $game_message.visible
      return unless Graphics.frame_count % $game_variables[Speed] == 0
      # 如果在这里报错 一定是你没有设置Speed所对应的变量的值
      @ticking = true
      $game_variables[Var] += 1
      @period += 1
      ensure_time_legal
      ensure_period_legal
      check_period_and_zone
      change_tone if TimeZone
      @ticking = false
    end
    # 确保变量在范围内
    def ensure_time_legal
      @ticking = true
      System.each_with_index do |(u, m, o), i|
        while $game_variables[Var + i] > m - (o ? 1 : 0)
          $game_variables[Var + i] -= m
          $game_variables[Var + i + 1] += 1
        end
        while $game_variables[Var + i] < 1 - (o ? 1 : 0)
          $game_variables[Var + i] += m
          $game_variables[Var + i + 1] -= 1
        end
      end
      @ticking = false
    end
    # 确保时段在范围内
    def ensure_period_legal
      @prd += (@period = 0) + 1 if @period >= PeriodSize
      @prd = 0 if @prd >= PeriodName.size
    end
    # 检查周期别名和时段
    def check_period_and_zone
      tone, @zone = Zone.find{|(r, t, n)| r.include?(@period)}[1, 2]
      @tone == tone ? nil : [@tone = tone, @need_change = true]
    end
    # 改变画面色调
    def change_tone(im = false, reset = false)
      return unless @need_change || im
      @need_change = false
      if indoor? || !$game_switches[Use] && reset
        $game_map.screen.start_tone_change(Tone.new(0, 0, 0, 0), 0)
      else
        return unless $game_switches[Use]
        $game_map.screen.start_tone_change(@tone, im ? 0 : 60)
      end
    end
    # 是否是室内地图
    def indoor?
      $game_map.instance_exec{ @map }.note =~ IndoorMap
    end
  end
end
#==============================================================================
# ** Smomo.calendar(*a, &b)
#==============================================================================
def Smomo.calendar(*a, &b)
  Smomo::Calendar.function(*a, &b)
end
#==============================================================================
# ** Game_Switches
#==============================================================================
class Game_Switches
  _def_ :on_change do
    Smomo::Calendar.change_tone true, true
  end
end
#==============================================================================
# ** Game_Variables
#==============================================================================
class Game_Variables
  _def_ :[]=, :c do |old, variable_id, value|
    if Smomo::Calendar.ticking
      old.call(variable_id, value)
    else
      min = Smomo::Calendar::Var
      max = min + Smomo::Calendar::System.size - 1
      if variable_id.between?(min, max)
        Smomo::Calendar.period += value - @data[variable_id]
        old.call(variable_id, value)
        Smomo::Calendar.ensure_time_legal
        Smomo::Calendar.ensure_period_legal
        Smomo::Calendar.check_period_and_zone
        Smomo::Calendar.change_tone
      else
        old.call(variable_id, value)
      end
    end
  end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  _def_ :update do |*args|
    Smomo::Calendar.i_look_into_the_sky_as_time_passes_by
  end
  _def_ :post_transfer, :b do |*args| Smomo::Calendar.change_tone(true) end
end
#==============================================================================
# ** DataManager
#==============================================================================
class << DataManager
  _def_ :setup_new_game do Smomo::Calendar.ini end
  _def_ :make_save_contents, :v do |contents, *args|
    contents[:mocalendar] = Smomo::Calendar.data
    contents
  end
  _def_ :extract_save_contents do |contents, *args|
    Smomo::Calendar.data = contents[:mocalendar]
  end
end

else # if $smomo
  msgbox "请不要重复加载此脚本 : )\n【虚拟日历】"
end
#==============================================================================#
#=====                        =================================================#
            "脚 本 尾"
#=====                        =================================================#
#==============================================================================#
这个时间系统很喜欢,唯独让我头疼的是它在战斗中也显示,我不会脚本一直不
脚本#==============================================================================
# ** Smomo脚本核心
#  作者:影月千秋
#------------------------------------------------------------------------------
# * 简介
#  Smomo脚本的核心,提供了一些常用功能,有些脚本需要依靠此脚本以正常工作
#------------------------------------------------------------------------------
# * 使用方法
#  插入到其他Smomo脚本上方
#------------------------------------------------------------------------------
# * 更新
#   V 1.5  2014.06.29 加入远端下载功能
#   V 1.41 2014.06.21 加入shell_execute系列
#   V 1.4  2014.06.20 加入括号匹配
#   V 1.3  2014.06.14 mail并入register 加入两个api moveAE优化并更名transition
#   V 1.2  2014.06.11 优化text_size的处理 为Smomo::Kit新增功能mail
#   V 1.1  2014.05.10 新方法:Smomo.traverse_dir
#   V 1.0  2014.04.05 新建
#------------------------------------------------------------------------------
# * 声明
#   本脚本来自"影月千秋", 使用/修改/转载请保留此信息
#==============================================================================

$smomo ||= {}
$smomo["RGSS Version"] =
  defined?(Audio.setup_midi) ? :VA : defined?(Graphics.wait) ? :VX : :XP

if $smomo["Core"].nil? || $smomo["Core"] < 1.5
$smomo["Core"] = 1.5

#==============================================================================
# ** Smomo!module_function
#----------------------------------------------------------------------------
# * text_size(str, font = nil) 确定合适的文字大小(Rect矩形类)
#
# * transition(object, attribute) 属性值的过渡渐变 返回一个渐变对象signal
#     object: 被操作的对象   attribute: 进行变换属性名
#   signal对象:
#     * target(value, duration = 1) 在duration帧内变换为value
#         如果正在变换中 则将该变换添加至原变换后 顺次执行
#         指令添加成功 返回true 否则false
#     * turn 改变变换方向 本质上是将指令队列反向执行
#     * lock(state = :switch) 锁定/解锁  可以使用参数 :on 和 :off
#         锁定状态下 会完成当前变换 但不再接受新的指令
#     * clear 停止移动 并清空指令队列
#     * kill 删除该signal对象
#     * arrived? 判定是否到达终点 判定条件和变换方向有关
#     * update 执行更新 不需要手动调用
#     如果被操作的属性不能读写 对应的signal对象将自动报废 不响应任何方法
#     返回值均为 nil
#
# * shell_execute 使用API调用外部程序打开文件或超链接
#   参数说明
#     * hwnd 整型 为用于展现用户接口或者错误信息的父窗口句柄 可以为空
#     * lpOperation 字符串 操作模式
#       可以使用的值 均可以顾名思义
#       "edit" "explore" "find" "open" "print"
#       可以为空 意味着默认方式 如果未定义默认方式 使用"open"
#     * lpFile 字符串 被操作的文件或超链接
#     * lpParameters 字符串 传递给所调用程序的参数
#     * lpDirectory 字符串 行为的默认工作目录
#     * nShowCmd 整型 标识应用程序应该如何被打开
#       可以使用的值及意义
#       0 隐藏 1 正常大小 2 激活并最小化 3 最大化 4 不激活 5 激活 6 最小化
#       7 最小化但仍保持激活 8 保持当前状态 9 激活并恢复正常大小 10 根据环境变量
#       请注意 这些值单纯的发送给被调用者 具体如何处理由被调用者决定
#   返回值
#     大于32时,操作成功,否则失败
#
# * quick_shell 快速调用shell_execute 改变了参数顺序 设置了默认值
#   新的参数顺序及默认值
#     lpFile 无默认值
#     lpOperation "open"  nShowCmd 1  hwnd 0  lpParameters ""  lpDirectory ""
#
# * web(url = "") 调用浏览器打开网页
#
# * dl2file(url, file) 丛网址下载内容到文件,file是文件名,需要加后缀名
#  可以使用绝对路径和相对路径
#
# * dl2cache(url, size = 1024) 从网址读取内容,size是缓存大小
#  一般情况下无需设置size,如果文件被截断或者出现奇怪的报错,请适度加大该值
#  将返回一个内容字符串
#
# * deep_clone(obj) 深度复制对象
#
# * traverse_dir(file_path = "."){} 遍历目录
#
# * mBrackets(str, brackets = {'(' => ')', '[' => ']', '{' => '}', '<' => '>'})
#   对字符串进行括号匹配
#============================================================================
module Smomo
  module_function
  
  # text_size
  def text_size(str, font = nil)
    tmp = Window_Base.new(Graphics.width, 0, Graphics.width, 1)
    tmp.reset_font_settings
    tmp.contents.font = font if font
    width = 0
    pos = {x: 0, y: 0, height: tmp.calc_line_height(str)}
    str.each_line do |s|
      s.gsub!(/[\n]/){""}
      tmp.process_character(s.slice!(0, 1), s, pos) until s.empty?
      width = [pos[:x], width].max
      pos[:x] = 0
      pos[:y] += pos[:height]
      pos[:height] = tmp.calc_line_height s
    end
    Rect.new 0, 0, width, pos[:y]
  end
  
  # transition
  def transition(object, attribute)
    ::Smomo::Kit.register[:transition].push signal = Object.new
    # Class Signal
    class << signal
      # target
      def target(value, duration = 1)
        return false if @lock
        @targets[-1][0] = (@current = @object.send(@attribute).to_f).to_i if
        @targets.size == 1
        @targets[-1][1] = @targets[-1][2] =
        duration.round == 0 ? 1 : duration.round
        @targets.push [value.round]
        return true
      end
      # turn
      def turn
        @position -= 1 if @direction == 1 && @position == @targets.size - 1
        @position += 1 if @direction == -1 && @position == -1
        @targets.each{|e| e[2] = e[1] - e[2] unless e[1].nil?}
        @direction = -@direction
      end
      # lock
      def lock(state = :switch)
        @lock = state == :on ? true : state == :off ? false : !@lock
      end
      # update
      def update
        return if @targets.size == 1
        return if arrived?
        @object.send "#{@attribute}=", @current +=
        (@targets[@position + (@direction == 1 ? 1 : 0)][0] - @current).to_f /
        @targets[@position][2]
        @targets[@position][2] -= 1
        if @targets[@position][2] == 0
          @position += @direction
          @object.send "#{@attribute}=", @current =
          @targets[@position + (@direction == 1 ? 0 : 1)][0].to_f
        end
      rescue RGSSError
        kill
      end
      # clear
      def clear
        @direction = 1
        @targets = [[@position = @current = 0]]
      end
      # arrived?
      def arrived?
        @position == (@direction == 1 ? @targets.size - 1 : -1)
      end
      # kill
      def kill
        dead = Object.new
        class << dead; def method_missing *args; end; end
        ::Smomo::Kit.register[:transition][@uid] = dead
      end
      # init
      def init object, attribute, uid
        clear
        @lock, @object, @attribute, @uid = false, object, attribute, uid
      end
    end # Class Signal
    signal.init object, attribute, ::Smomo::Kit.register[:transition].size - 1
    class << signal; undef init; end
    signal
  end
   
  # shell_execute
  def shell_execute(*args)
    __api "Shell32|ShellExecute|ippppi|i", *args
  end
  
  # quick_shell
  def quick_shell(f, o = "open", n = 1, h = 0, p = "", d = "")
    shell_execute h, o, f, p, d, n
  end
  
  # web
  def web(url = "")
    quick_shell(url)
  end
  
  # dl2file
  def dl2file(url, file)
    __api "Urlmon|URLDownloadToFile|ippii|i", 0, url, file, 0, 0
  end
  
  # dl2cache
  def dl2cache(url, size = 1024)
    __api "Urlmon|URLDownloadToCacheFile|ippiii|i",0,url,buf="\0"*size,size,0,0
    open(buf.sub(/\0+$/){}, 'rb'){|p| p.read}
  end
  
  # deep_clone
  def deep_clone(obj)
    Marshal.load Marshal.dump obj
  end
   
  # traverse_dir
  def traverse_dir(file_path = ".")
    return unless block_given?
    if FileTest.directory? file_path
      Dir.foreach(file_path) do |file|
        traverse_dir("#{file_path}/#{file}"){|x| yield x} if
        file != "." && file != ".."
      end
    else
      yield file_path
    end
  end
  
  # mBrackets
  def mBrackets str, brackets = {'(' => ')', '[' => ']', '{' => '}', '<' => '>'}
    matched = []
    result = [""]
    valid = [0]
    str.each_char do |c|
      valid.each{|v| result[v].concat(c)}
      if brackets.key?(c)
        matched.push(c)
        valid.push(result.size)
        result.push("")
      elsif brackets.value?(c)
        if brackets[matched[-1]] == c
          result[valid[-1]].chop!
          valid.pop
          matched.pop
        else
          raise ArgumentError, "False Matching!"
        end
      end
    end
    result
  end
end # Smomo

#============================================================================
# ** Smomo::Kit
#============================================================================
module Smomo::Kit
  # 公用寄存表
  @@register = {
    transition: [],
    temp: nil,
  } # @@register
  module_function
  # 获取寄存表
  def register
    @@register
  end
end # Smomo::Kit

#============================================================================
# ** Smomo::Mixin
#----------------------------------------------------------------------------
# * _def_ sym, type = :a, &append 快速重定义方法 添加新增的内容
#    方法获得的参数会传递给新增的块
#    三个参数依次为:方法名 添加方式 添加的块
#    方法名为一Symbol
#    添加方式
#      :a   after 之后  在原方法后添加新的内容
#      :b   before之前  在原方法前添加新的内容
#      :c   chain 链    将原方法作为第一个参数传递给块 需要.call才会调用原方法
#      :v   value 值    将原方法求值,并将所得值传递给块的第一个参数 不需要.call
#      :if        如果  如果新增的部分计算结果为真 则继续执行原方法
#      :unless    若非  如果新增的部分计算结果为假 则继续执行原方法
#      :ifold     若旧  如果原方法计算结果为真 则继续执行新增的部分
#      :unlessold 非旧  如果原方法计算结果为假 则继续执行新增的部分
#      缺省值为 :a
#      如果是其他的值 则不会对原方法进行更改 _def_什么也不做
#    添加的块
#      为了提高兼容性 建议使用|*args, &block|来定义形参 因为调用的时候会检查参数
#      对于:c和:v,建议使用|old, *args, &block|,这样可以方便地获得原方法
#
# * _api(code) 快速新建Win32API code的格式为"库|方法|参数类型|返回值类型"
#
# * __api(code, *args) 快速新建Win32API并用参数call code同上
#
#============================================================================
module Smomo::Mixin
  # _def_
  def _def_ sym, type = :a, &append
    access = public_method_defined?(sym) ? :public :
             protected_method_defined?(sym) ? :protected :
             private_method_defined?(sym) ? :private : :impossible
    origin_method = instance_method(sym)
    define_method sym, &append
    append_method = instance_method(sym)
    case type
    when :a; define_method sym do |*args, &block|
        origin_value = origin_method.bind(self).call *args, &block
        append_method.bind(self).call *args, &block
        origin_value
      end
    when :b; define_method sym do |*args, &block|
        append_method.bind(self).call *args, &block
        origin_method.bind(self).call *args, &block
      end
    when :c; define_method sym do |*args, &block|
        append_method.bind(self).call origin_method.bind(self), *args, &block
      end
    when :v; define_method sym do |*args, &block|
        origin_value = origin_method.bind(self).call *args, &block
        append_method.bind(self).call origin_value, *args, &block
      end
    when :if; define_method sym do |*args, &block|
        origin_method.bind(self).call *args, &block if
        append_method.bind(self).call *args, &block
      end
    when :unless; define_method sym do |*args, &block|
        origin_method.bind(self).call *args, &block unless
        append_method.bind(self).call *args, &block
      end
    when :ifold; define_method sym do |*args, &block|
        append_method.bind(self).call *args, &block if
        origin_method.bind(self).call *args, &block
      end
    when :unlessold; define_method sym do |*args, &block|
        append_method.bind(self).call *args, &block unless
        origin_method.bind(self).call *args, &block
      end
    else; define_method sym, origin_method
    end
    send access, sym
    return sym
  end
  
  # _api
  def _api code
    Win32API.new *code.split("|")
  end
  
  # __api
  def __api code, *args
    _api(code).call *args
  end
  
  # 混入Module模块类以便调用
  Module.send(:include, self)
end # Smomo::Mixin

#==============================================================================
# ** Graphics
#==============================================================================
class << Graphics
  _def_ :update do Smomo.update end
end

#==============================================================================
# ** Smomo!update
#==============================================================================
module Smomo
  module_function
  
  # update
  def update
    update_transition
  end
  
  # update_transition
  def update_transition
    ::Smomo::Kit.register[:transition].each &:update
  end
end # Smomo

else
  phone = $smomo["RGSS Version"] == :VA ? :msgbox : :p
  method(phone).call "你已经安装过了更高版本的Smomo脚本核心,不需要重复安装 : )"
end # if $smomo
#==============================================================================#
#=====                        =================================================#
            "脚 本 尾"
#=====                        =================================================#
#==============================================================================#
知道如何处理,脚本大触帮一下吧
搜狗截图20211017175852.png
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2021-10-17 18:33:16 | 显示全部楼层
回复 1 0

使用道具 举报

梦石
0
星屑
1554
在线时间
523 小时
注册时间
2015-8-23
回帖
83
 楼主| 发表于 2021-10-17 20:09:58 | 显示全部楼层
alexncf125 发表于 2021-10-17 18:33
用最新版试试?
https://github.com/ShadowMomo/Smomo-RGSS-Scripts/blob/master/Smomo%20Core.rb
https://g ...

非常感谢~完美解决了!爱你哟
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部