hedgewars/GSHandlers.inc
changeset 8602 f510cca2b988
parent 8601 7668f92734b8
child 8612 f7c194533d45
equal deleted inserted replaced
8601:7668f92734b8 8602:f510cca2b988
   614             move:=true
   614             move:=true
   615         // Solid pixel encountered
   615         // Solid pixel encountered
   616         else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then
   616         else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then
   617             begin
   617             begin
   618             lf:= Land[yy, xx] and (lfObject or lfBasic or lfIndestructible);
   618             lf:= Land[yy, xx] and (lfObject or lfBasic or lfIndestructible);
       
   619             if lf = 0 then lf:= lfObject;
   619             // If there's room below keep falling
   620             // If there's room below keep falling
   620             if (((yy-1) and LAND_HEIGHT_MASK) = 0) and (Land[yy-1, xx] = 0) then
   621             if (((yy-1) and LAND_HEIGHT_MASK) = 0) and (Land[yy-1, xx] = 0) then
   621                 begin
   622                 begin
   622                 X:= X - cWindSpeed * 1600 - dX;
   623                 X:= X - cWindSpeed * 1600 - dX;
   623                 end
   624                 end
  5095 procedure doStepIceGun(Gear: PGear);
  5096 procedure doStepIceGun(Gear: PGear);
  5096 const iceWaitCollision:Longint = 0;
  5097 const iceWaitCollision:Longint = 0;
  5097 const iceCollideWithGround:Longint = 1;
  5098 const iceCollideWithGround:Longint = 1;
  5098 const iceWaitNextTarget:Longint = 2;
  5099 const iceWaitNextTarget:Longint = 2;
  5099 const iceCollideWithHog:Longint = 4;
  5100 const iceCollideWithHog:Longint = 4;
       
  5101 const iceCollideWithWater:Longint = 5;
       
  5102 const waterFreezingTime:Longint = 500;
  5100 const groundFreezingTime:Longint = 1000;
  5103 const groundFreezingTime:Longint = 1000;
  5101 const iceRadius = 32;
  5104 const iceRadius = 32;
       
  5105 const iceHeight = 40;
  5102 var
  5106 var
  5103     HHGear: PGear;
  5107     HHGear: PGear;
  5104     ndX, ndY: hwFloat;
  5108     ndX, ndY: hwFloat;
  5105     i, t, gX, gY: LongInt;
  5109     i, t, gX, gY: LongInt;
  5106     hogs: PGearArrayS;
  5110     hogs: PGearArrayS;
  5143             if Target.X <> NoPointX then
  5147             if Target.X <> NoPointX then
  5144             begin
  5148             begin
  5145                 CheckCollisionWithLand(Gear);
  5149                 CheckCollisionWithLand(Gear);
  5146                 if (State and gstCollision) <> 0 then
  5150                 if (State and gstCollision) <> 0 then
  5147                 begin        
  5151                 begin        
       
  5152                 if IceState = iceWaitCollision then
       
  5153                     begin
       
  5154                     IceState := iceCollideWithGround;
       
  5155                     IceTime := GameTicks;                    
       
  5156                     end                    
       
  5157                 end
       
  5158                 else if (target.y >= cWaterLine) then
       
  5159                     begin
  5148                     if IceState = iceWaitCollision then
  5160                     if IceState = iceWaitCollision then
       
  5161                         begin
       
  5162                         IceState := iceCollideWithWater;
       
  5163                         IceTime := GameTicks;  
       
  5164                         end;
       
  5165                     end;
       
  5166 
       
  5167                 if (abs(gX-Target.X) < 2) and (abs(gY-Target.Y) < 2) then
  5149                     begin
  5168                     begin
  5150                         IceState := iceCollideWithGround;
       
  5151                         IceTime := GameTicks;                    
       
  5152                     end;
       
  5153                 end;
       
  5154 
       
  5155                 if (abs(gX-Target.X) < 2) and (abs(gY-Target.Y) < 2) then
       
  5156                 begin
       
  5157                     X:= HHGear^.X;
  5169                     X:= HHGear^.X;
  5158                     Y:= HHGear^.Y
  5170                     Y:= HHGear^.Y
  5159                 end;
  5171                     end;
  5160 
  5172 
  5161                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5173                 if (IceState = iceCollideWithGround) and ((GameTicks - IceTime) > groundFreezingTime) then
  5162                 begin 
  5174                     begin 
  5163                     FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
  5175                     FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
  5164                     SetAllHHToActive;                                     
  5176                     SetAllHHToActive;                                     
  5165                     IceState := iceWaitNextTarget;
  5177                     IceState := iceWaitNextTarget;
  5166                 end;
  5178                     end;
       
  5179 
       
  5180                 if (IceState = iceCollideWithWater) and ((GameTicks - IceTime) > groundFreezingTime) then
       
  5181                     begin                    
       
  5182                     DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight);
       
  5183                     SetAllHHToActive; 
       
  5184                     IceState := iceWaitNextTarget;
       
  5185                     end;
  5167 
  5186 
  5168 // freeze nearby hogs
  5187 // freeze nearby hogs
  5169                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5188                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5170                 if hogs.size > 0 then
  5189                 if hogs.size > 0 then
  5171                     for i:= 0 to hogs.size - 1 do
  5190                     for i:= 0 to hogs.size - 1 do