|
楼主 |
发表于 2020-1-10 23:23:23
|
显示全部楼层
本帖最后由 reclus@tj 于 2020-1-13 07:59 编辑
function husongDashiStart()
flag.idle = nil
exe('少林护送任务中')
exe('set env_msg')
EnableTriggerGroup("husongDashiAsk",false)
EnableTriggerGroup("husongFinish",true)
local path, len = map:getPath(road.id,"hengshan/baiyunan")
road.husong=utils.split(path,";")
return checkWait(husongStep,2)
end
这个函数是公版护送机器人计算路径的函数,getPath(road.id,"hengshan/baiyunan"),就是得到A点(road.id)到B点"hengshan/baiyunan"的路径。
road.id是什么东西?就是房间的id,也就是类似"hengshan/baiyunan",翻译过来就是“恒山/白云庵”。
road.id在这里是起始房间,也就是说找到大师的房间,就从那个地方出发往白云庵走。
护镖的话就更简单了,领任务就在福威镖局林镇南那里,从那个地方到目的地,用这个函数就能自动生成路径。
road.husong=utils.split(path,";")
路径生成后,自动存入了变量path里,每一步都是用;号分割的,我们机器人走路就是exe(path)的,现在再用utils.split(path,";")拆分,看到一个;号就拆分一次,最终拆成east,norh...,一堆的走路stop,然后依次存入road.husong里。
function husongStep()
flag.idle = nil
EnableTriggerGroup("husongFinish",true)
if locl.room=="白云庵" then
return
end
if type(road.husong)~="table" then
return husongWhere()
end
if table.getn(road.husong)==0 then
return husongWhere()
end
if hp.qixue_per<60 then
exe('fu dan')
end
road.step = road.husong[1]
if isNil(road.step) or road.step=="halt" or road.step=="open gate" then
table.remove(road.husong,1)
return husongStep()
end
EnableTriggerGroup("husongJiaotu",true)
flag.jiaotu=nil
flag.lost=nil
if locl.room=="山门殿" then
exe('open gate')
end
if locl.room=="渡船" then
return husongBoat()
end
if locl.room=="陕晋渡口" and road.id=="changan/road2" then
exe('yell boat;enter')
-- ain
return check_halt(husongBoat)
end
exe(road.step)
exe('hp')
return check_halt(husongLocate)
end
这个函数就是走路或者推车控制了,大概就是判定当前是推车,那就从road.step里读一次方向,比如护镖就是tui north(往北推车),判定车子往北走了,或者队友把车推到北了,自己紧接着exe('north'),推一步走一步。
road.step = road.husong[1]
road.step一次读road.husong里边的第一个数据,一直读取到路径为空为止。
遇到过门,坐船等特殊状况,跳到特殊函数处理,例如:
if locl.room=="山门殿" then
exe('open gate')
end
if locl.room=="渡船" then
return husongBoat()
end
以上就是过门和坐船的特殊处理,就不能施展轻功渡江了,因为推车需要坐船,护送大师也要坐船的。
以上就是护送和护镖的走路原理,看懂了后,其实是非常非常简单的,照猫画虎抄过来就能用。
大家感兴趣可以自己试试。
|
|