merge
authormikade <redgrinner@gmail.com>
Sun, 20 May 2012 10:54:52 +0200
changeset 7096 c2add22a787e
parent 7095 b20dfa82f453 (current diff)
parent 7093 2d7f1fb73335 (diff)
child 7097 ed417e912267
merge
--- a/hedgewars/GSHandlers.inc	Sun May 20 00:08:26 2012 +0200
+++ b/hedgewars/GSHandlers.inc	Sun May 20 10:54:52 2012 +0200
@@ -5437,16 +5437,36 @@
 var 
     HHGear, iter: PGear;
     ndX, ndY: hwFloat;
-    gX, gY: LongInt;
+    t, gX, gY: LongInt;
 begin
+    HHGear := Gear^.Hedgehog^.Gear;
+    if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
+        begin
+        DeleteGear(Gear);
+        AfterAttack;
+        exit
+        end
+    else
+        begin
+        t:= Gear^.Health div 10;
+        if (t <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
+            begin
+            Gear^.Damage:= t;
+            FreeTexture(Gear^.Tex);
+            Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(t) +
+                         '%', cWhiteColor, fntSmall)
+            end
+        end;
+    if GameTicks mod 10 = 0 then dec(Gear^.Health);
     with Gear^ do
         begin
-        HHGear := Hedgehog^.Gear;
         HedgehogChAngle(HHGear);
-        ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
-        ndY:= -AngleCos(HHGear^.Angle);
+        ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4;
+        ndY:= -AngleCos(HHGear^.Angle) * _4;
         if (ndX <> dX) or (ndY <> dY) then
             begin
+            dX:= ndX;
+            dY:= ndY;
             Pos:= 0;
             Target.X:= NoPointX;
             LastDamage:= nil;
@@ -5459,28 +5479,46 @@
                 if (iter^.Kind = gtHedgehog) and 
                    (iter^.Hedgehog^.Effects[heFrozen] < 0) then 
                     iter^.Hedgehog^.Effects[heFrozen]:= 0;
-                iter:= iter^.NextGear;
-                end;
+                iter:= iter^.NextGear
+                end
             end
         else
             begin
-            gX:= hwRound(X);
-            gY:= hwRound(Y);
             X:= X + dX;
             Y:= Y + dY;
+            gX:= hwRound(X);
+            gY:= hwRound(Y);
+            if Target.X = NoPointX then t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y));
             if Target.X <> NoPointX then
                 inc(Pos)
-            else if (gY > cWaterLine) or 
+            else if (gY > cWaterLine) or
                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
                         and ((Land[gY, gX] and $FF00 and not lfIce <> 0) or
-                             (Land[gY, gX] and $00FF <> 0))) then
+                             ((Land[gY, gX] and $00FF <> 0) and (t > 400)))) then
                 begin
                 Target.X:= gX;
                 Target.Y:= gY;
-                if Land[gY, gX] and $00FF <> 0 then // locate and tag hogs
+                if (gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0) then
                     begin
-                //GearsNear(X, Y, gtHedgehog, Radius);
+                    LandPixels[gY, gX]:= $FFFFFFFF; // just testing
+                    UpdateLandTexture(gX, 1, gY, 1);
+                    if Land[gY, gX] and $00FF <> 0 then // locate and tag hogs
+                        begin
+                    //GearsNear(X, Y, gtHedgehog, Radius);
+                        end
                     end;
+                X:= HHGear^.X;
+                Y:= HHGear^.Y
+                end;
+            if (gX > LAND_WIDTH*2) or
+                    (gX < -LAND_WIDTH) or
+                    (gY < -LAND_HEIGHT) or
+                    (gY > LAND_HEIGHT+512) or
+                    (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
+                     and (Land[gy, gX] > $FF)) then
+                begin
+                X:= HHGear^.X;
+                Y:= HHGear^.Y
                 end
         end
     end;
