hedgewars/uAIMisc.pas
changeset 10164 0570d4b22187
parent 10140 a846641d2b04
child 10354 56bd029245fc
equal deleted inserted replaced
10163:b994afa40326 10164:0570d4b22187
    53     X, Y: LongInt;
    53     X, Y: LongInt;
    54     Radius: LongInt;
    54     Radius: LongInt;
    55     Score: LongInt;
    55     Score: LongInt;
    56      end;
    56      end;
    57 
    57 
    58 Tbonuses = record
    58 TBonuses = record
       
    59           activity: boolean;
    59           Count : Longword;
    60           Count : Longword;
    60           ar    : array[0..Pred(MAXBONUS)] of TBonus;
    61           ar    : array[0..Pred(MAXBONUS)] of TBonus;
    61        end;
    62        end;
    62 
    63 
    63 Twalkbonuses =  record
    64 Twalkbonuses =  record
    90 function  AIrndSign(num: LongInt): LongInt;
    91 function  AIrndSign(num: LongInt): LongInt;
    91 
    92 
    92 var ThinkingHH: PGear;
    93 var ThinkingHH: PGear;
    93     Targets: TTargets;
    94     Targets: TTargets;
    94 
    95 
    95     bonuses: Tbonuses;
    96     bonuses: TBonuses;
    96 
    97 
    97     walkbonuses: Twalkbonuses;
    98     walkbonuses: Twalkbonuses;
    98 
    99 
    99 const KillScore = 200;
   100 const KillScore = 200;
   100 var friendlyfactor: LongInt = 300;
   101 var friendlyfactor: LongInt = 300;
   207 var Gear: PGear;
   208 var Gear: PGear;
   208     MyClan: PClan;
   209     MyClan: PClan;
   209     i: Longint;
   210     i: Longint;
   210 begin
   211 begin
   211 bonuses.Count:= 0;
   212 bonuses.Count:= 0;
       
   213 bonuses.activity:= false;
   212 MyClan:= ThinkingHH^.Hedgehog^.Team^.Clan;
   214 MyClan:= ThinkingHH^.Hedgehog^.Team^.Clan;
   213 Gear:= GearsList;
   215 Gear:= GearsList;
   214 while Gear <> nil do
   216 while Gear <> nil do
   215     begin
   217     begin
   216         case Gear^.Kind of
   218         case Gear^.Kind of
       
   219             gtGrenade
       
   220             , gtClusterBomb
       
   221             , gtGasBomb
       
   222             , gtShell
       
   223             , gtAirAttack
       
   224             , gtMortar
       
   225             , gtWatermelon
       
   226             , gtDrill
       
   227             , gtAirBomb
       
   228             , gtCluster
       
   229             , gtMelonPiece
       
   230             , gtMolotov: bonuses.activity:= true;
   217             gtCase:
   231             gtCase:
   218                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y) + 3, 37, 25);
   232                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y) + 3, 37, 25);
   219             gtFlame:
   233             gtFlame:
   220                 if (Gear^.State and gsttmpFlag) <> 0 then
   234                 if (Gear^.State and gsttmpFlag) <> 0 then
   221                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50);
   235                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50);
   222 // avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow
   236 // avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow
   223             gtMine:
   237             gtMine: begin
       
   238                 if (Gear^.State and gstMoving) <> 0 then bonuses.activity:= true;
       
   239                 
   224                 if ((Gear^.State and gstAttacking) = 0) and (((cMineDudPercent < 90) and (Gear^.Health <> 0))
   240                 if ((Gear^.State and gstAttacking) = 0) and (((cMineDudPercent < 90) and (Gear^.Health <> 0))
   225                 or (isAfterAttack and (Gear^.Health = 0) and (Gear^.Damage > 30))) then
   241                 or (isAfterAttack and (Gear^.Health = 0) and (Gear^.Damage > 30))) then
   226                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
   242                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50)
   227                 else if (Gear^.State and gstAttacking) <> 0 then
   243                 else if (Gear^.State and gstAttacking) <> 0 then
   228                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
   244                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
       
   245                 end;
   229 
   246 
   230             gtExplosives:
   247             gtExplosives:
   231             if isAfterAttack then
   248                 begin
   232                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 75, -60 + Gear^.Health);
   249                 //if (Gear^.State and gstMoving) <> 0 then bonuses.activity:= true;
   233 
   250 
   234             gtSMine:
   251                 if isAfterAttack then
       
   252                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 75, -60 + Gear^.Health);
       
   253                 end;
       
   254 
       
   255             gtSMine: begin
       
   256                 if (Gear^.State and (gstMoving or gstAttacking)) <> 0 then bonuses.activity:= true;
       
   257 
   235                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30);
   258                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30);
       
   259                 end;
   236 
   260 
   237             gtDynamite:
   261             gtDynamite:
       
   262                 begin
       
   263                 bonuses.activity:= true;
   238                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
   264                 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
       
   265                 end;
   239 
   266 
   240             gtHedgehog:
   267             gtHedgehog:
   241                 begin
   268                 begin
       
   269                 if (ThinkingHH <> Gear) 
       
   270                     and (((Gear^.State and (gstMoving or gstDrowning or gstHHDeath)) <> 0) 
       
   271                         or (Gear^.Health = 0)
       
   272                         or (Gear^.Damage >= Gear^.Health)) 
       
   273                     then begin
       
   274                     bonuses.activity:= true;
       
   275                     end;
       
   276                 
   242                 if Gear^.Damage >= Gear^.Health then
   277                 if Gear^.Damage >= Gear^.Health then
   243                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25)
   278                     AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25)
   244                 else
   279                 else
   245                     if isAfterAttack
   280                     if isAfterAttack
   246                       and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog)
   281                       and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog)
   251                             AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3)
   286                             AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3)
   252                 end;
   287                 end;
   253             end;
   288             end;
   254     Gear:= Gear^.NextGear
   289     Gear:= Gear^.NextGear
   255     end;
   290     end;
       
   291 
   256 if isAfterAttack and (KnownExplosion.Radius > 0) then
   292 if isAfterAttack and (KnownExplosion.Radius > 0) then
   257     with KnownExplosion do
   293     with KnownExplosion do
   258         AddBonus(X, Y, Radius + 10, -Radius);
   294         AddBonus(X, Y, Radius + 10, -Radius);
   259 if isAfterAttack then
   295 if isAfterAttack then
   260     begin
   296     begin