hedgewars/GSHandlers.inc
changeset 7093 2d7f1fb73335
parent 7092 c9ca770fd7fc
child 7098 f8c453ade379
equal deleted inserted replaced
7092:c9ca770fd7fc 7093:2d7f1fb73335
  5435 *)
  5435 *)
  5436 procedure doStepIceGun(Gear: PGear);
  5436 procedure doStepIceGun(Gear: PGear);
  5437 var 
  5437 var 
  5438     HHGear, iter: PGear;
  5438     HHGear, iter: PGear;
  5439     ndX, ndY: hwFloat;
  5439     ndX, ndY: hwFloat;
  5440     gX, gY: LongInt;
  5440     t, gX, gY: LongInt;
  5441 begin
  5441 begin
       
  5442     HHGear := Gear^.Hedgehog^.Gear;
       
  5443     if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
       
  5444         begin
       
  5445         DeleteGear(Gear);
       
  5446         AfterAttack;
       
  5447         exit
       
  5448         end
       
  5449     else
       
  5450         begin
       
  5451         t:= Gear^.Health div 10;
       
  5452         if (t <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
       
  5453             begin
       
  5454             Gear^.Damage:= t;
       
  5455             FreeTexture(Gear^.Tex);
       
  5456             Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(t) +
       
  5457                          '%', cWhiteColor, fntSmall)
       
  5458             end
       
  5459         end;
       
  5460     if GameTicks mod 10 = 0 then dec(Gear^.Health);
  5442     with Gear^ do
  5461     with Gear^ do
  5443         begin
  5462         begin
  5444         HHGear := Hedgehog^.Gear;
       
  5445         HedgehogChAngle(HHGear);
  5463         HedgehogChAngle(HHGear);
  5446         ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
  5464         ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4;
  5447         ndY:= -AngleCos(HHGear^.Angle);
  5465         ndY:= -AngleCos(HHGear^.Angle) * _4;
  5448         if (ndX <> dX) or (ndY <> dY) then
  5466         if (ndX <> dX) or (ndY <> dY) then
  5449             begin
  5467             begin
       
  5468             dX:= ndX;
       
  5469             dY:= ndY;
  5450             Pos:= 0;
  5470             Pos:= 0;
  5451             Target.X:= NoPointX;
  5471             Target.X:= NoPointX;
  5452             LastDamage:= nil;
  5472             LastDamage:= nil;
  5453             X:= HHGear^.X;
  5473             X:= HHGear^.X;
  5454             Y:= HHGear^.Y;
  5474             Y:= HHGear^.Y;
  5457             while iter <> nil do
  5477             while iter <> nil do
  5458                 begin
  5478                 begin
  5459                 if (iter^.Kind = gtHedgehog) and 
  5479                 if (iter^.Kind = gtHedgehog) and 
  5460                    (iter^.Hedgehog^.Effects[heFrozen] < 0) then 
  5480                    (iter^.Hedgehog^.Effects[heFrozen] < 0) then 
  5461                     iter^.Hedgehog^.Effects[heFrozen]:= 0;
  5481                     iter^.Hedgehog^.Effects[heFrozen]:= 0;
  5462                 iter:= iter^.NextGear;
  5482                 iter:= iter^.NextGear
  5463                 end;
  5483                 end
  5464             end
  5484             end
  5465         else
  5485         else
  5466             begin
  5486             begin
       
  5487             X:= X + dX;
       
  5488             Y:= Y + dY;
  5467             gX:= hwRound(X);
  5489             gX:= hwRound(X);
  5468             gY:= hwRound(Y);
  5490             gY:= hwRound(Y);
  5469             X:= X + dX;
  5491             if Target.X = NoPointX then t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y));
  5470             Y:= Y + dY;
       
  5471             if Target.X <> NoPointX then
  5492             if Target.X <> NoPointX then
  5472                 inc(Pos)
  5493                 inc(Pos)
  5473             else if (gY > cWaterLine) or 
  5494             else if (gY > cWaterLine) or
  5474                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
  5495                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
  5475                         and ((Land[gY, gX] and $FF00 and not lfIce <> 0) or
  5496                         and ((Land[gY, gX] and $FF00 and not lfIce <> 0) or
  5476                              (Land[gY, gX] and $00FF <> 0))) then
  5497                              ((Land[gY, gX] and $00FF <> 0) and (t > 400)))) then
  5477                 begin
  5498                 begin
  5478                 Target.X:= gX;
  5499                 Target.X:= gX;
  5479                 Target.Y:= gY;
  5500                 Target.Y:= gY;
  5480                 if Land[gY, gX] and $00FF <> 0 then // locate and tag hogs
  5501                 if (gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0) then
  5481                     begin
  5502                     begin
  5482                 //GearsNear(X, Y, gtHedgehog, Radius);
  5503                     LandPixels[gY, gX]:= $FFFFFFFF; // just testing
       
  5504                     UpdateLandTexture(gX, 1, gY, 1);
       
  5505                     if Land[gY, gX] and $00FF <> 0 then // locate and tag hogs
       
  5506                         begin
       
  5507                     //GearsNear(X, Y, gtHedgehog, Radius);
       
  5508                         end
  5483                     end;
  5509                     end;
       
  5510                 X:= HHGear^.X;
       
  5511                 Y:= HHGear^.Y
       
  5512                 end;
       
  5513             if (gX > LAND_WIDTH*2) or
       
  5514                     (gX < -LAND_WIDTH) or
       
  5515                     (gY < -LAND_HEIGHT) or
       
  5516                     (gY > LAND_HEIGHT+512) or
       
  5517                     (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0))
       
  5518                      and (Land[gy, gX] > $FF)) then
       
  5519                 begin
       
  5520                 X:= HHGear^.X;
       
  5521                 Y:= HHGear^.Y
  5484                 end
  5522                 end
  5485         end
  5523         end
  5486     end;
  5524     end;
  5487 end;
  5525 end;