查看: 1880|回复: 0

[RMVX发布] [渣型垃圾]事件脚本中变量/开关的简写

[复制链接]
梦石
0
星屑
660
在线时间
1286 小时
注册时间
2011-6-14
回帖
3949
发表于 2012-8-1 13:14:12 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 satgo1546 于 2012-8-2 18:29 编辑

首先,我选【VX发布】是因为我只在VX中测试过,别的不知道如何。
使用说明:脚本前面的注释!注释啊
啊对了,如有雷同,纯属凑巧!


这也没什么好截图的了。

要说明的是:
这样的调用都可以。
  1. p \v[1] # 数字形式
  2. p "\v[1]" # 字符串形式
复制代码
脚本:
  1. #==============================================================================
  2. # ■ 开关/变量在事件中简写
  3. #------------------------------------------------------------------------------
  4. # 超级无用脚本,仅仅是不想打字而已。
  5. # 使用方法:在可以输入脚本的地方输入\S[ID]表示ID号开关(true/false)
  6. #           输入\V[ID]表示ID号变量(数字)
  7. #==============================================================================

  8. # 移动路线里面的脚本

  9. class Game_Character
  10.   # 重定义 move_type_custom
  11.   alias mtc_swi move_type_custom
  12.   def move_type_custom
  13.     if @move_route.list[@move_route_index].code == 45 # 当执行内容是脚本时
  14.       command.parameters[0].gsub!(/\\s\[(\d+)\]/i) do
  15.         $game_switches[$1.to_i] ? "true" : "false"    # 替换开关
  16.       end
  17.       command.parameters[0].gsub!(/\\v\[(\d+)\]/i) do  # 替换变量
  18.         $game_variables[$1.to_i].to_s
  19.       end
  20.     end
  21.     mtc_swi # 刚刚加上去的,汗
  22.   end
  23. end

  24. # 事件中条件分歧的脚本和脚本
  25. # 偷懒了,条件分歧里的直接替换了……应该没什么脚本在里面
  26. class Game_Interpreter
  27.   def command_111
  28.     result = false
  29.     case @params[0]
  30.     when 0  # 开关
  31.       result = ($game_switches[@params[1]] == (@params[2] == 0))
  32.     when 1  # 变量
  33.       value1 = $game_variables[@params[1]]
  34.       if @params[2] == 0
  35.         value2 = @params[3]
  36.       else
  37.         value2 = $game_variables[@params[3]]
  38.       end
  39.       case @params[4]
  40.       when 0  # 数值 1 等于 数值 2
  41.         result = (value1 == value2)
  42.       when 1  # 数值 1 大于或等于 数值 2
  43.         result = (value1 >= value2)
  44.       when 2  # 数值 1 小于等于 数值 2
  45.         result = (value1 <= value2)
  46.       when 3  # 数值 1 大于 数值 2
  47.         result = (value1 > value2)
  48.       when 4  # 数值 1 小于 数值 2
  49.         result = (value1 < value2)
  50.       when 5  # 数值 1 不等于 数值 2
  51.         result = (value1 != value2)
  52.       end
  53.     when 2  # 独立开关
  54.       if @original_event_id > 0
  55.         key = [@map_id, @original_event_id, @params[1]]
  56.         if @params[2] == 0
  57.           result = ($game_self_switches[key] == true)
  58.         else
  59.           result = ($game_self_switches[key] != true)
  60.         end
  61.       end
  62.     when 3  # 计时器
  63.       if $game_system.timer_working
  64.         sec = $game_system.timer / Graphics.frame_rate
  65.         if @params[2] == 0
  66.           result = (sec >= @params[1])
  67.         else
  68.           result = (sec <= @params[1])
  69.         end
  70.       end
  71.     when 4  # 角色
  72.       actor = $game_actors[@params[1]]
  73.       if actor != nil
  74.         case @params[2]
  75.         when 0  # 角色在队伍中
  76.           result = ($game_party.members.include?(actor))
  77.         when 1  # 角色名称
  78.           result = (actor.name == @params[3])
  79.         when 2  # 角色已学会技能
  80.           result = (actor.skill_learn?($data_skills[@params[3]]))
  81.         when 3  # 角色已装备武器
  82.           result = (actor.weapons.include?($data_weapons[@params[3]]))
  83.         when 4  # 角色已装备武器
  84.           result = (actor.armors.include?($data_armors[@params[3]]))
  85.         when 5  # 状态
  86.           result = (actor.state?(@params[3]))
  87.         end
  88.       end
  89.     when 5  # 敌人
  90.       enemy = $game_troop.members[@params[1]]
  91.       if enemy != nil
  92.         case @params[2]
  93.         when 0  # 出现
  94.           result = (enemy.exist?)
  95.         when 1  # 状态为…
  96.           result = (enemy.state?(@params[3]))
  97.         end
  98.       end
  99.     when 6  # 角色
  100.       character = get_character(@params[1])
  101.       if character != nil
  102.         result = (character.direction == @params[2])
  103.       end
  104.     when 7  # 金钱
  105.       if @params[2] == 0
  106.         result = ($game_party.gold >= @params[1])
  107.       else
  108.         result = ($game_party.gold <= @params[1])
  109.       end
  110.     when 8  # 物品
  111.       result = $game_party.has_item?($data_items[@params[1]])
  112.     when 9  # 武器
  113.       result = $game_party.has_item?($data_weapons[@params[1]], @params[2])
  114.     when 10  # 防具
  115.       result = $game_party.has_item?($data_armors[@params[1]], @params[2])
  116.     when 11  # 按钮
  117.       result = Input.press?(@params[1])
  118.     when 12  # 脚本
  119.       #====================================================
  120.       @params[1].gsub!(/\\s\[(\d+)\]/i) do  # 替换开关
  121.         $game_switches[$1.to_i] ? "true" : "false"
  122.       end
  123.       @params[1].gsub!(/\\v\[(\d+)\]/i) do  # 替换变量
  124.         $game_variables[$1.to_i].to_s
  125.       end
  126.       #====================================================
  127.       result = eval(@params[1])
  128.     when 13  # 交通工具
  129.       result = ($game_player.vehicle_type == @params[1])
  130.     end
  131.     @branch[@indent] = result     # 判断结果保存在 hash 中
  132.     if @branch[@indent] == true
  133.       @branch.delete(@indent)
  134.       return true
  135.     end
  136.     return command_skip
  137.   end
  138.   
  139.   def command_355
  140.     script = @list[@index].parameters[0] + "\n"
  141.     loop do
  142.       if @list[@index+1].code == 655 # 下一个事件指令在脚本2行以上的情况下
  143.         script += @list[@index+1].parameters[0] + "\n"
  144.       else
  145.         break
  146.       end
  147.       @index += 1
  148.     end
  149.     script.gsub!(/\\s\[(\d+)\]/i) do  # 替换开关
  150.       $game_switches[$1.to_i] ? "true" : "false"
  151.     end
  152.     script.gsub!(/\\v\[(\d+)\]/i) do  # 替换变量
  153.       $game_variables[$1.to_i].to_s
  154.     end
  155.     eval(script)
  156.     return true
  157.   end
  158. end
复制代码


最后,发现貌似移动路线不行。改了一下~(其实我除了355code脚本测试过别的什么也没测试)
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部