hedgewars/uAIMisc.pas
changeset 8951 95dd846caf5d
parent 8950 3bf81ed1f984
child 8952 a6ee1e7310fb
equal deleted inserted replaced
8950:3bf81ed1f984 8951:95dd846caf5d
   426     RateExplosion:= RealRateExplosion(Me, x, y, r, Flags);
   426     RateExplosion:= RealRateExplosion(Me, x, y, r, Flags);
   427     ResetTargets;
   427     ResetTargets;
   428 end;
   428 end;
   429 
   429 
   430 function RealRateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
   430 function RealRateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt;
   431 var i, fallDmg, dmg, dmgBase, rate, erasure: LongInt;
   431 var i, fallDmg, dmg, dmgBase, rate, subrate, erasure: LongInt;
   432     pX, pY, dX, dY: real;
   432     pX, pY, dX, dY: real;
   433     hadSkips: boolean;
   433     hadSkips: boolean;
   434 begin
   434 begin
   435 fallDmg:= 0;
   435 fallDmg:= 0;
   436 rate:= 0;
   436 rate:= 0;
   486                     else if (dmg+fallDmg) >= abs(Score) then
   486                     else if (dmg+fallDmg) >= abs(Score) then
   487                         begin
   487                         begin
   488                         dead:= true;
   488                         dead:= true;
   489                         Targets.reset:= true;
   489                         Targets.reset:= true;
   490                         if dX < 0.035 then
   490                         if dX < 0.035 then
   491                             inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or (Flags and afTrackFall)));
   491                             begin
       
   492                             subrate:= RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or (Flags and afTrackFall));
       
   493                             if abs(subrate) > 2000 then inc(Rate,subrate)
       
   494                             end;
   492                         if Score > 0 then
   495                         if Score > 0 then
   493                              inc(rate, KillScore * 1024 + (dmg + fallDmg)) // tiny bonus for dealing more damage than needed to kill
   496                              inc(rate, KillScore * 1024 + (dmg + fallDmg)) // tiny bonus for dealing more damage than needed to kill
   494                         else dec(rate, KillScore * friendlyfactor div 100 * 1024)
   497                         else dec(rate, KillScore * friendlyfactor div 100 * 1024)
   495                         end
   498                         end
   496                     else
   499                     else
   504                 else if (Kind <> gtHedgehog) and (FallDmg >= 0) and ((dmg+fallDmg) >= Score) then
   507                 else if (Kind <> gtHedgehog) and (FallDmg >= 0) and ((dmg+fallDmg) >= Score) then
   505                     begin
   508                     begin
   506                     dead:= true;
   509                     dead:= true;
   507                     Targets.reset:= true;
   510                     Targets.reset:= true;
   508                     if Kind = gtExplosives then
   511                     if Kind = gtExplosives then
   509                          inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall)))
   512                          subrate:= RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall))
   510                     else inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall)))
   513                     else subrate:= RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall));
       
   514                     if abs(subrate) > 2000 then inc(Rate,subrate);
   511                     end
   515                     end
   512                 end
   516                 end
   513             end;
   517             end;
   514 
   518 
   515 if hadSkips and (rate = 0) then
   519 if hadSkips and (rate = 0) then
   517     else
   521     else
   518     RealRateExplosion:= rate;
   522     RealRateExplosion:= rate;
   519 end;
   523 end;
   520 
   524 
   521 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   525 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   522 var i, fallDmg, dmg, rate: LongInt;
   526 var i, fallDmg, dmg, rate, subrate: LongInt;
   523     dX, dY, pX, pY: real;
   527     dX, dY, pX, pY: real;
   524 begin
   528 begin
   525 fallDmg:= 0;
   529 fallDmg:= 0;
   526 dX:= gdX * 0.01 * kick;
   530 dX:= gdX * 0.01 * kick;
   527 dY:= gdY * 0.01 * kick;
   531 dY:= gdY * 0.01 * kick;
   555                 else if power+fallDmg >= abs(Score) then
   559                 else if power+fallDmg >= abs(Score) then
   556                     begin
   560                     begin
   557                     dead:= true;
   561                     dead:= true;
   558                     Targets.reset:= true;
   562                     Targets.reset:= true;
   559                     if dX < 0.035 then
   563                     if dX < 0.035 then
   560                         inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or (Flags and afTrackFall)) div 1024);
   564                         begin
       
   565                         subrate:= RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or afTrackFall);
       
   566                         if abs(subrate) > 2000 then inc(Rate,subrate div 1024)
       
   567                         end;
   561                     if Score > 0 then
   568                     if Score > 0 then
   562                         inc(rate, KillScore)
   569                         inc(rate, KillScore)
   563                     else
   570                     else
   564                         dec(rate, KillScore * friendlyfactor div 100)
   571                         dec(rate, KillScore * friendlyfactor div 100)
   565                     end
   572                     end
   575             else if (Kind <> gtHedgehog) and (fallDmg >= 0) and ((power+fallDmg) >= Score) then
   582             else if (Kind <> gtHedgehog) and (fallDmg >= 0) and ((power+fallDmg) >= Score) then
   576                 begin
   583                 begin
   577                 dead:= true;
   584                 dead:= true;
   578                 Targets.reset:= true;
   585                 Targets.reset:= true;
   579                 if Kind = gtExplosives then
   586                 if Kind = gtExplosives then
   580                      inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall)) div 1024)
   587                      subrate:= RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall))
   581                 else inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall)) div 1024)
   588                 else subrate:= RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall));
       
   589                 if abs(subrate) > 2000 then inc(Rate,subrate div 1024);
   582                 end
   590                 end
   583             end
   591             end
   584         end;
   592         end;
   585 RateShove:= rate * 1024
   593 RateShove:= rate * 1024
   586 end;
   594 end;
   587 
   595 
   588 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   596 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   589 var i, dmg, fallDmg, baseDmg, rate, erasure: LongInt;
   597 var i, dmg, fallDmg, baseDmg, rate, subrate, erasure: LongInt;
   590     pX, pY, dX, dY: real;
   598     pX, pY, dX, dY: real;
   591     hadSkips: boolean;
   599     hadSkips: boolean;
   592 begin
   600 begin
   593 rate:= 0;
   601 rate:= 0;
   594 gdX:= gdX * 0.01;
   602 gdX:= gdX * 0.01;
   646                     else if (dmg+fallDmg) >= abs(Score) then
   654                     else if (dmg+fallDmg) >= abs(Score) then
   647                         begin
   655                         begin
   648                         dead:= true;
   656                         dead:= true;
   649                         Targets.reset:= true;
   657                         Targets.reset:= true;
   650                         if dX < 0.035 then
   658                         if dX < 0.035 then
   651                             inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or afTrackFall) div 1024);
   659                             begin
       
   660                             subrate:= RealRateExplosion(Me, round(pX), round(pY), 61, afErasesLand or afTrackFall);
       
   661                             if abs(subrate) > 2000 then inc(Rate,subrate div 1024)
       
   662                             end;
   652                         if Score > 0 then
   663                         if Score > 0 then
   653                             inc(rate, KillScore)
   664                             inc(rate, KillScore)
   654                         else
   665                         else
   655                             dec(rate, KillScore * friendlyfactor div 100)
   666                             dec(rate, KillScore * friendlyfactor div 100)
   656                         end
   667                         end
   662                 else if (Kind <> gtHedgehog) and (fallDmg >= 0) and ((dmg+fallDmg) >= Score) then
   673                 else if (Kind <> gtHedgehog) and (fallDmg >= 0) and ((dmg+fallDmg) >= Score) then
   663                     begin
   674                     begin
   664                     dead:= true;
   675                     dead:= true;
   665                     Targets.reset:= true;
   676                     Targets.reset:= true;
   666                     if Kind = gtExplosives then
   677                     if Kind = gtExplosives then
   667                          inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or afTrackFall) div 1024)
   678                          subrate:= RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or afTrackFall)
   668                     else inc(Rate,RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or afTrackFall) div 1024)
   679                     else subrate:= RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or afTrackFall);
       
   680                     if abs(subrate) > 2000 then inc(Rate,subrate div 1024);
   669                     end
   681                     end
   670                 end
   682                 end
   671             end;
   683             end;
   672 
   684 
   673 if hadSkips and (rate = 0) then
   685 if hadSkips and (rate = 0) then