Add gstFrozen state to mines/gears in range on frozen land creation, and set the mines to dud state. gstFrozen does nothing yet. Visually or otherwise.
authornemo
Tue, 21 May 2013 16:13:32 -0400
changeset 9026 f6074540bab2
parent 9025 95d59fad8699
child 9036 1ae1b6017b27
Add gstFrozen state to mines/gears in range on frozen land creation, and set the mines to dud state. gstFrozen does nothing yet. Visually or otherwise.
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
--- a/hedgewars/GSHandlers.inc	Tue May 21 11:32:42 2013 -0400
+++ b/hedgewars/GSHandlers.inc	Tue May 21 16:13:32 2013 -0400
@@ -5109,17 +5109,6 @@
     LastDamage:= nil;
     X:= Hedgehog^.Gear^.X;
     Y:= Hedgehog^.Gear^.Y;
-    //unfreeze all semifrozen hogs - make this generic hog cleanup
-(*
-    iter := GearsList;
-    while iter <> nil do
-        begin
-        if (iter^.Kind = gtHedgehog) and
-        (iter^.Hedgehog^.Effects[heFrozen] and $FF = 0) then
-        iter^.Hedgehog^.Effects[heFrozen]:= 0;
-        iter:= iter^.NextGear
-        end
-*)
   end;
 end;
 
@@ -5134,7 +5123,7 @@
 const iceRadius = 32;
 const iceHeight = 40;
 var
-    HHGear: PGear;
+    HHGear, iter: PGear;
     landRect: TSDL_Rect;
     ndX, ndY: hwFloat;
     i, j, t, gX, gY: LongInt;
@@ -5204,6 +5193,28 @@
                     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
                     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
                     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
+                    
+                    // Freeze nearby mines/explosives/cases too
+                    iter := GearsList;
+                    while iter <> nil do
+                        begin
+                        if ((iter^.Kind = gtExplosives) or (iter^.Kind = gtCase) or (iter^.Kind = gtMine)) and 
+                           (abs(Gear^.X.Round-target.x)+abs(Gear^.Y.Round-target.y)+2<Gear^.Radius*2) and (Distance(Gear^.X-int2hwFloat(target.x),Gear^.Y-int2hwFloat(target.y))<int2hwFloat(Gear^.Radius*2)) then
+                            begin
+                            iter^.State:= iter^.State or gstFrozen;
+                            if iter^.Kind = gtMine then // dud mine block
+                                begin
+                                vg:= AddVisualGear(hwRound(Gear^.X) - 4  + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke);
+                                if vg <> nil then
+                                    vg^.Scale:= 0.5;
+                                PlaySound(sndVaporize);
+                                Gear^.Health := 0;
+                                Gear^.Damage := 0;
+                                Gear^.State := Gear^.State and (not gstAttacking)
+                                end
+                            end;
+                        iter:= iter^.NextGear
+                        end;
 
                     // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
                     SetAllHHToActive;
--- a/hedgewars/uConsts.pas	Tue May 21 11:32:42 2013 -0400
+++ b/hedgewars/uConsts.pas	Tue May 21 16:13:32 2013 -0400
@@ -212,7 +212,8 @@
     gstLoser          = $00080000;
     gstHHGone         = $00100000;
     gstInvisible      = $00200000;
-    gstSubmersible        = $00400000;
+    gstSubmersible    = $00400000;
+    gstFrozen         = $00800000;
 
     // gear messages
     gmLeft           = $00000001;