hedgewars/GSHandlers.inc
changeset 4747 095398eba689
parent 4708 aa1da6339eb3
child 4758 73aef6a577ba
equal deleted inserted replaced
4654:1cc14ece1486 4747:095398eba689
   592         if yy > cWaterLine then move:= true
   592         if yy > cWaterLine then move:= true
   593         else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] > 255) then
   593         else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] > 255) then
   594             begin
   594             begin
   595             // we've collided with land. draw some stuff and get back into the clouds
   595             // we've collided with land. draw some stuff and get back into the clouds
   596             move:= true;
   596             move:= true;
       
   597             if (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope) then
       
   598                 begin
   597 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
   599 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
   598             if cWindSpeed * 1600 + dX < _0 then i:= -1
   600                 if cWindSpeed * 1600 + dX < _0 then i:= -1
   599             else i:= 1;
   601                 else i:= 1;
   600             if (yy > 0) and ((Land[yy-1, xx] and $FF00) = 0) then dec(yy)
   602                 if (yy > 0) and ((Land[yy-1, xx] and $FF00) = 0) then dec(yy)
   601             else dec(xx, i);
   603                 else dec(xx, i);
   602             dec(yy,2);
   604                 dec(yy,2);
   603             dec(xx,i);
   605                 dec(xx,i);
   604             s:= SpritesData[sprSnow].Surface;
   606                 s:= SpritesData[sprSnow].Surface;
   605             p:= s^.pixels;
   607                 p:= s^.pixels;
   606             allpx:= true;
   608                 allpx:= true;
   607             for py:= 0 to Pred(s^.h) do
   609                 for py:= 0 to Pred(s^.h) do
   608                 begin
   610                     begin
   609                 for px:= 0 to Pred(s^.w) do
   611                     for px:= 0 to Pred(s^.w) do
   610                     if ((yy + py and LAND_HEIGHT_MASK) = 0) and ((xx + px and LAND_WIDTH_MASK) = 0) and 
   612                         if (((yy + py) and LAND_HEIGHT_MASK) = 0) and (((xx + px) and LAND_WIDTH_MASK) = 0) and 
   611                        ((Land[yy + py, xx + px] and $FF00) = 0) then
   613                            ((Land[yy + py, xx + px] and $FF00) = 0) then
   612                         begin
   614                             begin
   613                         if (cReducedQuality and rqBlurryLand) = 0 then
   615                             if (cReducedQuality and rqBlurryLand) = 0 then
   614                             LandPixels[yy + py, xx + px]:= p^[px]
   616                                 LandPixels[yy + py, xx + px]:= p^[px]
   615                         else
   617                             else
   616                             LandPixels[(yy + py) div 2, (xx + px) div 2]:= p^[px]
   618                                 LandPixels[(yy + py) div 2, (xx + px) div 2]:= p^[px]
   617                         end
   619                             end
   618                     else allpx:= false;
   620                         else allpx:= false;
   619                 p:= @(p^[s^.pitch shr 2])
   621                     p:= @(p^[s^.pitch shr 2])
   620                 end;
   622                     end;
   621             if allpx then UpdateLandTexture(xx, 4, yy, 4)
   623                 if allpx then UpdateLandTexture(xx, 4, yy, 4)
   622             else UpdateLandTexture(xx, 1, yy, 1);
   624                 else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) then UpdateLandTexture(xx, 1, yy, 1);
   623             inc(yy,2);
   625                 inc(yy,2);
   624             inc(xx,i);
   626                 inc(xx,i);
   625             if ((xx and LAND_WIDTH_MASK) = 0) and ((yy and LAND_HEIGHT_MASK) = 0) then Land[yy, xx]:= Land[yy, xx] or lfObject;
   627                 if ((xx and LAND_WIDTH_MASK) = 0) and ((yy and LAND_HEIGHT_MASK) = 0) then Land[yy, xx]:= Land[yy, xx] or lfObject;
   626             if yy > 0 then
   628                 if yy > 0 then
   627                 begin 
   629                     begin 
   628                 Land[yy-1, xx]:= Land[yy-1, xx] or lfObject;
   630                     Land[yy-1, xx]:= Land[yy-1, xx] or lfObject;
   629                 if ((xx-i and LAND_WIDTH_MASK) = 0) then Land[yy-1, xx-i]:= Land[yy-1, xx-i] or lfObject;
   631                     if ((xx-i and LAND_WIDTH_MASK) = 0) then Land[yy-1, xx-i]:= Land[yy-1, xx-i] or lfObject;
   630                 end;
   632                     end;
   631             if ((xx-i and LAND_WIDTH_MASK) = 0) and ((yy and LAND_HEIGHT_MASK) = 0) then Land[yy, xx-i]:= Land[yy, xx-i] or lfObject
   633                 if ((xx-i and LAND_WIDTH_MASK) = 0) and ((yy and LAND_HEIGHT_MASK) = 0) then Land[yy, xx-i]:= Land[yy, xx-i] or lfObject
   632 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
   634 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
       
   635                 end
   633             end;
   636             end;
   634         if move then
   637         if move then
   635             begin
   638             begin
   636             X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512);
   639             X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512);
   637             Y:= int2hwFloat(750+(GetRandom(50)-25))
   640             Y:= int2hwFloat(750+(GetRandom(50)-25))
   907 end;
   910 end;
   908 
   911 
   909 procedure doStepDEagleShot(Gear: PGear);
   912 procedure doStepDEagleShot(Gear: PGear);
   910 begin
   913 begin
   911     PlaySound(sndGun);
   914     PlaySound(sndGun);
       
   915     // add an initial step to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths
       
   916     Gear^.X := Gear^.X + Gear^.dX;  
       
   917     Gear^.Y := Gear^.Y + Gear^.dY;
   912     Gear^.doStep := @doStepBulletWork
   918     Gear^.doStep := @doStepBulletWork
   913 end;
   919 end;
   914 
   920 
   915 procedure doStepSniperRifleShot(Gear: PGear);
   921 procedure doStepSniperRifleShot(Gear: PGear);
   916 var 
   922 var 
   940         end;
   946         end;
   941         Gear^.State := Gear^.State or gstAnimation;
   947         Gear^.State := Gear^.State or gstAnimation;
   942         Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
   948         Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
   943         Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5;
   949         Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5;
   944         PlaySound(sndGun);
   950         PlaySound(sndGun);
       
   951         // add an initial step to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths
       
   952         Gear^.X := Gear^.X + Gear^.dX;  
       
   953         Gear^.Y := Gear^.Y + Gear^.dY;
   945         Gear^.doStep := @doStepBulletWork;
   954         Gear^.doStep := @doStepBulletWork;
   946     end
   955     end
   947     else
   956     else
   948         if (GameTicks mod 32) = 0 then
   957         if (GameTicks mod 32) = 0 then
   949             if (GameTicks mod 4096) < 2048 then
   958             if (GameTicks mod 4096) < 2048 then
  1033         end;
  1042         end;
  1034 
  1043 
  1035     if (Gear^.Timer mod 47) = 0 then
  1044     if (Gear^.Timer mod 47) = 0 then
  1036         begin
  1045         begin
  1037         // ok. this was an attempt to turn off dust if not actually drilling land.  I have no idea why it isn't working as expected
  1046         // ok. this was an attempt to turn off dust if not actually drilling land.  I have no idea why it isn't working as expected
  1038         //if ((y + 12 and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y + 12, x] > 255) then 
  1047         if (( (y + 12) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y + 12, x] > 255) then 
  1039             for i:= 0 to 1 do
  1048             for i:= 0 to 1 do
  1040                 AddVisualGear(x - 5 + Random(10), y + 12, vgtDust);
  1049                 AddVisualGear(x - 5 + Random(10), y + 12, vgtDust);
  1041 
  1050 
  1042         i := x - Gear^.Radius - LongInt(GetRandom(2));
  1051         i := x - Gear^.Radius - LongInt(GetRandom(2));
  1043         ei := x + Gear^.Radius + LongInt(GetRandom(2));
  1052         ei := x + Gear^.Radius + LongInt(GetRandom(2));