| 赞 | 481  | 
 
| VIP | 56 | 
 
| 好人卡 | 75 | 
 
| 积分 | 471 | 
 
| 经验 | 124650 | 
 
| 最后登录 | 2025-11-4 | 
 
| 在线时间 | 7739 小时 | 
 
 
 
 
 
Lv5.捕梦者 (管理员) 老黄鸡 
	- 梦石
 - 4 
 
        - 星屑
 - 43131 
 
        - 在线时间
 - 7739 小时
 
        - 注册时间
 - 2009-7-6
 
        - 帖子
 - 13548
 
 
     
 
 | 
	
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员  
 
x
 
 本帖最后由 fux2 于 2012-7-1 16:02 编辑  
 
终于独立写出了自己的脚本……   
可能有很多BUG,欢迎大家指出. 
 
嘛,有的时候在游戏里走迷宫啊什么的,走错路很蛋疼。 
啦啦,这个脚本的通途跟指南针啊,导游啊什么的差不多。 
详细说明在脚本的注释里了,看看吧 
 
findwayplus.rar
(216.69 KB, 下载次数: 113)
 
范例下载3 
以下是脚本- # 跨地图寻路 by fux2
 
 - # 感谢九夜神尊纠正错误和提供技术支持
 
 - # rpg.blue
 
 - #
 
 - # 喵,说明下用法,在事件脚本里输入:
 
 - #
 
 - # findway(目标所在地图ID,目标X,目标Y),停止命令stopfindway
 
 - #
 
 - # 即可出现导航箭头~~照着目标走一般就可以到目的地啦~
 
 - # 此脚本只负责找到可以通向目标的地图,途中障碍神马的无法判读(是你懒吧!)
 
 - # 还有只能判断常规的事件移动指令,是否需要自动、并行处理事件可以在79行修改
 
 - # 需要自动行走的可以自行添加(PIA飞!)
 
 - # 箭头图像"Graphics/Arrow/Arrow.png".  197行可以修改
 
 - # 喵,欢迎来 http://rpg.blue/?65553 逛逛~
 
 - #
 
 - #============================================================================
 
  
