hedgewars/uAIAmmoTests.pas
changeset 8998 d38fb4158342
parent 8974 d360e97ce842
child 9005 15a6ed0bd074
equal deleted inserted replaced
8997:c3a4731f0d84 8998:d38fb4158342
   169         EX:= trunc(x);
   169         EX:= trunc(x);
   170         EY:= trunc(y);
   170         EY:= trunc(y);
   171         if Level = 1 then
   171         if Level = 1 then
   172             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   172             value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
   173         else value:= RateExplosion(Me, EX, EY, 101);
   173         else value:= RateExplosion(Me, EX, EY, 101);
   174         if (value = 0) and (Targ.Kind = gtHedgehog) then
   174         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   175             value:= 1024 - Metric(Targ.Point.X, Targ.Point.Y, EX, EY) div 64;
   175             value:= 1024 - Metric(Targ.Point.X, Targ.Point.Y, EX, EY) div 64;
   176         if valueResult <= value then
   176         if valueResult <= value then
   177             begin
   177             begin
   178             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   178             ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
   179             ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   179             ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
   605            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, EX, EY, 4))) or (EY > cWaterLine);
   605            ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, EX, EY, 4))) or (EY > cWaterLine);
   606 
   606 
   607     if (EY < cWaterLine) and (dY >= 0) then
   607     if (EY < cWaterLine) and (dY >= 0) then
   608         begin
   608         begin
   609         Score:= RateExplosion(Me, EX, EY, 91);
   609         Score:= RateExplosion(Me, EX, EY, 91);
   610         if (Score = 0) then
   610         if (Score = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   611             if (dY > 0.15) then
   611             if (dY > 0.15) then
   612                 Score:= - abs(Targ.Point.Y - EY) div 32
   612                 Score:= - abs(Targ.Point.Y - EY) div 32
   613             else
   613             else
   614                 Score:= BadTurn
   614                 Score:= BadTurn
   615         else if (Score < 0) then
   615         else if (Score < 0) then
   616             Score:= BadTurn
   616             Score:= BadTurn
   617         end
   617         end
   618     else
   618     else
   619         Score:= BadTurn;
   619         Score:= BadTurn;
   620 
   620 
   621     if BadTurn < Score then
   621     if Score > 0 then
   622         begin
   622         begin
   623         ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   623         ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
   624         ap.Power:= 1;
   624         ap.Power:= 1;
   625         ap.ExplR:= 100;
   625         ap.ExplR:= 100;
   626         ap.ExplX:= EX;
   626         ap.ExplX:= EX;
   660     begin
   660     begin
   661         x:= x + vX * 8;
   661         x:= x + vX * 8;
   662         y:= y + vY * 8;
   662         y:= y + vY * 8;
   663         valueResult:= RateShotgun(Me, vX, vY, rx, ry);
   663         valueResult:= RateShotgun(Me, vX, vY, rx, ry);
   664 
   664 
   665         if (valueResult = 0) and (Targ.Kind = gtHedgehog) then
   665         if (valueResult = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   666             valueResult:= 1024 - Metric(Targ.Point.X, Targ.Point.Y, rx, ry) div 64
   666             valueResult:= 1024 - Metric(Targ.Point.X, Targ.Point.Y, rx, ry) div 64
   667         else
   667         else
   668             dec(valueResult, Level * 4000);
   668             dec(valueResult, Level * 4000);
   669         // 27/20 is reuse bonus
   669         // 27/20 is reuse bonus
   670         exit(valueResult * 27 div 20)
   670         exit(valueResult * 27 div 20)