- Fixed console behavior
authorunc0rr
Mon, 09 Jan 2006 20:33:12 +0000
changeset 42 72ffe21f027c
parent 41 5d7a505875cd
child 43 e297fea1a2f3
- Fixed console behavior - Fixed pickhammer - Fixed bots using of shotgun and desert eagle - Fixed shotgun and desert eagle - Added health cases
hedgewars/Data/Graphics/FirstAid.png
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uKeys.pas
hedgewars/uStore.pas
Binary file hedgewars/Data/Graphics/FirstAid.png has changed
--- a/hedgewars/GSHandlers.inc	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Mon Jan 09 20:33:12 2006 +0000
@@ -254,7 +254,7 @@
    if t = nil then t:= CheckGearsCollision(Gear, Sign(Gear.dY), false);
    if t <> nil then
       AmmoShove(Gear, t, 25);
-   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage);
+   doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH);
    DeleteGear(Gear);
    exit
    end;
@@ -348,7 +348,8 @@
          inc(i, 1)
          end;
    Gear.X:= Gear.X + Gear.dX;
-   Gear.Y:= Gear.Y + 1.9
+   Gear.Y:= Gear.Y + 1.9;
+   SetAllHHToActive;
    end;
 if TestCollisionYwithGear(Gear, 1) then
    begin
@@ -387,7 +388,7 @@
    inc(y, 2);
    inc(i)
    end;
-DrawHLineExplosions(@ar, 3, round(Gear.Y) - cHHHalfHeight*2, 2, Pred(i));
+DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHHalfHeight*2, 2, Pred(i));
 Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY;
 doStepPickHammerWork(Gear);
 Gear.doStep:= doStepPickHammerWork
--- a/hedgewars/HHHandlers.inc	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/HHHandlers.inc	Mon Jan 09 20:33:12 2006 +0000
@@ -47,15 +47,14 @@
 cnt:= 0;
 while (t <> nil) do
       begin
-      if (t <> Gear) then
+      if (t <> Gear) and not (t.Kind in [gtGrave, gtMine]) then
          if (x < t.X + t.HalfWidth ) and (t.X - t.HalfWidth  < xw) and
             (y < t.Y + t.HalfHeight) and (t.Y - t.HalfHeight < yh) then
             if t.Kind = gtHedgehog then
                begin
                ar[cnt]:= t;
                inc(cnt)
-               end else
-               if not (t.Kind in [gtGrave, gtMine]) then b:= true;
+               end else b:= true;
       t:= t.NextGear
       end;
 ar[cnt]:= Gear;
@@ -171,12 +170,22 @@
      end
 end;
 
-
+////////////////////////////////////////////////////////////////////////////////
+procedure PickUp(HH, Gear: PGear);
+begin
+case Gear.Pos of
+     posCaseHealth: begin
+                    inc(HH.Health, Gear.Health);
+                    RenderHealth(PHedgehog(HH.Hedgehog)^)
+                    end;
+     end;
+end;
 
 procedure doStepHedgehog(Gear: PGear); forward;
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepHedgehogDriven(Gear: PGear);
 const StepTicks: LongWord = 0;
+      cStepTicks = 38;
 var t: PGear;
 begin
 if isinMultiShoot and (Gear.Damage = 0) then
@@ -194,13 +203,16 @@
       Gear.State:= Gear.State and not gstHHJumping;
    exit
    end;
-
-// check for case with ammo
-t:= CheckGearNear(Gear, gtCase, 30, 30);
-if t <> nil then
+if ((Gear.State and gstFalling) <> 0) or (StepTicks = cStepTicks)
+   or (CurAmmoGear <> nil) then // we're moving
    begin
-   t.Message:= gm_Destroy;
-   ; // take ammo from it
+   // check for case with ammo
+   t:= CheckGearNear(Gear, gtCase, 36, 36);
+   if t <> nil then
+      begin
+      t.Message:= gm_Destroy;
+      PickUp(Gear, t)
+      end;
    end;
 
 if CurAmmoGear <> nil then
