hedgewars/uAIMisc.pas
changeset 8956 e0e914642e73
parent 8955 b8cae4fe8edb
child 8957 bdeb52d57dae
equal deleted inserted replaced
8955:b8cae4fe8edb 8956:e0e914642e73
   113 Targets.reset:= false;
   113 Targets.reset:= false;
   114 end;
   114 end;
   115 procedure FillTargets;
   115 procedure FillTargets;
   116 var i, t: Longword;
   116 var i, t: Longword;
   117     f, e: LongInt;
   117     f, e: LongInt;
   118     iter: PGear;
   118     Gear: PGear;
   119 begin
   119 begin
   120 Targets.Count:= 0;
   120 Targets.Count:= 0;
   121 Targets.reset:= false;
   121 Targets.reset:= false;
   122 f:= 0;
   122 f:= 0;
   123 e:= 0;
   123 e:= 0;
   124 iter:= GearsList;
   124 Gear:= GearsList;
   125 while iter <> nil do
   125 while Gear <> nil do
   126     begin
   126     begin
   127     if  ((iter^.Kind = gtHedgehog) and
   127     if  ((Gear^.Kind = gtHedgehog) and
   128             (iter <> ThinkingHH) and
   128             (Gear <> ThinkingHH) and
   129             (iter^.Health > iter^.Damage) and
   129             (Gear^.Health > Gear^.Damage) and
   130             not(iter^.Hedgehog^.Team^.hasgone)) or
   130             not(Gear^.Hedgehog^.Team^.hasgone)) or
   131         ((iter^.Kind = gtExplosives) and
   131         ((Gear^.Kind = gtExplosives) and
   132             (iter^.Health > iter^.Damage)) or
   132             (Gear^.Health > Gear^.Damage)) or
   133         ((iter^.Kind = gtMine) and
   133         ((Gear^.Kind = gtMine) and
   134             (iter^.Health = 0) and
   134             ((Gear^.Health = 0) and
   135             (iter^.Damage < 35)) and
   135              (Gear^.Damage < 35)) or
       
   136             ((Gear^.Health > 0) and 
       
   137              (cMineDudPercent > 95) and
       
   138              (cMinesTime < 3000)) 
       
   139              ) and
   136         (Targets.Count < 256) then
   140         (Targets.Count < 256) then
   137         begin
   141         begin
   138         with Targets.ar[Targets.Count] do
   142         with Targets.ar[Targets.Count] do
   139             begin
   143             begin
   140             skip:= false;
   144             skip:= false;
   141             dead:= false;
   145             dead:= false;
   142             Kind:= iter^.Kind;
   146             Kind:= Gear^.Kind;
   143             matters:= (iter^.AIHints and aihDoesntMatter) = 0;
   147             matters:= (Gear^.AIHints and aihDoesntMatter) = 0;
   144 
   148 
   145             Point.X:= hwRound(iter^.X);
   149             Point.X:= hwRound(Gear^.X);
   146             Point.Y:= hwRound(iter^.Y);
   150             Point.Y:= hwRound(Gear^.Y);
   147             if (iter^.Kind = gtHedgehog) then
   151             if (Gear^.Kind = gtHedgehog) then
   148                 begin
   152                 begin
   149                 if (iter^.Hedgehog^.Team^.Clan = CurrentTeam^.Clan) then
   153                 if (Gear^.Hedgehog^.Team^.Clan = CurrentTeam^.Clan) then
   150                     begin
   154                     begin
   151                     Score:= iter^.Damage - iter^.Health;
   155                     Score:= Gear^.Damage - Gear^.Health;
   152                     inc(f)
   156                     inc(f)
   153                     end
   157                     end
   154                 else 
   158                 else 
   155                     begin
   159                     begin
   156                     Score:= iter^.Health - iter^.Damage;
   160                     Score:= Gear^.Health - Gear^.Damage;
   157                     inc(e)
   161                     inc(e)
   158                     end;
   162                     end;
   159                 Density:= 1;
   163                 Density:= 1;
   160                 end
   164                 end
   161             else if iter^.Kind = gtExplosives then
   165             else if Gear^.Kind = gtExplosives then
   162                 begin
   166                 begin
   163                 Score:= iter^.Health - iter^.Damage;
   167                 Score:= Gear^.Health - Gear^.Damage;
   164                 Density:= 2
   168                 Density:= 2
   165                 end
   169                 end
   166             else if iter^.Kind = gtMine then 
   170             else if Gear^.Kind = gtMine then 
   167                 begin
   171                 begin
   168                 Score:= max(0,35-iter^.Damage);
   172                 Score:= max(0,35-Gear^.Damage);
   169                 Density:= 1/3
   173                 Density:= 1/3
   170                 end
   174                 end
   171             end;
   175             end;
   172         inc(Targets.Count)
   176         inc(Targets.Count)
   173         end;
   177         end;
   174     iter:= iter^.NextGear
   178     Gear:= Gear^.NextGear
   175     end;
   179     end;
   176 
   180 
   177 if e > f then friendlyfactor:= 300 + (e - f) * 30
   181 if e > f then friendlyfactor:= 300 + (e - f) * 30
   178 else friendlyfactor:= max(30, 300 - f * 80 div max(1,e))
   182 else friendlyfactor:= max(30, 300 - f * 80 div max(1,e))
   179 end;
   183 end;