设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1522|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
555
在线时间
1286 小时
注册时间
2011-6-14
帖子
4086
跳转到指定楼层
1
发表于 2012-8-1 13:14:12 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

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

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


这也没什么好截图的了。

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


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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-10-1 07:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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