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

Project1

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

[已经解决] 让事件不可穿透图块

[复制链接]

Lv1.梦旅人

梦石
0
星屑
68
在线时间
436 小时
注册时间
2010-7-19
帖子
414
跳转到指定楼层
1
发表于 2013-8-27 19:49:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 zhouzhuofan1 于 2013-8-27 19:53 编辑

事件的“选项”里有个“允许穿透”。。。
可以穿透“事件”、“角色”、“地图图块”。。。
如何改成只允许穿透“事件”、““角色”。。。

Lv4.逐梦者

梦石
7
星屑
1113
在线时间
334 小时
注册时间
2008-1-28
帖子
1566
2
发表于 2013-8-27 20:08:26 | 只看该作者
本帖最后由 未命名 于 2013-8-27 20:32 编辑

平常的话,我会让想要 被 穿透的事件打开穿透,然后对 想 穿透的事件编辑,碰到主角就穿透,离开恢复。

要不然我就在脚本的“Game_Character 1”里修改(前后打#的地方),
后果是所有事件都能相互穿透,地图无法穿透。具体的话自定义好了,删掉部分#就行。
  1. #==============================================================================
  2. # ■ Game_Character (分割定义 1)
  3. #------------------------------------------------------------------------------
  4. #  处理角色的类。本类作为 Game_Player 类与 Game_Event
  5. # 类的超级类使用。
  6. #==============================================================================

  7. class Game_Character
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :id                       # ID
  12.   attr_reader   :x                        # 地图 X 坐标 (理论坐标)
  13.   attr_reader   :y                        # 地图 Y 坐标 (理论坐标)
  14.   attr_reader   :real_x                   # 地图 X 坐标 (实际坐标 * 128)
  15.   attr_reader   :real_y                   # 地图 Y 坐标 (实际坐标 * 128)
  16.   attr_reader   :tile_id                  # 元件 ID  (0 为无效)
  17.   attr_reader   :character_name           # 角色 文件名
  18.   attr_reader   :character_hue            # 角色 色相
  19.   attr_reader   :opacity                  # 不透明度
  20.   attr_reader   :blend_type               # 合成方式
  21.   attr_reader   :direction                # 朝向
  22.   attr_reader   :pattern                  # 图案
  23.   attr_reader   :move_route_forcing       # 移动路线强制标志
  24.   attr_reader   :through                  # 穿透
  25.   attr_accessor :animation_id             # 动画 ID
  26.   attr_accessor :transparent              # 透明状态
  27.   #--------------------------------------------------------------------------
  28.   # ● 初始化对像
  29.   #--------------------------------------------------------------------------
  30.   def initialize
  31.     @id = 0
  32.     @x = 0
  33.     @y = 0
  34.     @real_x = 0
  35.     @real_y = 0
  36.     @tile_id = 0
  37.     @character_name = ""
  38.     @character_hue = 0
  39.     [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  40.     @blend_type = 0
  41.     @direction = 2
  42.     @pattern = 0
  43.     @move_route_forcing = false
  44.     @through = false
  45.     @animation_id = 0
  46.     @transparent = false
  47.     @original_direction = 2
  48.     @original_pattern = 0
  49.     @move_type = 0
  50.     @move_speed = 4
  51.     @move_frequency = 6
  52.     @move_route = nil
  53.     @move_route_index = 0
  54.     @original_move_route = nil
  55.     @original_move_route_index = 0
  56.     @walk_anime = true
  57.     @step_anime = false
  58.     @direction_fix = false
  59.     @always_on_top = false
  60.     @anime_count = 0
  61.     @stop_count = 0
  62.     @jump_count = 0
  63.     @jump_peak = 0
  64.     @wait_count = 0
  65.     @locked = false
  66.     @prelock_direction = 0
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 移动中判定
  70.   #--------------------------------------------------------------------------
  71.   def moving?
  72.     # 如果在移动中理论坐标与实际坐标不同
  73.     return (@real_x != @x * 128 or @real_y != @y * 128)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 跳跃中判定
  77.   #--------------------------------------------------------------------------
  78.   def jumping?
  79.     # 如果跳跃中跳跃点数比 0 大
  80.     return @jump_count > 0
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 矫正姿势
  84.   #--------------------------------------------------------------------------
  85.   def straighten
  86.     # 移动时动画以及停止动画为 ON 的情况下
  87.     if @walk_anime or @step_anime
  88.       # 设置图形为 0
  89.       @pattern = 0
  90.     end
  91.     # 清除动画计数
  92.     @anime_count = 0
  93.     # 清除被锁定的向前朝向
  94.     @prelock_direction = 0
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 强制移动路线
  98.   #     move_route : 新的移动路线
  99.   #--------------------------------------------------------------------------
  100.   def force_move_route(move_route)
  101.     # 保存原来的移动路线
  102.     if @original_move_route == nil
  103.       @original_move_route = @move_route
  104.       @original_move_route_index = @move_route_index
  105.     end
  106.     # 更改移动路线
  107.     @move_route = move_route
  108.     @move_route_index = 0
  109.     # 设置强制移动路线标志
  110.     @move_route_forcing = true
  111.     # 清除被锁定的向前朝向
  112.     @prelock_direction = 0
  113.     # 清除等待计数
  114.     @wait_count = 0
  115.     # 自定义移动
  116.     move_type_custom
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 可以通行判定
  120.   #     x : X 坐标
  121.   #     y : Y 坐标
  122.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  123.   #--------------------------------------------------------------------------
  124.   def passable?(x, y, d)
  125.     # 求得新的坐标
  126.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  127.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  128.     # 坐标在地图以外的情况
  129.     unless $game_map.valid?(new_x, new_y)
  130.       # 不能通行
  131.       return false
  132.     end
  133.     # 穿透是 ON 的情况下
  134.     if @through
  135.       # 可以通行
  136.       return true
  137.     end
  138.     # 移动者的元件无法来到指定方向的情况下
  139.     unless $game_map.passable?(x, y, d, self)
  140.       # 通行不可
  141.       return false
  142.     end
  143.     # 从指定方向不能进入到移动处的元件的情况下
  144.     unless $game_map.passable?(new_x, new_y, 10 - d)
  145.       # 不能通行
  146.       return false
  147.     end
  148.     # 循环全部事件
  149.     for event in $game_map.events.values
  150.       # 事件坐标于移动目标坐标一致的情况下
  151.       if event.x == new_x and event.y == new_y
  152.         # 穿透为 ON
  153.         unless event.through
  154.           # 自己就是事件的情况下
  155. #          if self != $game_player                                            #
  156.             # 不能通行
  157. #            return false                                                     #
  158. #          end                                                                #
  159.           # 自己是主角、对方的图形是角色的情况下
  160. #          if event.character_name != ""                                      #
  161.             # 不能通行
  162. #            return false                                                     #
  163. #          end                                                                #
  164.         end
  165.       end
  166.     end
  167.     # 主角的坐标与移动目标坐标一致的情况下
  168.     if $game_player.x == new_x and $game_player.y == new_y
  169.       # 穿透为 ON
  170.       unless $game_player.through
  171.         # 自己的图形是角色的情况下
  172. #        if @character_name != ""                                             #
  173.           # 不能通行
  174. #          return false                                                       #
  175. #        end                                                                  #
  176.       end
  177.     end
  178.     # 可以通行
  179.     return true
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 锁定
  183.   #--------------------------------------------------------------------------
  184.   def lock
  185.     # 如果已经被锁定的情况下
  186.     if @locked
  187.       # 过程结束
  188.       return
  189.     end
  190.     # 保存锁定前的朝向
  191.     @prelock_direction = @direction
  192.     # 保存主角的朝向
  193.     turn_toward_player
  194.     # 设置锁定中标志
  195.     @locked = true
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 锁定中判定
  199.   #--------------------------------------------------------------------------
  200.   def lock?
  201.     return @locked
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● 解除锁定
  205.   #--------------------------------------------------------------------------
  206.   def unlock
  207.     # 没有锁定的情况下
  208.     unless @locked
  209.       # 过程结束
  210.       return
  211.     end
  212.     # 清除锁定中标志
  213.     @locked = false
  214.     # 没有固定朝向的情况下
  215.     unless @direction_fix
  216.       # 如果保存了锁定前的方向
  217.       if @prelock_direction != 0
  218.         # 还原为锁定前的方向
  219.         @direction = @prelock_direction
  220.       end
  221.     end
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # ● 移动到指定位置
  225.   #     x : X 坐标
  226.   #     y : Y 坐标
  227.   #--------------------------------------------------------------------------
  228.   def moveto(x, y)
  229.     @x = x % $game_map.width
  230.     @y = y % $game_map.height
  231.     @real_x = @x * 128
  232.     @real_y = @y * 128
  233.     @prelock_direction = 0
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 获取画面 X 坐标
  237.   #--------------------------------------------------------------------------
  238.   def screen_x
  239.     # 通过实际坐标和地图的显示位置来求得画面坐标
  240.     return (@real_x - $game_map.display_x + 3) / 4 + 16
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 获取画面 Y 坐标
  244.   #--------------------------------------------------------------------------
  245.   def screen_y
  246.     # 通过实际坐标和地图的显示位置来求得画面坐标
  247.     y = (@real_y - $game_map.display_y + 3) / 4 + 32
  248.     # 取跳跃计数小的 Y 坐标
  249.     if @jump_count >= @jump_peak
  250.       n = @jump_count - @jump_peak
  251.     else
  252.       n = @jump_peak - @jump_count
  253.     end
  254.     return y - (@jump_peak * @jump_peak - n * n) / 2
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ● 获取画面 Z 坐标
  258.   #     height : 角色的高度
  259.   #--------------------------------------------------------------------------
  260.   def screen_z(height = 0)
  261.     # 在最前显示的标志为 ON 的情况下
  262.     if @always_on_top
  263.       # 无条件设置为 999
  264.       return 999
  265.     end
  266.     # 通过实际坐标和地图的显示位置来求得画面坐标
  267.     z = (@real_y - $game_map.display_y + 3) / 4 + 32
  268.     # 元件的情况下
  269.     if @tile_id > 0
  270.       # 元件的优先不足 * 32
  271.       return z + $game_map.priorities[@tile_id] * 32
  272.     # 角色的场合
  273.     else
  274.       # 如果高度超过 32 就判定为满足 31
  275.       return z + ((height > 32) ? 31 : 0)
  276.     end
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 取得茂密
  280.   #--------------------------------------------------------------------------
  281.   def bush_depth
  282.     # 是元件、并且在最前显示为 ON 的情况下
  283.     if @tile_id > 0 or @always_on_top
  284.       return 0
  285.     end
  286.     # 以跳跃中以外要是繁茂处属性的元件为 12,除此之外为 0
  287.     if @jump_count == 0 and $game_map.bush?(@x, @y)
  288.       return 12
  289.     else
  290.       return 0
  291.     end
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 取得地形标记
  295.   #--------------------------------------------------------------------------
  296.   def terrain_tag
  297.     return $game_map.terrain_tag(@x, @y)
  298.   end
  299. end
复制代码
我是不是有些啰唆?

点评

非常感谢。。。  发表于 2013-8-27 20:30

评分

参与人数 1星屑 +100 收起 理由
︶ㄣ牛排ぶ + 100 认可答案

查看全部评分

终于有可以放在这里的游戏了……
极短13 新生 《箱子新世界》
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 02:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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