hedgewars/uAIAmmoTests.pas
changeset 15728 cc8882e46784
parent 15706 f2930fe1b6d0
child 15729 34138bf36c5c
equal deleted inserted replaced
15727:f9c2fd4bfb3e 15728:cc8882e46784
   651         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   651         until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or
   652                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t < -timeLimit);
   652                ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t < -timeLimit);
   653 
   653 
   654         EX:= trunc(x);
   654         EX:= trunc(x);
   655         EY:= trunc(y);
   655         EY:= trunc(y);
   656 
       
   657         // Sanity check 1: Make sure we're not too close to impact location
       
   658         range:= Metric(trunc(meX), trunc(meY), EX, EY);
   656         range:= Metric(trunc(meX), trunc(meY), EX, EY);
   659         if (range < 150) and (Level < 5) then
   657 
   660             exit(BadTurn);
   658         // Sanity check 1: Make sure we've hit a hedgehog or object
   661 
   659         if not TestCollHogsOrObjects(EX, EY, 5) then
   662         // Sanity check 2: If impact location is close, above us and wind blows
   660             value:= BadTurn
       
   661         // Sanity check 2: Make sure we're not too close to impact location
       
   662         else if (range < 150) and (Level < 5) then
       
   663             value:= BadTurn
       
   664         // Sanity check 3: If impact location is close, above us and wind blows
   663         // towards us, there's a risk of fire flying towards us, so fail in this case.
   665         // towards us, there's a risk of fire flying towards us, so fail in this case.
   664         if (Level < 3) and (range <= 600) and (trunc(meY) >= EX) and
   666         else if (Level < 3) and (range <= 600) and (trunc(meY) >= EX) and
   665             (((ap.Angle < 0) and (aiWindSpeed > 0)) or ((ap.Angle > 0) and (aiWindSpeed < 0))) then
   667             (((ap.Angle < 0) and (aiWindSpeed > 0)) or ((ap.Angle > 0) and (aiWindSpeed < 0))) then
   666             exit(BadTurn);
   668             value:= BadTurn
   667 
   669         // Timeout
   668         if t >= -timeLimit then
   670         else if t < -timeLimit then
   669             value:= RateExplosion(Me, EX, EY, 97) // average of 17 attempts, most good, but some failing spectacularly
   671             value:= BadTurn
   670         else
   672         else
   671             value:= BadTurn;
   673         // Valid hit!
       
   674             // Weapon does not actually explode, so this rating is an approximation
       
   675             value:= RateExplosion(Me, EX, EY, 97); // average of 17 attempts, most good, but some failing spectacularly
   672 
   676 
   673         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   677         if (value = 0) and (Targ.Kind = gtHedgehog) and (Targ.Score > 0) then
   674             value := BadTurn;
   678             value := BadTurn;
   675 
   679 
   676         if (valueResult < value) or ((valueResult = value) and (Level < 3)) then
   680         if (valueResult < value) or ((valueResult = value) and (Level < 3)) then