- # 当前地图的目标和箭头显示开关
 
 - $target = nil    
 
 - $arrowswitch = false
 
 - $getallevent = false
 
 - $havefindmapid = []                 # 用于记录所有找到的传送事件
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 寻找地图类
 
 -   #--------------------------------------------------------------------------
 
 - class SearchMap
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 初始化
 
 -   #--------------------------------------------------------------------------
 
 -   def initialize
 
 -     @currentmapid = 1                   # 记录当前地图ID
 
 -     @faildcount = 0                     # 寻路失败次数
 
 -     @realway = []                       # 正确的路地图以及事件ID
 
 -     @havefindmap = []                   # realway寻找过的地图
 
 -     @fakeway = []                       # 错误的路地图以及事件ID
 
 -     @checkways = []                     # 用于检查正确的路是否改变
 
 -     @targetx = 0                        # 目标的X坐标
 
 -     @targety = 0                        # 目标的Y坐标
 
 -     @currrenttargetid = 0               # 记录当前地图的正确传送事件ID
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 获取当前地图ID
 
 -   #--------------------------------------------------------------------------
 
 -   def get_currentmapId
 
 -     @currentmapid = $game_map.map_id
 
 -     return @currentmapid 
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 获取最大地图数目
 
 -   #--------------------------------------------------------------------------
 
 -   def get_maxmapid
 
 -     $data_mapinfos = load_data("Data/MapInfos.rxdata")
 
 -     return $data_mapinfos.size
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 修改目标地图ID
 
 -   #--------------------------------------------------------------------------
 
 -   def targetmapid=(mapid)
 
 -     @targetmapid = mapid
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 数组子项是否包含
 
 -   #--------------------------------------------------------------------------
 
 -   def included(arr,str)
 
 -     arr.each do |i|
 
 -       if i.include?(str)
 
 -         return true
 
 -       end
 
 -     end
 
 -     return false
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 找出通行路径与获得传送事件ID
 
 -   #--------------------------------------------------------------------------
 
 -   def getway(firsttarget,targetx,targety)
 
 -     @targetx = targetx
 
 -     @targety = targety
 
 -     maxmapid = get_maxmapid
 
 -     nowmapid = get_currentmapId
 
 -     target = firsttarget
 
 -     done = false
 
 -     while done == false
 
 -     # 获取全部传送事件
 
 -       if $getallevent == false
 
 -         for workcount in 1..maxmapid
 
 -           temp = load_data(sprintf("Data/Map%03d.rxdata", workcount))
 
 -           for ev in temp.events.values
 
 -             for page in ev.pages
 
 -               for eventline in page.list
 
 -                 # 过滤非传送事件、已寻找过事件、自动、并行处理事件.
 
 -                 if eventline.code == 201 && $havefindmapid.include?([workcount,ev.id,eventline.parameters[1]]) == false && page.trigger != 3 && page.trigger != 4
 
 -                   $havefindmapid.push [workcount,ev.id,eventline.parameters[1]]
 
 -                 end
 
 -               end
 
 -             end
 
 -           end
 
 -         end
 
 -         # 打开开关以只搜寻一次所有传送事件
 
 -         $getallevent = true
 
 -       else
 
 -         # 检查所有传送事件是否符合正确的路径
 
 -         for checkcount in 0..$havefindmapid.size - 1
 
 -           finded = false
 
 -           tempcheck = $havefindmapid[checkcount]
 
 -           tempmapid = target
 
 -           if tempcheck[2] == tempmapid && @havefindmap.include?(tempcheck[2]) == false && @realway.include?([tempcheck[0],tempcheck[1],tempcheck[2]]) == false && @fakeway.include?([tempcheck[0],tempcheck[1],tempcheck[2]]) == false && finded == false
 
 -             @realway += [tempcheck]
 
 -             @havefindmap.push tempcheck[2]
 
 -             @currrenttargetid = tempcheck[1]
 
 -             target = tempcheck[0] 
 
 -             finded = true
 
 -             @faildcount = 0
 
 -           end
 
 -         end
 
 -         # 如果目标就在当前地图(表示找到了~)
 
 -         if target == nowmapid
 
 -           done = true
 
 -           $targetid = @currrenttargetid
 
 -           $trueway = @realway
 
 -           $truetarget = @havefindmap
 
 -         # 如果没有找到目标且真实路径在上一次没有改变
 
 -         elsif @realway == @checkways
 
 -           if @faildcount >= 2
 
 -             done = true
 
 -             if $tempVariable1 != nil
 
 -               # 初始化目标
 
 -               $tempVariable1 = 0
 
 -               $tempVariable2 = 0
 
 -               $tempVariable3 = 0
 
 -               $targetid = nil
 
 -               $arrowswitch = false
 
 -               $game_player.move_backward    # 为了避免重复对话,后退一步,可以修改
 
 -               $game_temp.message_text = "目标无法到达."
 
 -             end
 
 -           else
 
 -             # 如果没有找到路径则失败次数加1并且清空目前的正确道路
 
 -             @faildcount += 1
 
 -             @fakeway.push @realway[@realway.size - 1]
 
 -             @realway = []
 
 -             @havefindmap = []
 
 -             target = firsttarget
 
 -           end
 
 -         else
 
 -         # 没有找到目标且真实路径改变
 
 -           @checkways = @realway
 
 -         end
 
 -       end
 
 -     end
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 当地图更改时更改导航指针
 
 -   #--------------------------------------------------------------------------
 
 -   def changeway
 
 -     check = false
 
 -     finded = false
 
 -     nowmapid = get_currentmapId
 
 -     # 当前地图是否在正确路径列表中
 
 -     for i in 0..$truetarget.size - 1
 
 -       if $trueway[i][0] == nowmapid && finded == false
 
 -         $targetid = $trueway[i][1]
 
 -         finded = true
 
 -       end
 
 -     end
 
 -     # 如果走出了正确道路则检查是否能返回
 
 -     if finded == false
 
 -       for j in 0..$havefindmapid.size - 1
 
 -         if $havefindmapid[j][0] == nowmapid && included($trueway,$havefindmapid[j][2]) && check == false
 
 -           $trueway.push $havefindmapid[j]
 
 -           check = true
 
 -         end
 
 -       end
 
 -       # 如果无法返回则……
 
 -       if check == false
 
 -         check = true
 
 -         Interpreter.new.stopfindway
 
 -         $game_temp.message_text = "乃偏移了导航并且这里无法返回原来的路."
 
 -       end
 
 -     end
 
 -   end
 
  
