Project1

标题: 航海的问题 [打印本页]

作者: faust    时间: 2007-12-24 01:57
标题: 航海的问题
  1. =begin
  2. --------------------------------------------------------------------------
  3. 跨地图航海辅佐脚本 v1.1
  4. By 叶子
  5. Date 4-8-2006
  6. --------------------------------------------------------------------------
  7. 跨地图航海由一个脚本+一个事件完成

  8. 使用方法(请耐心阅读完全部说明!每一步都必不可少):

  9. -插入本脚本到Main之上

  10. -二选一:
  11. 一)插入航海脚本懒人插件到Main之上,或者
  12. 二)仔细观察插件脚本,找到:
  13.     #-----------插入船命令-----------OK
  14.     setup_ship
  15.     #--------------------------------
  16.    和
  17.     #---------插入船刷新命令---------OK
  18.     $game_player.shipping_update
  19.     #--------------------------------
  20. 插入到Game_Map中相同位置(出现冲突时采用此方法)

  21. -小船事件设置方法:
  22. 小船为范例工程工程里湖中的矿道车,可以改成其它船的行走图
  23. 第二页出现条件设置为航行中标志开关打开(默认50号开关),第三页为独立开关A打开

  24. -水中通行设置方法:
  25. 把所有水的图块的地形标志设置为1,把水中不可通行图块(例如水中礁石)的地形标志
  26. 设置为2或以上(反正要大于水的地形标志)

  27. 注意事项:

  28. -不明白小船实现原理的话最好不要改小船事件(除了注释说可以随便改的地方之外)
  29. -默认角色航行中的话,50号开关打开,这时可以利用并行公共事件判断角色遇敌等
  30. -航行中标志开关只能用于判断,不要在其它事件中打开或关闭,否则可能出错误

  31. =end

  32. SHIPPING_SWITCH = 50                # 默认50号开关为是否航行中标志开关

  33. #==============================================================================
  34. # ■ Game_Player
  35. #------------------------------------------------------------------------------
  36. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  37. # 本类的实例请参考 $game_player。
  38. #==============================================================================

  39. class Game_Player < Game_Character
  40.   TERRAIN_TAG = 1                     # 默认1号地形标志为水的地形标志
  41.   attr_accessor :x                    # x坐标
  42.   attr_accessor :y                    # y坐标
  43.   attr_accessor :shipping             # 航海中标志
  44.   attr_accessor :ship                 # 船信息
  45.   #--------------------------------------------------------------------------
  46.   # ● 航海更新
  47.   #--------------------------------------------------------------------------
  48.   def shipping_update
  49.     return if !@shipping
  50.     @old_x = @x
  51.     @old_y = @y
  52.     # 着陆判断初始化
  53.     @land = false
  54.     # 移动中、事件执行中、强制移动路线中、
  55.     # 信息窗口一个也不显示的时候
  56.     unless moving? or $game_system.map_interpreter.running? or
  57.            @move_route_forcing or $game_temp.message_window_showing
  58.       # 如果方向键被按下、主角就朝那个方向移动
  59.       case Input.dir4
  60.       when 2
  61.         ship_move_down
  62.       when 4
  63.         ship_move_left
  64.       when 6
  65.         ship_move_right
  66.       when 8
  67.         ship_move_up
  68.       end
  69.     end
  70.     # 着陆判断
  71.     if @land
  72.       end_shipping
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 开始航海
  77.   #--------------------------------------------------------------------------
  78.   def start_shipping(ship)
  79.     $game_player.shipping = true
  80.     need_setup = false
  81.     # 处女航的话,刷新地图
  82.     if @ship.nil?
  83.       need_setup = true
  84.     end
  85.     # 把船事件添加入资料中
  86.     @ship = ship
  87.     # 移动角色
  88.     @x = @ship.x
  89.     @y = @ship.y
  90.     # 记录位置
  91.     @ship.ship_position = [$game_map.map_id, @ship.x, @ship.y]
  92.     if need_setup
  93.       $game_map.setup_ship
  94.     end
  95.     $game_map.need_refresh = true
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 着陆
  99.   #--------------------------------------------------------------------------
  100.   def end_shipping
  101.     # 获取带头的角色
  102.     actor = $game_party.actors[0]
  103.     # 设置角色的文件名及对像
  104.     @character_name = actor.character_name
  105.     @character_hue = actor.character_hue
  106.     # 关闭标志
  107.     @shipping = false
  108.     $game_switches[SHIPPING_SWITCH] = false
  109.     # 关闭停止时动画
  110.     @step_anime = false
  111.     # 回复速度
  112.     @move_speed = 4
  113.     # 设置船位置
  114.     @ship.ship_position = [$game_map.map_id, @old_x, @old_y]
  115.     @ship.moveto(@ship.ship_position[1], @ship.ship_position[2])
  116.     # 刷新地图
  117.     $game_map.need_refresh = true
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 向下移动
  121.   #     turn_enabled : 本场地位置更改许可标志
  122.   #--------------------------------------------------------------------------
  123.   def ship_move_down(turn_enabled = true)
  124.     # 面向下
  125.     if turn_enabled
  126.       turn_down
  127.     end
  128.     # 可以通行的场合
  129.     if ship_passable?(@x, @y, 2)
  130.       # 面向下
  131.       turn_down
  132.       # 更新坐标
  133.       @y += 1
  134.       # 增加步数
  135.       increase_steps
  136.     # 不能通行的情况下
  137.     else
  138.       # 接触事件的启动判定
  139.       check_event_trigger_touch(@x, @y+1)
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 向左移动
  144.   #     turn_enabled : 本场地位置更改许可标志
  145.   #--------------------------------------------------------------------------
  146.   def ship_move_left(turn_enabled = true)
  147.     # 面向左
  148.     if turn_enabled
  149.       turn_left
  150.     end
  151.     # 可以通行的情况下
  152.     if ship_passable?(@x, @y, 4)
  153.       # 面向左
  154.       turn_left
  155.       # 更新坐标
  156.       @x -= 1
  157.       # 增加步数
  158.       increase_steps
  159.     # 不能通行的情况下
  160.     else
  161.       # 接触事件的启动判定
  162.       check_event_trigger_touch(@x-1, @y)
  163.     end
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 向右移动
  167.   #     turn_enabled : 本场地位置更改许可标志
  168.   #--------------------------------------------------------------------------
  169.   def ship_move_right(turn_enabled = true)
  170.     # 面向右
  171.     if turn_enabled
  172.       turn_right
  173.     end
  174.     # 可以通行的场合
  175.     if ship_passable?(@x, @y, 6)
  176.       # 面向右
  177.       turn_right
  178.       # 更新坐标
  179.       @x += 1
  180.       # 增加部数
  181.       increase_steps
  182.     # 不能通行的情况下
  183.     else
  184.       # 接触事件的启动判定
  185.       check_event_trigger_touch(@x+1, @y)
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 向上移动
  190.   #     turn_enabled : 本场地位置更改许可标志
  191.   #--------------------------------------------------------------------------
  192.   def ship_move_up(turn_enabled = true)
  193.     # 面向上
  194.     if turn_enabled
  195.       turn_up
  196.     end
  197.     # 可以通行的情况下
  198.     if ship_passable?(@x, @y, 8)
  199.       # 面向上
  200.       turn_up
  201.       # 更新坐标
  202.       @y -= 1
  203.       # 歩数増加
  204.       increase_steps
  205.     # 不能通行的情况下
  206.     else
  207.       # 接触事件的启动判定
  208.       check_event_trigger_touch(@x, @y-1)
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 可以通行判定
  213.   #     x : X 坐标
  214.   #     y : Y 坐标
  215.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  216.   #--------------------------------------------------------------------------
  217.   def ship_passable?(x, y, d)
  218.     # 求得新的坐标
  219.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  220.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  221.     # 坐标在地图以外的情况
  222.     unless $game_map.valid?(new_x, new_y)
  223.       # 不能通行
  224.       return false
  225.     end
  226.     # 穿透是 ON 的情况下
  227.     if @through
  228.       # 可以通行
  229.       return true
  230.     end
  231.     # 移动者的元件无法来到指定方向的情况下
  232.     unless $game_map.passable?(x, y, d, self)
  233.       # 通行不可
  234.       return false
  235.     end
  236.     # 从指定方向不能进入到移动处的元件的情况下
  237.     unless $game_map.passable?(new_x, new_y, 10 - d)
  238.       # 不能通行
  239.       return false
  240.     end
  241.     # 循环全部事件
  242.     for event in $game_map.events.values
  243.       # 事件坐标于移动目标坐标一致的情况下
  244.       if event.x == new_x and event.y == new_y
  245.         # 穿透为 ON
  246.         unless event.through
  247.           # 自己就是事件的情况下
  248.           if self != $game_player
  249.             # 不能通行
  250.             return false
  251.           end
  252.           # 自己是主角、对方的图形是角色的情况下
  253.           if event.character_name != ""
  254.             # 不能通行
  255.             return false
  256.           end
  257.         end
  258.       end
  259.     end
  260.     # 主角的坐标与移动目标坐标一致的情况下
  261.     if $game_player.x == new_x and $game_player.y == new_y
  262.       # 穿透为 ON
  263.       unless $game_player.through
  264.         # 自己的图形是角色的情况下
  265.         if @character_name != ""
  266.           # 不能通行
  267.           return false
  268.         end
  269.       end
  270.     end
  271.     # 地形标志判断通行
  272.     for i in [2, 1, 0]
  273.       tile_id = $game_map.data[new_x, new_y, i]
  274.       return false if tile_id == nil
  275.     end
  276.     if $game_map.terrain_tag(new_x, new_y) != TERRAIN_TAG
  277.       if passable?(new_x, new_y, 0)
  278.         @land = true
  279.         return true
  280.       end
  281.       return false
  282.     end
  283.     # 可以通行
  284.     return true
  285.   end
  286. end

  287. #==============================================================================
  288. # ■ Game_Map
  289. #------------------------------------------------------------------------------
  290. #  处理地图的类。包含卷动以及可以通行的判断功能。
  291. # 本类的实例请参考 $game_map 。
  292. #==============================================================================

  293. class Game_Map
  294.   attr_accessor :events                    # 事件
  295.   def setup_ship
  296.     return if $game_player.ship.nil?
  297.     # 航行中或船停泊在此则创建船事件
  298.     if $game_player.shipping or $game_player.ship.ship_position[0] == @map_id
  299.       id = @events.values.size + 1
  300.       # 防止事件错误
  301.       while @events[id] != nil
  302.         id += 1
  303.       end
  304.       @events[id] = $game_player.ship
  305.       @events[id].id = id
  306.       @events[id].map_id = @map_id
  307.       @events[id].moveto($game_player.ship.ship_position[1],
  308.       $game_player.ship.ship_position[2])
  309.       # 不在航行中则关闭开关使船出现
  310.       if !$game_player.shipping
  311.         $game_switches[SHIPPING_SWITCH] = false
  312.       end
  313.     end
  314.   end
  315. end

  316. #==============================================================================
  317. # ■ Game_Event
  318. #------------------------------------------------------------------------------
  319. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  320. # 在 Game_Map 类的内部使用。
  321. #==============================================================================

  322. class Game_Event < Game_Character
  323.   #--------------------------------------------------------------------------
  324.   # ● 定义实例变量
  325.   #--------------------------------------------------------------------------
  326.   attr_accessor :id                               # 事件ID
  327.   attr_accessor :map_id                           # 地图ID
  328.   attr_accessor :ship_position                    # 记录船位置数组
  329.   #--------------------------------------------------------------------------
  330.   # ● 越过目标判定 (不能将相同位置作为启动条件)
  331.   #--------------------------------------------------------------------------
  332.   def over_trigger?
  333.     # 图形是角色、没有开启穿透的情况下
  334.     if @character_name != "" and not @through
  335.       # 启动判定是正面
  336.       return false
  337.     end
  338.     # 地图上的这个位置不能通行,并且不在航海中的情况下
  339.     if !$game_map.passable?(@x, @y, 0) and $game_player.shipping != true
  340.       # 启动判定是正面
  341.       return false
  342.     end
  343.     # 启动判定在同位置
  344.     return true
  345.   end
  346.   def id=(new_id)
  347.     @id = new_id
  348.     @event.id = new_id
  349.   end
  350. end

  351. #==============================================================================
  352. # ■ Interpreter
  353. #------------------------------------------------------------------------------
  354. #  执行事件命令的解释器。本类在 Game_System 类
  355. # 与 Game_Event 类的内部使用。
  356. #==============================================================================

  357. class Interpreter
  358.   #--------------------------------------------------------------------------
  359.   # ● 开始航海
  360.   #--------------------------------------------------------------------------
  361.   def start_shipping
  362.     $game_player.start_shipping($game_map.events[@event_id])
  363.   end
  364. end
