hedgewars/GSHandlers.inc
changeset 8812 fdac638c6f9a
parent 8795 b5b79a8f9354
child 8814 01e13871f578
equal deleted inserted replaced
8810:b885b995aa95 8812:fdac638c6f9a
  5145         ndY:= -AngleCos(HHGear^.Angle) * _4;
  5145         ndY:= -AngleCos(HHGear^.Angle) * _4;
  5146         if (ndX <> dX) or (ndY <> dY) or
  5146         if (ndX <> dX) or (ndY <> dY) or
  5147            ((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and
  5147            ((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and
  5148              (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0))) then
  5148              (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0))) then
  5149             begin
  5149             begin
  5150                 updateTarget(Gear, ndX, ndY);
  5150             updateTarget(Gear, ndX, ndY);
  5151                 Health := iceWaitCollision;
  5151             Timer := iceWaitCollision;
  5152             end
  5152             end
  5153         else
  5153         else
  5154             begin
  5154             begin
  5155             X:= X + dX;
  5155             X:= X + dX;
  5156             Y:= Y + dY;
  5156             Y:= Y + dY;
  5157             gX:= hwRound(X);
  5157             gX:= hwRound(X);
  5158             gY:= hwRound(Y);
  5158             gY:= hwRound(Y);
  5159             if Target.X = NoPointX then
  5159             if Target.X = NoPointX then t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y));
  5160             begin
       
  5161                 t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y));
       
  5162             end;
       
  5163 
  5160 
  5164             if Target.X <> NoPointX then
  5161             if Target.X <> NoPointX then
  5165             begin
  5162                 begin
  5166                 CheckCollisionWithLand(Gear);
  5163                 CheckCollisionWithLand(Gear);
  5167                 if (State and gstCollision) <> 0 then
  5164                 if (State and gstCollision) <> 0 then
  5168                 begin
       
  5169                 if Health = iceWaitCollision then
       
  5170                     begin
  5165                     begin
  5171                     Health := iceCollideWithGround;
  5166                     if Timer = iceWaitCollision then
  5172                     Power := GameTicks;
  5167                         begin
       
  5168                         Timer := iceCollideWithGround;
       
  5169                         Power := GameTicks;
       
  5170                         end
  5173                     end
  5171                     end
  5174                 end
       
  5175                 else if (target.y >= cWaterLine) then
  5172                 else if (target.y >= cWaterLine) then
  5176                     begin
  5173                     begin
  5177                     if Health = iceWaitCollision then
  5174                     if Timer = iceWaitCollision then
  5178                         begin
  5175                         begin
  5179                         Health := iceCollideWithWater;
  5176                         Timer := iceCollideWithWater;
  5180                         Power := GameTicks;
  5177                         Power := GameTicks;
  5181                         end;
  5178                         end;
  5182                     end;
  5179                     end;
  5183 
  5180 
  5184                 if (abs(gX-Target.X) < 2) and (abs(gY-Target.Y) < 2) then
  5181                 if (abs(gX-Target.X) < 2) and (abs(gY-Target.Y) < 2) then
  5185                     begin
  5182                     begin
  5186                     X:= HHGear^.X;
  5183                     X:= HHGear^.X;
  5187                     Y:= HHGear^.Y
  5184                     Y:= HHGear^.Y
  5188                     end;
  5185                     end;
  5189 
  5186 
  5190                 if (Health = iceCollideWithGround) and ((GameTicks - Power) > groundFreezingTime) then
  5187                 if (Timer = iceCollideWithGround) and ((GameTicks - Power) > groundFreezingTime) then
  5191                     begin
  5188                     begin
  5192                     FillRoundInLand(target.x, target.y, iceRadius, icePixel);
  5189                     FillRoundInLand(target.x, target.y, iceRadius, icePixel);
  5193                     landRect.x := min(max(target.x - iceRadius, 0), LAND_WIDTH - 1);
  5190                     landRect.x := min(max(target.x - iceRadius, 0), LAND_WIDTH - 1);
  5194                     landRect.y := min(max(target.y - iceRadius, 0), LAND_HEIGHT - 1);
  5191                     landRect.y := min(max(target.y - iceRadius, 0), LAND_HEIGHT - 1);
  5195                     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
  5192                     landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1);
  5196                     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
  5193                     landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1);
  5197                     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
  5194                     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
  5198 
  5195 
  5199                     // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
  5196                     // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
  5200                     SetAllHHToActive;
  5197                     SetAllHHToActive;
  5201                     Health := iceWaitCollision;
  5198                     Timer := iceWaitCollision;
  5202                     end;
  5199                     end;
  5203 
  5200 
  5204                 if (Health = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then
  5201                 if (Timer = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then
  5205                     begin
  5202                     begin
  5206                     DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight);
  5203                     DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight);
  5207                     SetAllHHToActive;
  5204                     SetAllHHToActive;
  5208                     Health := iceWaitCollision;
  5205                     Timer := iceWaitCollision;
  5209                     end;
  5206                     end;
  5210 
  5207 
  5211 // freeze nearby hogs
  5208 // freeze nearby hogs
  5212                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5209                 hogs := GearsNear(int2hwFloat(Target.X), int2hwFloat(Target.Y), gtHedgehog, Gear^.Radius*2);
  5213                 if hogs.size > 0 then
  5210                 if hogs.size > 0 then
  5220                                     hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] := hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] + 1
  5217                                     hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] := hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] + 1
  5221                                 else if hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] = 256 then
  5218                                 else if hogs.ar^[i]^.Hedgehog^.Effects[heFrozen] = 256 then
  5222                                     hogs.ar^[i]^.Hedgehog^.Effects[heFrozen]:= 200000;//cHedgehogTurnTime + cReadyDelay
  5219                                     hogs.ar^[i]^.Hedgehog^.Effects[heFrozen]:= 200000;//cHedgehogTurnTime + cReadyDelay
  5223                                 end;
  5220                                 end;
  5224                 inc(Pos)
  5221                 inc(Pos)
  5225             end
  5222                 end
  5226             else if (t > 400) and ((gY > cWaterLine) or
  5223             else if (t > 400) and ((gY > cWaterLine) or
  5227                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
  5224                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
  5228                         and (Land[gY, gX] <> 0))) then
  5225                         and (Land[gY, gX] <> 0))) then
  5229             begin
  5226                 begin
  5230                 Target.X:= gX;
  5227                 Target.X:= gX;
  5231                 Target.Y:= gY;
  5228                 Target.Y:= gY;
  5232                 X:= HHGear^.X;
  5229                 X:= HHGear^.X;
  5233                 Y:= HHGear^.Y
  5230                 Y:= HHGear^.Y
  5234             end;
  5231                 end;
  5235             {if (gX > max(LAND_WIDTH,4096)*2) or
  5232             {if (gX > max(LAND_WIDTH,4096)*2) or
  5236                     (gX < -max(LAND_WIDTH,4096)) or
  5233                     (gX < -max(LAND_WIDTH,4096)) or
  5237                     (gY < -max(LAND_HEIGHT,4096)) or
  5234                     (gY < -max(LAND_HEIGHT,4096)) or
  5238                     (gY > max(LAND_HEIGHT,4096)+512) then
  5235                     (gY > max(LAND_HEIGHT,4096)+512) then
  5239             begin
  5236             begin