--- a/hedgewars/uGearsList.pas	Sun May 20 00:08:26 2012 +0200
+++ b/hedgewars/uGearsList.pas	Sun May 20 10:54:52 2012 +0200
@@ -33,7 +33,7 @@
     uTextures, uScript, uRenderUtils, uAI, uCollisions,
     uGearsRender, uGearsUtils;
 
-var GCounter: LongWord = 0; // this doesn't get re-initialized, but should be harmless
+var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
 
 procedure InsertGearToList(Gear: PGear);
 var tmp, ptmp: PGear;
@@ -457,6 +457,7 @@
                 gear^.Tag:= TotalRounds + 3;
                 gear^.Pos:= 1;
                 end;
+      gtIceGun: gear^.Health:= 1000;
     end;
 
 InsertGearToList(gear);
--- a/hedgewars/uGearsRender.pas	Sun May 20 00:08:26 2012 +0200
+++ b/hedgewars/uGearsRender.pas	Sun May 20 10:54:52 2012 +0200
@@ -37,7 +37,7 @@
                 end;
 
 implementation
-uses uRender, uUtils, uVariables, uAmmos, Math;
+uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGears;
 
 procedure DrawRopeLinesRQ(Gear: PGear);
 begin
@@ -522,6 +522,11 @@
                     if CurAmmoGear^.Tex <> nil then
                         DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex)
                     end;
+                gtIceGun:
+                    begin DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
+                    if CurAmmoGear^.Tex <> nil then
+                        DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex)
+                    end;
             end;
 
             case CurAmmoGear^.Kind of
@@ -648,6 +653,7 @@
                 amBee: DrawSpriteRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
                 amFlamethrower: DrawSpriteRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
                 amLandGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
+                amIceGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle);
                 amResurrector: DrawCircle(ox, oy, 98, 4, $F5, $DB, $35, $AA); // I'd rather not like to hardcode 100 here
             end;
 
@@ -907,6 +913,7 @@
 procedure RenderGear(Gear: PGear; x, y: LongInt);
 var
     HHGear: PGear;
+    vg: PVisualGear;
     i: Longword;
     aAngle: real;
     startX, endX, startY, endY: LongInt;
@@ -915,7 +922,9 @@
         if Gear^.AmmoType = amBee then
             DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
 	else if Gear^.AmmoType = amIceGun then
-	    DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 3) mod 360)
+	    //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8)
+        //DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
+        DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1/(1+(RealTicks shr 8) mod 5), 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360)
     else
         DrawSpriteRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
 
@@ -1169,6 +1178,32 @@
                         Tint($FF, $FF, $FF, $FF)
 *)
                         end;
+            gtIceGun: begin
+                      HHGear := Gear^.Hedgehog^.Gear;
+                      if HHGear <> nil then
+                          begin
+                          i:= hwRound(hwSqr(Gear^.X-HHGear^.X)+hwSqr(Gear^.Y-HHGear^.Y));
+                          if RealTicks mod max(1,50-(round(sqrt(i)) div 4)) = 0 then // experiment in "intensifying" might not get used
+                            begin
+                            vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust, 1);
+                            if vg <> nil then
+                                begin
+                                i:= random(100)+155;
+                                vg^.Tint:= i shl 24 or i shl 16 or $FF shl 8 or ((random(200)+55));
+                                vg^.Angle:= random(360);
+                                vg^.dx:= 0.001 * (random(80));
+                                vg^.dy:= 0.001 * (random(80))
+                                end
+                            end;
+                          if RealTicks mod 2 = 0 then
+                                begin
+                                i:= random(100)+100;
+                                DrawLine(hwRound(HHGear^.X), hwRound(HHGear^.Y), hwRound(Gear^.X), hwRound(Gear^.Y), 4.0, i, i, $FF, $40);
+                                if Gear^.Target.X <> NoPointX then
+                                    DrawLine(Gear^.Target.X, Gear^.Target.Y, hwRound(Gear^.X), hwRound(Gear^.Y), 4.0, i, i, $FF, $40);
+                                end
+                          end
+                      end
 
 
          end;