hedgewars/uAIAmmoTests.pas
changeset 3697 d5b30d6373fc
parent 3677 7d917b587547
child 3710 411f5c2b5292
equal deleted inserted replaced
3695:c11abf387a7d 3697:d5b30d6373fc
   687     TestTeleport := BadTurn;
   687     TestTeleport := BadTurn;
   688     Level:= Level; // avoid compiler hint
   688     Level:= Level; // avoid compiler hint
   689     FillBonuses(true, [gtCase]);
   689     FillBonuses(true, [gtCase]);
   690     if bonuses.Count = 0 then begin
   690     if bonuses.Count = 0 then begin
   691         if Me^.Health <= 100  then begin
   691         if Me^.Health <= 100  then begin
   692             maxTop := Targ.Y - cHHRadius * 2; 
   692             maxTop := Targ.Y - cHHRadius * 2;
   693             while not TestColl(Targ.X, maxTop, cHHRadius) and (maxTop > topY + cHHRadius * 2 + 1) do
   693             while not TestColl(Targ.X, maxTop, cHHRadius) and (maxTop > topY + cHHRadius * 2 + 1) do
   694             dec(maxTop, cHHRadius*2);
   694             dec(maxTop, cHHRadius*2);
   695             if not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius) then begin
   695             if not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius) then begin
   696                 ap.AttackPutX := Targ.X;
   696                 ap.AttackPutX := Targ.X;
   697                 ap.AttackPutY := maxTop + cHHRadius;
   697                 ap.AttackPutY := maxTop + cHHRadius;
   699             end;
   699             end;
   700         end;
   700         end;
   701     end
   701     end
   702     else begin
   702     else begin
   703         failNum := 0;
   703         failNum := 0;
   704         repeat 
   704         repeat
   705             i := random(bonuses.Count);
   705             i := random(bonuses.Count);
   706             inc(failNum);
   706             inc(failNum);
   707         until not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) or (failNum = bonuses.Count*2);
   707         until not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) or (failNum = bonuses.Count*2);
   708         if failNum < bonuses.Count*2 then begin
   708         if failNum < bonuses.Count*2 then begin
   709             ap.AttackPutX := bonuses.ar[i].X;
   709             ap.AttackPutX := bonuses.ar[i].X;