@@ -306,7 +318,7 @@
    if (Gear.Message and gm_Left  )<>0 then Gear.dX:= -1.0 else
    if (Gear.Message and gm_Right )<>0 then Gear.dX:=  1.0 else exit;
    PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7;
-   StepTicks:= 40;
+   StepTicks:= cStepTicks;
    RemoveIntersectorsCR(Gear);
    if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
       begin
--- a/hedgewars/uAIAmmoTests.pas	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Mon Jan 09 20:33:12 2006 +0000
@@ -181,6 +181,11 @@
 function TestShotgun(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean;
 var Vx, Vy, x, y: real;
 begin
+if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then
+   begin
+   Result:= false;
+   exit
+   end;
 Time:= 0;
 Power:= 1;
 Vx:= (Targ.X - Me.X)/1024;
@@ -206,6 +211,11 @@
 var Vx, Vy, x, y: real;
     d: Longword;
 begin
+if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then
+   begin
+   Result:= false;
+   exit
+   end;
 Time:= 0;
 Power:= 1;
 Vx:= (Targ.X - Me.X)/1024;
--- a/hedgewars/uConsts.pas	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/uConsts.pas	Mon Jan 09 20:33:12 2006 +0000
@@ -44,7 +44,7 @@
      TSprite    = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame,
                    sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO,
                    sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff,
-                   sprMineOn, sprCase);
+                   sprMineOn, sprCase, sprFAid);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtActionTimer, gtPickHammer, gtRope,
                    gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite);
@@ -150,9 +150,13 @@
       capgrpAmmoinfo      = 1;
       capgrpNetSay        = 2;
 
-      EXPLAllDamageInRadius = 1;
-      EXPLAutoSound         = 2;
-      EXPLNoDamage          = 4;
+      EXPLAllDamageInRadius = $00000001;
+      EXPLAutoSound         = $00000002;
+      EXPLNoDamage          = $00000004;
+      EXPLDoNotTouchHH      = $00000008;
+
+      posCaseAmmo    = $00000001;
+      posCaseHealth  = $00000002;
 
       cToggleConsoleKey     = 39;
 
@@ -232,7 +236,8 @@
                      (FileName:    'Expl50.png'; Path: ptGraphics; Width:  64; Height: 64; hasAlpha: false),// sprExplosion50
                      (FileName:   'MineOff.png'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false),// sprMineOff
                      (FileName:    'MineOn.png'; Path: ptGraphics; Width:  16; Height: 16; hasAlpha: false),// sprMineOn
-                     (FileName:      'Case.png'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false) // sprCase
+                     (FileName:      'Case.png'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false),// sprCase
+                     (FileName:  'FirstAid.png'; Path: ptGraphics; Width:  32; Height: 32; hasAlpha: false) // sprFAid
                      );
       Soundz: array[TSound] of record
                                        FileName: String[31];
--- a/hedgewars/uGears.pas	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/uGears.pas	Mon Jan 09 20:33:12 2006 +0000
@@ -47,7 +47,8 @@
              Y : Real;
              dX: Real;
              dY: Real;
-             Kind  : TGearType;
+             Kind: TGearType;
+             Pos: Longword;
              doStep: TGearStepProcedure;
              HalfWidth, HalfHeight: integer;
              Angle, Power : Cardinal;
@@ -497,7 +498,10 @@
                        then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
                        else DrawSprite(sprMineOn  , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
         //!!!              ACHTUNG!!!!                     
-            gtCase: DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
+            gtCase: case Gear.Pos of
+                         posCaseAmmo  : DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
+                         posCaseHealth: DrawSprite(sprFAid, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, (GameTicks shr 6) and $F, Surface);
+                         end;
               end;
       Gear:= Gear.NextGear
       end;
@@ -553,10 +557,13 @@
                   gtMine,
                   gtCase: begin
                           if (Mask and EXPLNoDamage) = 0 then inc(Gear.Damage, dmg);
-                          Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
-                          Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);
-                          Gear.Active:= true;
-                          FollowGear:= Gear
+                          if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear.Kind <> gtHedgehog) then
+                             begin
+                             Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
+                             Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);
+                             Gear.Active:= true;
+                             FollowGear:= Gear
+                             end;
                           end;
                  gtGrave: Gear.dY:= - dmg / 250;
               end;
