查看: 2532|回复: 1

[已经过期] 如何操作B-E型的图块ID

[复制链接]

百合控

梦石
0
星屑
6548
在线时间
1275 小时
注册时间
2013-8-21
回帖
3522

开拓者

发表于 2013-8-29 11:20:25 | 显示全部楼层 |阅读模式

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

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

×
还是被动跳跃脚本,只不过有小幅度修正
001.jpg 以下脚本允许从木桶 牌子 墓碑上跳过(从一边跳到另一边) 但是 也允许从树的左边跳跃到右边
但我不想允许从树上跳跃 于是在脚本中找到如下代码段
[pre lang="ruby" line="110"]    # 前第一格判断
    if tile_id_1[1]>1
      return false # 前一格的B~E层无法通行时也不能跳跃
    end[/pre]
然后尝试改成了这样(其实就是取消了这段判定)
[pre lang="ruby" line="110"]    # 前第一格判断
    #if tile_id_1[1]>1
    #  return false # 前一格的B~E层无法通行时也不能跳跃
    #end[/pre]
结果 确实不能再从树上跃过,可是也不能跳跃其他的地图元件
我想设定为允许跳跃特定的图块 或者禁止跳跃特定图块 可是不知道怎么做……
另外有几个帖子可以参考http://rpg.blue/thread-330027-1-1.html
http://rpg.blue/thread-325209-1-1.html

放脚本:
[pre lang="ruby" line="1"]#2013.8 影有小幅度修改
class Game_Map
  #--------------------------------------------------------------------------
  # ● 计算地图元件ID
  #--------------------------------------------------------------------------
  def get_tile_id(x, y)
    a = data[x, y, 0]
    return 0 unless a
    a-=2000
    map_tile_id_0 = (a >= 0) ? a/48 : (a+593)
    map_tile_id_1 = (data[x, y, 1]-2000) / 48
    map_tile_id_2 = (data[x, y, 2])
         
    map_tile_id_0 = 0 if map_tile_id_0 == -42 # A
    map_tile_id_1 = 0 if map_tile_id_1 == -42 # I
    map_tile_id_2 = 0 if map_tile_id_2 == -42 # B~E
   
    # 图块 ID 矫正
    map_tile_id_0 = map_tile_id_1 if map_tile_id_1 > 0
    unless @events.nil?
      for event in @events.values
        if event.pos?(x, y) and event.tile_id > 0
          # 若是事件使用地图元件,使用该地图元件的ID
          map_tile_id_2 = event.tile_id
        end
      end
    end
    # 返回 [底层ID, 上层ID]
    return [map_tile_id_0, map_tile_id_2]
  end
