hedgewars/uAI.pas
changeset 8946 3e07b8ff2ae1
parent 8938 c321264439c6
child 8959 ad680848a5c9
equal deleted inserted replaced
8944:ed2509832311 8946:3e07b8ff2ae1
   375 switchImmediatelyAvailable:= (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtSwitcher);
   375 switchImmediatelyAvailable:= (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtSwitcher);
   376 if Me^.Hedgehog^.BotLevel <> 5 then
   376 if Me^.Hedgehog^.BotLevel <> 5 then
   377     switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch)
   377     switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch)
   378 else switchCount:= 0;
   378 else switchCount:= 0;
   379 
   379 
   380 if (Me^.State and gstAttacked) = 0 then
   380 if ((Me^.State and gstAttacked) = 0) or isInMultiShoot then
   381     if Targets.Count > 0 then
   381     if Targets.Count > 0 then
   382         begin
   382         begin
   383         // iterate over current team hedgehogs
   383         // iterate over current team hedgehogs
   384         repeat
   384         repeat
   385             WalkMe:= CurrentTeam^.Hedgehogs[itHedgehog].Gear^;
   385             WalkMe:= CurrentTeam^.Hedgehogs[itHedgehog].Gear^;
   424 
   424 
   425         end else SDL_Delay(100)
   425         end else SDL_Delay(100)
   426 else
   426 else
   427     begin
   427     begin
   428     BackMe:= Me^;
   428     BackMe:= Me^;
   429     while (not StopThinking) and (BestActions.Count = 0) do
   429     i:= 12;
       
   430     while (not StopThinking) and (BestActions.Count = 0) and (i > 0) do
   430         begin
   431         begin
   431 (*
   432 (*
   432         // Maybe this would get a bit of movement out of them? Hopefully not *toward* water. Need to check how often he'd choose that strategy
   433         // Maybe this would get a bit of movement out of them? Hopefully not *toward* water. Need to check how often he'd choose that strategy
   433         if SuddenDeathDmg and ((hwRound(BackMe.Y)+cWaterRise*2) > cWaterLine) then
   434         if SuddenDeathDmg and ((hwRound(BackMe.Y)+cWaterRise*2) > cWaterLine) then
   434             AddBonus(hwRound(BackMe.X), hwRound(BackMe.Y), 250, -40);
   435             AddBonus(hwRound(BackMe.X), hwRound(BackMe.Y), 250, -40);
   437         WalkMe:= BackMe;
   438         WalkMe:= BackMe;
   438         Actions.Count:= 0;
   439         Actions.Count:= 0;
   439         Actions.Pos:= 0;
   440         Actions.Pos:= 0;
   440         Actions.Score:= 0;
   441         Actions.Score:= 0;
   441         Walk(@WalkMe, Actions);
   442         Walk(@WalkMe, Actions);
       
   443         dec(i);
   442         if not StopThinking then
   444         if not StopThinking then
   443             SDL_Delay(100)
   445             SDL_Delay(100)
   444         end
   446         end
   445     end;
   447     end;
   446 
   448 
   475     begin
   477     begin
   476     OutError('AI: no targets!?', false);
   478     OutError('AI: no targets!?', false);
   477     exit
   479     exit
   478     end;
   480     end;
   479 
   481 
   480 FillBonuses((Me^.State and gstAttacked) <> 0);
   482 FillBonuses(((Me^.State and gstAttacked) <> 0) and (not isInMultiShoot));
   481 
   483 
   482 SDL_LockMutex(ThreadLock);
   484 SDL_LockMutex(ThreadLock);
   483 ThinkThread:= SDL_CreateThread(@Think{$IFDEF SDL13}, 'think'{$ENDIF}, Me);
   485 ThinkThread:= SDL_CreateThread(@Think{$IFDEF SDL13}, 'think'{$ENDIF}, Me);
   484 SDL_UnlockMutex(ThreadLock);
   486 SDL_UnlockMutex(ThreadLock);
   485 end;
   487 end;