@@ -568,7 +575,9 @@
 procedure AmmoShove(Ammo, Gear: PGear; Power: Longword);
 begin
 case Gear.Kind of
-     gtHedgehog: begin
+     gtHedgehog,
+         gtMine,
+         gtCase: begin
                  inc(Gear.Damage, Power);
                  Gear.dX:= Ammo.dX * Power * 0.01;
                  Gear.dY:= Ammo.dY * Power * 0.01;
@@ -651,12 +660,11 @@
 var i, x, y, k: integer;
     b: boolean;
 begin
-exit; // temp hack until boxes are fully implemented
 if CountGears(gtCase) > 2 then exit;
 k:= 7;
 repeat
   x:= getrandom(2000) + 24;
-  {$IFDEF DEBUGFILE}AddFileLog('SpawnBoxOfSmth: check x = '+inttostr(x));{$ENDIF}
+//  {$IFDEF DEBUGFILE}AddFileLog('SpawnBoxOfSmth: check x = '+inttostr(x));{$ENDIF}
   b:= false;
   y:= -1;
   while (y < 1023) and not b do
@@ -677,7 +685,12 @@
      b:= CheckGearsNear(x, y, [gtMine, gtHedgehog, gtCase], 70, 70) = nil;
   dec(k)
 until (k = 0) or b;
-if b then FollowGear:= AddGear(x, -30, gtCase, 0)
+if b then
+   begin
+   FollowGear:= AddGear(x, -30, gtCase, 0);
+   FollowGear.Health:= 25;
+   FollowGear.Pos:= posCaseHealth
+   end;
 end;
 
 initialization
--- a/hedgewars/uKeys.pas	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/uKeys.pas	Mon Jan 09 20:33:12 2006 +0000
@@ -60,6 +60,7 @@
      pkbd: PByteArray;
 begin
 if (CurrentTeam = nil)
+   or (GameState = gsConsole)
    or (CurrentTeam.ExtDriven)
    or (CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].BotLevel <> 0) then exit;
 pkbd:= SDL_GetKeyState(nil);
--- a/hedgewars/uStore.pas	Mon Jan 09 20:29:14 2006 +0000
+++ b/hedgewars/uStore.pas	Mon Jan 09 20:33:12 2006 +0000
@@ -37,9 +37,9 @@
 {$INCLUDE options.inc}
 
 type PRangeArray = ^TRangeArray;
-     TRangeArray = array[byte] of record
-                                  Left, Right: integer;
-                                  end;
+     TRangeArray = array[0..31] of record
+                                   Left, Right: integer;
+                                   end;
 
 procedure StoreInit;
 procedure StoreLoad;
@@ -52,7 +52,7 @@
 procedure DrawCaption(X, Y: integer; Rect: TSDL_Rect; Surface: PSDL_Surface; const fromTempSurf: boolean = false);
 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
 procedure DrawExplosion(X, Y, Radius: integer);
-procedure DrawHLineExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
+procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
 procedure DrawTunnel(X, Y, dX, dY: real; ticks, HalfWidth: integer);
 procedure RenderHealth(var Hedgehog: THedgehog);
 function  RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect;
@@ -125,7 +125,7 @@
 SDL_UpdateRect(LandSurface, X - Radius, Y - Radius, Radius * 2, Radius * 2)
 end;
 
-procedure DrawHLineExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
+procedure DrawHLinesExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte);
 var tx, ty, i, p: integer;
 begin
 if SDL_MustLock(LandSurface) then