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

Project1

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

[RMVA发布] VA鼠标脚本 6/9 更新 v2.32 by Sion

  [复制链接]

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

跳转到指定楼层
1
 楼主| 发表于 2013-2-7 19:51:13 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 Sion 于 2015-6-3 22:31 编辑
更新日志



主要功能

    1,智能寻路,按住 D 键可以扩大寻路的范围
    2,变量输入框改良
    3,鼠标启动事件:
      在事件中加入“注释”:鼠标启动
      该事件将无法用其它方式启动,只能用鼠标左键点击启动
      
  鼠标指针图片 MouseCursor.png 放入 Graphics\System 文件夹
  路径点指示图片 $Arrow.png 放入 Graphics\Characters 文件夹
  如果未放入会使用RM自带图片代替缺失文件

改良的变量输入框


------- 下载 -------
鼠标2.32 + 指针变换脚本.rar (340.04 KB, 下载次数: 3963) 附件未包含 RGSS300.dll 运行前 Ctrl + S 保存即可。
https://rpg.blue/thread-347535-1-1.html 提供了 dll 支持的鼠标脚本 v3.00,支持鼠标滚轮功能。
------ 额外功能 ------
.rb 文件可以直接用记事本打开。
鼠标选择敌人v1.3.rb (4.27 KB, 下载次数: 1287)
鼠标选择敌人 v1.3 兼容后知后觉横版战斗.rb (4.33 KB, 下载次数: 948) 如果你没有使用这个横版战斗,请下载上面的脚本


八方移动补丁v1.3.rb (18.09 KB, 下载次数: 722)
需要使用八方行走图的话这里有:脚本链接

路径可视化补丁v1.1.rar (5.76 KB, 下载次数: 1173)
感觉蛮鸡肋,需要的话就带走吧。

评分

参与人数 18星屑 +2531 梦石 +1 +2 收起 理由
鸽牌万人迷 + 1 精品文章
MCCF + 1 精品文章
威风镰鼬 + 1 塞糖
llkrm + 20 极好的
哇哈哈哇哈哈 + 10 精品文章
yychchhh + 39 精品文章
冲啊小笼包 + 45 我很赞同
我在孤岛等你 + 12 精品文章
怪蜀黍 + 1970 + 1 评分明细见99楼!
我爱吴悦淇 + 30 突破404

查看全部评分

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

2
 楼主| 发表于 2013-2-7 22:24:19 | 显示全部楼层
