Project1

标题: 脚本错误 [打印本页]

作者: 够爱    时间: 2018-5-23 23:36
标题: 脚本错误
=============================================================================
# ■ Scene_By
#------------------------------------------------------------------------------
#  乘降画面
#==============================================================================
class Scene_By < Scene_ByBase
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    create_command_window
  end
  #--------------------------------------------------------------------------
  # ● 生成指令窗口
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_By.new
    @command_window.set_handler(:all_actor_up,   method(:all_actor_up))
    @command_window.set_handler(:all_actor_down, method(:all_actor_down))
    @command_window.set_handler(:ok,             method(:ok           ))
    @command_window.set_handler(:cancel,         method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 窗口进入
  #--------------------------------------------------------------------------
  def move_start
    Window_move::speed(@command_window,3)
  end
  #--------------------------------------------------------------------------
  # ● 窗口离开
  #--------------------------------------------------------------------------
  def move_end
    Window_move::speed_back(@command_window,3)
  end
  
  #--------------------------------------------------------------------------
  # ● 指令“全体上车”
  #--------------------------------------------------------------------------
  def all_actor_up
    for i in 0...$game_party.actors.size
      if $game_party.actors[i] <= $game_party.bus_actor
        bus_up($game_party.actors[i])
      end
    end
    SceneManager.goto(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # ● 指令“全体下车”
  #--------------------------------------------------------------------------
  def all_actor_down
    for i in 0...$game_party.actors.size
      if $game_party.actors[i] > $game_party.bus_actor
        a = $game_party.actors[i]-$game_party.bus_actor
        b = $game_party.bus[a*7+5]
        bus_down(b)
      end
    end
    SceneManager.goto(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # ● 指令“个别乘降”
  #--------------------------------------------------------------------------
  def ok  
    actor =  @command_window.current_ext
    bus(actor.id)
  end
  #--------------------------------------------------------------------------
  # ● 个别角色判定
  #--------------------------------------------------------------------------
  def bus(actor)
    #判定坐标
    if $game_actors[actor].index == 0
      x = $game_player.x
      y = $game_player.y
      d = $game_player.direction
    elsif $game_actors[actor].index == nil
      actor_id_i = $game_party.actor_by[actor]
      if $game_actors[actor_id_i].index == 0
        x = $game_player.x
        y = $game_player.y
        d = $game_player.direction
      else
        x = $game_player.followers[$game_actors[actor_id_i].index-1].x
        y = $game_player.followers[$game_actors[actor_id_i].index-1].y
        d = $game_player.followers[$game_actors[actor_id_i].index-1].direction
      end
    else
      x = $game_player.followers[$game_actors[actor].index-1].x
      y = $game_player.followers[$game_actors[actor].index-1].y
      d = $game_player.followers[$game_actors[actor].index-1].direction
    end
    for i in 1..$game_party.bus_max
      #如果这辆车没有得到,直接往下判断,本质没什么用,但可以优化一下内存
      if $game_party.bus[i*7+6] == false
        next
      end
      #车与角色的位置判定
      if $game_party.bus[i*7+4] == false and x == $game_party.bus[i*7] and y == $game_party.bus[i*7+1] and $game_party.bus[i*7+3] == $game_map.map_id
        $game_party.bus[i*7+4] = true   #更改停放状态
        $game_party.bus[i*7+5] = actor  #更改此车被几号角色所称
        #更改角色所乘战车ID
        $game_party.actor_by[actor] = i+$game_party.bus_actor
        $game_party.add_actor(i+$game_party.bus_actor) #加人战车
        #替换战车与角色位置
        $game_party.swap_order($game_actors[actor].index,$game_actors[i+$game_party.bus_actor].index)
        $game_party.remove_actor(actor) #角色离队
        Audio.se_play("Audio/SE/001-上下车",100,100) #播放上车音效
        break #跳出循环
      elsif $game_party.bus[i*7+4] == true  and $game_party.bus[i*7+5] == actor
        $game_party.add_actor($game_party.bus[i*7+5]) #加人角色
        $game_party.bus[i*7+4] = false #更改停放状态
        #更改角色所乘战车ID
        $game_party.actor_by[actor] = nil
        a = $game_actors[$game_party.bus[i*7+5]].index
        $game_party.bus[i*7+5] = nil   #清空车内角色id
        #记录战车停放位置
        $game_party.bus[i*7]   = x
        $game_party.bus[i*7+1] = y
        $game_party.bus[i*7+2] = d
        $game_party.bus[i*7+3] = $game_map.map_id
        #替换战车与角色位置
        b = $game_actors[i+$game_party.bus_actor].index
        $game_party.swap_order(a, b)
        $game_party.remove_actor(i+$game_party.bus_actor)  #战车离队
        Audio.se_play("Audio/SE/001-上下车",100,100)        #播放下车音效
        break #跳出循环
      end
    end
    SceneManager.goto(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # ● 上车判定
  #--------------------------------------------------------------------------
  def bus_up(actor)
    #判定坐标
    if $game_actors[actor].index == 0
      x = $game_player.x
      y = $game_player.y
      d = $game_player.direction
    elsif $game_actors[actor].index == nil
      actor_id_i = $game_party.actor_by[actor]
      if $game_actors[actor_id_i].index == 0
        x = $game_player.x
        y = $game_player.y
        d = $game_player.direction
      else
        x = $game_player.followers[$game_actors[actor_id_i].index-1].x
        y = $game_player.followers[$game_actors[actor_id_i].index-1].y
        d = $game_player.followers[$game_actors[actor_id_i].index-1].direction
      end
    else
      x = $game_player.followers[$game_actors[actor].index-1].x
      y = $game_player.followers[$game_actors[actor].index-1].y
      d = $game_player.followers[$game_actors[actor].index-1].direction
    end
    for i in 1..$game_party.bus_max
      #如果这辆车没有得到,直接往下判断,本质没什么用,但可以优化一下内存
      if $game_party.bus[i*7+6] == false
        next
      end
      #车与角色的位置判定
      if $game_party.bus[i*7+4] == false and x == $game_party.bus[i*7] and y == $game_party.bus[i*7+1] and $game_party.bus[i*7+3] == $game_map.map_id
        $game_party.bus[i*7+4] = true   #更改停放状态
        $game_party.bus[i*7+5] = actor  #更改此车被几号角色所称
        #更改角色所乘战车ID
        $game_party.actor_by[actor] = i+$game_party.bus_actor
        $game_party.add_actor(i+$game_party.bus_actor) #加人战车
        #替换战车与角色位置
        $game_party.swap_order($game_actors[actor].index,$game_actors[i+$game_party.bus_actor].index)
        $game_party.remove_actor(actor) #角色离队
        Audio.se_play("Audio/SE/001-上下车",100,100) #播放上车音效
        break #跳出循环
      end
    end
    SceneManager.goto(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # ● 下车判定
  #--------------------------------------------------------------------------
  def bus_down(actor)
   #判定坐标
    if $game_actors[actor].index == 0
      x = $game_player.x
      y = $game_player.y
      d = $game_player.direction
    elsif $game_actors[actor].index == nil
      actor_id_i = $game_party.actor_by[actor]
      if $game_actors[actor_id_i].index == 0
        x = $game_player.x
        y = $game_player.y
        d = $game_player.direction
      else
        x = $game_player.followers[$game_actors[actor_id_i].index-1].x
        y = $game_player.followers[$game_actors[actor_id_i].index-1].y
        d = $game_player.followers[$game_actors[actor_id_i].index-1].direction
      end
    else
      x = $game_player.followers[$game_actors[actor].index-1].x
      y = $game_player.followers[$game_actors[actor].index-1].y
      d = $game_player.followers[$game_actors[actor].index-1].direction
    end
   for i in 1..$game_party.bus_max
      #如果这辆车没有得到,直接往下判断,本质没什么用,但可以优化一下内存
      if $game_party.bus[i*7+6] == false
        next
      end
      if $game_party.bus[i*7+4] == true  and $game_party.bus[i*7+5] == actor
        $game_party.add_actor($game_party.bus[i*7+5]) #加人角色
        $game_party.bus[i*7+4] = false #更改停放状态
        #更改角色所乘战车ID
        $game_party.actor_by[actor] = nil
        a = $game_actors[$game_party.bus[i*7+5]].index
        $game_party.bus[i*7+5] = nil   #清空车内角色id
        #记录战车停放位置
        $game_party.bus[i*7]   = x
        $game_party.bus[i*7+1] = y
        $game_party.bus[i*7+2] = d
        $game_party.bus[i*7+3] = $game_map.map_id
        #替换战车与角色位置
        b = $game_actors[i+$game_party.bus_actor].index
        $game_party.swap_order(a, b)
        $game_party.remove_actor(i+$game_party.bus_actor)  #战车离队
        Audio.se_play("Audio/SE/001-上下车",100,100)        #播放下车音效
        break #跳出循环
      end
      SceneManager.goto(Scene_Map)
    end
  end
end

@888ND8ES16A14C(53KC]9B.png (2.76 KB, 下载次数: 26)

@888ND8ES16A14C(53KC]9B.png

5O@2]FZ)WH5ATDNU]R61ROY.png (14.32 KB, 下载次数: 27)

5O@2]FZ)WH5ATDNU]R61ROY.png

作者: 够爱    时间: 2018-5-23 23:38
队伍角色在=/<4的时候能正常使用“全体上车”功能
队伍角色>4时就出现上述问题
作者: 够爱    时间: 2018-5-23 23:39
望懂的大神帮忙解析下
作者: 够爱    时间: 2018-5-24 16:04
求大神围观
作者: 够爱    时间: 2018-5-28 00:34
已经去除全体上下车效果   制定人物效果怎么弄成只显示队伍中前四个
作者: 够爱    时间: 2018-5-28 00:35
够爱 发表于 2018-5-28 00:34
已经去除全体上下车效果   制定人物效果怎么弄成只显示队伍中前四个

指定人物 上下车     




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1