merge
authorStepan777 <stepik-777@mail.ru>
Mon, 09 Jul 2012 16:42:13 +0400
changeset 7373 d5ec4e4eb2d5
parent 7371 911b53e8c00a (current diff)
parent 7370 d50b874e7ee8 (diff)
child 7376 48b79b3ca592
merge
hedgewars/CMakeLists.txt
hedgewars/uGearsHedgehog.pas
hedgewars/uWorld.pas
--- a/hedgewars/CMakeLists.txt	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Mon Jul 09 16:42:13 2012 +0400
@@ -32,6 +32,7 @@
     uFloat.pas
     uGame.pas
     uGears.pas
+    uGearsHandlers.pas
     uGearsRender.pas
     uIO.pas
     uInputHandler.pas
--- a/hedgewars/GSHandlers.inc	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/GSHandlers.inc	Mon Jul 09 16:42:13 2012 +0400
@@ -3054,20 +3054,10 @@
 end;
 
 
-procedure PrevAngle(Gear: PGear; dA: LongInt);
-begin
-    Gear^.Angle := (LongInt(Gear^.Angle) + 4 - dA) mod 4
-end;
-
-procedure NextAngle(Gear: PGear; dA: LongInt);
-begin
-    Gear^.Angle := (LongInt(Gear^.Angle) + 4 + dA) mod 4
-end;
-
 procedure doStepCakeWork(Gear: PGear);
 
 const dirs: array[0..3] of TPoint =   ((X: 0; Y: -1), (X: 1; Y: 0),(X: 0; Y: 1),(X: -1; Y: 0));
-var 
+var
     xx, yy, xxn, yyn: LongInt;
     dA: LongInt;
     tdx, tdy: hwFloat;
@@ -3078,39 +3068,7 @@
     if Gear^.Tag < 7 then
         exit;
 
-    dA := hwSign(Gear^.dX);
-    xx := dirs[Gear^.Angle].x;
-    yy := dirs[Gear^.Angle].y;
-    xxn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x;
-    yyn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y;
-
-    if (xx = 0) then
-        if TestCollisionYwithGear(Gear, yy) <> 0 then
-            PrevAngle(Gear, dA)
-    else
-        begin
-        Gear^.Tag := 0;
-        Gear^.Y := Gear^.Y + int2hwFloat(yy);
-        if not TestCollisionXwithGear(Gear, xxn) then
-            begin
-            Gear^.X := Gear^.X + int2hwFloat(xxn);
-            NextAngle(Gear, dA)
-            end;
-        end;
-
-    if (yy = 0) then
-        if TestCollisionXwithGear(Gear, xx) then
-            PrevAngle(Gear, dA)
-    else
-        begin
-        Gear^.Tag := 0;
-        Gear^.X := Gear^.X + int2hwFloat(xx);
-        if TestCollisionYwithGear(Gear, yyn) = 0 then
-            begin
-            Gear^.Y := Gear^.Y + int2hwFloat(yyn);
-            NextAngle(Gear, dA)
-            end;
-        end;
+    cakeStep(Gear);
 
     if Gear^.Tag = 0 then
         begin
--- a/hedgewars/uAIMisc.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uAIMisc.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -404,7 +404,10 @@
                 begin
                 dX:= 0.005 * dmg + 0.01;
                 dY:= dX;
-                fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod);
+                if (x and LAND_WIDTH_MASK = 0) and ((y+cHHRadius+2) and LAND_HEIGHT_MASK = 0) and 
+                   (Land[y+cHHRadius+2, x] and lfIndestructible <> 0) then
+                     fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, 0) * dmgMod)
+                else fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod)
                 end;
             if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI
                 if Score > 0 then
@@ -503,7 +506,10 @@
             dY:= gdY * dmg;
             if dX < 0 then dX:= dX - 0.01
             else dX:= dX + 0.01;
-            fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod);
+            if (x and LAND_WIDTH_MASK = 0) and ((y+cHHRadius+2) and LAND_HEIGHT_MASK = 0) and 
+               (Land[y+cHHRadius+2, x] and lfIndestructible <> 0) then
+                 fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, 0) * dmgMod)
+            else fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod);
             if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI
                 if Score > 0 then
                     inc(rate, KillScore + Score div 10)   // Add a bit of a bonus for bigger hog drownings
--- a/hedgewars/uGears.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uGears.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -59,7 +59,7 @@
 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
     uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables,
     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture,
-    uGearsHedgehog, uGearsUtils, uGearsList;
+    uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers;
 
 var skipFlag: boolean;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uGearsHandlers.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -0,0 +1,85 @@