end
class Game_Character < Game_CharacterBase
  #--------------------------------------------------------------------------
  # ● 获取地图元件ID
  #--------------------------------------------------------------------------
  def get_map_tile_id(x, y)
    return $game_map.get_tile_id(x, y)
  end
  #--------------------------------------------------------------------------
  # ● 判断是否能跳跃
  #--------------------------------------------------------------------------
  def can_jump?
    # 面向与方向键不同时不跳跃
    return false if Input.dir4 != @direction
    return false if debug_through? # 测试行走(按下Ctrl)时不跳跃
   
    #判断是否步行,不是步行的时候不跳跃
    return false if @vehicle_type != :walk
   
    x_f1 = x_f2 = @x
    y_f1 = y_f2 = @y
   
    # 计算前两格座标
    case @direction
    when 2
      y_f2 += 2
      y_f1 += 1
    when 4
      x_f2 -= 2
      x_f1 -= 1
    when 6
      x_f2 += 2
      x_f1 += 1
    when 8
      y_f2 -= 2
      y_f1 -= 1
    end
   
    #落地判断
    return false if !(map_passable?(x_f2, y_f2, 2)|map_passable?(x_f2, y_f2, 4)|map_passable?(x_f2, y_f2, 6)|map_passable?(x_f2, y_f2, 8))
   
    tile_id_0 = get_map_tile_id(@x, @y)       # 获取当前格元件ID
    tile_id_1 = get_map_tile_id(x_f1, y_f1)   # 获取前一格元件ID
    tile_id_2 = get_map_tile_id(x_f2, y_f2)   # 获取前两格元件ID
    event_1 = $game_map.events_xy(x_f1, y_f1) # 获取前一格事件
    event_2 = $game_map.events_xy(x_f2, y_f2) # 获取前两格事件
   
    return false if $game_map.counter?(x_f1, y_f1) # 前一格为柜台时无法跳跃
    return false if !event_2.empty? # 前两格也有事件则不能跳跃
   
    # 判断面前一格是否墙壁元件
    # 获取墙壁元件ID
    wall_tile = (57..64).to_a + (73..80).to_a + (89..96).to_a + (105..112).to_a + (121..128).to_a + (241..243).to_a + (246..251).to_a + (254..256).to_a
    # 获取墙顶元件ID
    w_top_tile = (49..56).to_a + (65..72).to_a + (81..88).to_a + (97..104).to_a + (113..120).to_a + (217..240).to_a + (244..245).to_a + (252..253).to_a
   
    return false if wall_tile.include?(tile_id_2[0]) # 前两格为墙壁时无法跳跃
   
    if w_top_tile.include?(tile_id_0[0])
      if w_top_tile.include?(tile_id_2[0])
        return true if !event_1.empty?&&check_event_jumpable?(event_1)
        return true if !map_passable?(@x, @y, @direction)
        return true if !map_passable?(x_f1, y_f1, @direction)
        return true if !map_passable?(x_f1, y_f1, 8)&&@direction==2
      end
      return false
    end
  
   
    return false if w_top_tile.include?(tile_id_1[0])
    return false if wall_tile.include?(tile_id_1[0])
    return false if w_top_tile.include?(tile_id_2[0]) #前两格是墙顶不能跳
   
    if !event_1.empty? # 若前一格有事件
      return false if w_top_tile.include?(tile_id_1[0]) #事件在墙顶不能跳
      return false if !map_passable?(x_f1, y_f1, @direction)
      return check_event_jumpable?(event_1) # 判断是否指定可以跳跃
    end

    # 前第一格判断
    if tile_id_1[1]>1
      return false # 前一格的B~E层无法通行时也不能跳跃
    end
   
    # 判断面前两格是否相同
    return false if tile_id_1 == tile_id_2
    return false if tile_id_1 == tile_id_0
    return false if map_passable?(x_f1, y_f1, 4)
   
    return true
   
  end
  #--------------------------------------------------------------------------
  # ● 判断某格的事件是否能跳跃
  #--------------------------------------------------------------------------
  def check_event_jumpable?(events)
    events.each{|event|
      return true if event.can_jump?
    }
    return false
  end
  #--------------------------------------------------------------------------
  # ● 执行跳跃
  #--------------------------------------------------------------------------
  def do_jump(d=@direction)
    # 判断跳跃方向
    Audio.se_play("Audio/SE/"+"Jump1",80,100)
    case d
    when 2;  jump(0, 2)  # 向下跳
    when 4;  jump(-2, 0) # 向左跳
    when 6;  jump(2, 0)  # 向右跳
    when 8;  jump(0, -2) # 向上跳
    end
  end
end
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # ● 判断事件是否能跳跃
  #--------------------------------------------------------------------------
  def can_jump?
    return false if @list[0].code != 108 # 第一个指令不是“注释”时返回 false
    return @list[0].parameters[0] == "jump"
  end
end
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 输入移动处理
  #--------------------------------------------------------------------------
  alias old_move_by_input move_by_input
  def move_by_input
    # 不能行动时忽略所有动作
    return unless movable?
    # 解释器执行时忽略所有动作
    return if $game_map.interpreter.running?
    d = Input.dir4
    if can_jump?# 能够跳跃时
      if $game_player.followers.visible # 队伍跟随时
        $game_player.followers.gather   # 跟随队伍聚集
        while !$game_player.followers.gather?
          $game_player.followers.update # 跟随队伍刷新
        end
        # 跟随队员跳跃
        $game_player.followers.each{ |follower|
          follower.do_jump(d)
        }
      end
      do_jump(d) # 执行跳跃
    else
      old_move_by_input # 呼叫原有方法
    end
  end
end[/pre]

百合控

梦石
0
星屑
6548
在线时间
1275 小时
注册时间
2013-8-21
回帖
3522

开拓者

 楼主| 发表于 2013-8-29 11:25:28 | 显示全部楼层
另外@gaogs123456 ,这个脚本可以从悬崖上跳下——只要前面的图块是A5区域的就行
说实话,我记得好像有改动,但好像又真的没改什么,貌似只加了一个载具不允许跳跃@.@ 果然不擅长这个

点评

辛苦了!加油!  发表于 2013-8-30 00:39
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部