hedgewars/uAI.pas
changeset 83 207c85fbef51
parent 82 2f4f3236cccc
child 95 1ef5e2c41115
equal deleted inserted replaced
82:2f4f3236cccc 83:207c85fbef51
    79               inc(BestActions.Score, Score + Targets.ar[i].Score);
    79               inc(BestActions.Score, Score + Targets.ar[i].Score);
    80               AddAction(BestActions, aia_Weapon, Longword(a), 500);
    80               AddAction(BestActions, aia_Weapon, Longword(a), 500);
    81               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400);
    81               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400);
    82               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200)
    82               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200)
    83               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200);
    83               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200);
    84               Angle:= integer(Me.Angle) - Abs(Angle);
    84               if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
    85               if Angle > 0 then
       
    86                  begin
    85                  begin
    87                  AddAction(BestActions, aia_Up, aim_push, 500);
    86                  Angle:= integer(Me.Angle) - Abs(Angle);
    88                  AddAction(BestActions, aia_Up, aim_release, Angle)
    87                  if Angle > 0 then
    89                  end else if Angle < 0 then
    88                     begin
    90                  begin
    89                     AddAction(BestActions, aia_Up, aim_push, 500);
    91                  AddAction(BestActions, aia_Down, aim_push, 500);
    90                     AddAction(BestActions, aia_Up, aim_release, Angle)
    92                  AddAction(BestActions, aia_Down, aim_release, -Angle)
    91                     end else if Angle < 0 then
       
    92                     begin
       
    93                     AddAction(BestActions, aia_Down, aim_push, 500);
       
    94                     AddAction(BestActions, aia_Down, aim_release, -Angle)
       
    95                     end
    93                  end;
    96                  end;
    94               AddAction(BestActions, aia_attack, aim_push, 800);
    97               AddAction(BestActions, aia_attack, aim_push, 800);
    95               AddAction(BestActions, aia_attack, aim_release, Power);
    98               AddAction(BestActions, aia_attack, aim_release, Power);
    96               if ExplR > 0 then
    99               if ExplR > 0 then
    97                  AddAction(BestActions, aia_AwareExpl, ExplR, 10, ExplX, ExplY);
   100                  AddAction(BestActions, aia_AwareExpl, ExplR, 10, ExplX, ExplY);
   148     begin
   151     begin
   149     i:= 0;
   152     i:= 0;
   150     Result:= false;
   153     Result:= false;
   151     while (i < Stack.Count) and not Result do
   154     while (i < Stack.Count) and not Result do
   152           begin
   155           begin
   153           Result:= abs(Stack.States[i].Hedgehog.X - Me.X) +
   156           Result:= (abs(Stack.States[i].Hedgehog.X - Me.X) +
   154                    abs(Stack.States[i].Hedgehog.Y - Me.Y) <= 2;
   157                     abs(Stack.States[i].Hedgehog.Y - Me.Y) <= 2)
       
   158                     and (Stack.States[i].Hedgehog.Message = Me.Message);
   155           inc(i)
   159           inc(i)
   156           end
   160           end
   157     end;
   161     end;
   158 
   162 
   159 
   163