From a4cd661ed88d976263ac206a6d0cc174e734240e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 20 Sep 2020 01:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E6=89=A7=E8=A1=8C=E5=89=A9?= =?UTF-8?q?=E4=BD=99=E9=83=A8=E5=88=86CC=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E4=B9=9F=E8=AE=B8=E4=B8=8D=E4=BC=9A=E5=86=8D=E9=97=AA=E9=80=80?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/ai.lua | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/parts/ai.lua b/parts/ai.lua index 4be089bf..37ea87ee 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -335,31 +335,36 @@ return{ return 2 end, function(P,ctrl)--Poll keys - local success,dest,hold,move=CC.getMove(P.AI_bot) - if success==2 then - ins(ctrl,6) - return 3 - elseif success==0 then - for i=1,#dest do - for j=1,#dest[i]do - dest[i][j]=dest[i][j]+1 + local success,result,dest,hold,move=pcall(CC.getMove,P.AI_bot) + if success then + if result==2 then + ins(ctrl,6) + return 3 + elseif result==0 then + for i=1,#dest do + for j=1,#dest[i]do + dest[i][j]=dest[i][j]+1 + end end - end - P.AI_dest=dest - if hold then ctrl[1]=8 end--Hold - while move[1]do - local m=rem(move,1) - if m<4 then - ins(ctrl,m+1) - elseif not P.AIdata._20G then - ins(ctrl,13) + P.AI_dest=dest + if hold then ctrl[1]=8 end--Hold + while move[1]do + local m=rem(move,1) + if m<4 then + ins(ctrl,m+1) + elseif not P.AIdata._20G then + ins(ctrl,13) + end end + ins(ctrl,6) + return 3 + else + --Stay this stage + return 2 end - ins(ctrl,6) - return 3 else - --Stay this stage - return 2 + LOG.print("CC is dead ("..P.id..")","error") + return 0 end end, function(P)--Check if time to change target