hedgewars/uAI.pas
changeset 15447 6031c0cfec89
parent 15370 fcdb6e3a9d36
equal deleted inserted replaced
15446:61a0bd0bb021 15447:6031c0cfec89
   105     useThisActions: boolean;
   105     useThisActions: boolean;
   106 begin
   106 begin
   107 BotLevel:= Me^.Hedgehog^.BotLevel;
   107 BotLevel:= Me^.Hedgehog^.BotLevel;
   108 windSpeed:= hwFloat2Float(cWindSpeed);
   108 windSpeed:= hwFloat2Float(cWindSpeed);
   109 useThisActions:= false;
   109 useThisActions:= false;
       
   110 Me^.AIHints:= Me^.AIHints and (not aihAmmosChanged);
   110 
   111 
   111 for i:= 0 to Pred(Targets.Count) do
   112 for i:= 0 to Pred(Targets.Count) do
   112     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
   113     if (Targets.ar[i].Score >= 0) and (not StopThinking) then
   113         begin
   114         begin
   114         with Me^.Hedgehog^ do
   115         with Me^.Hedgehog^ do
   430 switchImmediatelyAvailable:= (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtSwitcher);
   431 switchImmediatelyAvailable:= (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtSwitcher);
   431 if Me^.Hedgehog^.BotLevel <> 5 then
   432 if Me^.Hedgehog^.BotLevel <> 5 then
   432     switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch)
   433     switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch)
   433 else switchCount:= 0;
   434 else switchCount:= 0;
   434 
   435 
   435 if ((Me^.State and gstAttacked) = 0) or isInMultiShoot or bonuses.activity then
   436 if ((Me^.State and gstAttacked) = 0) or isInMultiShoot or bonuses.activity or ((Me^.AIHints and aihAmmosChanged) <> 0) then
   436     if Targets.Count > 0 then
   437     if Targets.Count > 0 then
   437         begin
   438         begin
   438         // iterate over current team hedgehogs
   439         // iterate over current team hedgehogs
   439         repeat
   440         repeat
   440             WalkMe:= CurrentTeam^.Hedgehogs[itHedgehog].Gear^;
   441             WalkMe:= CurrentTeam^.Hedgehogs[itHedgehog].Gear^;
   476             BestActions.Count:= 0;
   477             BestActions.Count:= 0;
   477 
   478 
   478             FillBonuses(false);
   479             FillBonuses(false);
   479 
   480 
   480             // Hog has no idea what to do. Use tardis or skip
   481             // Hog has no idea what to do. Use tardis or skip
   481             if not bonuses.activity then
   482             if (not bonuses.activity) and ((Me^.AIHints and aihAmmosChanged) = 0) then
   482                 if (((GameFlags and gfInfAttack) <> 0) or (CurrentHedgehog^.MultiShootAttacks = 0)) and (HHHasAmmo(Me^.Hedgehog^, amTardis) > 0) and (CanUseTardis(Me^.Hedgehog^.Gear)) and (random(4) < 3) then
   483                 if (((GameFlags and gfInfAttack) <> 0) or (CurrentHedgehog^.MultiShootAttacks = 0)) and (HHHasAmmo(Me^.Hedgehog^, amTardis) > 0) and (CanUseTardis(Me^.Hedgehog^.Gear)) and (random(4) < 3) then
   483                     // Tardis brings hog to a random place. Perfect for clueless AI
   484                     // Tardis brings hog to a random place. Perfect for clueless AI
   484                     begin
   485                     begin
   485                     AddAction(BestActions, aia_Weapon, Longword(amTardis), 80, 0, 0);
   486                     AddAction(BestActions, aia_Weapon, Longword(amTardis), 80, 0, 0);
   486                     AddAction(BestActions, aia_attack, aim_push, 10, 0, 0);
   487                     AddAction(BestActions, aia_attack, aim_push, 10, 0, 0);
   487                     AddAction(BestActions, aia_attack, aim_release, 10, 0, 0);
   488                     AddAction(BestActions, aia_attack, aim_release, 10, 0, 0);
   488                     end
   489                     end
   489                 else
   490                 else
   490                     AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
   491                     AddAction(BestActions, aia_Skip, 0, 250, 0, 0);
       
   492             Me^.AIHints := ME^.AIHints and (not aihAmmosChanged);
   491             end;
   493             end;
   492 
   494 
   493         end else SDL_Delay(100)
   495         end else SDL_Delay(100)
   494 else
   496 else
   495     begin
   497     begin