|
楼主 |
发表于 2019-2-24 00:11:44
|
显示全部楼层
2.主函数(起始函数)初始化。
本帖最后由 liumaisj@tj 于 2019-2-25 17:37 编辑
function wudang()--武当任务主函数,也是起始调用的函数
if hp.shen<0 then
return turnShen('+')--这个应该是判定正神不够,可以自动转换正神的,但是turnshen这个函数没找到,看来已经没有这个功能了!
end
wudangTrigger()--这个就是调用之前讲的武当触发器定义了。
job.level=nil--这些是变量初始化,这里先不讲作用,等遇到了再解释。
job.lost=0
job.name='wudang'--任务名称初始化为‘wudang’,这个非常非常关键,很多功能的调用都是通过这个来控制的,比如肚子饿了,发出咕咕声,如果判断是处于任务中,则不会去吃喝,否则就会战斗中突然跑去吃喝,导致任务失败。
return check_halt(wudangGo)--以上程序跑完后,接下一个函数wudangGo,check_halt的作用就是检查不忙后,再调用wudangGo
end
-------------
function wudangGo()--到达武当山,三清殿后,准备要任务。
return go(wudangBegin,"武当山","三清殿")--go这个函数的使用,在小猪猪的教学贴里有详细介绍,这里就不介绍了,大家可以去看看。
end
function wudangBegin()--要任务前的准备,如果是newbie,也就是选择了任务前内力准备,则返回内力准备,否则直接调用wdstart
if newbie==1 then return zhunbeineili(wdstart) else return wdstart() end
end
function wdstart()--武当任务开始,先执行prepare_lianxi,然后再执行wudangStart
return prepare_lianxi(wudangStart)
end
----------
大家也许会奇怪,为什么要任务前,要检查内力,检查练习呢?
原来做任务前,内力不足的话,会导致战斗失败,而状态busy,则无法要到任务,所以检查内力和检查是否busy,就分别由zhunbeineili()和prepare_lianxi()两个函数完成。
先看prepare_lianxi(),它是定义在job.lua中。
prepare_lianxi=function(func)--这个函数是带参数的,(func)就是参数,是一个函数参数。
prepare_trigger()
EnableTriggerGroup("prepare_neili",true)
flag.prepare=1
if func~=nil then--如果函数参数不为空,则job.prepare=func,后边就可以调用这个函数参数了。
job.prepare=func
else
job.prepare=test
end
condition={}
exe('cond')--这里是检查condition状态,看看是否busy.
return check_busy(prepareLianxi)--最后转去函数prepareLianxi(),check_busy()就是检查是否busy,小猪猪的帖子有详细解释。
end
function prepareLianxi()--这个函数就是真正的准备练习技能的函数了。
if mydummy==true then--如果发现有大米出现,则直接转去做大米任务。
EnableTriggerGroup("prepare_neili",false)
DeleteTriggerGroup("prepare_neili")
return dummyfind()
end
if (not condition.busy or condition.busy == 0) and job.prepare~=duHhe_start and job.prepare~=duCjiang_start then--如果不busy,也不是渡江渡河开始状态,则转去内力准备
return prepare_neili(job.prepare)--这里就是先内力准备,然后执行job.prepare,这个变量在上边已经赋值为func这个参数了,也就是wudangStart
end
if condition.busy>60 then --如果busy>60秒,则练功和打坐等待。
if score.party=="姑苏慕容" and need_dzxy=="yes" and dzxy_level==3 and hp.food>50 and hp.water>50 and (locl.time=="戊" or locl.time=="亥" or locl.time=="子" or locl.time=="丑" ) then
messageShow("任务监控:是三段斗转星移,而且是晚上,可以去看星星领悟斗转星移了!","white")
return check_halt(checkdzxy)
end
end
flag.jixu=1
if hp.neili_max>hp.neili_lim-10 then
exe('unset 积蓄')
elseif job.prepare and (job.prepare==test or job.prepare==duHhe_start or job.prepare==duCjiang_start) then
exe('unset 积蓄')
else
flag.jixu=0
exe('unset 积蓄')
end
if job.zuhe["gblu"] and not locl.id["铜钱"] and hp.exp<2000000 then exe('drop 1 coin') end
prepare_neili_a()
end
----------
prepare_neili=function(func,p_cmd)--准备内力函数异常复杂,后边还调用了prepare_neili_a,prepare_neili_b,prepare_neili_c等等,这里就不详细介绍了,将来有机会另外开贴详细介绍。
local l_db
if func~=nil then
job.prepare=func
else
job.prepare=test
end
tmp.db=p_cmd
l_db=1/2
if tmp.db and type(tmp.db)=="number" and tmp.db<2 then
l_db=tmp.db
end
if hp.neili>hp.neili_max*l_db and job.prepare~=test and job.prepare~=fight_prepare then
return check_bei(job.prepare)
end
prepare_trigger()
EnableTriggerGroup("prepare_neili",true)
flag.jixu=1
exe('unset 积蓄')
flag.prepare=0
exe('yun jing;yun jingli;hp')
if job.zuhe["gblu"] and not locl.id["铜钱"] then exe('drop 1 coin') end
prepare_neili_a()
end
-----
好了,今天这贴是关于武当任务初始化的,大家只需要记住几个关键点!
1.wudang()函数是初始化函数,将触发器和变量等初始化。
2.去武当山,三清殿,用go函数找宋远桥要任务。
3.zhunbeineili(任务前准备内力),preparelianxi(如果busy则练功等待,否则就跳转去准备内力) |
评分
-
1
查看全部评分
-
|