查看: 1729|回复: 5

[已经解决] 关于神宝重力系统加个速度MAX

[复制链接]

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
发表于 2013-10-19 12:31:57 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 铃仙·优昙华院·因幡 于 2013-10-19 12:44 编辑

重力系统如何加一个速度上限,让下落的速度达到一个峰值……

  1. #=============================================================================
  2. #★RMVX重力系统★
  3. #-----------------------------------------------------------------------------
  4. #★作者: Zhong_zw
  5. #★联系方式: 66rpg.com论坛短信 或 [email]zhong8890@126.com[/email] 或 [email]zhong317@126.com[/email]
  6. #★游戏中引用本脚本,请保留以上信息,并作相关说明.
  7. #☆如若转载本脚本请联系本人☆
  8. #==============================================================================
  9. #==============================================================================
  10. # ★ Game_Character
  11. #------------------------------------------------------------------------------
  12. #  涉及角色的类。本类作为 Game_Player 类与 Game_Event 的超级类
  13. # 使用。
  14. #==============================================================================

  15. #==============================================================================
  16. #★参数设置
  17. #==============================================================================
  18. #跳跃初速度
  19. JUMP_SPEED = 100

  20. #重力加速度
  21. GRAVITATIONAL = 1

  22. #连跳次数
  23. JUME_SERIES = 2

  24. #连跳速度衰减
  25. JUMP_SERIES_WEAKEN = 10
  26. #跳跃键
  27. JUMP_KEY = Input::X #默认为键盘A键

  28. #弹跳时的行走图 (格式为:[名称,index])
  29. JUMP_CHARACTER = nil

  30. #弹跳时的声音 (注:声音文件放在SE文件夹下)
  31. JUMP_SE = "Jump1.ogg"

  32. #掉出屏幕时打开的开关(用于调用相关公共事件)
  33. DEAD_SWITCHES_ID = 105

  34. #各地图交通工具的摆放位置
  35. MAP_VEHICLE = {1 => [[2,1],[3,1],[4,1],[5,1],[8,2],[6,2],[7,2,1]],
  36.                5 => [[2,1],[3,1],[4,1],[5,1],[6,2],[7,2]]
  37. }


  38. #各地图可以飞的事件
  39. MAP_FLY_EVENT = {1=>[10]}

  40. #默认地图模式 0为正常模式 1为重力模式
  41. DEFAULT_MAP_MODE = 0


  42. #==============================================================================

  43. class Game_Character
  44.   #--------------------------------------------------------------------------
  45.   # ● 定义实例变量
  46.   #--------------------------------------------------------------------------
  47.   attr_reader   :id                       # ID
  48.   #===============================================================
  49.   attr_accessor :x                        # 地图 X 坐标 (理论坐标)
  50.   attr_accessor :y                        # 地图 Y 坐标 (理论坐标)
  51.   attr_accessor :real_x                   # 地图 X 坐标 (实际坐标 * 256)
  52.   attr_accessor :real_y                   # 地图 Y 坐标 (实际坐标 * 256)
  53.   attr_accessor :move_speed               #角色移动速度
  54.   attr_accessor :jump_series              #连跳次数
  55.   attr_accessor :gravitational            #重力加速度
  56.   attr_accessor :vertical_speed           #垂直速度
  57.   attr_accessor :can_fly                  #飞行开关  
  58.   attr_accessor :jump_speed               #跳跃初速度
  59.   attr_accessor :on_ladder                #是否在梯子上
  60.   attr_accessor :map_vehicle              #地图交通工具 0 无 1 为梯子 2 为踏板
  61.   attr_accessor :pedal_type               #踏板类型
  62.   attr_accessor :on_pedal                 #是否在踏板
  63.   attr_accessor :jump_character           #弹跳时的行走图
  64.   #=====================================================
  65.   #==========================================================================
  66.   # ★ 初始化对象
  67.   #==========================================================================
  68.   def initialize
  69.     @id = 0
  70.     @x = 0
  71.     @y = 0
  72.     @real_x = 0
  73.     @real_y = 0
  74.     @tile_id = 0
  75.     @character_name = ""
  76.     @character_index = 0
  77.     [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  78.     @blend_type = 0
  79.     @direction = 2
  80.     @pattern = 1
  81.     @move_route_forcing = false
  82.     @priority_type = 1
  83.     @through = false
  84.     @bush_depth = 0
  85.     @animation_id = 0
  86.     @balloon_id = 0
  87.     @transparent = false
  88.     @original_direction = 2               # 原朝向
  89.     @original_pattern = 1                 # 原图案
  90.     @move_type = 0                        # 移动类型
  91.     @move_speed = 4                       # 移动速度
  92.     @move_frequency = 6                   # 移动频度
  93.     @move_route = nil                     # 移动路径
  94.     @move_route_index = 0                 # 移动路径执行位置
  95.     @original_move_route = nil            # 原移动路径
  96.     @original_move_route_index = 0        # 原移动路径执行位置
  97.     @walk_anime = true                    # 步行动画
  98.     @step_anime = false                   # 踏步动画
  99.     @direction_fix = false                # 朝向固定
  100.     @anime_count = 0                      # 动画计数
  101.     @stop_count = 0                       # 停止计数
  102.     @jump_count = 0                       # 跳跃计数
  103.     @jump_peak = 0                        # 跳跃顶点计数
  104.     @wait_count = 0                       # 等待计数
  105.     @locked = false                       # 锁定标志
  106.     @prelock_direction = 0                # 锁定前的朝向
  107.     @move_failed = false                  # 移动失败标志
  108.    
  109.    
  110.    
  111.     #===========================================================
  112.     @jump_speed = JUMP_SPEED  #跳跃速度
  113.    
  114.     #@jump_height = JUMP_HEIGHT
  115.    
  116.     @jump_series = 0                #连跳次数累计
  117.    
  118.     @jump_max_series = JUME_SERIES  #最大连跳次数
  119.    
  120.     @can_fly = false
  121.    
  122.    
  123.    
  124.    
  125.     #计算重力加速度
  126.     [url=home.php?mod=space&uid=282336]@gravitational[/url] = GRAVITATIONAL
  127.    
  128.     #垂直速度为0
  129.     @vertical_speed  = 0
  130.    
  131.     #初始速度
  132.     @init_Vspeed = 0
  133.    
  134.     #着陆
  135.     @is_land = true
  136.    
  137.     #不需要继续下落的开关
  138.     @no_need_fall = false
  139.    
  140.    
  141.     #是否可以坠入悬崖
  142.     @can_falldown_screen = true
  143.    
  144.     #交通工具性质
  145.     @map_vehicle = 0            #地图交通工具 0 无  1为梯子 2 为踏板
  146.    
  147.    
  148.     #是否在梯子上
  149.     @on_ladder = false
  150.    
  151.     #踏板类型
  152.     @pedal_type = 0              # 0 为推进型踏板 1 为即落型踏板
  153.    
  154.     #是否在踏板
  155.     @on_pedal = false
  156.    
  157.     #弹跳时的行走图
  158.     @jump_character = nil
  159.    
  160.     #跳前行走图
  161.     @last_character = nil
  162.    
  163.     #乘客(踏板的情况下)
  164.     @passengers = nil

  165.     #===========================================================
  166.    
  167.   end
  168.   
  169.   #==========================================================================
  170.   #★ 设置跳跃初速度
  171.   #==========================================================================
  172.   def set_jump_speed(speed)
  173.      @jump_speed = speed
  174.   end #def
  175.   
  176.   #==========================================================================
  177.   
  178.   #--------------------------------------------------------------------------
  179.   # ★ 判断是否在跳跃
  180.   #--------------------------------------------------------------------------
  181.   def jumping?
  182.     if $game_map.scene_mode == 0
  183.       return @jump_count > 0
  184.     else
  185.       return false  #废弃跳跃判定.主判定已放进update_falling里
  186.     end #if  
  187.   end

  188.   #==========================================================================
  189.   # ★ 判断角色冲突
  190.   #     x : X 坐标
  191.   #     y : Y 坐标
  192.   #    包含玩家和交通工具、检测普通角色的冲突。
  193.   #==========================================================================
  194.   def collide_with_characters?(x, y)
  195.     for event in $game_map.events_xy(x, y)          # 与事件坐标一致
  196.       if($game_map.scene_mode == 1 && event.map_vehicle == 1)
  197.         return false
  198.       end  
  199.       unless event.through                          # 穿越 OFF?
  200.         return true if self.is_a?(Game_Event)       # 自己是事件
  201.         return true if event.priority_type == 1     # 对方是普通角色
  202.       end
  203.       
  204.     end
  205.     if @priority_type == 1                          # 自己是普通角色
  206.       return true if $game_player.pos_nt?(x, y)     # 与玩家的坐标一致
  207.       return true if $game_map.boat.pos_nt?(x, y)   # 与小型船坐标一致
  208.       return true if $game_map.ship.pos_nt?(x, y)   # 与大型船坐标一致
  209.     end
  210.     return false
  211.   end
  212.   #==========================================================================
  213.   # ★ 获取画面 Y 坐标
  214.   #==========================================================================
  215.   def screen_y
  216.     y = ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  217.     #================================================
  218.     y -= 4 unless object? || $game_map.scene_mode == 1
  219.     #================================================
  220.     if $game_map.scene_mode == 0
  221.      if @jump_count >= @jump_peak
  222.        n = @jump_count - @jump_peak
  223.      else
  224.        n = @jump_peak - @jump_count
  225.      end
  226.      return y - (@jump_peak * @jump_peak - n * n) / 2
  227.    else
  228.      return y
  229.    end #if  
  230.   end
  231.   #==========================================================================
  232.   # ★ 刷新画面
  233.   #==========================================================================
  234.   def update
  235.    
  236.     if $game_map.scene_mode == 1
  237.      if falling?
  238.        update_falling
  239.      else
  240.       
  241.       #如果本身是踏板的话检查上面有没乘客
  242.       check_passenger
  243.       
  244.       if @real_y < @y*256 && !@on_ladder && !@can_fly && !on_pedal
  245.         free_fall
  246.         #update_horizontal_fly
  247.       else
  248.         if !@on_ladder && !@can_fly && !@on_pedal  #不在梯子上
  249.          @real_y = @y*256  #修正
  250.         end
  251.         @vertical_speed = 0
  252.         @init_Vspeed = 0
  253.         @jump_count = 0
  254.         if moving?
  255.           update_move
  256.         else                        # 正在停止
  257.           update_stop
  258.         end
  259.         if @wait_count > 0          # 正在等待
  260.           @wait_count -= 1
  261.         elsif @move_route_forcing   # 强制移动路径
  262.           move_type_custom
  263.         elsif not @locked           # 被锁定以外
  264.           update_self_movement
  265.          end
  266.          update_animation
  267.       
  268.        end
  269.       
  270.      end
  271.       
  272.     else
  273.      if jumping?                 # 正在跳跃
  274.       update_jump
  275.      elsif moving?               # 正在移动
  276.       update_move
  277.      else                        # 正在停止
  278.       update_stop
  279.      end
  280.      if @wait_count > 0          # 正在等待
  281.       @wait_count -= 1
  282.      elsif @move_route_forcing   # 强制移动路径
  283.       move_type_custom
  284.      elsif not @locked           # 被锁定以外
  285.       update_self_movement
  286.      end
  287.      update_animation
  288.     end #if
  289.   end
  290.   #==========================================================================
  291.   #★判断是否会下落
  292.   #==========================================================================
  293.   def falling?
  294.    
  295.     if @jump_series > 0 && !@on_ladder && @jump_character != nil
  296.       if @last_character == nil || @character_name != @jump_character[0]
  297.         @last_character = [@character_name,@character_index]
  298.       end  
  299.       set_graphic(@jump_character[0],@jump_character[1])
  300.     elsif @last_character != nil  && @last_character[0] != @character_name
  301.      set_graphic(@last_character[0],@last_character[1])
  302.     end
  303.    
  304.      if @can_fly  || @no_need_fall || @map_vehicle >= 1
  305.        return false
  306.      end
  307.      
  308.      have_ladder = false
  309.      for event in $game_map.events_xy(@x, @y)          # 与事件坐标一致
  310.        if event.map_vehicle == 1
  311.          have_ladder = true
  312.          @on_ladder = true
  313.          @is_land = true
  314.         end  
  315.      end
  316.      
  317.      if !have_ladder  
  318.        @on_ladder = false if @on_ladder
  319.      else
  320.        return false
  321.      end  
  322.       
  323.      
  324.      
  325.      dir =  @vertical_speed >= 0  ? 1 : -1
  326.      if @jump_count < 0 && @init_Vspeed < 0
  327.        dir = -1
  328.      end  
  329.      
  330.      x = @x
  331.      
  332.      if @x*256-@real_x > 0 #向右
  333.       x = (@real_x*1.0/256).floor
  334.      elsif @x*256-@real_x < 0
  335.       x = (@real_x*1.0/256).ceil
  336.      end
  337.      
  338.      result = passable?(x, @y+dir) && passable?(@x, @y+dir)
  339.      
  340.      if ((@y+dir) >= $game_map.height || @real_y/256 > $game_map.height) && @can_falldown_screen
  341.         @y = ($game_map.height+1)
  342.         @no_need_fall = true
  343.         if self.is_a?(Game_Player)
  344.           $game_switches[DEAD_SWITCHES_ID] = true
  345.         end #
  346.         
  347.      elsif (@y+dir) <= 0
  348.         result = true   
  349.      end  
  350.      

  351.       
  352.      if @on_pedal&&result
  353.        @on_pedal = false
  354.      end
  355.      
  356.      last_state = @is_land
  357.      @is_land = !result && dir == 1
  358.      
  359.       #判断上顶或着陆事件
  360.      if !result  && (self.is_a?(Game_Player) || self.is_a?(Game_Event))
  361.        dir = -1 if @vertical_speed < 0
  362.        check_event_trigger_touch(@x,@y+dir)
  363.      end
  364.      
  365.      
  366.      
  367.      return result
  368.    
  369.   end  
  370.   
  371.   #==========================================================================
  372.   #★ 下落的更新
  373.   #==========================================================================
  374.   def update_falling
  375.      last_y = @real_y
  376.      y = (last_y/256).ceil
  377.      free_fall
  378.      dir =  @vertical_speed >= 0 ? 1 : -1
  379.      d =  (dir*@vertical_speed*1.00/256).ceil.abs
  380.      lst_i = 0
  381.       
  382.    
  383.      for i in 0..d
  384.       
  385.        if !passable?(@x, y+i*dir)
  386.          
  387.          break
  388.       
  389.        end #if
  390.       
  391.        lst_i = i
  392.       
  393.      end #for
  394.      
  395.      if  i > 0
  396.       @y = y+lst_i*dir
  397.       if !passable?(@x, @y+dir) && @y +dir > 0
  398.         @real_y = @y*256
  399.         #@vertical_speed = 0
  400.         @init_Vspeed = 0
  401.         @jump_count = 0
  402.       end
  403.      end

  404.      
  405.      update_horizontal_fly
  406.      

  407.   end
  408.   #==========================================================================
  409.   #★自由落体运动
  410.   #==========================================================================
  411.   def free_fall
  412.     @jump_count += 1
  413.     @vertical_speed = @init_Vspeed + @gravitational*@jump_count
  414.     @real_y = @real_y + @vertical_speed
  415.   end
  416.   
  417.   #=========================================================================
  418.   #★空中横向移动
  419.   #=========================================================================
  420.   def update_horizontal_fly
  421.     distance = 2 ** @move_speed*2   # 变换移动速度与移动距离
  422.     distance += 5 if dash?        # 跑步状态时移动速度加倍
  423.    
  424.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  425.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  426.   end
  427.   #=========================================================================
  428.   #★ 检查乘客(踏板专用)
  429.   #=========================================================================
  430.   def check_passenger
  431.       return if @map_vehicle != 2 || $game_map.scene_mode != 1
  432.       if @passengers == nil
  433.         @passengers = []
  434.       end  
  435.       if @passengers.size > 0
  436.         @passengers.clear
  437.       end
  438.       for event in $game_map.events_xy(@x, @y-1)
  439.         if  @pedal_type == 1 #即落型
  440.           @map_vehicle = 0    #设为普通角色(重力下自动掉落)
  441.           return
  442.         else
  443.            @passengers.push(event)
  444.         end  
  445.       end   
  446.       if $game_player.x == @x && $game_player.y == @y-1
  447.         if  @pedal_type == 1 #即落型
  448.           @map_vehicle = 0    #设为普通角色(重力下自动掉落)
  449.           return
  450.         else
  451.            @passengers.push($game_player)
  452.         end  
  453.         
  454.       end  
  455.      
  456.   end
  457.   #==========================================================================
  458.   #--------------------------------------------------------------------------
  459.   # ★ 跳跃时的更新
  460.   #--------------------------------------------------------------------------
  461.   def update_jump
  462.    
  463.     if $game_map.scene_mode == 0
  464.       @jump_count -= 1
  465.       @real_x = (@real_x * @jump_count + @x * 256) / (@jump_count + 1)
  466.       @real_y = (@real_y * @jump_count + @y * 256) / (@jump_count + 1)
  467.       update_bush_depth
  468.      end #if
  469.   end

  470.    
  471.   #--------------------------------------------------------------------------
  472.   # ★ 向下移动
  473.   #     turn_ok : 此地可以更改朝向
  474.   #--------------------------------------------------------------------------
  475.   def move_down(turn_ok = true)
  476.                  
  477.       if $game_map.scene_mode == 1
  478.         @on_ladder =true
  479.       end
  480.       
  481.       if passable?(@x, @y+1)                               # 可以通过
  482.        if $game_map.scene_mode == 0                        #正常模式下
  483.          turn_down
  484.        elsif $game_map.scene_mode == 1                     #重力模式
  485.          turn_up if !@can_fly                              #设置爬梯时的朝向
  486.          #是否踏板,是否有乘客
  487.          if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  488.             for event in @passengers
  489.                event.y = @y
  490.                event.on_pedal = true
  491.             end  
  492.          end  
  493.        end  
  494.         @y = $game_map.round_y(@y+1)
  495.         @real_y = (@y-1)*256
  496.         increase_steps
  497.         @move_failed = false
  498.       
  499.       else                                     # 不可以通过
  500.         turn_down if turn_ok
  501.         check_event_trigger_touch(@x, @y+1)    # 判断接触的事件启动
  502.         @move_failed = true
  503.       end
  504.       
  505.     #end #if
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ★ 向左移动
  509.   #     turn_ok : 此地可以更改朝向
  510.   #--------------------------------------------------------------------------
  511.   def move_left(turn_ok = true)
  512.     if passable?(@x-1, @y)                  # 可以通过
  513.       turn_left
  514.       if $game_map.scene_mode == 1
  515.         if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  516.             for event in @passengers
  517.                event.x = $game_map.round_x(@x-1)
  518.                event.on_pedal = true
  519.             end  
  520.         end
  521.       end  
  522.       @x = $game_map.round_x(@x-1)
  523.       @real_x = (@x+1)*256
  524.       increase_steps
  525.       @move_failed = false
  526.     else                                    # 不可以通过
  527.       turn_left if turn_ok
  528.       check_event_trigger_touch(@x-1, @y)   # 判断接触的事件启动
  529.       @move_failed = true
  530.     end
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ★ 向右移动
  534.   #     turn_ok : 此地可以更改朝向
  535.   #--------------------------------------------------------------------------
  536.   def move_right(turn_ok = true)
  537.     if passable?(@x+1, @y)                  # 可以通过
  538.       turn_right
  539.       if $game_map.scene_mode == 1
  540.         if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  541.             for event in @passengers
  542.                event.x = $game_map.round_x(@x+1)
  543.                event.on_pedal = true
  544.             end #for

  545.         end
  546.       end  
  547.       @x = $game_map.round_x(@x+1)
  548.       @real_x = (@x-1)*256
  549.       increase_steps
  550.       @move_failed = false
  551.     else                                    # 不可以通过
  552.       turn_right if turn_ok
  553.       check_event_trigger_touch(@x+1, @y)   # 判断接触的事件启动
  554.       @move_failed = true
  555.     end
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ★ 向上移动
  559.   #     turn_ok : 此地可以更改朝向
  560.   #--------------------------------------------------------------------------
  561.   def move_up(turn_ok = true)
  562.    if $game_map.scene_mode == 0 || ($game_map.scene_mode == 1 && (@on_ladder || @can_fly || @map_vehicle == 2))
  563.      pedal_passable = false
  564.      if @map_vehicle == 2 && $game_map.scene_mode == 1 && @passengers != nil && @passengers.size > 0
  565.            for event in @passengers
  566.              if (event.passable?(@x,@y-2))
  567.                pedal_passable = true
  568.                event.y = $game_map.round_y(@y-2)
  569.                event.on_pedal = true
  570.              end #if  
  571.            end#for  
  572.      end     
  573.      if passable?(@x, @y-1) || pedal_passable      # 可以通过
  574.        turn_up
  575.        @y = $game_map.round_y(@y-1)
  576.        @real_y = (@y+1)*256
  577.        increase_steps
  578.        @move_failed = false
  579.      else                                    # 不可以通过
  580.        turn_up if turn_ok
  581.        check_event_trigger_touch(@x, @y-1)   # 判断接触的事件启动
  582.        @move_failed = true
  583.      end
  584.       
  585.    end #if
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # ★ 向左下移动(为了不引起不必要的bug,把重力模式暂时没用到的屏蔽了)
  589.   #--------------------------------------------------------------------------
  590.   def move_lower_left
  591.    if $game_map.scene_mode == 0  
  592.     unless @direction_fix
  593.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  594.     end
  595.     if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
  596.        (passable?(@x-1, @y) and passable?(@x-1, @y+1))
  597.       @x -= 1
  598.       @y += 1
  599.       increase_steps
  600.       @move_failed = false
  601.     else
  602.       @move_failed = true
  603.     end
  604.    end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ★ 向右下移动
  608.   #--------------------------------------------------------------------------
  609.   def move_lower_right
  610.     if $game_map.scene_mode == 0
  611.      unless @direction_fix
  612.        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  613.      end
  614.      if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
  615.         (passable?(@x+1, @y) and passable?(@x+1, @y+1))
  616.        @x += 1
  617.        @y += 1
  618.        increase_steps
  619.        @move_failed = false
  620.      else
  621.        @move_failed = true
  622.      end
  623.     end #if  
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ★ 向左上移动
  627.   #--------------------------------------------------------------------------
  628.   def move_upper_left
  629.     if $game_map.scene_mode == 0
  630.      unless @direction_fix
  631.        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  632.      end
  633.      if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
  634.         (passable?(@x-1, @y) and passable?(@x-1, @y-1))
  635.        @x -= 1
  636.        @y -= 1
  637.        increase_steps
  638.        @move_failed = false
  639.      else
  640.        @move_failed = true
  641.      end
  642.     end #if  
  643.   end
  644.   #--------------------------------------------------------------------------
  645.   # ★ 向右上移动
  646.   #--------------------------------------------------------------------------
  647.   def move_upper_right
  648.     if $game_map.scene_mode == 0
  649.      unless @direction_fix
  650.        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  651.      end
  652.      if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
  653.         (passable?(@x+1, @y) and passable?(@x+1, @y-1))
  654.        @x += 1
  655.        @y -= 1
  656.        increase_steps
  657.        @move_failed = false
  658.      else
  659.        @move_failed = true
  660.      end
  661.     end #if
  662.   end
  663.   #==========================================================================
  664.   #★以下这几个是默认的,但是留着方便以后进一步扩展
  665.   #==========================================================================
  666.   #--------------------------------------------------------------------------
  667.   # ★ 随机移动
  668.   #--------------------------------------------------------------------------
  669.   def move_random
  670.     case rand(4)
  671.     when 0;  move_down(false)
  672.     when 1;  move_left(false)
  673.     when 2;  move_right(false)
  674.     when 3;  move_up(false)
  675.     end
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ★ 接近玩家
  679.   #--------------------------------------------------------------------------
  680.   def move_toward_player
  681.     sx = distance_x_from_player
  682.     sy = distance_y_from_player
  683.     if sx != 0 or sy != 0
  684.       if sx.abs > sy.abs                  # 如果横向距离长
  685.         sx > 0 ? move_left : move_right   # 左右方向优先
  686.         if @move_failed and sy != 0
  687.           sy > 0 ? move_up : move_down
  688.         end
  689.       else                                # 如果纵向距离等长
  690.         sy > 0 ? move_up : move_down      # 上下方向优先
  691.         if @move_failed and sx != 0
  692.           sx > 0 ? move_left : move_right
  693.         end
  694.       end
  695.     end
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ★ 远离玩家
  699.   #--------------------------------------------------------------------------
  700.   def move_away_from_player
  701.     sx = distance_x_from_player
  702.     sy = distance_y_from_player
  703.     if sx != 0 or sy != 0
  704.       if sx.abs > sy.abs                  # 如果横向距离长
  705.         sx > 0 ? move_right : move_left   # 左右方向优先
  706.         if @move_failed and sy != 0
  707.           sy > 0 ? move_down : move_up
  708.         end #if
  709.       else                                # 如果纵向距离等长
  710.         sy > 0 ? move_down : move_up      # 上下方向优先
  711.         if @move_failed and sx != 0
  712.           sx > 0 ? move_right : move_left
  713.         end #if
  714.       end #if
  715.     end #if
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ★ 前进一步
  719.   #--------------------------------------------------------------------------
  720.   def move_forward
  721.     case @direction
  722.     when 2;  move_down(false)
  723.     when 4;  move_left(false)
  724.     when 6;  move_right(false)
  725.     when 8;  move_up(false)
  726.     end
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ★ 后退一步
  730.   #--------------------------------------------------------------------------
  731.   def move_backward
  732.     last_direction_fix = @direction_fix
  733.     @direction_fix = true
  734.     case @direction
  735.     when 2;  move_up(false)
  736.     when 4;  move_right(false)
  737.     when 6;  move_left(false)
  738.     when 8;  move_down(false)
  739.     end
  740.     @direction_fix = last_direction_fix
  741.   end
  742.   #==========================================================================
  743.   #★以上这几个是默认的,但是留着方便以后进一步扩展
  744.   #==========================================================================
  745.   
  746.   #--------------------------------------------------------------------------
  747.   # ★ 跳跃(重力模式该函数被屏蔽)
  748.   #     x_plus : X 坐标增加值
  749.   #     y_plus : Y 坐标增加值
  750.   #--------------------------------------------------------------------------
  751.   def jump(x_plus, y_plus)
  752.     if $game_map.scene_mode == 0
  753.       if x_plus.abs > y_plus.abs            # 横向距离长
  754.        x_plus < 0 ? turn_left : turn_right
  755.       elsif x_plus.abs > y_plus.abs         # 纵向距离长
  756.        y_plus < 0 ? turn_up : turn_down
  757.       end
  758.       @x += x_plus
  759.       @y += y_plus
  760.       distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  761.       @jump_peak = 10 + distance - @move_speed
  762.       @jump_count = @jump_peak * 2
  763.       @stop_count = 0
  764.       straighten
  765.     end #if
  766.   end
  767.   
  768.   
  769. end # class

  770. #==============================================================================
  771. # ★ Game_Map
  772. #------------------------------------------------------------------------------
  773. #  处理地图的类。包含卷动以及可以通行的判断功能。
  774. # 本类的实例请参考 $game_map 。
  775. #==============================================================================

  776. class Game_Map
  777.   
  778.   attr_accessor :scene_mode  #地图模式
  779.   attr_accessor :events      # 事件
  780.   #--------------------------------------------------------------------------
  781.   # ● 初始化对象
  782.   #--------------------------------------------------------------------------
  783.   def initialize
  784.     @screen = Game_Screen.new
  785.     @interpreter = Game_Interpreter.new(0, true)
  786.     @map_id = 0
  787.     @display_x = 0
  788.     @display_y = 0
  789.     @scene_mode = DEFAULT_MAP_MODE #0为正常模式 1为重力模式
  790.     create_vehicles
  791.   end
  792.   #--------------------------------------------------------------------------
  793.   # ● 设置事件
  794.   #--------------------------------------------------------------------------
  795.   def setup_events
  796.     @events = {}          # 地图事件
  797.     for i in @map.events.keys
  798.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  799.     end
  800.     @common_events = {}   # 公共事件
  801.     for i in 1...$data_common_events.size
  802.       @common_events[i] = Game_CommonEvent.new(i)
  803.     end
  804.     if @scene_mode == 1
  805.      if  MAP_VEHICLE != nil && MAP_VEHICLE.include?(@map_id)
  806.        for v in MAP_VEHICLE[@map_id]
  807.          @events[v[0]].map_vehicle = v[1]
  808.          if  v[1] == 2
  809.           #如果是踏板且有设定其类型的情况下 设置其踏板类型
  810.           @events[v[0]].pedal_type = v[2] if v.size > 2
  811.           #设置踏板移动速度与角色速度相同,解决踏板与角色脱节的bug.但仍有缺陷,鉴于RM本身地图设计的局限性,忍了!
  812.           @events[v[0]].move_speed = $game_player.move_speed
  813.          end#if
  814.         end #for  
  815.     end
  816.     if MAP_FLY_EVENT != nil && MAP_FLY_EVENT.include?(@map_id)
  817.        for v in MAP_FLY_EVENT[@map_id]
  818.          @events[v].can_fly = true
  819.        end #for
  820.      end  
  821.     end #if  
  822.   end
  823.   
  824.   #=========================================================================
  825.   # ★ 判断是否可以通行
  826.   #     x    : X 坐标
  827.   #     y    : Y 坐标
  828.   #     flag : 不能通行的点 (一般情况下为 0x01、可以在交通工具的情况下被更改)
  829.   #=========================================================================
  830.   def passable?(x, y, flag = 0x01)
  831.     for event in events_xy(x, y)            # 调用坐标一致的事件
  832.       next if event.tile_id == 0            # 没有元件图片
  833.       next if event.priority_type > 0       # 不是"在普通角色下"
  834.       next if event.through                 # 直接通过状态
  835.       pass = @passages[event.tile_id]       # 获取通行属性
  836.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  837.       return true if pass & flag == 0x00    # [○] : 可以通行
  838.       #=========================================================================
  839.       if($game_map.scene_mode == 1 && $game_player.on_ladder && event.map_vehicle == 1)
  840.         return true
  841.       end  
  842.       #=========================================================================
  843.       return false if pass & flag == flag   # [×] : 不可以通行
  844.     end
  845.     for i in [2, 1, 0]                      # 调用图层顺序
  846.       tile_id = @map.data[x, y, i]          # 获取元件 ID
  847.       return false if tile_id == nil        # 获取元件 ID 失败 : 不可以通行
  848.       pass = @passages[tile_id]             # 获取通行属性
  849.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  850.       return true if pass & flag == 0x00    # [○] : 可以通行
  851.       return false if pass & flag == flag   # [×] : 不可以通行
  852.     end
  853.     return false                            # 不可以通行
  854.   end
  855.   
  856. end #class

  857. #==============================================================================
  858. # ★ Game_Player
  859. #------------------------------------------------------------------------------
  860. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  861. # 本类的实例请参考 $game_player。
  862. #==============================================================================

  863. class Game_Player < Game_Character

  864.   #--------------------------------------------------------------------------
  865.   # ★ 初始化对象
  866.   #--------------------------------------------------------------------------
  867.   def initialize
  868.     super
  869.     @vehicle_type = -1
  870.     @vehicle_getting_on = false     # 乘座动作中标志
  871.     @vehicle_getting_off = false    # 降下动作中标志
  872.     @transferring = false           # 场所移动标志
  873.     @new_map_id = 0                 # 移动目标地图 ID
  874.     @new_x = 0                      # 移动目标 X 坐标
  875.     @new_y = 0                      # 移动目标 Y 坐标
  876.     @new_direction = 0              # 移动后朝向
  877.     @walking_bgm = nil              # 记忆步行时的 BGM 用
  878.    
  879.     #=====================================================
  880.     @keypress_period = 0
  881.     @jump_character = JUMP_CHARACTER
  882.     #=====================================================
  883.    
  884.   end
  885.   #==========================================================================
  886.   #★ 刷新输入
  887.   #==========================================================================
  888.   def update_input
  889.     return if $game_map.interpreter.running?
  890.     if @is_land
  891.        @jump_series = 0
  892.     end
  893.     #按下跳跃键时
  894.     if Input.press?(JUMP_KEY)
  895.       if @jump_series < @jump_max_series && @keypress_period == 0 && (@is_land || @jump_series > 0) && @y <= $game_map.height
  896.          @init_Vspeed  = - @jump_speed  + JUMP_SERIES_WEAKEN*@jump_series
  897.          @jump_count = -1
  898.          @jump_series += 1
  899.          if  JUMP_SE != nil && JUMP_SE != ""
  900.           Audio.se_play("Audio/SE/"+JUMP_SE,100,100)
  901.          end
  902.       end
  903.       @keypress_period += 1
  904.      
  905.     else
  906.       if @keypress_period > 0
  907.        @keypress_period = 0
  908.        @init_Vspeed = 0
  909.        @jump_count = -1
  910.       end
  911.     end  
  912.    
  913.     case Input.dir4
  914.       #向下
  915.       when 2;
  916.         move_down if movable?
  917.       #向左
  918.       when 4;
  919.         
  920.         move_left if movable? || (!@is_land && flyable?)
  921.    
  922.       #向右  
  923.       when 6;
  924.       
  925.         move_right if  movable? || (!@is_land && flyable?)
  926.         
  927.         
  928.       #向上  
  929.       when 8;
  930.          move_up if  movable?
  931.         
  932.     end #case
  933.    
  934.   end
  935.   #==========================================================================
  936.   #★ 判断是否可以滑翔
  937.   #==========================================================================
  938.   def flyable?
  939.     return !(@real_x != @x * 256)
  940.    
  941.   end  
  942.   #==========================================================================
  943.   #★ 角色调入悬崖后重生(重新初始化相关重力数据)
  944.   #==========================================================================
  945.   def reborn
  946.     @no_need_fall = false
  947.   end  
  948.   #==========================================================================

  949.   #--------------------------------------------------------------------------
  950.   # ★ 刷新画面
  951.   #--------------------------------------------------------------------------
  952.   def update
  953.     last_real_x = @real_x
  954.     last_real_y = @real_y
  955.     last_moving = moving?
  956.     if $game_map.scene_mode == 1 #重力模式
  957.      update_input
  958.     else  
  959.      move_by_input
  960.     end
  961.     super
  962.     update_scroll(last_real_x, last_real_y)
  963.     update_vehicle
  964.     update_nonmoving(last_moving)
  965.   end

  966.   #==========================================================================
  967.   #★以下这几个是默认的,但是留着方便以后进一步扩展
  968.   #==========================================================================

  969.   #--------------------------------------------------------------------------
  970.   # ● 乘降交通工具
  971.   #--------------------------------------------------------------------------
  972.   def get_on_off_vehicle
  973.     return false unless movable?
  974.     if in_vehicle?
  975.       return get_off_vehicle
  976.     else
  977.       return get_on_vehicle
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ● 乘座交通工具
  982.   #    前提是当前没有乘座交通工具。
  983.   #--------------------------------------------------------------------------
  984.   def get_on_vehicle
  985.     front_x = $game_map.x_with_direction(@x, @direction)
  986.     front_y = $game_map.y_with_direction(@y, @direction)
  987.     if $game_map.airship.pos?(@x, @y)             # 与飞行船重合了吗?
  988.       get_on_airship
  989.       return true
  990.     elsif $game_map.ship.pos?(front_x, front_y)   # 正面有大型船?
  991.       get_on_ship
  992.       return true
  993.     elsif $game_map.boat.pos?(front_x, front_y)   # 正面有小型船?
  994.       get_on_boat
  995.       return true
  996.     end
  997.     return false
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # ● 乘座小型船
  1001.   #--------------------------------------------------------------------------
  1002.   def get_on_boat
  1003.     @vehicle_getting_on = true        # 乘座中标志
  1004.     @vehicle_type = 0                 # 设置交通工具类型
  1005.     force_move_forward                # 前进一步
  1006.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1007.     $game_map.boat.get_on             # 乘座处理
  1008.   end
  1009.   #--------------------------------------------------------------------------
  1010.   # ● 乘座大型船
  1011.   #--------------------------------------------------------------------------
  1012.   def get_on_ship
  1013.     @vehicle_getting_on = true        # 乘座
  1014.     @vehicle_type = 1                 # 设置交通工具类型
  1015.     force_move_forward                # 前进一步
  1016.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1017.     $game_map.ship.get_on             # 乘座处理
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # ● 乘座飞行船
  1021.   #--------------------------------------------------------------------------
  1022.   def get_on_airship
  1023.     @vehicle_getting_on = true        # 开始乘座动作
  1024.     @vehicle_type = 2                 # 设置交通工具类型
  1025.     @through = true                   # 穿越 ON
  1026.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1027.     $game_map.airship.get_on          # 乘座处理
  1028.   end
  1029.   #--------------------------------------------------------------------------
  1030.   # ● 降下交通工具
  1031.   #    前提是现在乘座了交通工具。
  1032.   #--------------------------------------------------------------------------
  1033.   def get_off_vehicle
  1034.     if in_airship?                                # 飞行船
  1035.       return unless airship_land_ok?(@x, @y)      # 无法着陆?
  1036.     else                                          # 小型船·大型船
  1037.       front_x = $game_map.x_with_direction(@x, @direction)
  1038.       front_y = $game_map.y_with_direction(@y, @direction)
  1039.       return unless can_walk?(front_x, front_y)   # 无法靠岸?
  1040.     end
  1041.     $game_map.vehicles[@vehicle_type].get_off     # 降下处理
  1042.     if in_airship?                                # 飞行船
  1043.       @direction = 2                              # 面朝下
  1044.     else                                          # 小型船·大型船
  1045.       force_move_forward                          # 前进一步
  1046.       @transparent = false                        # 解除透明
  1047.     end
  1048.     @vehicle_getting_off = true                   # 开始降下动作
  1049.     @move_speed = 4                               # 还原移动速度
  1050.     @through = false                              # 穿越 OFF
  1051.     @walking_bgm.play                             # 还原步行时的 BGM
  1052.     make_encounter_count                          # 初始化遇敌率
  1053.   end
  1054.   
  1055.   #==========================================================================
  1056.   #★以上这几个是默认的,但是留着方便以后进一步扩展
  1057.   #==========================================================================
  1058. end #class
复制代码
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890

狂気の月兔

梦石
0
星屑
421
在线时间
1245 小时
注册时间
2009-4-7
回帖
866

贵宾

发表于 2013-10-22 19:17:31 | 显示全部楼层
  1. @vertical_speed = [@vertical_speed, ???].min
复制代码
好吧, 刚才在写脚本中 一心N用, 改成这个.

点评

你改下重力加速度  发表于 2013-10-22 19:29
还是控制不了下落速度,时间晚点就快成狗……  发表于 2013-10-22 19:25
回复

使用道具 举报

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
 楼主| 发表于 2013-10-22 18:09:44 | 显示全部楼层

请教重力系统的两个问题

请教在这个重力系统里加一个速度最大值,到达这个数值后不增长
  1. #=============================================================================
  2. #★RMVX重力系统★
  3. #-----------------------------------------------------------------------------
  4. #★作者: Zhong_zw
  5. #★联系方式: 66rpg.com论坛短信 或 zhong8890@126.com 或 zhong317@126.com
  6. #★游戏中引用本脚本,请保留以上信息,并作相关说明.
  7. #☆如若转载本脚本请联系本人☆
  8. #==============================================================================
  9. #==============================================================================
  10. # ★ Game_Character
  11. #------------------------------------------------------------------------------
  12. #  涉及角色的类。本类作为 Game_Player 类与 Game_Event 的超级类
  13. # 使用。
  14. #==============================================================================

  15. #==============================================================================
  16. #★参数设置
  17. #==============================================================================
  18. #跳跃初速度
  19. JUMP_SPEED = 100

  20. #重力加速度
  21. GRAVITATIONAL = 1

  22. #连跳次数
  23. JUME_SERIES = 2

  24. #连跳速度衰减
  25. JUMP_SERIES_WEAKEN = 10
  26. #跳跃键
  27. JUMP_KEY = Input::X #默认为键盘A键

  28. #弹跳时的行走图 (格式为:[名称,index])
  29. JUMP_CHARACTER = nil

  30. #弹跳时的声音 (注:声音文件放在SE文件夹下)
  31. JUMP_SE = "Jump1.ogg"

  32. #掉出屏幕时打开的开关(用于调用相关公共事件)
  33. DEAD_SWITCHES_ID = 105

  34. #各地图交通工具的摆放位置
  35. MAP_VEHICLE = {1 => [[2,1],[3,1],[4,1],[5,1],[8,2],[6,2],[7,2,1]],
  36.                5 => [[2,1],[3,1],[4,1],[5,1],[6,2],[7,2]]
  37. }


  38. #各地图可以飞的事件
  39. MAP_FLY_EVENT = {1=>[10]}

  40. #默认地图模式 0为正常模式 1为重力模式
  41. DEFAULT_MAP_MODE = 0


  42. #==============================================================================

  43. class Game_Character
  44.   #--------------------------------------------------------------------------
  45.   # ● 定义实例变量
  46.   #--------------------------------------------------------------------------
  47.   attr_reader   :id                       # ID
  48.   #===============================================================
  49.   attr_accessor :x                        # 地图 X 坐标 (理论坐标)
  50.   attr_accessor :y                        # 地图 Y 坐标 (理论坐标)
  51.   attr_accessor :real_x                   # 地图 X 坐标 (实际坐标 * 256)
  52.   attr_accessor :real_y                   # 地图 Y 坐标 (实际坐标 * 256)
  53.   attr_accessor :move_speed               #角色移动速度
  54.   attr_accessor :jump_series              #连跳次数
  55.   attr_accessor :gravitational            #重力加速度
  56.   attr_accessor :vertical_speed           #垂直速度
  57.   attr_accessor :can_fly                  #飞行开关  
  58.   attr_accessor :jump_speed               #跳跃初速度
  59.   attr_accessor :on_ladder                #是否在梯子上
  60.   attr_accessor :map_vehicle              #地图交通工具 0 无 1 为梯子 2 为踏板
  61.   attr_accessor :pedal_type               #踏板类型
  62.   attr_accessor :on_pedal                 #是否在踏板
  63.   attr_accessor :jump_character           #弹跳时的行走图
  64.   #=====================================================
  65.   #==========================================================================
  66.   # ★ 初始化对象
  67.   #==========================================================================
  68.   def initialize
  69.     @id = 0
  70.     @x = 0
  71.     @y = 0
  72.     @real_x = 0
  73.     @real_y = 0
  74.     @tile_id = 0
  75.     @character_name = ""
  76.     @character_index = 0
  77.     [url=home.php?mod=space&uid=316553]@opacity[/url] = 255
  78.     @blend_type = 0
  79.     @direction = 2
  80.     @pattern = 1
  81.     @move_route_forcing = false
  82.     @priority_type = 1
  83.     @through = false
  84.     @bush_depth = 0
  85.     @animation_id = 0
  86.     @balloon_id = 0
  87.     @transparent = false
  88.     @original_direction = 2               # 原朝向
  89.     @original_pattern = 1                 # 原图案
  90.     @move_type = 0                        # 移动类型
  91.     @move_speed = 4                       # 移动速度
  92.     @move_frequency = 6                   # 移动频度
  93.     @move_route = nil                     # 移动路径
  94.     @move_route_index = 0                 # 移动路径执行位置
  95.     @original_move_route = nil            # 原移动路径
  96.     @original_move_route_index = 0        # 原移动路径执行位置
  97.     @walk_anime = true                    # 步行动画
  98.     @step_anime = false                   # 踏步动画
  99.     @direction_fix = false                # 朝向固定
  100.     @anime_count = 0                      # 动画计数
  101.     @stop_count = 0                       # 停止计数
  102.     @jump_count = 0                       # 跳跃计数
  103.     @jump_peak = 0                        # 跳跃顶点计数
  104.     @wait_count = 0                       # 等待计数
  105.     @locked = false                       # 锁定标志
  106.     @prelock_direction = 0                # 锁定前的朝向
  107.     @move_failed = false                  # 移动失败标志
  108.    
  109.    
  110.    
  111.     #===========================================================
  112.     @jump_speed = JUMP_SPEED  #跳跃速度
  113.    
  114.     #@jump_height = JUMP_HEIGHT
  115.    
  116.     @jump_series = 0                #连跳次数累计
  117.    
  118.     @jump_max_series = JUME_SERIES  #最大连跳次数
  119.    
  120.     @can_fly = false
  121.    
  122.    
  123.    
  124.    
  125.     #计算重力加速度
  126.     [url=home.php?mod=space&uid=282336]@gravitational[/url] = GRAVITATIONAL
  127.    
  128.     #垂直速度为0
  129.     @vertical_speed  = 0
  130.    
  131.     #初始速度
  132.     @init_Vspeed = 0
  133.    
  134.     #着陆
  135.     @is_land = true
  136.    
  137.     #不需要继续下落的开关
  138.     @no_need_fall = false
  139.    
  140.    
  141.     #是否可以坠入悬崖
  142.     @can_falldown_screen = true
  143.    
  144.     #交通工具性质
  145.     @map_vehicle = 0            #地图交通工具 0 无  1为梯子 2 为踏板
  146.    
  147.    
  148.     #是否在梯子上
  149.     @on_ladder = false
  150.    
  151.     #踏板类型
  152.     @pedal_type = 0              # 0 为推进型踏板 1 为即落型踏板
  153.    
  154.     #是否在踏板
  155.     @on_pedal = false
  156.    
  157.     #弹跳时的行走图
  158.     @jump_character = nil
  159.    
  160.     #跳前行走图
  161.     @last_character = nil
  162.    
  163.     #乘客(踏板的情况下)
  164.     @passengers = nil

  165.     #===========================================================
  166.    
  167.   end
  168.   
  169.   #==========================================================================
  170.   #★ 设置跳跃初速度
  171.   #==========================================================================
  172.   def set_jump_speed(speed)
  173.      @jump_speed = speed
  174.   end #def
  175.   
  176.   #==========================================================================
  177.   
  178.   #--------------------------------------------------------------------------
  179.   # ★ 判断是否在跳跃
  180.   #--------------------------------------------------------------------------
  181.   def jumping?
  182.     if $game_map.scene_mode == 0
  183.       return @jump_count > 0
  184.     else
  185.       return false  #废弃跳跃判定.主判定已放进update_falling里
  186.     end #if  
  187.   end

  188.   #==========================================================================
  189.   # ★ 判断角色冲突
  190.   #     x : X 坐标
  191.   #     y : Y 坐标
  192.   #    包含玩家和交通工具、检测普通角色的冲突。
  193.   #==========================================================================
  194.   def collide_with_characters?(x, y)
  195.     for event in $game_map.events_xy(x, y)          # 与事件坐标一致
  196.       if($game_map.scene_mode == 1 && event.map_vehicle == 1)
  197.         return false
  198.       end  
  199.       unless event.through                          # 穿越 OFF?
  200.         return true if self.is_a?(Game_Event)       # 自己是事件
  201.         return true if event.priority_type == 1     # 对方是普通角色
  202.       end
  203.       
  204.     end
  205.     if @priority_type == 1                          # 自己是普通角色
  206.       return true if $game_player.pos_nt?(x, y)     # 与玩家的坐标一致
  207.       return true if $game_map.boat.pos_nt?(x, y)   # 与小型船坐标一致
  208.       return true if $game_map.ship.pos_nt?(x, y)   # 与大型船坐标一致
  209.     end
  210.     return false
  211.   end
  212.   #==========================================================================
  213.   # ★ 获取画面 Y 坐标
  214.   #==========================================================================
  215.   def screen_y
  216.     y = ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
  217.     #================================================
  218.     y -= 4 unless object? || $game_map.scene_mode == 1
  219.     #================================================
  220.     if $game_map.scene_mode == 0
  221.      if @jump_count >= @jump_peak
  222.        n = @jump_count - @jump_peak
  223.      else
  224.        n = @jump_peak - @jump_count
  225.      end
  226.      return y - (@jump_peak * @jump_peak - n * n) / 2
  227.    else
  228.      return y
  229.    end #if  
  230.   end
  231.   #==========================================================================
  232.   # ★ 刷新画面
  233.   #==========================================================================
  234.   def update
  235.    
  236.     if $game_map.scene_mode == 1
  237.      if falling?
  238.        update_falling
  239.      else
  240.       
  241.       #如果本身是踏板的话检查上面有没乘客
  242.       check_passenger
  243.       
  244.       if @real_y < @y*256 && !@on_ladder && !@can_fly && !on_pedal
  245.         free_fall
  246.         #update_horizontal_fly
  247.       else
  248.         if !@on_ladder && !@can_fly && !@on_pedal  #不在梯子上
  249.          @real_y = @y*256  #修正
  250.         end
  251.         @vertical_speed = 0
  252.         @init_Vspeed = 0
  253.         @jump_count = 0
  254.         if moving?
  255.           update_move
  256.         else                        # 正在停止
  257.           update_stop
  258.         end
  259.         if @wait_count > 0          # 正在等待
  260.           @wait_count -= 1
  261.         elsif @move_route_forcing   # 强制移动路径
  262.           move_type_custom
  263.         elsif not @locked           # 被锁定以外
  264.           update_self_movement
  265.          end
  266.          update_animation
  267.       
  268.        end
  269.       
  270.      end
  271.       
  272.     else
  273.      if jumping?                 # 正在跳跃
  274.       update_jump
  275.      elsif moving?               # 正在移动
  276.       update_move
  277.      else                        # 正在停止
  278.       update_stop
  279.      end
  280.      if @wait_count > 0          # 正在等待
  281.       @wait_count -= 1
  282.      elsif @move_route_forcing   # 强制移动路径
  283.       move_type_custom
  284.      elsif not @locked           # 被锁定以外
  285.       update_self_movement
  286.      end
  287.      update_animation
  288.     end #if
  289.   end
  290.   #==========================================================================
  291.   #★判断是否会下落
  292.   #==========================================================================
  293.   def falling?
  294.    
  295.     if @jump_series > 0 && !@on_ladder && @jump_character != nil
  296.       if @last_character == nil || @character_name != @jump_character[0]
  297.         @last_character = [@character_name,@character_index]
  298.       end  
  299.       set_graphic(@jump_character[0],@jump_character[1])
  300.     elsif @last_character != nil  && @last_character[0] != @character_name
  301.      set_graphic(@last_character[0],@last_character[1])
  302.     end
  303.    
  304.      if @can_fly  || @no_need_fall || @map_vehicle >= 1
  305.        return false
  306.      end
  307.      
  308.      have_ladder = false
  309.      for event in $game_map.events_xy(@x, @y)          # 与事件坐标一致
  310.        if event.map_vehicle == 1
  311.          have_ladder = true
  312.          @on_ladder = true
  313.          @is_land = true
  314.         end  
  315.      end
  316.      
  317.      if !have_ladder  
  318.        @on_ladder = false if @on_ladder
  319.      else
  320.        return false
  321.      end  
  322.       
  323.      
  324.      
  325.      dir =  @vertical_speed >= 0  ? 1 : -1
  326.      if @jump_count < 0 && @init_Vspeed < 0
  327.        dir = -1
  328.      end  
  329.      
  330.      x = @x
  331.      
  332.      if @x*256-@real_x > 0 #向右
  333.       x = (@real_x*1.0/256).floor
  334.      elsif @x*256-@real_x < 0
  335.       x = (@real_x*1.0/256).ceil
  336.      end
  337.      
  338.      result = passable?(x, @y+dir) && passable?(@x, @y+dir)
  339.      
  340.      if ((@y+dir) >= $game_map.height || @real_y/256 > $game_map.height) && @can_falldown_screen
  341.         @y = ($game_map.height+1)
  342.         @no_need_fall = true
  343.         if self.is_a?(Game_Player)
  344.           $game_switches[DEAD_SWITCHES_ID] = true
  345.         end #
  346.         
  347.      elsif (@y+dir) <= 0
  348.         result = true   
  349.      end  
  350.      

  351.       
  352.      if @on_pedal&&result
  353.        @on_pedal = false
  354.      end
  355.      
  356.      last_state = @is_land
  357.      @is_land = !result && dir == 1
  358.      
  359.       #判断上顶或着陆事件
  360.      if !result  && (self.is_a?(Game_Player) || self.is_a?(Game_Event))
  361.        dir = -1 if @vertical_speed < 0
  362.        check_event_trigger_touch(@x,@y+dir)
  363.      end
  364.      
  365.      
  366.      
  367.      return result
  368.    
  369.   end  
  370.   
  371.   #==========================================================================
  372.   #★ 下落的更新
  373.   #==========================================================================
  374.   def update_falling
  375.      last_y = @real_y
  376.      y = (last_y/256).ceil
  377.      free_fall
  378.      dir =  @vertical_speed >= 0 ? 1 : -1
  379.      d =  (dir*@vertical_speed*1.00/256).ceil.abs
  380.      lst_i = 0
  381.       
  382.    
  383.      for i in 0..d
  384.       
  385.        if !passable?(@x, y+i*dir)
  386.          
  387.          break
  388.       
  389.        end #if
  390.       
  391.        lst_i = i
  392.       
  393.      end #for
  394.      
  395.      if  i > 0
  396.       @y = y+lst_i*dir
  397.       if !passable?(@x, @y+dir) && @y +dir > 0
  398.         @real_y = @y*256
  399.         #@vertical_speed = 0
  400.         @init_Vspeed = 0
  401.         @jump_count = 0
  402.       end
  403.      end

  404.      
  405.      update_horizontal_fly
  406.      

  407.   end
  408.   #==========================================================================
  409.   #★自由落体运动
  410.   #==========================================================================
  411.   def free_fall
  412.     @jump_count += 1
  413.     @vertical_speed = @init_Vspeed + @gravitational*@jump_count
  414.     @real_y = @real_y + @vertical_speed
  415.   end
  416.   
  417.   #=========================================================================
  418.   #★空中横向移动
  419.   #=========================================================================
  420.   def update_horizontal_fly
  421.     distance = 2 ** @move_speed*2   # 变换移动速度与移动距离
  422.     distance += 5 if dash?        # 跑步状态时移动速度加倍
  423.    
  424.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  425.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  426.   end
  427.   #=========================================================================
  428.   #★ 检查乘客(踏板专用)
  429.   #=========================================================================
  430.   def check_passenger
  431.       return if @map_vehicle != 2 || $game_map.scene_mode != 1
  432.       if @passengers == nil
  433.         @passengers = []
  434.       end  
  435.       if @passengers.size > 0
  436.         @passengers.clear
  437.       end
  438.       for event in $game_map.events_xy(@x, @y-1)
  439.         if  @pedal_type == 1 #即落型
  440.           @map_vehicle = 0    #设为普通角色(重力下自动掉落)
  441.           return
  442.         else
  443.            @passengers.push(event)
  444.         end  
  445.       end   
  446.       if $game_player.x == @x && $game_player.y == @y-1
  447.         if  @pedal_type == 1 #即落型
  448.           @map_vehicle = 0    #设为普通角色(重力下自动掉落)
  449.           return
  450.         else
  451.            @passengers.push($game_player)
  452.         end  
  453.         
  454.       end  
  455.      
  456.   end
  457.   #==========================================================================
  458.   #--------------------------------------------------------------------------
  459.   # ★ 跳跃时的更新
  460.   #--------------------------------------------------------------------------
  461.   def update_jump
  462.    
  463.     if $game_map.scene_mode == 0
  464.       @jump_count -= 1
  465.       @real_x = (@real_x * @jump_count + @x * 256) / (@jump_count + 1)
  466.       @real_y = (@real_y * @jump_count + @y * 256) / (@jump_count + 1)
  467.       update_bush_depth
  468.      end #if
  469.   end

  470.    
  471.   #--------------------------------------------------------------------------
  472.   # ★ 向下移动
  473.   #     turn_ok : 此地可以更改朝向
  474.   #--------------------------------------------------------------------------
  475.   def move_down(turn_ok = true)
  476.                  
  477.       if $game_map.scene_mode == 1
  478.         @on_ladder =true
  479.       end
  480.       
  481.       if passable?(@x, @y+1)                               # 可以通过
  482.        if $game_map.scene_mode == 0                        #正常模式下
  483.          turn_down
  484.        elsif $game_map.scene_mode == 1                     #重力模式
  485.          turn_up if !@can_fly                              #设置爬梯时的朝向
  486.          #是否踏板,是否有乘客
  487.          if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  488.             for event in @passengers
  489.                event.y = @y
  490.                event.on_pedal = true
  491.             end  
  492.          end  
  493.        end  
  494.         @y = $game_map.round_y(@y+1)
  495.         @real_y = (@y-1)*256
  496.         increase_steps
  497.         @move_failed = false
  498.       
  499.       else                                     # 不可以通过
  500.         turn_down if turn_ok
  501.         check_event_trigger_touch(@x, @y+1)    # 判断接触的事件启动
  502.         @move_failed = true
  503.       end
  504.       
  505.     #end #if
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ★ 向左移动
  509.   #     turn_ok : 此地可以更改朝向
  510.   #--------------------------------------------------------------------------
  511.   def move_left(turn_ok = true)
  512.     if passable?(@x-1, @y)                  # 可以通过
  513.       turn_left
  514.       if $game_map.scene_mode == 1
  515.         if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  516.             for event in @passengers
  517.                event.x = $game_map.round_x(@x-1)
  518.                event.on_pedal = true
  519.             end  
  520.         end
  521.       end  
  522.       @x = $game_map.round_x(@x-1)
  523.       @real_x = (@x+1)*256
  524.       increase_steps
  525.       @move_failed = false
  526.     else                                    # 不可以通过
  527.       turn_left if turn_ok
  528.       check_event_trigger_touch(@x-1, @y)   # 判断接触的事件启动
  529.       @move_failed = true
  530.     end
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ★ 向右移动
  534.   #     turn_ok : 此地可以更改朝向
  535.   #--------------------------------------------------------------------------
  536.   def move_right(turn_ok = true)
  537.     if passable?(@x+1, @y)                  # 可以通过
  538.       turn_right
  539.       if $game_map.scene_mode == 1
  540.         if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0        
  541.             for event in @passengers
  542.                event.x = $game_map.round_x(@x+1)
  543.                event.on_pedal = true
  544.             end #for

  545.         end
  546.       end  
  547.       @x = $game_map.round_x(@x+1)
  548.       @real_x = (@x-1)*256
  549.       increase_steps
  550.       @move_failed = false
  551.     else                                    # 不可以通过
  552.       turn_right if turn_ok
  553.       check_event_trigger_touch(@x+1, @y)   # 判断接触的事件启动
  554.       @move_failed = true
  555.     end
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ★ 向上移动
  559.   #     turn_ok : 此地可以更改朝向
  560.   #--------------------------------------------------------------------------
  561.   def move_up(turn_ok = true)
  562.    if $game_map.scene_mode == 0 || ($game_map.scene_mode == 1 && (@on_ladder || @can_fly || @map_vehicle == 2))
  563.      pedal_passable = false
  564.      if @map_vehicle == 2 && $game_map.scene_mode == 1 && @passengers != nil && @passengers.size > 0
  565.            for event in @passengers
  566.              if (event.passable?(@x,@y-2))
  567.                pedal_passable = true
  568.                event.y = $game_map.round_y(@y-2)
  569.                event.on_pedal = true
  570.              end #if  
  571.            end#for  
  572.      end     
  573.      if passable?(@x, @y-1) || pedal_passable      # 可以通过
  574.        turn_up
  575.        @y = $game_map.round_y(@y-1)
  576.        @real_y = (@y+1)*256
  577.        increase_steps
  578.        @move_failed = false
  579.      else                                    # 不可以通过
  580.        turn_up if turn_ok
  581.        check_event_trigger_touch(@x, @y-1)   # 判断接触的事件启动
  582.        @move_failed = true
  583.      end
  584.       
  585.    end #if
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # ★ 向左下移动(为了不引起不必要的bug,把重力模式暂时没用到的屏蔽了)
  589.   #--------------------------------------------------------------------------
  590.   def move_lower_left
  591.    if $game_map.scene_mode == 0  
  592.     unless @direction_fix
  593.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  594.     end
  595.     if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
  596.        (passable?(@x-1, @y) and passable?(@x-1, @y+1))
  597.       @x -= 1
  598.       @y += 1
  599.       increase_steps
  600.       @move_failed = false
  601.     else
  602.       @move_failed = true
  603.     end
  604.    end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ★ 向右下移动
  608.   #--------------------------------------------------------------------------
  609.   def move_lower_right
  610.     if $game_map.scene_mode == 0
  611.      unless @direction_fix
  612.        @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  613.      end
  614.      if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
  615.         (passable?(@x+1, @y) and passable?(@x+1, @y+1))
  616.        @x += 1
  617.        @y += 1
  618.        increase_steps
  619.        @move_failed = false
  620.      else
  621.        @move_failed = true
  622.      end
  623.     end #if  
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ★ 向左上移动
  627.   #--------------------------------------------------------------------------
  628.   def move_upper_left
  629.     if $game_map.scene_mode == 0
  630.      unless @direction_fix
  631.        @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  632.      end
  633.      if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
  634.         (passable?(@x-1, @y) and passable?(@x-1, @y-1))
  635.        @x -= 1
  636.        @y -= 1
  637.        increase_steps
  638.        @move_failed = false
  639.      else
  640.        @move_failed = true
  641.      end
  642.     end #if  
  643.   end
  644.   #--------------------------------------------------------------------------
  645.   # ★ 向右上移动
  646.   #--------------------------------------------------------------------------
  647.   def move_upper_right
  648.     if $game_map.scene_mode == 0
  649.      unless @direction_fix
  650.        @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  651.      end
  652.      if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
  653.         (passable?(@x+1, @y) and passable?(@x+1, @y-1))
  654.        @x += 1
  655.        @y -= 1
  656.        increase_steps
  657.        @move_failed = false
  658.      else
  659.        @move_failed = true
  660.      end
  661.     end #if
  662.   end
  663.   #==========================================================================
  664.   #★以下这几个是默认的,但是留着方便以后进一步扩展
  665.   #==========================================================================
  666.   #--------------------------------------------------------------------------
  667.   # ★ 随机移动
  668.   #--------------------------------------------------------------------------
  669.   def move_random
  670.     case rand(4)
  671.     when 0;  move_down(false)
  672.     when 1;  move_left(false)
  673.     when 2;  move_right(false)
  674.     when 3;  move_up(false)
  675.     end
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ★ 接近玩家
  679.   #--------------------------------------------------------------------------
  680.   def move_toward_player
  681.     sx = distance_x_from_player
  682.     sy = distance_y_from_player
  683.     if sx != 0 or sy != 0
  684.       if sx.abs > sy.abs                  # 如果横向距离长
  685.         sx > 0 ? move_left : move_right   # 左右方向优先
  686.         if @move_failed and sy != 0
  687.           sy > 0 ? move_up : move_down
  688.         end
  689.       else                                # 如果纵向距离等长
  690.         sy > 0 ? move_up : move_down      # 上下方向优先
  691.         if @move_failed and sx != 0
  692.           sx > 0 ? move_left : move_right
  693.         end
  694.       end
  695.     end
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ★ 远离玩家
  699.   #--------------------------------------------------------------------------
  700.   def move_away_from_player
  701.     sx = distance_x_from_player
  702.     sy = distance_y_from_player
  703.     if sx != 0 or sy != 0
  704.       if sx.abs > sy.abs                  # 如果横向距离长
  705.         sx > 0 ? move_right : move_left   # 左右方向优先
  706.         if @move_failed and sy != 0
  707.           sy > 0 ? move_down : move_up
  708.         end #if
  709.       else                                # 如果纵向距离等长
  710.         sy > 0 ? move_down : move_up      # 上下方向优先
  711.         if @move_failed and sx != 0
  712.           sx > 0 ? move_right : move_left
  713.         end #if
  714.       end #if
  715.     end #if
  716.   end
  717.   #--------------------------------------------------------------------------
  718.   # ★ 前进一步
  719.   #--------------------------------------------------------------------------
  720.   def move_forward
  721.     case @direction
  722.     when 2;  move_down(false)
  723.     when 4;  move_left(false)
  724.     when 6;  move_right(false)
  725.     when 8;  move_up(false)
  726.     end
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ★ 后退一步
  730.   #--------------------------------------------------------------------------
  731.   def move_backward
  732.     last_direction_fix = @direction_fix
  733.     @direction_fix = true
  734.     case @direction
  735.     when 2;  move_up(false)
  736.     when 4;  move_right(false)
  737.     when 6;  move_left(false)
  738.     when 8;  move_down(false)
  739.     end
  740.     @direction_fix = last_direction_fix
  741.   end
  742.   #==========================================================================
  743.   #★以上这几个是默认的,但是留着方便以后进一步扩展
  744.   #==========================================================================
  745.   
  746.   #--------------------------------------------------------------------------
  747.   # ★ 跳跃(重力模式该函数被屏蔽)
  748.   #     x_plus : X 坐标增加值
  749.   #     y_plus : Y 坐标增加值
  750.   #--------------------------------------------------------------------------
  751.   def jump(x_plus, y_plus)
  752.     if $game_map.scene_mode == 0
  753.       if x_plus.abs > y_plus.abs            # 横向距离长
  754.        x_plus < 0 ? turn_left : turn_right
  755.       elsif x_plus.abs > y_plus.abs         # 纵向距离长
  756.        y_plus < 0 ? turn_up : turn_down
  757.       end
  758.       @x += x_plus
  759.       @y += y_plus
  760.       distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
  761.       @jump_peak = 10 + distance - @move_speed
  762.       @jump_count = @jump_peak * 2
  763.       @stop_count = 0
  764.       straighten
  765.     end #if
  766.   end
  767.   
  768.   
  769. end # class

  770. #==============================================================================
  771. # ★ Game_Map
  772. #------------------------------------------------------------------------------
  773. #  处理地图的类。包含卷动以及可以通行的判断功能。
  774. # 本类的实例请参考 $game_map 。
  775. #==============================================================================

  776. class Game_Map
  777.   
  778.   attr_accessor :scene_mode  #地图模式
  779.   attr_accessor :events      # 事件
  780.   #--------------------------------------------------------------------------
  781.   # ● 初始化对象
  782.   #--------------------------------------------------------------------------
  783.   def initialize
  784.     @screen = Game_Screen.new
  785.     @interpreter = Game_Interpreter.new(0, true)
  786.     @map_id = 0
  787.     @display_x = 0
  788.     @display_y = 0
  789.     @scene_mode = DEFAULT_MAP_MODE #0为正常模式 1为重力模式
  790.     create_vehicles
  791.   end
  792.   #--------------------------------------------------------------------------
  793.   # ● 设置事件
  794.   #--------------------------------------------------------------------------
  795.   def setup_events
  796.     @events = {}          # 地图事件
  797.     for i in @map.events.keys
  798.       @events[i] = Game_Event.new(@map_id, @map.events[i])
  799.     end
  800.     @common_events = {}   # 公共事件
  801.     for i in 1...$data_common_events.size
  802.       @common_events[i] = Game_CommonEvent.new(i)
  803.     end
  804.     if @scene_mode == 1
  805.      if  MAP_VEHICLE != nil && MAP_VEHICLE.include?(@map_id)
  806.        for v in MAP_VEHICLE[@map_id]
  807.          @events[v[0]].map_vehicle = v[1]
  808.          if  v[1] == 2
  809.           #如果是踏板且有设定其类型的情况下 设置其踏板类型
  810.           @events[v[0]].pedal_type = v[2] if v.size > 2
  811.           #设置踏板移动速度与角色速度相同,解决踏板与角色脱节的bug.但仍有缺陷,鉴于RM本身地图设计的局限性,忍了!
  812.           @events[v[0]].move_speed = $game_player.move_speed
  813.          end#if
  814.         end #for  
  815.     end
  816.     if MAP_FLY_EVENT != nil && MAP_FLY_EVENT.include?(@map_id)
  817.        for v in MAP_FLY_EVENT[@map_id]
  818.          @events[v].can_fly = true
  819.        end #for
  820.      end  
  821.     end #if  
  822.   end
  823.   
  824.   #=========================================================================
  825.   # ★ 判断是否可以通行
  826.   #     x    : X 坐标
  827.   #     y    : Y 坐标
  828.   #     flag : 不能通行的点 (一般情况下为 0x01、可以在交通工具的情况下被更改)
  829.   #=========================================================================
  830.   def passable?(x, y, flag = 0x01)
  831.     for event in events_xy(x, y)            # 调用坐标一致的事件
  832.       next if event.tile_id == 0            # 没有元件图片
  833.       next if event.priority_type > 0       # 不是"在普通角色下"
  834.       next if event.through                 # 直接通过状态
  835.       pass = @passages[event.tile_id]       # 获取通行属性
  836.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  837.       return true if pass & flag == 0x00    # [○] : 可以通行
  838.       #=========================================================================
  839.       if($game_map.scene_mode == 1 && $game_player.on_ladder && event.map_vehicle == 1)
  840.         return true
  841.       end  
  842.       #=========================================================================
  843.       return false if pass & flag == flag   # [×] : 不可以通行
  844.     end
  845.     for i in [2, 1, 0]                      # 调用图层顺序
  846.       tile_id = @map.data[x, y, i]          # 获取元件 ID
  847.       return false if tile_id == nil        # 获取元件 ID 失败 : 不可以通行
  848.       pass = @passages[tile_id]             # 获取通行属性
  849.       next if pass & 0x10 == 0x10           # [☆] : 不受通行影响
  850.       return true if pass & flag == 0x00    # [○] : 可以通行
  851.       return false if pass & flag == flag   # [×] : 不可以通行
  852.     end
  853.     return false                            # 不可以通行
  854.   end
  855.   
  856. end #class

  857. #==============================================================================
  858. # ★ Game_Player
  859. #------------------------------------------------------------------------------
  860. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  861. # 本类的实例请参考 $game_player。
  862. #==============================================================================

  863. class Game_Player < Game_Character

  864.   #--------------------------------------------------------------------------
  865.   # ★ 初始化对象
  866.   #--------------------------------------------------------------------------
  867.   def initialize
  868.     super
  869.     @vehicle_type = -1
  870.     @vehicle_getting_on = false     # 乘座动作中标志
  871.     @vehicle_getting_off = false    # 降下动作中标志
  872.     @transferring = false           # 场所移动标志
  873.     @new_map_id = 0                 # 移动目标地图 ID
  874.     @new_x = 0                      # 移动目标 X 坐标
  875.     @new_y = 0                      # 移动目标 Y 坐标
  876.     @new_direction = 0              # 移动后朝向
  877.     @walking_bgm = nil              # 记忆步行时的 BGM 用
  878.    
  879.     #=====================================================
  880.     @keypress_period = 0
  881.     @jump_character = JUMP_CHARACTER
  882.     #=====================================================
  883.    
  884.   end
  885.   #==========================================================================
  886.   #★ 刷新输入
  887.   #==========================================================================
  888.   def update_input
  889.     return if $game_map.interpreter.running?
  890.     if @is_land
  891.        @jump_series = 0
  892.     end
  893.     #按下跳跃键时
  894.     if Input.press?(JUMP_KEY)
  895.       if @jump_series < @jump_max_series && @keypress_period == 0 && (@is_land || @jump_series > 0) && @y <= $game_map.height
  896.          @init_Vspeed  = - @jump_speed  + JUMP_SERIES_WEAKEN*@jump_series
  897.          @jump_count = -1
  898.          @jump_series += 1
  899.          if  JUMP_SE != nil && JUMP_SE != ""
  900.           Audio.se_play("Audio/SE/"+JUMP_SE,100,100)
  901.          end
  902.       end
  903.       @keypress_period += 1
  904.      
  905.     else
  906.       if @keypress_period > 0
  907.        @keypress_period = 0
  908.        @init_Vspeed = 0
  909.        @jump_count = -1
  910.       end
  911.     end  
  912.    
  913.     case Input.dir4
  914.       #向下
  915.       when 2;
  916.         move_down if movable?
  917.       #向左
  918.       when 4;
  919.         
  920.         move_left if movable? || (!@is_land && flyable?)
  921.    
  922.       #向右  
  923.       when 6;
  924.       
  925.         move_right if  movable? || (!@is_land && flyable?)
  926.         
  927.         
  928.       #向上  
  929.       when 8;
  930.          move_up if  movable?
  931.         
  932.     end #case
  933.    
  934.   end
  935.   #==========================================================================
  936.   #★ 判断是否可以滑翔
  937.   #==========================================================================
  938.   def flyable?
  939.     return !(@real_x != @x * 256)
  940.    
  941.   end  
  942.   #==========================================================================
  943.   #★ 角色调入悬崖后重生(重新初始化相关重力数据)
  944.   #==========================================================================
  945.   def reborn
  946.     @no_need_fall = false
  947.   end  
  948.   #==========================================================================

  949.   #--------------------------------------------------------------------------
  950.   # ★ 刷新画面
  951.   #--------------------------------------------------------------------------
  952.   def update
  953.     last_real_x = @real_x
  954.     last_real_y = @real_y
  955.     last_moving = moving?
  956.     if $game_map.scene_mode == 1 #重力模式
  957.      update_input
  958.     else  
  959.      move_by_input
  960.     end
  961.     super
  962.     update_scroll(last_real_x, last_real_y)
  963.     update_vehicle
  964.     update_nonmoving(last_moving)
  965.   end

  966.   #==========================================================================
  967.   #★以下这几个是默认的,但是留着方便以后进一步扩展
  968.   #==========================================================================

  969.   #--------------------------------------------------------------------------
  970.   # ● 乘降交通工具
  971.   #--------------------------------------------------------------------------
  972.   def get_on_off_vehicle
  973.     return false unless movable?
  974.     if in_vehicle?
  975.       return get_off_vehicle
  976.     else
  977.       return get_on_vehicle
  978.     end
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # ● 乘座交通工具
  982.   #    前提是当前没有乘座交通工具。
  983.   #--------------------------------------------------------------------------
  984.   def get_on_vehicle
  985.     front_x = $game_map.x_with_direction(@x, @direction)
  986.     front_y = $game_map.y_with_direction(@y, @direction)
  987.     if $game_map.airship.pos?(@x, @y)             # 与飞行船重合了吗?
  988.       get_on_airship
  989.       return true
  990.     elsif $game_map.ship.pos?(front_x, front_y)   # 正面有大型船?
  991.       get_on_ship
  992.       return true
  993.     elsif $game_map.boat.pos?(front_x, front_y)   # 正面有小型船?
  994.       get_on_boat
  995.       return true
  996.     end
  997.     return false
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # ● 乘座小型船
  1001.   #--------------------------------------------------------------------------
  1002.   def get_on_boat
  1003.     @vehicle_getting_on = true        # 乘座中标志
  1004.     @vehicle_type = 0                 # 设置交通工具类型
  1005.     force_move_forward                # 前进一步
  1006.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1007.     $game_map.boat.get_on             # 乘座处理
  1008.   end
  1009.   #--------------------------------------------------------------------------
  1010.   # ● 乘座大型船
  1011.   #--------------------------------------------------------------------------
  1012.   def get_on_ship
  1013.     @vehicle_getting_on = true        # 乘座
  1014.     @vehicle_type = 1                 # 设置交通工具类型
  1015.     force_move_forward                # 前进一步
  1016.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1017.     $game_map.ship.get_on             # 乘座处理
  1018.   end
  1019.   #--------------------------------------------------------------------------
  1020.   # ● 乘座飞行船
  1021.   #--------------------------------------------------------------------------
  1022.   def get_on_airship
  1023.     @vehicle_getting_on = true        # 开始乘座动作
  1024.     @vehicle_type = 2                 # 设置交通工具类型
  1025.     @through = true                   # 穿越 ON
  1026.     @walking_bgm = RPG::BGM::last     # 记忆步行时 BGM 用
  1027.     $game_map.airship.get_on          # 乘座处理
  1028.   end
  1029.   #--------------------------------------------------------------------------
  1030.   # ● 降下交通工具
  1031.   #    前提是现在乘座了交通工具。
  1032.   #--------------------------------------------------------------------------
  1033.   def get_off_vehicle
  1034.     if in_airship?                                # 飞行船
  1035.       return unless airship_land_ok?(@x, @y)      # 无法着陆?
  1036.     else                                          # 小型船·大型船
  1037.       front_x = $game_map.x_with_direction(@x, @direction)
  1038.       front_y = $game_map.y_with_direction(@y, @direction)
  1039.       return unless can_walk?(front_x, front_y)   # 无法靠岸?
  1040.     end
  1041.     $game_map.vehicles[@vehicle_type].get_off     # 降下处理
  1042.     if in_airship?                                # 飞行船
  1043.       @direction = 2                              # 面朝下
  1044.     else                                          # 小型船·大型船
  1045.       force_move_forward                          # 前进一步
  1046.       @transparent = false                        # 解除透明
  1047.     end
  1048.     @vehicle_getting_off = true                   # 开始降下动作
  1049.     @move_speed = 4                               # 还原移动速度
  1050.     @through = false                              # 穿越 OFF
  1051.     @walking_bgm.play                             # 还原步行时的 BGM
  1052.     make_encounter_count                          # 初始化遇敌率
  1053.   end
  1054.   
  1055.   #==========================================================================
  1056.   #★以上这几个是默认的,但是留着方便以后进一步扩展
  1057.   #==========================================================================
  1058. end #class

复制代码
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890
回复

使用道具 举报

狂気の月兔

梦石
0
星屑
421
在线时间
1245 小时
注册时间
2009-4-7
回帖
866

贵宾

发表于 2013-10-22 18:38:55 | 显示全部楼层
脚本 432行 之后添加 :
  1. @vertical_speed = [@vertical_speed, ???].max
复制代码
这里的 ??? 请输入你需要的数值.
回复

使用道具 举报

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
 楼主| 发表于 2013-10-22 19:14:01 | 显示全部楼层
铃仙·优昙华院·因幡 发表于 2013-10-22 18:38
脚本 432行 之后添加 :这里的 ??? 请输入你需要的数值.

貌似没有效果……
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890
回复

使用道具 举报

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
 楼主| 发表于 2013-11-2 13:36:33 | 显示全部楼层
这个问题还木有解决……

点评

"6.若问题在7天后未得到解决,版主未结帖或者发贴人没有自主结帖的,将帖子直接过期处理" 着帖子到现在都半个月了.  发表于 2013-11-2 14:00
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部