make using the teleporter a bit less challenging
authorsheepluva
Fri, 13 Jun 2014 17:51:55 +0200
changeset 10298 7d5d93f9a515
parent 10297 e5ed72b40c57
child 10299 45e3e901b3b9
make using the teleporter a bit less challenging
hedgewars/uGearsHandlersMess.pas
hedgewars/uVisualGearsHandlers.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGearsHandlersMess.pas	Fri Jun 13 14:55:06 2014 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Jun 13 17:51:55 2014 +0200
@@ -2529,7 +2529,7 @@
         PlaySound(sndDenied);
         if not distFail then
             begin
-            warn:= AddVisualGear(Gear^.Target.X, Gear^.Target.Y, vgtNoPlaceWarn, 0);
+            warn:= AddVisualGear(Gear^.Target.X, Gear^.Target.Y, vgtNoPlaceWarn, 0, true);
             if warn <> nil then
                 warn^.Tex := GetPlaceCollisionTex(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State);
             end;
@@ -2587,20 +2587,45 @@
 
 procedure doStepTeleport(Gear: PGear);
 var
-    HHGear: PGear;
+    lx, ty, y, oy: LongInt;
+    HHGear       : PGear;
+    valid        : Boolean;
+    warn         : PVisualGear;
+const
+    ytol = cHHRadius;
 begin
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
-    if not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprHHTelepMask].Width div 2,
-        Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2,
-        sprHHTelepMask, 0, false, not hasBorder, 0) then
+
+    valid:= false;
+
+    lx:= Gear^.Target.X - SpritesData[sprHHTelepMask].Width  div 2; // left
+    ty:= Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2; // top
+
+    // remember original target location
+    oy:= Gear^.Target.Y;
+
+    for y:= ty downto ty - ytol do
+        begin
+        if TryPlaceOnLand(lx, y, sprHHTelepMask, 0, false, not hasBorder, 0) then
+            begin
+            valid:= true;
+            break;
+            end;
+        dec(Gear^.Target.Y);
+        end;
+
+    if not valid then
         begin
         HHGear^.Message := HHGear^.Message and (not gmAttack);
         HHGear^.State := HHGear^.State and (not gstAttacking);
         HHGear^.State := HHGear^.State or gstHHChooseTarget;
         DeleteGear(Gear);
         isCursorVisible := true;
+        warn:= AddVisualGear(Gear^.Target.X, oy, vgtNoPlaceWarn, 0, true);
+        if warn <> nil then
+            warn^.Tex := GetPlaceCollisionTex(lx, ty, sprHHTelepMask, 0);
         PlaySound(sndDenied)
         end
     else
--- a/hedgewars/uVisualGearsHandlers.pas	Fri Jun 13 14:55:06 2014 +0200
+++ b/hedgewars/uVisualGearsHandlers.pas	Fri Jun 13 17:51:55 2014 +0200
@@ -906,14 +906,12 @@
     // age
     dec(Gear^.FrameTicks, Steps);
     // toggle between orange and red every few ticks
-    if (Gear^.FrameTicks div 300) mod 2 = 0 then
+    if (Gear^.FrameTicks div 256) mod 2 = 0 then
         Gear^.Tint:= $FF400000
     else
         Gear^.Tint:= $FF000000;
     // fade out alpha
-    Gear^.Tint:= Gear^.Tint or ((Gear^.FrameTicks * $FF) div 3000);
-    // get bigger as we fade out
-    // Gear^.Scale:= 1.1 - 0.001 * (Gear^.FrameTicks div 30);
+    Gear^.Tint:= (Gear^.Tint and not $FF) or (255 * Gear^.FrameTicks div 3000);
     end
 end;
 
--- a/hedgewars/uWorld.pas	Fri Jun 13 14:55:06 2014 +0200
+++ b/hedgewars/uWorld.pas	Fri Jun 13 17:51:55 2014 +0200
@@ -1837,11 +1837,13 @@
             with Ammoz[CurAmmoType] do
                 if PosCount > 1 then
                     begin
-                    if (CurAmmoType = amGirder) or (CurAmmoType = amRubber) then
-                        Tint($FF, $FF, $FF, $A0);
+                    // pulsating transparency
+                    if ((GameTicks div 16) mod $80) >= $40 then
+                        Tint($FF, $FF, $FF, $C0 - (GameTicks div 16) mod $40)
+                    else
+                        Tint($FF, $FF, $FF, $80 + (GameTicks div 16) mod $40);
                     DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
-                    if (CurAmmoType = amGirder) or (CurAmmoType = amRubber) then
-                        Untint();
+                    Untint();
                     end;
                 end;
         DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)