hedgewars/uAIMisc.pas
changeset 509 fd58135a4407
parent 498 9c8b385dc9a1
child 542 ec26095f1bed
equal deleted inserted replaced
508:f5473c50adbd 509:fd58135a4407
    41 procedure AwareOfExplosion(x, y, r: LongInt);
    41 procedure AwareOfExplosion(x, y, r: LongInt);
    42 function RatePlace(Gear: PGear): LongInt;
    42 function RatePlace(Gear: PGear): LongInt;
    43 function TestColl(x, y, r: LongInt): boolean;
    43 function TestColl(x, y, r: LongInt): boolean;
    44 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
    44 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt;
    45 function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
    45 function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt;
       
    46 function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
    46 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
    47 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
    47 function AIrndSign(num: LongInt): LongInt;
    48 function AIrndSign(num: LongInt): LongInt;
    48 
    49 
    49 var ThinkingHH: PGear;
    50 var ThinkingHH: PGear;
    50     Targets: TTargets;
    51     Targets: TTargets;
   182          begin
   183          begin
   183          dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
   184          dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
   184          if dmg > 0 then
   185          if dmg > 0 then
   185             begin
   186             begin
   186             dmg:= dmg shr 1;
   187             dmg:= dmg shr 1;
   187             if dmg > abs(Score) then
   188             if dmg >= abs(Score) then
   188                if Score > 0 then inc(Result, KillScore)
   189                if Score > 0 then inc(Result, KillScore)
   189                             else dec(Result, KillScore * 3)
   190                             else dec(Result, KillScore * 3)
   190             else
   191             else
   191                if Score > 0 then inc(Result, dmg)
   192                if Score > 0 then inc(Result, dmg)
   192                             else dec(Result, dmg * 3)
   193                             else dec(Result, dmg * 3)
   203     with Targets.ar[i] do
   204     with Targets.ar[i] do
   204          begin
   205          begin
   205          dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
   206          dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
   206          if dmg > 0 then
   207          if dmg > 0 then
   207             begin
   208             begin
   208             if power > abs(Score) then
   209             if power >= abs(Score) then
   209                if Score > 0 then inc(Result, KillScore)
   210                if Score > 0 then inc(Result, KillScore)
   210                             else dec(Result, KillScore * 3)
   211                             else dec(Result, KillScore * 3)
   211             else
   212             else
   212                if Score > 0 then inc(Result, power)
   213                if Score > 0 then inc(Result, power)
   213                             else dec(Result, power * 3)
   214                             else dec(Result, power * 3)
   214             end;
   215             end;
   215          end;
   216          end;
   216 RateShove:= Result * 1024
   217 RateShove:= Result * 1024
       
   218 end;
       
   219 
       
   220 function RateShotgun(Me: PGear; x, y: LongInt): LongInt;
       
   221 var i, dmg, Result: LongInt;
       
   222 begin
       
   223 Result:= 0;
       
   224 // add our virtual position
       
   225 with Targets.ar[Targets.Count] do
       
   226      begin
       
   227      Point.x:= hwRound(Me^.X);
       
   228      Point.y:= hwRound(Me^.Y);
       
   229      Score:= - ThinkingHH^.Health
       
   230      end;
       
   231 // rate shot
       
   232 for i:= 0 to Targets.Count do
       
   233     with Targets.ar[i] do
       
   234          begin
       
   235          dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25);
       
   236          if dmg > 0 then
       
   237             begin
       
   238             if dmg >= abs(Score) then
       
   239                if Score > 0 then inc(Result, KillScore)
       
   240                             else dec(Result, KillScore * 3)
       
   241             else
       
   242                if Score > 0 then inc(Result, dmg)
       
   243                             else dec(Result, dmg * 3)
       
   244             end;
       
   245          end;
       
   246 RateShotgun:= Result * 1024
   217 end;
   247 end;
   218 
   248 
   219 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   249 function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean;
   220 var bX, bY: LongInt;
   250 var bX, bY: LongInt;
   221     Result: boolean;
   251     Result: boolean;