429259591 发表于 2013-2-7 22:12
自动寻路的算法是怎么写的?没写过于是不知道是怎么样的←(喂,其实你是个脚本盲来的,说什么没写过啊,根 ...

从起点开始,逐步绘制所有可能的路径,直到覆盖到终点。然后反相移动回去得到路径。具体算法在脚本里780行左右。这个模型还算简单的,都是方格,上个图吧:
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

3
 楼主| 发表于 2013-2-17 13:47:25 | 显示全部楼层
q854240045 发表于 2013-2-17 12:33
再麻烦您一次,用脸图战斗无法用鼠标选择单个敌人应该怎么优化?
http://rpg.blue/home.php?mod=spa ...

脸图战斗.rar (4.02 KB, 下载次数: 281)

用默认的选择框吧。
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

4
 楼主| 发表于 2013-3-3 14:48:58 | 显示全部楼层
本帖最后由 Sion 于 2013-3-3 14:54 编辑
风与炎的旋律 发表于 2013-3-3 13:01
不好意思又来问问题了,想问下判定鼠标移动到了某选项或者物品上上的命令是怎么写的,我想整合一 ...


就参照默认的帮助窗口吧:Window_Help
  1.   #--------------------------------------------------------------------------
  2.   # ● 设置光标位置 (class Window_Selectable)
  3.   #--------------------------------------------------------------------------
  4.   def index=(index)
  5.     @index = index
  6.     update_cursor
  7.     call_update_help # 这是设置好索引之后用来更新帮助窗口的命令
  8.   end
复制代码
要让帮助窗口关闭,不太好弄吧。因为光标总是要停留在某一个物品上的,这个鼠标脚本只是根据鼠标的位置去设置光标的位置而已。你可以在鼠标脚本里搜索
  1. Window_Selectable
复制代码
里面有详细的说明的
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

5
 楼主| 发表于 2013-3-14 21:37:19 | 显示全部楼层
为RPG生 发表于 2013-3-14 21:16
首先说下,这真是个不错的脚本!
不过还是希望楼主能加入一个鼠标移动到选项会播放声效的效果——这个应该 ...
  1. class Window_Selectable
  2.   #--------------------------------------------------------------------------
  3.   # ● 将光标设置到鼠标所在的位置,附带卷动菜单的功能
  4.   #--------------------------------------------------------------------------
  5.   def set_cursor
  6.     mouse_row, mouse_col = mouse_window_area
  7.     if    mouse_row == -1
  8.       @move_state += 1 if need_scroll?
  9.       cursor_up if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  10.     elsif mouse_row == -2
  11.       @move_state += 1 if need_scroll?
  12.       cursor_down if (@move_state - 1) % 4 == 0 && !is_horzcommand?
  13.     elsif mouse_col == -1
  14.       @move_state += 1 if need_scroll?
  15.       cursor_left if (@move_state - 1) % 16 == 0 && is_horzcommand?
  16.     elsif mouse_col == -2
  17.       @move_state += 1 if need_scroll?
  18.       cursor_right if (@move_state - 1) % 16 == 0 && is_horzcommand?
  19.     else
  20.       @move_state = 0
  21.       new_index = (top_row + mouse_row) * col_max + mouse_col
  22.       if new_index < item_max && new_index != @index
  23.         Sound.play_cursor
  24.         select(new_index)
  25.       end
  26.     end
  27.   end
  28. end
复制代码
你可以自己试一试效果,放到鼠标脚本以下就行了;一些特殊的菜单还要另外改
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

6
 楼主| 发表于 2013-3-23 18:41:55 | 显示全部楼层
本帖最后由 Sion 于 2013-10-28 18:58 编辑
ayano2k 发表于 2013-3-20 16:34
感谢楼主的脚本,很好用~~
但是这个功能想知道该怎么设置??
  [[  1.3a: 代码小修改;


RUBY 代码复制
  1. =begin ========================================================================
  2.  
  3.   八方移动补丁 置于Sion_Mouse_System脚本下
  4.  
  5.   2013.10.28 v1.2 鼠标2.0+更新修正
  6.   2013.5.3 v1.1 修正斜向触发事件
  7.  
  8. =end #=========================================================================
  9.  
  10. class Game_Player
  11.   # ───────────────────────────────────────
  12.   #  † 八方移动
  13.   # ───────────────────────────────────────
  14.   def move_by_input
  15.     return if !movable? || $game_map.interpreter.running?
  16.     case Input.dir8
  17.     when 2,4,6,8; move_straight(Input.dir8)
  18.     when 1
  19.       if diagonal_passable?(x, y, 4, 2); move_diagonal(4, 2)
  20.       elsif passable?(x, y, 4); move_straight(4)
  21.       else; move_straight(2)
  22.       end
  23.     when 3
  24.       if diagonal_passable?(x, y, 6, 2); move_diagonal(6, 2)
  25.       elsif passable?(x, y, 6); move_straight(6)
  26.       else; move_straight(2)
  27.       end
  28.     when 7
  29.       if diagonal_passable?(x, y, 4, 8); move_diagonal(4, 8)
  30.       elsif passable?(x, y, 4); move_straight(4)
  31.       else; move_straight(8)
  32.       end
  33.     when 9
  34.       if diagonal_passable?(x, y, 6, 8); move_diagonal(6, 8)
  35.       elsif passable?(x, y, 6); move_straight(6)
  36.       else; move_straight(6)
  37.       end
  38.     else;   move_by_mouse
  39.     end
  40.   end
  41.   # ───────────────────────────────────────
  42.   #  † 鼠标八方移动
  43.   # ───────────────────────────────────────
  44.   def move_by_mouse
  45.     unless @mouse_move_path.empty? # 移动路线数组不为空则执行移动
  46.       dir = @mouse_move_path.shift
  47.       if passable?(x, y, dir) && !@mouse_move_path.empty?
  48.         if @mouse_move_path[0] == dir
  49.           move_straight(dir)
  50.         else
  51.           if @mouse_move_path.size == 1 &&
  52.               touch_event?(x, y, dir, @mouse_move_path[0])
  53.             move_straight(dir)
  54.           elsif dir == 4 || dir == 6
  55.             move_diagonal(dir, @mouse_move_path.shift)
  56.           else
  57.             move_diagonal(@mouse_move_path.shift, dir)
  58.           end
  59.         end
  60.       elsif @mouse_move_path.empty? # 判断是否是最后一步
  61.         x2 = $game_map.round_x_with_direction(x, dir)
  62.         y2 = $game_map.round_y_with_direction(y, dir)
  63.         move_straight(dir) unless dir.zero?
  64.         unless x == x2 && y == y2 # 如果移动失败,检查是否启动前方事件、上下载具
  65.           check_event_trigger_there([0,1,2])
  66.           get_on_off_vehicle unless $game_map.setup_starting_event
  67.         end
  68.         $mouse_move_sign.transparent = true if $mouse_move_sign.direction == 2
  69.         @mouse_dash = false
  70.       elsif @mouse_move_path[0].zero? # 目标点无法抵达,调整朝向→目标点
  71.         @mouse_move_path.shift
  72.         @direction = dir
  73.         @mouse_dash = false
  74.       else
  75.         draw_move_path
  76.       end
  77.     end
  78.   end
  79.   def touch_event?(x, y, dir, dir_)
  80.     x = $game_map.round_x_with_direction(
  81.       $game_map.round_x_with_direction(x, dir), dir_)
  82.     y = $game_map.round_y_with_direction(
  83.       $game_map.round_y_with_direction(y, dir), dir_)
  84.     if collide_with_events?(x, y)
  85.       return x, y
  86.     else
  87.       return nil, nil
  88.     end
  89.   end
  90.   # ───────────────────────────────────────
  91.   #  † 步行路径
  92.   # ───────────────────────────────────────
  93.   def draw_walk_path
  94.     # 准备绘制路径表格
  95.     sheet = Table.new($game_map.width, $game_map.height)
  96.     chase_path  = []
  97.     new_end_points = [@moveto_x, @moveto_y]
  98.     sheet[@moveto_x, @moveto_y] = 1
  99.     reach_point = false
  100.     step = 2
  101.     loop do #loop1 开始填充表格
  102.       draw_path = false
  103.       check_points = new_end_points
  104.       new_end_points = []
  105.       break if step > KsOfSion::Break_Steps &&
  106.                !Input.press?(KsOfSion::Find_Path_Key)
  107.       loop do #loop3 从终点开始反向填充
  108.         point_x = check_points.shift
  109.         break if point_x == nil
  110.         point_y = check_points.shift
  111.         # 判断路径是否连通
  112.         if point_x == x && point_y == y
  113.           reach_point = true; break; end
  114.         # 以需要抵达该点的步数填充路径表格 #
  115.         left_x  = $game_map.round_x(point_x - 1)
  116.         right_x = $game_map.round_x(point_x + 1)
  117.         up_y    = $game_map.round_y(point_y - 1)
  118.         down_y  = $game_map.round_y(point_y + 1)
  119.         if sheet[left_x, point_y] == 0              &&
  120.            $game_map.passable?(left_x, point_y, 6)  &&
  121.            !collide_with_events?(left_x, point_y)   &&
  122.            $game_map.passable?(point_x, point_y, 4) &&
  123.            !collide_with_vehicles?(left_x, point_y) #judge_end
  124.           sheet[left_x, point_y] = step
  125.           draw_path = true
  126.           new_end_points.push(left_x, point_y)
  127.         end
  128.         if sheet[right_x, point_y] == 0             &&
  129.            $game_map.passable?(right_x, point_y, 4) &&
  130.            !collide_with_events?(right_x, point_y)  &&
  131.            $game_map.passable?(point_x, point_y, 6) &&
  132.            !collide_with_vehicles?(right_x, point_y)#judge_end
  133.           sheet[right_x, point_y] = step
  134.           draw_path = true
  135.           new_end_points.push(right_x, point_y)
  136.         end
  137.         if sheet[point_x, up_y] == 0                &&
  138.            $game_map.passable?(point_x, up_y, 2)    &&
  139.            !collide_with_events?(point_x, up_y)     &&
  140.            $game_map.passable?(point_x, point_y, 8) &&
  141.            !collide_with_vehicles?(point_x, up_y)   #judge_end
  142.           sheet[point_x, up_y] = step
  143.           draw_path = true
  144.           new_end_points.push(point_x, up_y)
  145.         end
  146.         if sheet[point_x, down_y] == 0              &&
  147.            $game_map.passable?(point_x, down_y, 8)  &&
  148.            !collide_with_events?(point_x, down_y)   &&
  149.            $game_map.passable?(point_x, point_y, 2) &&
  150.            !collide_with_vehicles?(point_x, down_y) #judge_end
  151.           sheet[point_x, down_y] = step
  152.           draw_path = true
  153.           new_end_points.push(point_x, down_y)
  154.         end
  155.       end#endOfLoop3
  156.       break if !draw_path || reach_point
  157.       step += 1
  158.     end #endOfLoop1 路径表格填充完毕
  159.     $mouse_move_sign.transparent = false
  160.     # 判断指定地点能否抵达
  161.     if reach_point
  162.       $mouse_move_sign.direction = 2
  163.     else
  164.       return not_reach_point
  165.     end
  166.     # 根据路径表格绘制最短移动路径(正向)
  167.     step -= 1 # 因为需要再填充一次才能判定是否抵达
  168.     point_x, point_y = x, y
  169.     for i in 2..step
  170.     step -= 1
  171.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  172.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step          &&
  173.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  174.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  175.         chase_path.push(2)
  176.         point_y = $game_map.round_y(point_y + 1)
  177.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step          &&
  178.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  179.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  180.         chase_path.push(8)
  181.         point_y = $game_map.round_y(point_y - 1)
  182.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step          &&
  183.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  184.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  185.         chase_path.push(4)
  186.         point_x = $game_map.round_x(point_x - 1)
  187.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step          &&
  188.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  189.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  190.         chase_path.push(6)
  191.         point_x = $game_map.round_x(point_x + 1)
  192.       end
  193.     else
  194.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step          &&
  195.             $game_map.passable?($game_map.round_x(point_x - 1), point_y, 6) &&
  196.             $game_map.passable?(point_x, point_y, 4)                #judge_end
  197.         chase_path.push(4)
  198.         point_x = $game_map.round_x(point_x - 1)
  199.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step          &&
  200.             $game_map.passable?($game_map.round_x(point_x + 1), point_y, 4) &&
  201.             $game_map.passable?(point_x, point_y, 6)                #judge_end
  202.         chase_path.push(6)
  203.         point_x = $game_map.round_x(point_x + 1)
  204.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step          &&
  205.             $game_map.passable?(point_x, $game_map.round_y(point_y + 1), 8) &&
  206.             $game_map.passable?(point_x, point_y, 2)                #judge_end
  207.         chase_path.push(2)
  208.         point_y = $game_map.round_y(point_y + 1)
  209.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step          &&
  210.             $game_map.passable?(point_x, $game_map.round_y(point_y - 1), 2) &&
  211.             $game_map.passable?(point_x, point_y, 8)                #judge_end
  212.         chase_path.push(8)
  213.         point_y = $game_map.round_y(point_y - 1)
  214.       end
  215.     end
  216.     end#endOfForLoop
  217.     return chase_path
  218.   end#walk
  219.   # ───────────────────────────────────────
  220.   #  † boat路径
  221.   # ───────────────────────────────────────
  222.   def draw_boat_path
  223.     # 准备绘制路径表格
  224.     sheet = Table.new($game_map.width, $game_map.height)
  225.     chase_path  = []
  226.     new_end_points = [@moveto_x, @moveto_y]
  227.     sheet[@moveto_x, @moveto_y] = 1
  228.     reach_point = false
  229.     step = 2
  230.     loop do #loop1 开始填充表格
  231.       draw_path = false
  232.       check_points = new_end_points
  233.       new_end_points = []
  234.       break if step > KsOfSion::Break_Steps &&
  235.                !Input.press?(KsOfSion::Find_Path_Key)
  236.       loop do #loop3 从终点开始反向填充
  237.         point_x = check_points.shift
  238.         break if point_x == nil
  239.         point_y = check_points.shift
  240.         left_x  = $game_map.round_x(point_x - 1)
  241.         right_x = $game_map.round_x(point_x + 1)
  242.         up_y    = $game_map.round_y(point_y - 1)
  243.         down_y  = $game_map.round_y(point_y + 1)
  244.         # 判断路径是否连通
  245.         if left_x == x && point_y == y
  246.           reach_point = true; break
  247.         elsif right_x == x && point_y == y
  248.           reach_point = true; break
  249.         elsif point_x == x && up_y == y
  250.           reach_point = true; break
  251.         elsif point_x == x && down_y == y
  252.           reach_point = true; break
  253.         end
  254.         # 以需要抵达该点的步数填充路径表格 #
  255.         if sheet[left_x, point_y] == 0                &&
  256.            $game_map.boat_passable?(left_x, point_y)  &&
  257.            !collide_with_events?(left_x, point_y)     &&
  258.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  259.           sheet[left_x, point_y] = step
  260.           draw_path = true
  261.           new_end_points.push(left_x, point_y)
  262.         end
  263.         if sheet[right_x, point_y] == 0               &&
  264.            $game_map.boat_passable?(right_x, point_y) &&
  265.            !collide_with_events?(right_x, point_y)    &&
  266.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  267.           sheet[right_x, point_y] = step
  268.           draw_path = true
  269.           new_end_points.push(right_x, point_y)
  270.         end
  271.         if sheet[point_x, up_y] == 0                  &&
  272.            $game_map.boat_passable?(point_x, up_y)    &&
  273.            !collide_with_events?(point_x, up_y)       &&
  274.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  275.           sheet[point_x, up_y] = step
  276.           draw_path = true
  277.           new_end_points.push(point_x, up_y)
  278.         end
  279.         if sheet[point_x, down_y] == 0                &&
  280.            $game_map.boat_passable?(point_x, down_y)  &&
  281.            !collide_with_events?(point_x, down_y)     &&
  282.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  283.           sheet[point_x, down_y] = step
  284.           draw_path = true
  285.           new_end_points.push(point_x, down_y)
  286.         end
  287.       end#endOfLoop3
  288.       break if !draw_path || reach_point
  289.       step += 1
  290.     end #endOfLoop1 路径表格填充完毕
  291.     $mouse_move_sign.transparent = false
  292.     # 判断指定地点能否抵达
  293.     if reach_point
  294.       $mouse_move_sign.direction = 2
  295.     else
  296.       return not_reach_point
  297.     end
  298.     # 根据路径表格绘制最短移动路径(正向)
  299.     point_x, point_y = x, y
  300.     for i in 2..step # forLoop
  301.     step -= 1
  302.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  303.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
  304.         chase_path.push(2)
  305.         point_y = $game_map.round_y(point_y + 1)
  306.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  307.         chase_path.push(8)
  308.         point_y = $game_map.round_y(point_y - 1)
  309.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
  310.         chase_path.push(4)
  311.         point_x = $game_map.round_x(point_x - 1)
  312.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  313.         chase_path.push(6)
  314.         point_x = $game_map.round_x(point_x + 1)
  315.       end
  316.     else
  317.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
  318.         chase_path.push(4)
  319.         point_x = $game_map.round_x(point_x - 1)
  320.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  321.         chase_path.push(6)
  322.         point_x = $game_map.round_x(point_x + 1)
  323.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
  324.         chase_path.push(2)
  325.         point_y = $game_map.round_y(point_y + 1)
  326.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  327.         chase_path.push(8)
  328.         point_y = $game_map.round_y(point_y - 1)
  329.       end
  330.     end
  331.     end #endOfForLoop
  332.     # 如果指定点无法抵达或者登陆
  333.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  334.     return chase_path
  335.   end#boat
  336.   # ───────────────────────────────────────
  337.   #  † ship路径
  338.   # ───────────────────────────────────────
  339.   def draw_ship_path
  340.     # 准备绘制路径表格
  341.     sheet = Table.new($game_map.width, $game_map.height)
  342.     chase_path  = []
  343.     new_end_points = [@moveto_x, @moveto_y]
  344.     sheet[@moveto_x, @moveto_y] = 1
  345.     reach_point = false
  346.     step = 2
  347.     loop do #loop1 开始填充表格
  348.       draw_path = false
  349.       check_points = new_end_points
  350.       new_end_points = []
  351.       break if step > KsOfSion::Break_Steps &&
  352.                !Input.press?(KsOfSion::Find_Path_Key)
  353.       loop do #loop3 从终点开始反向填充
  354.         point_x = check_points.shift
  355.         break if point_x == nil
  356.         point_y = check_points.shift
  357.         left_x  = $game_map.round_x(point_x - 1)
  358.         right_x = $game_map.round_x(point_x + 1)
  359.         up_y    = $game_map.round_y(point_y - 1)
  360.         down_y  = $game_map.round_y(point_y + 1)
  361.         # 判断路径是否连通
  362.         if left_x == x && point_y == y
  363.           reach_point = true; break
  364.         elsif right_x == x && point_y == y
  365.           reach_point = true; break
  366.         elsif point_x == x && up_y == y
  367.           reach_point = true; break
  368.         elsif point_x == x && down_y == y
  369.           reach_point = true; break
  370.         end
  371.         # 以需要抵达该点的步数填充路径表格 #
  372.         if sheet[left_x, point_y] == 0                &&
  373.            $game_map.ship_passable?(left_x, point_y)  &&
  374.            !collide_with_events?(left_x, point_y)     &&
  375.            !collide_with_vehicles?(left_x, point_y)   #judge_end
  376.           sheet[left_x, point_y] = step
  377.           draw_path = true
  378.           new_end_points.push(left_x, point_y)
  379.         end
  380.         if sheet[right_x, point_y] == 0               &&
  381.            $game_map.ship_passable?(right_x, point_y) &&
  382.            !collide_with_events?(right_x, point_y)    &&
  383.            !collide_with_vehicles?(right_x, point_y)  #judge_end
  384.           sheet[right_x, point_y] = step
  385.           draw_path = true
  386.           new_end_points.push(right_x, point_y)
  387.         end
  388.         if sheet[point_x, up_y] == 0                  &&
  389.            $game_map.ship_passable?(point_x, up_y)    &&
  390.            !collide_with_events?(point_x, up_y)       &&
  391.            !collide_with_vehicles?(point_x, up_y)     #judge_end
  392.           sheet[point_x, up_y] = step
  393.           draw_path = true
  394.           new_end_points.push(point_x, up_y)
  395.         end
  396.         if sheet[point_x, down_y] == 0                &&
  397.            $game_map.ship_passable?(point_x, down_y)  &&
  398.            !collide_with_events?(point_x, down_y)     &&
  399.            !collide_with_vehicles?(point_x, down_y)   #judge_end
  400.           sheet[point_x, down_y] = step
  401.           draw_path = true
  402.           new_end_points.push(point_x, down_y)
  403.         end
  404.       end#endOfLoop3
  405.       break if !draw_path || reach_point
  406.       step += 1
  407.     end #endOfLoop1 路径表格填充完毕
  408.     $mouse_move_sign.transparent = false
  409.     # 判断指定地点能否抵达
  410.     if reach_point
  411.       $mouse_move_sign.direction = 2
  412.     else
  413.       not_reach_point
  414.       return
  415.     end
  416.     # 根据路径表格绘制最短移动路径(正向)
  417.     point_x, point_y = x, y
  418.     for i in 2..step
  419.     step -= 1
  420.     if (@moveto_x - point_x).abs < (@moveto_y - point_y).abs
  421.       if    sheet[point_x, $game_map.round_y(point_y + 1)] == step
  422.         chase_path.push(2)
  423.         point_y = $game_map.round_y(point_y + 1)
  424.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  425.         chase_path.push(8)
  426.         point_y = $game_map.round_y(point_y - 1)
  427.       elsif sheet[$game_map.round_x(point_x - 1), point_y] == step
  428.         chase_path.push(4)
  429.         point_x = $game_map.round_x(point_x - 1)
  430.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  431.         chase_path.push(6)
  432.         point_x = $game_map.round_x(point_x + 1)
  433.       end
  434.     else
  435.       if    sheet[$game_map.round_x(point_x - 1), point_y] == step
  436.         chase_path.push(4)
  437.         point_x = $game_map.round_x(point_x - 1)
  438.       elsif sheet[$game_map.round_x(point_x + 1), point_y] == step
  439.         chase_path.push(6)
  440.         point_x = $game_map.round_x(point_x + 1)
  441.       elsif sheet[point_x, $game_map.round_y(point_y + 1)] == step
  442.         chase_path.push(2)
  443.         point_y = $game_map.round_y(point_y + 1)
  444.       elsif sheet[point_x, $game_map.round_y(point_y - 1)] == step
  445.         chase_path.push(8)
  446.         point_y = $game_map.round_y(point_y - 1)
  447.       end
  448.     end
  449.     end #endOfForLoop
  450.     # 如果指定点无法抵达或者登陆
  451.     return not_reach_point unless landable?(@moveto_x, @moveto_y, chase_path)
  452.     return chase_path
  453.   end#ship
  454. end

评分

参与人数 1星屑 +45 收起 理由
黑舞嗜 + 45 赞美LZ

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

7
 楼主| 发表于 2013-4-21 14:17:00 | 显示全部楼层
本帖最后由 Sion 于 2013-4-21 15:09 编辑

@曉磊@米酒獭酱@muyumuyulnny

这是区域响应的代码,因为时间比较紧,所以没有把它弄成傻瓜式的,需要大家自己动手设置了。
要使用它的话,预先在事件中执行脚本
  1. area_response(type, ox, oy, width, height, switch_id)
复制代码
参数规范:
---------------------------------------------------------------------
其中type是区域响应类型
type = 0:鼠标移动到屏幕对应区域后开启对应的开关(只执行一次)
type = 1:鼠标在屏幕对应区域按下按键后,对应的开关开启(只执行一次)
type = 2:鼠标移动到屏幕对应区域时开关开启,移动到区域外时开关关闭,并行的处理。如果需要关闭响应,在事件脚本中执行代码
  1. $area_responses.delete_if {|rsp| rsp.type == 2 }# 关闭全部类型为2的响应
复制代码
ox,oy  为区域左上角坐标 width,height 为区域宽度 switch_id为操作的公共开关id

例子:鼠标移动到屏幕左上角32*32区域内,按下鼠标左键,启动开关3(只响应一次)
  1. area_response(1, 0, 0, 32, 32, 3)
复制代码
---------------------------------------------------------------------
type = 3:鼠标移动到地图坐标指定的事件上,则启动该区域上的事件(只执行一次)
type = 4;鼠标移动到地图坐标指定的事件上,则启动该事件(可以反复触发)如果需要关闭响应,在事件脚本中执行代码
  1. $area_responses.delete_if {|rsp| rsp.type == 4 } # 关闭全部类型为4的响应
复制代码
例子:鼠标移动到地图坐标(0, 5) 时,启动位于该格子的事件
  1. area_response(4, 0, 5) #启动事件只使用3个参数
复制代码
---------------------------------------------------------------------

以下代码放到鼠标脚本之下
  1. ####泥煤的height
  2. # [url=home.php?mod=space&uid=291977]@height[/url] = height

  3. class Area_Response
  4.   attr_accessor :type
  5.   attr_reader :ox
  6.   attr_reader :oy
  7.   attr_reader :width
  8.   attr_reader :height
  9.   attr_reader :switch_id
  10.   def initialize(type, ox, oy, width = 32, height = 32, switch_id = nil)
  11.     @type = type
  12.     @ox = ox
  13.     @oy = oy
  14.     @width = width
  15.     @height = height
  16.     @switch_id = switch_id
  17.   end
  18. end

  19. $area_responses = []

  20. class Scene_Map
  21.   alias update_mouse_2013421 update_mouse_action
  22.   def update_mouse_action
  23.     update_area_response
  24.     update_mouse_2013421
  25.   end
  26.   def update_area_response
  27.     responses = $area_responses
  28.     responses.each {|response|
  29.       ox = response.ox
  30.       oy = response.oy
  31.       width = response.width
  32.       height = response.height
  33.       switch_id = response.switch_id
  34.       case response.type
  35.       when 0
  36.         if mouse_in_area?(ox, oy, width, height)
  37.           $game_switches[switch_id] = true
  38.           $area_responses.delete(response)
  39.         end
  40.       when 1
  41.         if mouse_in_area?(ox, oy, width, height) && Mouse.trigger?(0x01)
  42.           $game_switches[switch_id] = true
  43.           $area_responses.delete(response)
  44.         end
  45.       when 2
  46.         if mouse_in_area?(ox, oy, width, height)
  47.           $game_switches[switch_id] = true
  48.         else
  49.           $game_switches[switch_id] = false
  50.         end
  51.       when 3
  52.         if mouse_in_area?((ox - $game_map.display_x) * 32 ,
  53.             (oy - $game_map.display_y) * 32, width, height)
  54.           $game_map.events_xy(ox, oy).each {|event|
  55.           event.start
  56.           $area_responses.delete(response)
  57.           return
  58.           }
  59.         end
  60.       when 4
  61.         if mouse_in_area?((ox - $game_map.display_x) * 32,
  62.             (oy - $game_map.display_y) * 32, width, height)
  63.           $game_map.events_xy(ox, oy).each {|event|
  64.             event.start
  65.             return
  66.           }
  67.         end
  68.       end
  69.     }
  70.   end
  71.   def mouse_in_area?(ox, oy, width, height)
  72.     Mouse.mouse_x >= ox && Mouse.mouse_x <= ox + width &&
  73.     Mouse.mouse_y >= oy && Mouse.mouse_y <= oy + height
  74.   end
  75. end
  76. class Game_Interpreter
  77.   def area_response(*arg)
  78.     $area_responses.push(Area_Response.new(*arg))
  79.   end
  80. end
复制代码

评分

参与人数 1星屑 +66 收起 理由
千葉玖濑 + 66 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

8
 楼主| 发表于 2013-4-30 14:58:02 | 显示全部楼层
本帖最后由 Sion 于 2013-4-30 16:37 编辑
黑舞嗜 发表于 2013-4-29 20:08
没法配合8方行走图的脚本啊...把def move_by_input 到下一个 end 还有它们之间的内容都删掉也不行啊 ...


八方行走图补丁,鼠标八方移动补丁见29楼
  1. #===============================================================================
  2. #  八方向行走
  3. #    by:铅笔描绘的思念
  4. #    在Characters里添加八方向行走图(命名规范:在四方向上的基础上+_8D)
  5. #    行走动画就为8方向的。否则就会原4方向的代替8方向的。
  6. #
  7. #    八方向:数字键盘方向对应的数字
  8. #     7   8   9
  9. #      ↖ ↑ ↗
  10. #     4← 0 →6
  11. #      ↙ ↓ ↘
  12. #     1   2   3
  13. #
  14. #  2013.4.30 Edited by me
  15. #   
  16. #    各种bug修正 + 各种效率优化
  17. #    8d行走图需用.png格式
  18. #
  19. #    这个脚本可以独立正常工作
  20. #    注意:同鼠标脚本配合使用,需要置于·八方移动补丁·上方!
  21. #
  22. #===============================================================================

  23. class Game_Player
  24.   def move_by_input
  25.     return if !movable? || $game_map.interpreter.running?
  26.     case Input.dir8
  27.     when 2,4,6,8; move_straight(Input.dir8)
  28.     when 1; move_diagonal(4, 2)
  29.     when 3; move_diagonal(6, 2)
  30.     when 7; move_diagonal(4, 8)
  31.     when 9; move_diagonal(6, 8)
  32.     end
  33.   end
  34. end

  35. class Game_CharacterBase

  36.   def move_diagonal(horz, vert)
  37.     @move_succeed = diagonal_passable?(x, y, horz, vert)
  38.     if @move_succeed
  39.       @x = $game_map.round_x_with_direction(@x, horz)
  40.       @y = $game_map.round_y_with_direction(@y, vert)
  41.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  42.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  43.       increase_steps
  44.     end
  45.     if horz == 4
  46.       vert == 2 ? set_direction(1) : set_direction(7)
  47.     else
  48.       vert == 2 ? set_direction(3) : set_direction(9)
  49.     end
  50.   end
  51. end

  52. class Sprite_Character < Sprite_Base

  53.   def set_character_bitmap
  54.     if File.exist?("Graphics/Characters/#{@character_name}_8D.png")
  55.       @_8d = true
  56.       bitmap1 = Cache.character(@character_name)
  57.       bitmap2 = Cache.character(@character_name + "_8D")
  58.       width = bitmap1.width
  59.       height = bitmap1.height
  60.       rect = Rect.new(0, 0, width, height)
  61.       self.bitmap = Bitmap.new(width * 2, height * 2)
  62.       self.bitmap.blt(0, 0, bitmap1, rect)
  63.       self.bitmap.blt(width, 0, bitmap2, rect)
  64.       sign = @character_name[/^[\!\$]./]
  65.       if sign && sign.include?("$")
  66.         @cw = width / 3
  67.         @ch = height / 4
  68.       else
  69.         @cw = width / 12
  70.         @ch = height / 8
  71.       end
  72.       self.ox = @cw / 2
  73.       self.oy = @ch
  74.     else
  75.       self.bitmap = Cache.character(@character_name)
  76.       sign = @character_name[/^[\!\$]./]
  77.       if sign && sign.include?("$")
  78.         @cw = bitmap.width / 3
  79.         @ch = bitmap.height / 4
  80.       else
  81.         @cw = bitmap.width / 12
  82.         @ch = bitmap.height / 8
  83.       end
  84.       self.ox = @cw / 2
  85.       self.oy = @ch
  86.     end
  87.   end

  88.   def update_src_rect
  89.     return if @tile_id != 0
  90.     index = @character.character_index
  91.     pattern = @character.pattern < 3 ? @character.pattern : 1
  92.     sx = (index % 4 * 3 + pattern) * @cw
  93.     if @character.direction % 2 == 1
  94.       sx += self.bitmap.width / 2 if @_8d
  95.       row = case @character.direction
  96.       when 1; 0
  97.       when 3; 2
  98.       when 7; 1
  99.       when 9; 3
  100.       end
  101.       sy = (index / 4 * 4 + row) * @ch
  102.     else
  103.       sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  104.     end
  105.     self.src_rect.set(sx, sy, @cw, @ch)
  106.   end
  107. end
复制代码

评分

参与人数 1星屑 +45 收起 理由
黑舞嗜 + 45 麻烦LZ了,LZ好人

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

9
 楼主| 发表于 2013-5-19 18:42:23 | 显示全部楼层
Mr.红茶 发表于 2013-5-18 18:11
鼠标脚本导致跳跃脚本出错了,阁下应如何解决
附上跳跃脚本:


改好了
使用时在事件内插入脚本jump_over 触发事件就会跳过去
  1. class Game_Map
  2. #--------------------------------------------------------------------------
  3. # ● 计算地图元件ID
  4. #--------------------------------------------------------------------------
  5. def get_tile_id(x, y)
  6. a = data[x, y, 0]
  7. return 0 unless a
  8. a-=2000
  9. map_tile_id_0 = (a >= 0) ? a/48 : (a+593)
  10. map_tile_id_1 = (data[x, y, 1]-2000) / 48
  11. map_tile_id_2 = (data[x, y, 2])

  12. map_tile_id_0 = 0 if map_tile_id_0 == -42 # A
  13. map_tile_id_1 = 0 if map_tile_id_1 == -42 # I
  14. map_tile_id_2 = 0 if map_tile_id_2 == -42 # B~E

  15. # 图块 ID 矫正
  16. map_tile_id_0 = map_tile_id_1 if map_tile_id_1 > 0
  17. unless @events.nil?
  18. for event in @events.values
  19. if event.pos?(x, y) and event.tile_id > 0
  20. # 若是事件使用地图元件,使用该地图元件的ID
  21. map_tile_id_2 = event.tile_id
  22. end
  23. end
  24. end
  25. # 返回 [底层ID, 上层ID]
  26. return [map_tile_id_0, map_tile_id_2]
  27. end
  28. end


  29. class Game_Character < Game_CharacterBase
  30. #--------------------------------------------------------------------------
  31. # ● 获取地图元件ID
  32. #--------------------------------------------------------------------------
  33. def get_map_tile_id(x, y)
  34. return $game_map.get_tile_id(x, y)
  35. end
  36. #--------------------------------------------------------------------------
  37. # ● 判断是否能跳跃
  38. #--------------------------------------------------------------------------
  39. def can_jump?
  40. # 面向与方向键不同时不跳跃
  41. return false if Input.dir4 != @direction
  42. return false if debug_through? # 测试行走(按下Ctrl)时不跳跃
  43. x_f1 = x_f2 = @x
  44. y_f1 = y_f2 = @y

  45. # 计算前两格座标
  46. case @direction
  47. when 2
  48. y_f2 += 2
  49. y_f1 += 1
  50. when 4
  51. x_f2 -= 2
  52. x_f1 -= 1
  53. when 6
  54. x_f2 += 2
  55. x_f1 += 1
  56. when 8
  57. y_f2 -= 2
  58. y_f1 -= 1
  59. end
  60. tile_id_0 = get_map_tile_id(@x, @y) # 获取当前格元件ID
  61. tile_id_1 = get_map_tile_id(x_f1, y_f1) # 获取前一格元件ID
  62. tile_id_2 = get_map_tile_id(x_f2, y_f2) # 获取前两格元件ID
  63. event_1 = $game_map.events_xy(x_f1, y_f1) # 获取前一格事件
  64. event_2 = $game_map.events_xy(x_f2, y_f2) # 获取前两格事件

  65. # 事件判断
  66. if !event_1.empty? # 若前一格有事件
  67. return false if !event_2.empty? # 前两格也有事件则不能跳跃
  68. return check_event_jumpable?(event_1) # 判断是否指定可以跳跃
  69. end

  70. # 前第一格判断
  71. if tile_id_1[1]>1
  72. return false # 前一格的B~E层无法通行时也不能跳跃
  73. elsif $game_map.counter?(x_f1, y_f1)
  74. return false # 前一格为柜台时无法跳跃
  75. end

  76. # 判断面前两格是否相同
  77. return false if tile_id_1 == tile_id_2
  78. return false if tile_id_1 == tile_id_0

  79. # 判断面前一格是否墙壁元件
  80. wall_tile = (89..96).to_a + (105..112).to_a + (121..128).to_a # 获取墙壁元件ID
  81. w_top_tile = (81..88).to_a + (97..104).to_a + (113..120).to_a # 获取墙顶元件ID
  82. return false if wall_tile.include?(tile_id_1[0]) # 前一格为墙壁时无法跳跃
  83. if w_top_tile.include?(tile_id_0[0]) # 若当前格为墙顶
  84. # 前一格非墙顶,而前两格为墙顶时则可以跳跃
  85. if !w_top_tile.include?(tile_id_1[0]) && w_top_tile.include?(tile_id_2[0])
  86. return true
  87. end
  88. end
  89. return false if map_passable?(x_f1, y_f1, @direction) # 前一格能通行时不跳跃
  90. return map_passable?(x_f2, y_f2, @direction) # 判断前两格是否能通行
  91. end
  92. #--------------------------------------------------------------------------
  93. # ● 判断某格的事件是否能跳跃
  94. #--------------------------------------------------------------------------
  95. def check_event_jumpable?(events)
  96. events.each{|event|
  97. return true if event.can_jump?
  98. }
  99. return false
  100. end
  101. #--------------------------------------------------------------------------
  102. # ● 执行跳跃
  103. #--------------------------------------------------------------------------
  104. def do_jump(d=@direction)
  105. # 判断跳跃方向
  106. case d
  107. when 2; jump(0, 2) # 向下跳
  108. when 4; jump(-2, 0) # 向左跳
  109. when 6; jump(2, 0) # 向右跳
  110. when 8; jump(0, -2) # 向上跳
  111. end
  112. end
  113. end


  114. class Game_Interpreter
  115.   def jump_over
  116.                 d = $game_player.direction
  117.                         if $game_player.followers.visible # 队伍跟随时
  118.                                 $game_player.followers.gather # 跟随队伍聚集
  119.                                 while !$game_player.followers.gather?
  120.                                         $game_player.followers.update # 跟随队伍刷新
  121.                                 end
  122.                                 # 跟随队员跳跃
  123.                                 $game_player.followers.each{|follower| follower.do_jump(d)}
  124.                         end
  125.                         $game_player.do_jump(d) # 执行跳跃
  126.         end
  127. end
复制代码
吐槽:这是哪个大神写的脚本啊.....都不带缩进的- -b
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

10
 楼主| 发表于 2013-11-23 22:05:47 | 显示全部楼层
夕仔 发表于 2013-11-18 20:37
发现了一个BUG,选择敌人的那个脚本,用 后知后觉的横版战斗系统,将敌人打死后,在下回合选择攻击时,一点 ...


那个BUG是早就修复了,主楼的脚本有更新。
你的传工程我今天才看到 - -b

点评

谢谢  发表于 2013-11-26 20:28
没看到呀...发给链接给我吧  发表于 2013-11-24 20:41
谢谢  发表于 2013-11-24 20:38
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-11 01:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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