- New /skip command
authorunc0rr
Thu, 12 Jan 2006 22:07:36 +0000
changeset 48 0f396d0c429d
parent 47 8daf1ee0b9a3
child 49 3afe33c1cf06
- New /skip command - Fixed "AI: incorrect try to switch weapon" bug
hedgewars/CCHandlers.inc
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
hedgewars/uConsole.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
--- a/hedgewars/CCHandlers.inc	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Jan 12 22:07:36 2006 +0000
@@ -334,3 +334,9 @@
 flagMakeCapture:= true
 end;
 
+procedure chSkip(var s: shortstring);
+begin
+if not CurrentTeam.ExtDriven then SendIPC(',');
+TurnTimeLeft:= 0
+end;
+
--- 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;
 
--- a/hedgewars/uAIAmmoTests.pas	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Thu Jan 12 22:07:36 2006 +0000
@@ -49,10 +49,10 @@
                     Test: TAmmoTestProc;
                     Flags: Longword;
                     end = (
-                    ( Test: TestGrenade;
+                    ( Test: nil;//TestGrenade;
                       Flags: ctfNotFull;
                     ),
-                    ( Test: TestBazooka;
+                    ( Test: nil;//TestBazooka;
                       Flags: ctfNotFull or ctfBreach;
                     ),
                     ( Test: nil;
--- a/hedgewars/uConsole.pas	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/uConsole.pas	Thu Jan 12 22:07:36 2006 +0000
@@ -279,6 +279,7 @@
 RegisterVariable('grave'   , vtCommand, @chGrave        );
 RegisterVariable('bind'    , vtCommand, @chBind         );
 RegisterVariable('add'     , vtCommand, @chAdd          );
+RegisterVariable('skip'    , vtCommand, @chSkip         );
 RegisterVariable('say'     , vtCommand, @chSay          );
 RegisterVariable('+left'   , vtCommand, @chLeft_p       );
 RegisterVariable('-left'   , vtCommand, @chLeft_m       );
--- a/hedgewars/uGears.pas	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/uGears.pas	Thu Jan 12 22:07:36 2006 +0000
@@ -228,6 +228,7 @@
 end;
 
 procedure DeleteGear(Gear: PGear);
+var team: PTeam;
 begin
 if Gear.CollIndex < High(Longword) then DeleteCR(Gear);
 if Gear.Kind = gtHedgehog then
@@ -239,8 +240,9 @@
       exit
       end else
       begin
-      RecountTeamHealth(PHedgehog(Gear.Hedgehog).Team);
+      team:= PHedgehog(Gear.Hedgehog).Team;
       PHedgehog(Gear.Hedgehog).Gear:= nil;
+      RecountTeamHealth(team);
       end;
 if CurAmmoGear = Gear then
    CurAmmoGear:= nil;
--- a/hedgewars/uIO.pas	Thu Jan 12 16:33:26 2006 +0000
+++ b/hedgewars/uIO.pas	Thu Jan 12 22:07:36 2006 +0000
@@ -184,6 +184,7 @@
         'S': ParseCommand('switch');
         'j': ParseCommand('ljump');
         'J': ParseCommand('hjump');
+        ',': ParseCommand('skip');
         'N': begin
              tmpflag:= false;
              {$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+inttostr(extcmd[cmdcurpos].Time)){$ENDIF}