+(*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *)
+
+{$INCLUDE "options.inc"}
+
+unit uGearsHandlers;
+interface
+
+uses uTypes;
+
+procedure cakeStep(Gear: PGear);
+
+implementation
+
+uses SDLh, uFloat, uCollisions;
+
+const dirs: array[0..3] of TPoint =   ((X: 0; Y: -1), (X: 1; Y: 0),(X: 0; Y: 1),(X: -1; Y: 0));
+
+procedure PrevAngle(Gear: PGear; dA: LongInt); inline;
+begin
+    Gear^.Angle := (LongInt(Gear^.Angle) + 4 - dA) mod 4
+end;
+
+procedure NextAngle(Gear: PGear; dA: LongInt); inline;
+begin
+    Gear^.Angle := (LongInt(Gear^.Angle) + 4 + dA) mod 4
+end;
+
+procedure cakeStep(Gear: PGear);
+var
+    xx, yy, xxn, yyn: LongInt;
+    dA: LongInt;
+    tdx, tdy: hwFloat;
+begin
+    dA := hwSign(Gear^.dX);
+    xx := dirs[Gear^.Angle].x;
+    yy := dirs[Gear^.Angle].y;
+    xxn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x;
+    yyn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y;
+
+    if (xx = 0) then
+        if TestCollisionYwithGear(Gear, yy) <> 0 then
+            PrevAngle(Gear, dA)
+    else
+        begin
+        Gear^.Tag := 0;
+        Gear^.Y := Gear^.Y + int2hwFloat(yy);
+        if not TestCollisionXwithGear(Gear, xxn) then
+            begin
+            Gear^.X := Gear^.X + int2hwFloat(xxn);
+            NextAngle(Gear, dA)
+            end;
+        end;
+
+    if (yy = 0) then
+        if TestCollisionXwithGear(Gear, xx) then
+            PrevAngle(Gear, dA)
+    else
+        begin
+        Gear^.Tag := 0;
+        Gear^.X := Gear^.X + int2hwFloat(xx);
+        if TestCollisionYwithGear(Gear, yyn) = 0 then
+            begin
+            Gear^.Y := Gear^.Y + int2hwFloat(yyn);
+            NextAngle(Gear, dA)
+            end;
+        end;
+end;
+
+end.
--- a/hedgewars/uGearsHedgehog.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -957,11 +957,11 @@
             SetLittle(Gear^.dX);
 
 if (not isFalling)
-and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then
+  and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then
     begin
     Gear^.State:= Gear^.State and (not gstWinner);
     Gear^.State:= Gear^.State and (not gstMoving);
-    while TestCollisionYWithGear(Gear,1) = 0 do
+    while (TestCollisionYWithGear(Gear,1) = 0) and not CheckGearDrowning(Gear) do
         Gear^.Y:= Gear^.Y+_1;
     SetLittle(Gear^.dX);
     Gear^.dY:= _0
--- a/hedgewars/uGearsList.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uGearsList.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -40,7 +40,7 @@
 begin
     tmp:= GearsList;
     ptmp:= GearsList;
-    while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
+    while (tmp <> nil) and (tmp^.Z < Gear^.Z) do
         begin
         ptmp:= tmp;
         tmp:= tmp^.NextGear
@@ -105,7 +105,7 @@
 
 if CurrentHedgehog <> nil then gear^.Hedgehog:= CurrentHedgehog;
 
-if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
+if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
     gear^.Z:= cHHZ+1
 else gear^.Z:= cUsualZ;
 
@@ -295,6 +295,7 @@
                 gear^.Radius:= 15;
                 gear^.Tag:= Y
                 end;
+   gtAirAttack: gear^.Z:= cHHZ+2;
      gtAirBomb: begin
                 gear^.Radius:= 5;
                 gear^.Density:= _2;
--- a/hedgewars/uGearsUtils.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uGearsUtils.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -446,6 +446,10 @@
     sparkles: PVisualGear;
     gX, gY: LongInt;
 begin
+    if (Gear^.LastDamage <> nil) then
+        uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
+    else
+        uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
     AttackBar:= 0;
     gear^.dX := _0;
     gear^.dY := _0;
--- a/hedgewars/uWorld.pas	Sun Jul 08 13:29:06 2012 +0400
+++ b/hedgewars/uWorld.pas	Mon Jul 09 16:42:13 2012 +0400
@@ -1369,6 +1369,19 @@
             r.w:= TeamHealthBarWidth + 1;
             r.h:= HealthTex^.h - 4;
             DrawTextureFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex);
+            if not hasGone and (TeamHealth > 1) then
+                begin
+                Tint(Clan^.Color shl 8 or $FF);
+                for i:= 0 to cMaxHHIndex do
+                    if Hedgehogs[i].Gear <> nil then
+                        begin
+                        inc(h,Hedgehogs[i].Gear^.Health);
+                        if h < TeamHealth then DrawTexture(15 + h*TeamHealthBarWidth div TeamHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture);
+                        end;
+                if TeamsCount * 20 > Longword(cScreenHeight) div 5 then
+                    Tint($FF,$FF,$FF,$80)
+                else Tint($FF, $FF, $FF, $FF);
+                end;
             end;
         end;
 if smallScreenOffset <> 0 then