hedgewars/uAI.pas
changeset 602 f7628ebfccde
parent 599 7c7b90c402d3
child 676 2aa3082937ac
equal deleted inserted replaced
601:78a68cc4d846 602:f7628ebfccde
    43    repeat
    43    repeat
    44      SDL_Delay(10)
    44      SDL_Delay(10)
    45    until hasThread = 0
    45    until hasThread = 0
    46    end;
    46    end;
    47 
    47 
    48 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
    48 with CurrentHedgehog^ do
    49      if Gear <> nil then
    49      if Gear <> nil then
    50         if BotLevel <> 0 then
    50         if BotLevel <> 0 then
    51            begin
    51            begin
    52            if (Gear^.Message and gm_Left) <> 0 then ParseCommand('-left', true);
    52            if (Gear^.Message and gm_Left) <> 0 then ParseCommand('-left', true);
    53            if (Gear^.Message and gm_Right) <> 0 then ParseCommand('-right', true);
    53            if (Gear^.Message and gm_Right) <> 0 then ParseCommand('-right', true);
    66 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
    66 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
    67 
    67 
    68 for i:= 0 to Pred(Targets.Count) do
    68 for i:= 0 to Pred(Targets.Count) do
    69     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    69     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
    70        begin
    70        begin
    71        with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
    71        with CurrentHedgehog^ do
    72             a:= Ammo^[CurSlot, CurAmmo].AmmoType;
    72             a:= Ammo^[CurSlot, CurAmmo].AmmoType;
    73        aa:= a;
    73        aa:= a;
    74        repeat
    74        repeat
    75         if (CanUseAmmo[a]) and
    75         if (CanUseAmmo[a]) and
    76            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
    76            ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then
   113               end
   113               end
   114            end;
   114            end;
   115         if a = High(TAmmoType) then a:= Low(TAmmoType)
   115         if a = High(TAmmoType) then a:= Low(TAmmoType)
   116                                else inc(a)
   116                                else inc(a)
   117        until (a = aa) or
   117        until (a = aa) or
   118              (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].AttacksNum > 0) or
   118              (CurrentHedgehog^.AttacksNum > 0) or
   119              StopThinking
   119              StopThinking
   120        end
   120        end
   121 end;
   121 end;
   122 
   122 
   123 procedure Walk(Me: PGear);
   123 procedure Walk(Me: PGear);
   315 
   315 
   316 procedure ProcessBot;
   316 procedure ProcessBot;
   317 const StartTicks: Longword = 0;
   317 const StartTicks: Longword = 0;
   318       cStopThinkTime = 40;
   318       cStopThinkTime = 40;
   319 begin
   319 begin
   320 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do
   320 with CurrentHedgehog^ do
   321      if (Gear <> nil)
   321      if (Gear <> nil)
   322         and ((Gear^.State and gstHHDriven) <> 0)
   322         and ((Gear^.State and gstHHDriven) <> 0)
   323         and (TurnTimeLeft < cHedgehogTurnTime - 50) then
   323         and (TurnTimeLeft < cHedgehogTurnTime - 50) then
   324         if ((Gear^.State and gstHHThinking) = 0) then
   324         if ((Gear^.State and gstHHThinking) = 0) then
   325            if (BestActions.Pos >= BestActions.Count)
   325            if (BestActions.Pos >= BestActions.Count)