- end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 获取事件内容
 
 -   #--------------------------------------------------------------------------
 
 - class Game_Event < Game_Character
 
 -   # 获取事件内容
 
 -   def parameters
 
 -     return @parameters
 
 -   end
 
 -   # 获取运行编号
 
 -   def code
 
 -     return @code
 
 -   end
 
 -   # 获取触发方式
 
 -   def trigger
 
 -     return @trigger
 
 -   end
 
 - end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 在分割定义里增加方法
 
 -   #--------------------------------------------------------------------------
 
 - class Interpreter
 
 -   # 打开导航
 
 -   def findway(firsttarget,targetx,targety)
 
 -     # 如果和上次指定目标一样,则不重新扫描
 
 -     unless firsttarget == $tempVariable1 or targetx == $tempVariable2 or targety == $tempVariable3
 
 -       $tempVariable1 = firsttarget
 
 -       $tempVariable2 = targetx
 
 -       $tempVariable3 = targety
 
 -       SearchMap.new.getway($tempVariable1,$tempVariable2,$tempVariable3)
 
 -     end
 
 -     $arrowswitch = true
 
 -   end
 
 -   
 
 -   # 关闭导航
 
 -   def stopfindway
 
 -     $arrowswitch = false
 
 -     return
 
 -   end
 
 - end
 
  
 
-   #--------------------------------------------------------------------------
 
 -   # ● 在地图上描绘箭头的类
 
 -   #--------------------------------------------------------------------------
 
 - class ArrowGuide < Window_Base
 
 -   def initialize
 
 -   super(0 , 0, 640, 480)
 
 -     self.opacity = 0
 
 -     self.back_opacity = 0
 
 -     self.contents_opacity = 255
 
 -     self.contents = Bitmap.new(608, 448)
 
 -   end
 
 -   
 
 -   def SetArrow   
 
 -     unless $targetid == nil || $arrowswitch == false || $tempVariable1 == nil
 
 -       # 获取地图ID以判断地图是否变化
 
 -       nowmapid = $game_map.map_id
 
 -       if nowmapid != @id 
 
 -         @id = nowmapid 
 
 -         unless nowmapid == $tempVariable1
 
 -           SearchMap.new.changeway
 
 -         end
 
 -       end      
 
 -       # 开始描绘箭头
 
 -       self.contents.clear
 
 -       bitmap = Bitmap.new("Graphics/Arrow/Arrow.png")
 
 -       src_rect = Rect.new(0, 0, 100, 100)
 
 -       # 是否在目标位置
 
 -       unless nowmapid == $tempVariable1 || $game_map.events[$targetid] == nil
 
 -         x = $game_map.events[$targetid].screen_x
 
 -         y = $game_map.events[$targetid].screen_y
 
 -       else
 
 -         x = ($tempVariable2 * 128 - $game_map.display_x + 3) / 4 + 16
 
 -         y = ($tempVariable3 * 128 - $game_map.display_y + 3) / 4 + 32
 
 -       end
 
 -         # 判断目标位置
 
 -         if y < 48
 
 -           sy = 0
 
 -         elsif y > 464
 
 -           sy = 416
 
 -         else
 
 -           sy = y - 48
 
 -         end
 
 -         # 囧
 
 -         if x < 32
 
 -           sx = 0
 
 -         elsif x > 608
 
 -           sx = 576
 
 -         else
 
 -           sx = x - 32
 
 -         end
 
 -       self.contents.blt(sx, sy, bitmap, src_rect)
 
 -     else
 
 -       self.contents.clear
 
 -     end
 
 -   end
 
 - end
 
  
-   #--------------------------------------------------------------------------
 
 -   # ● 在地图上描绘箭头
 
 -   #--------------------------------------------------------------------------
 
 - class Scene_Map
 
 -   # 不必理解
 
 -   alias fux2 main
 
 -   def main
 
 -     @arrow = ArrowGuide.new
 
 -     fux2
 
 -     @arrow.dispose
 
 -   end
 
 -   
 
 -   alias fux2update update
 
 -   def update
 
 -     @arrow.SetArrow
 
 -     fux2update
 
 -   end
 
 - end
 
  复制代码 |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |