hedgewars/uAIMisc.pas
changeset 13470 0d27f0c21b71
parent 13463 f1d349a52bc7
child 13472 d3209e0caf12
equal deleted inserted replaced
13469:2c7ae236b2d8 13470:0d27f0c21b71
   615                 end
   615                 end
   616             end;
   616             end;
   617 
   617 
   618 if hadSkips and (rate = 0) then
   618 if hadSkips and (rate = 0) then
   619     RealRateExplosion:= BadTurn
   619     RealRateExplosion:= BadTurn
   620     else
   620 else
   621     RealRateExplosion:= rate;
   621     RealRateExplosion:= rate;
   622 end;
   622 end;
   623 
   623 
   624 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   624 function RateShove(Me: PGear; x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt;
   625 var i, fallDmg, dmg, rate, subrate: LongInt;
   625 var i, fallDmg, dmg, rate, subrate: LongInt;
   626     dX, dY, pX, pY: real;
   626     dX, dY, pX, pY: real;
       
   627     hadSkips: boolean;
   627 begin
   628 begin
   628 fallDmg:= 0;
   629 fallDmg:= 0;
   629 dX:= gdX * 0.01 * kick;
   630 dX:= gdX * 0.01 * kick;
   630 dY:= gdY * 0.01 * kick;
   631 dY:= gdY * 0.01 * kick;
   631 rate:= 0;
   632 rate:= 0;
       
   633 hadSkips:= false;
   632 for i:= 0 to Pred(Targets.Count) do
   634 for i:= 0 to Pred(Targets.Count) do
   633     with Targets.ar[i] do
   635     with Targets.ar[i] do
   634         if skip then
   636         if skip then
   635             begin
   637             begin
   636             if Flags and afSetSkip = 0 then skip:= false
   638             if Flags and afSetSkip = 0 then skip:= false
   693                          subrate:= RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall))
   695                          subrate:= RealRateExplosion(Me, round(pX), round(pY), 151, afErasesLand or (Flags and afTrackFall))
   694                     else subrate:= RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall));
   696                     else subrate:= RealRateExplosion(Me, round(pX), round(pY), 101, afErasesLand or (Flags and afTrackFall));
   695                     if abs(subrate) > 2000 then inc(Rate,subrate div 1024);
   697                     if abs(subrate) > 2000 then inc(Rate,subrate div 1024);
   696                     end
   698                     end
   697                 end
   699                 end
   698             end;
   700             end
   699 RateShove:= rate * 1024;
   701         else
       
   702             hadSkips:= true;
       
   703 
       
   704 if hadSkips and (rate = 0) then
       
   705     RateShove:= BadTurn
       
   706 else
       
   707     RateShove:= rate * 1024;
   700 ResetTargets
   708 ResetTargets
   701 end;
   709 end;
   702 
   710 
   703 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   711 function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt;
   704 var i, dmg, fallDmg, baseDmg, rate, subrate, erasure: LongInt;
   712 var i, dmg, fallDmg, baseDmg, rate, subrate, erasure: LongInt;
   799                 end
   807                 end
   800             end;
   808             end;
   801 
   809 
   802 if hadSkips and (rate = 0) then
   810 if hadSkips and (rate = 0) then
   803     RateShotgun:= BadTurn
   811     RateShotgun:= BadTurn
   804     else
   812 else
   805     RateShotgun:= rate * 1024;
   813     RateShotgun:= rate * 1024;
   806     ResetTargets;
   814 ResetTargets;
   807 end;
   815 end;
   808 
   816 
   809 function RateHammer(Me: PGear): LongInt;
   817 function RateHammer(Me: PGear): LongInt;
   810 var x, y, i, r, rate: LongInt;
   818 var x, y, i, r, rate: LongInt;
       
   819     hadSkips: boolean;
   811 begin
   820 begin
   812 // hammer hit shift against attecker hog is 10
   821 // hammer hit shift against attecker hog is 10
   813 x:= hwRound(Me^.X) + hwSign(Me^.dX) * 10;
   822 x:= hwRound(Me^.X) + hwSign(Me^.dX) * 10;
   814 y:= hwRound(Me^.Y);
   823 y:= hwRound(Me^.Y);
   815 rate:= 0;
   824 rate:= 0;
   816 
   825 hadSkips:= false;
   817 for i:= 0 to Pred(Targets.Count) do
   826 for i:= 0 to Pred(Targets.Count) do
   818     with Targets.ar[i] do
   827     with Targets.ar[i] do
   819          // hammer hit radius is 8, shift is 10
   828          // hammer hit radius is 8, shift is 10
   820       if matters and (Kind = gtHedgehog) and (abs(Point.x - x) + abs(Point.y - y) < 18) then
   829       if (not matters) then
       
   830           hadSkips:= true
       
   831       else if matters and (Kind = gtHedgehog) and (abs(Point.x - x) + abs(Point.y - y) < 18) then
   821             begin
   832             begin
   822             r:= trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)));
   833             r:= trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)));
   823 
   834 
   824             if r <= 18 then
   835             if r <= 18 then
   825                 if Score > 0 then
   836                 if Score > 0 then
   826                     inc(rate, Score div 3)
   837                     inc(rate, Score div 3)
   827                 else
   838                 else
   828                     inc(rate, Score div 3 * friendlyfactor div 100)
   839                     inc(rate, Score div 3 * friendlyfactor div 100)
   829             end;
   840             end;
   830 RateHammer:= rate * 1024;
   841 
       
   842 if hadSkips and (rate = 0) then
       
   843     RateHammer:= BadTurn
       
   844 else
       
   845     RateHammer:= rate * 1024;
   831 end;
   846 end;
   832 
   847 
   833 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   848 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   834 var bX, bY: LongInt;
   849 var bX, bY: LongInt;
   835 begin
   850 begin