|
早上发现shaolin/sengshe3地图出了问题
看了下locate 的记录是当成了sengshe2
很有意思我就看了看代码
第一反应就是sengshe3居然没有room_relative,然后跑过去locate一把拷贝了下来
所以第一个改动
- - rooms.lua
- Room {
- id = "shaolin/sengshe3",
- name = "僧舍",
- no_fight = true,
- ways = {
- ["north"] = "shaolin/sengshe1",
- },
- room_relative="僧舍|僧舍僧舍",
- }
复制代码
但是sengshe3 和僧舍2的relative秒输是一样的?
那怎么处理呢?
第一反应最简单就是学比别的地图写个肯定成功的路径,例如n,n,s 或者s,s,n 保证跑到sengshe1就能找对位置了
但是这样就不能灌水了啊!
所以我们来改善下写法
目前path_consider如果遇到同名房间,做法就是比较room_relative
拿第一个相同的房间来尝试行走。
那我们能不能比较下出口呢?
众所周知,出口在地图的ways里面有, 当前房间也存在了exit.locl.那就改造下把!
ways是hashmap类型表格,key是路径方向,例如north, south.
exit.locl 是类array表格,key是数字,value是方向
所以我们写个简单的方程把ways的key拿出来比较
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
复制代码
然后就是改造path_consider,这里代码也不复杂,我懒得打字,大家看看吧。。
- for i = 1, table.getn(sour.rooms) do
- local roomInfo = map.rooms[sour.rooms[i]]
- if (locl.room_relation ~= '' and
- roomInfo.room_relative == locl.room_relation) then
- if exit.locl and roomInfo.ways and #exit.locl == tablelength(roomInfo.ways) then
- local match = true
- for k,v in ipairs(exit.locl) do
- if not roomInfo.ways[v] then
- match = false
- end
- end
- if match then
- sour.id = sour.rooms[i]
- chats_locate('定位系统:尝试精确定位!猜测目前位置为'..sour.id,
- 'LimeGreen')
- return check_halt(path_consider)
- end
- else
- chats_locate('定位系统:尝试精确定位!',
- 'LimeGreen')
- sour.id = sour.rooms[i]
- return check_halt(path_consider)
- end
- -- return go(road.act,dest.area,dest.room,sour.rooms[i])
- end
- end
复制代码
|
评分
-
1
查看全部评分
-
|