复制代码


这是航海的脚本



问题是

当有若干个“船”时,只要上一个船,其他的都会消失



[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: faust    时间: 2007-12-24 01:57
标题: 航海的问题
  1. =begin
  2. --------------------------------------------------------------------------
  3. 跨地图航海辅佐脚本 v1.1
  4. By 叶子
  5. Date 4-8-2006
  6. --------------------------------------------------------------------------
  7. 跨地图航海由一个脚本+一个事件完成

  8. 使用方法(请耐心阅读完全部说明!每一步都必不可少):

  9. -插入本脚本到Main之上

  10. -二选一:
  11. 一)插入航海脚本懒人插件到Main之上,或者
  12. 二)仔细观察插件脚本,找到:
  13.     #-----------插入船命令-----------OK
  14.     setup_ship
  15.     #--------------------------------
  16.    和
  17.     #---------插入船刷新命令---------OK
  18.     $game_player.shipping_update
  19.     #--------------------------------
  20. 插入到Game_Map中相同位置(出现冲突时采用此方法)

  21. -小船事件设置方法:
  22. 小船为范例工程工程里湖中的矿道车,可以改成其它船的行走图
  23. 第二页出现条件设置为航行中标志开关打开(默认50号开关),第三页为独立开关A打开

  24. -水中通行设置方法:
  25. 把所有水的图块的地形标志设置为1,把水中不可通行图块(例如水中礁石)的地形标志
  26. 设置为2或以上(反正要大于水的地形标志)

  27. 注意事项:

  28. -不明白小船实现原理的话最好不要改小船事件(除了注释说可以随便改的地方之外)
  29. -默认角色航行中的话,50号开关打开,这时可以利用并行公共事件判断角色遇敌等
  30. -航行中标志开关只能用于判断,不要在其它事件中打开或关闭,否则可能出错误

  31. =end

  32. SHIPPING_SWITCH = 50                # 默认50号开关为是否航行中标志开关

  33. #==============================================================================
  34. # ■ Game_Player
  35. #------------------------------------------------------------------------------
  36. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  37. # 本类的实例请参考 $game_player。
  38. #==============================================================================

  39. class Game_Player < Game_Character
  40.   TERRAIN_TAG = 1                     # 默认1号地形标志为水的地形标志
  41.   attr_accessor :x                    # x坐标
  42.   attr_accessor :y                    # y坐标
  43.   attr_accessor :shipping             # 航海中标志
  44.   attr_accessor :ship                 # 船信息
  45.   #--------------------------------------------------------------------------
  46.   # ● 航海更新
  47.   #--------------------------------------------------------------------------
  48.   def shipping_update
  49.     return if !@shipping
  50.     @old_x = @x
  51.     @old_y = @y
  52.     # 着陆判断初始化
  53.     @land = false
  54.     # 移动中、事件执行中、强制移动路线中、
  55.     # 信息窗口一个也不显示的时候
  56.     unless moving? or $game_system.map_interpreter.running? or
  57.            @move_route_forcing or $game_temp.message_window_showing
  58.       # 如果方向键被按下、主角就朝那个方向移动
  59.       case Input.dir4
  60.       when 2
  61.         ship_move_down
  62.       when 4
  63.         ship_move_left
  64.       when 6
  65.         ship_move_right
  66.       when 8
  67.         ship_move_up
  68.       end
  69.     end
  70.     # 着陆判断
  71.     if @land
  72.       end_shipping
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 开始航海
  77.   #--------------------------------------------------------------------------
  78.   def start_shipping(ship)
  79.     $game_player.shipping = true
  80.     need_setup = false
  81.     # 处女航的话,刷新地图
  82.     if @ship.nil?
  83.       need_setup = true
  84.     end
  85.     # 把船事件添加入资料中
  86.     @ship = ship
  87.     # 移动角色
  88.     @x = @ship.x
  89.     @y = @ship.y
  90.     # 记录位置
  91.     @ship.ship_position = [$game_map.map_id, @ship.x, @ship.y]
  92.     if need_setup
  93.       $game_map.setup_ship
  94.     end
  95.     $game_map.need_refresh = true
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 着陆
  99.   #--------------------------------------------------------------------------
  100.   def end_shipping
  101.     # 获取带头的角色
  102.     actor = $game_party.actors[0]
  103.     # 设置角色的文件名及对像
  104.     @character_name = actor.character_name
  105.     @character_hue = actor.character_hue
  106.     # 关闭标志
  107.     @shipping = false
  108.     $game_switches[SHIPPING_SWITCH] = false
  109.     # 关闭停止时动画
  110.     @step_anime = false
  111.     # 回复速度
  112.     @move_speed = 4
  113.     # 设置船位置
  114.     @ship.ship_position = [$game_map.map_id, @old_x, @old_y]
  115.     @ship.moveto(@ship.ship_position[1], @ship.ship_position[2])
  116.     # 刷新地图
  117.     $game_map.need_refresh = true
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 向下移动
  121.   #     turn_enabled : 本场地位置更改许可标志
  122.   #--------------------------------------------------------------------------
  123.   def ship_move_down(turn_enabled = true)
  124.     # 面向下
  125.     if turn_enabled
  126.       turn_down
  127.     end
  128.     # 可以通行的场合
  129.     if ship_passable?(@x, @y, 2)
  130.       # 面向下
  131.       turn_down
  132.       # 更新坐标
  133.       @y += 1
  134.       # 增加步数
  135.       increase_steps
  136.     # 不能通行的情况下
  137.     else
  138.       # 接触事件的启动判定
  139.       check_event_trigger_touch(@x, @y+1)
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 向左移动
  144.   #     turn_enabled : 本场地位置更改许可标志
  145.   #--------------------------------------------------------------------------
  146.   def ship_move_left(turn_enabled = true)
  147.     # 面向左
  148.     if turn_enabled
  149.       turn_left
  150.     end
  151.     # 可以通行的情况下
  152.     if ship_passable?(@x, @y, 4)
  153.       # 面向左
  154.       turn_left
  155.       # 更新坐标
  156.       @x -= 1
  157.       # 增加步数
  158.       increase_steps
  159.     # 不能通行的情况下
  160.     else
  161.       # 接触事件的启动判定
  162.       check_event_trigger_touch(@x-1, @y)
  163.     end
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 向右移动
  167.   #     turn_enabled : 本场地位置更改许可标志
  168.   #--------------------------------------------------------------------------
  169.   def ship_move_right(turn_enabled = true)
  170.     # 面向右
  171.     if turn_enabled
  172.       turn_right
  173.     end
  174.     # 可以通行的场合
  175.     if ship_passable?(@x, @y, 6)
  176.       # 面向右
  177.       turn_right
  178.       # 更新坐标
  179.       @x += 1
  180.       # 增加部数
  181.       increase_steps
  182.     # 不能通行的情况下
  183.     else
  184.       # 接触事件的启动判定
  185.       check_event_trigger_touch(@x+1, @y)
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 向上移动
  190.   #     turn_enabled : 本场地位置更改许可标志
  191.   #--------------------------------------------------------------------------
  192.   def ship_move_up(turn_enabled = true)
  193.     # 面向上
  194.     if turn_enabled
  195.       turn_up
  196.     end
  197.     # 可以通行的情况下
  198.     if ship_passable?(@x, @y, 8)
  199.       # 面向上
  200.       turn_up
  201.       # 更新坐标
  202.       @y -= 1
  203.       # 歩数増加
  204.       increase_steps
  205.     # 不能通行的情况下
  206.     else
  207.       # 接触事件的启动判定
  208.       check_event_trigger_touch(@x, @y-1)
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 可以通行判定
  213.   #     x : X 坐标
  214.   #     y : Y 坐标
  215.   #     d : 方向 (0,2,4,6,8)  ※ 0 = 全方向不能通行的情况判定 (跳跃用)
  216.   #--------------------------------------------------------------------------
  217.   def ship_passable?(x, y, d)
  218.     # 求得新的坐标
  219.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  220.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  221.     # 坐标在地图以外的情况
  222.     unless $game_map.valid?(new_x, new_y)
  223.       # 不能通行
  224.       return false
  225.     end
  226.     # 穿透是 ON 的情况下
  227.     if @through
  228.       # 可以通行
  229.       return true
  230.     end
  231.     # 移动者的元件无法来到指定方向的情况下
  232.     unless $game_map.passable?(x, y, d, self)
  233.       # 通行不可
  234.       return false
  235.     end
  236.     # 从指定方向不能进入到移动处的元件的情况下
  237.     unless $game_map.passable?(new_x, new_y, 10 - d)
  238.       # 不能通行
  239.       return false
  240.     end
  241.     # 循环全部事件
  242.     for event in $game_map.events.values
  243.       # 事件坐标于移动目标坐标一致的情况下
  244.       if event.x == new_x and event.y == new_y
  245.         # 穿透为 ON
  246.         unless event.through
  247.           # 自己就是事件的情况下
  248.           if self != $game_player
  249.             # 不能通行
  250.             return false
  251.           end
  252.           # 自己是主角、对方的图形是角色的情况下
  253.           if event.character_name != ""
  254.             # 不能通行
  255.             return false
  256.           end
  257.         end
  258.       end
  259.     end
  260.     # 主角的坐标与移动目标坐标一致的情况下
  261.     if $game_player.x == new_x and $game_player.y == new_y
  262.       # 穿透为 ON
  263.       unless $game_player.through
  264.         # 自己的图形是角色的情况下
  265.         if @character_name != ""
  266.           # 不能通行
  267.           return false
  268.         end
  269.       end
  270.     end
  271.     # 地形标志判断通行
  272.     for i in [2, 1, 0]
  273.       tile_id = $game_map.data[new_x, new_y, i]
  274.       return false if tile_id == nil
  275.     end
  276.     if $game_map.terrain_tag(new_x, new_y) != TERRAIN_TAG
  277.       if passable?(new_x, new_y, 0)
  278.         @land = true
  279.         return true
  280.       end
  281.       return false
  282.     end
  283.     # 可以通行
  284.     return true
  285.   end
  286. end

  287. #==============================================================================
  288. # ■ Game_Map
  289. #------------------------------------------------------------------------------
  290. #  处理地图的类。包含卷动以及可以通行的判断功能。
  291. # 本类的实例请参考 $game_map 。
  292. #==============================================================================

  293. class Game_Map
  294.   attr_accessor :events                    # 事件
  295.   def setup_ship
  296.     return if $game_player.ship.nil?
  297.     # 航行中或船停泊在此则创建船事件
  298.     if $game_player.shipping or $game_player.ship.ship_position[0] == @map_id
  299.       id = @events.values.size + 1
  300.       # 防止事件错误
  301.       while @events[id] != nil
  302.         id += 1
  303.       end
  304.       @events[id] = $game_player.ship
  305.       @events[id].id = id
  306.       @events[id].map_id = @map_id
  307.       @events[id].moveto($game_player.ship.ship_position[1],
  308.       $game_player.ship.ship_position[2])
  309.       # 不在航行中则关闭开关使船出现
  310.       if !$game_player.shipping
  311.         $game_switches[SHIPPING_SWITCH] = false
  312.       end
  313.     end
  314.   end
  315. end

  316. #==============================================================================
  317. # ■ Game_Event
  318. #------------------------------------------------------------------------------
  319. #  处理事件的类。条件判断、事件页的切换、并行处理、执行事件功能
  320. # 在 Game_Map 类的内部使用。
  321. #==============================================================================

  322. class Game_Event < Game_Character
  323.   #--------------------------------------------------------------------------
  324.   # ● 定义实例变量
  325.   #--------------------------------------------------------------------------
  326.   attr_accessor :id                               # 事件ID
  327.   attr_accessor :map_id                           # 地图ID
  328.   attr_accessor :ship_position                    # 记录船位置数组
  329.   #--------------------------------------------------------------------------
  330.   # ● 越过目标判定 (不能将相同位置作为启动条件)
  331.   #--------------------------------------------------------------------------
  332.   def over_trigger?
  333.     # 图形是角色、没有开启穿透的情况下
  334.     if @character_name != "" and not @through
  335.       # 启动判定是正面
  336.       return false
  337.     end
  338.     # 地图上的这个位置不能通行,并且不在航海中的情况下
  339.     if !$game_map.passable?(@x, @y, 0) and $game_player.shipping != true
  340.       # 启动判定是正面
  341.       return false
  342.     end
  343.     # 启动判定在同位置
  344.     return true
  345.   end
  346.   def id=(new_id)
  347.     @id = new_id
  348.     @event.id = new_id
  349.   end
  350. end

  351. #==============================================================================
  352. # ■ Interpreter
  353. #------------------------------------------------------------------------------
  354. #  执行事件命令的解释器。本类在 Game_System 类
  355. # 与 Game_Event 类的内部使用。
  356. #==============================================================================

  357. class Interpreter
  358.   #--------------------------------------------------------------------------
  359.   # ● 开始航海
  360.   #--------------------------------------------------------------------------
  361.   def start_shipping
  362.     $game_player.start_shipping($game_map.events[@event_id])
  363.   end
  364. end
复制代码


这是航海的脚本



问题是

当有若干个“船”时,只要上一个船,其他的都会消失



[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: faust    时间: 2007-12-24 06:58
对了,这个还要配合NPC事件

但是我认为影响不大

作者: 六芒幽狐    时间: 2007-12-24 07:13
呵呵,正好我现在做得也用到了~

前几天才求到了答案,就说说吧~


用[效果:飞艇的制作方法]这个帖中方法制作船(工程在[RM大师天干宝典--癸卷]里有)

然后把事件中的第二页中,替换人物的图片修改为脚本:$game_player.refresh


就OK拉~ [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




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