hedgewars/uAI.pas
changeset 48 0f396d0c429d
parent 17 a6bed8d31444
child 51 b6e3ae05857f
--- a/hedgewars/uAI.pas	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/uAI.pas	Thu Jan 12 22:07:36 2006 +0000
@@ -37,7 +37,7 @@
 procedure ProcessBot;
 
 implementation
-uses uAIActions, uAIMisc, uMisc, uTeams, uConsts, uAIAmmoTests, uGears, SDLh;
+uses uAIActions, uAIMisc, uMisc, uTeams, uConsts, uAIAmmoTests, uGears, SDLh, uConsole;
 
 procedure Think;
 var Targets: TTargets;
@@ -56,7 +56,8 @@
          Me.Y:= round(Gear.Y);
          end;
     repeat
-      if isInMultiShoot then with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
+      if isInMultiShoot or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum > 0)
+                        then with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
                              a:= Ammo[CurSlot, CurAmmo].AmmoType
                         else a:= TAmmoType(random(ord(High(TAmmoType))));
       aa:= a;
@@ -71,7 +72,7 @@
               end;
       if a = High(TAmmoType) then a:= Low(TAmmoType)
                              else inc(a)
-      until isInMultiShoot or (a = aa);
+      until isInMultiShoot or (a = aa) or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum > 0);
     inc(t)
     until (t >= Targets.Count)
     end;
@@ -112,7 +113,8 @@
 
 begin
 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
-     if ((Gear.State and (gstAttacked or gstAttacking or gstMoving or gstFalling)) <> 0) then exit;
+     if ((Gear.State and (gstAttacked or gstAttacking or gstMoving or gstFalling)) <> 0)
+        or isInMultiShoot then exit;
 
 FillTargets(Targets);
 
@@ -125,8 +127,11 @@
 
 if IsActionListEmpty then
    begin
-   AddAction(aia_Weapon, ord(amSkip), 1000);
-   AddAction(aia_Attack, aim_push, 1000);
+   if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].AttacksNum = 0 then
+      begin
+      AddAction(aia_Weapon, ord(amSkip), 1000);
+      AddAction(aia_Attack, aim_push, 1000);
+      end else ParseCommand('skip');
    exit
    end;