hedgewars/uAIMisc.pas
changeset 5645 b434ba5d064e
parent 5642 0ce9e01bae56
child 5881 099464aab4b6
equal deleted inserted replaced
5642:0ce9e01bae56 5645:b434ba5d064e
    54 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean;
    54 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean;
    55 function TestColl(x, y, r: LongInt): boolean;
    55 function TestColl(x, y, r: LongInt): boolean;
    56 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
    56 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
    57 function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
    57 function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
    58 function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
    58 function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
       
    59 function RateHammer(Me: PGear): LongInt;
    59 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
    60 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
    60 function AIrndSign(num: LongInt): LongInt;
    61 function AIrndSign(num: LongInt): LongInt;
    61 
    62 
    62 var ThinkingHH: PGear;
    63 var ThinkingHH: PGear;
    63     Targets: TTargets;
    64     Targets: TTargets;
   293                 if Score > 0 then inc(rate, dmg)
   294                 if Score > 0 then inc(rate, dmg)
   294                 else dec(rate, dmg * friendlyfactor div 100);
   295                 else dec(rate, dmg * friendlyfactor div 100);
   295             end;
   296             end;
   296          end;        
   297          end;        
   297 RateShotgun:= rate * 1024;
   298 RateShotgun:= rate * 1024;
       
   299 end;
       
   300 
       
   301 function RateHammer(Me: PGear): LongInt;
       
   302 var x, y, i, r, rate: LongInt;
       
   303 begin
       
   304 // hammer hit shift against attecker hog is 10
       
   305 x:= hwRound(Me^.X) + hwSign(Me^.dX) * 10;
       
   306 y:= hwRound(Me^.Y);
       
   307 rate:= 0;
       
   308 
       
   309 for i:= 0 to Pred(Targets.Count) do
       
   310     with Targets.ar[i] do
       
   311          begin
       
   312          // hammer hit radius is 8, shift is 10
       
   313          r:= hwRound(DistanceI(Point.x - x, Point.y - y));
       
   314 
       
   315          if r <= 18 then
       
   316             if Score > 0 then 
       
   317                 inc(rate, Score div 3)
       
   318                 else 
       
   319                 inc(rate, Score div 3 * friendlyfactor div 100)
       
   320          end;
       
   321 RateHammer:= rate * 1024;
   298 end;
   322 end;
   299 
   323 
   300 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   324 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   301 var bX, bY: LongInt;
   325 var bX, bY: LongInt;
   302     bRes: boolean;
   326     bRes: boolean;