hedgewars/uGearsHandlersMess.pas
branchwebgl
changeset 9954 bf51bc7e2808
parent 9950 2759212a27de
child 10015 4feced261c68
equal deleted inserted replaced
9952:32f5982604f4 9954:bf51bc7e2808
  1052         if Gear^.Timer = 0 then
  1052         if Gear^.Timer = 0 then
  1053             begin
  1053             begin
  1054             // no need to display remaining time anymore
  1054             // no need to display remaining time anymore
  1055             Gear^.RenderTimer:= false;
  1055             Gear^.RenderTimer:= false;
  1056             // bee can drown when timer reached 0
  1056             // bee can drown when timer reached 0
  1057             Gear^.State:= Gear^.State and not gstSubmersible;
  1057             Gear^.State:= Gear^.State and (not gstSubmersible);
  1058             end;
  1058             end;
  1059         end;
  1059         end;
  1060 end;
  1060 end;
  1061 
  1061 
  1062 procedure doStepBee(Gear: PGear);
  1062 procedure doStepBee(Gear: PGear);
  1233         y := hwRound(Gear^.Y);
  1233         y := hwRound(Gear^.Y);
  1234 
  1234 
  1235         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
  1235         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
  1236             inc(Gear^.Damage);
  1236             inc(Gear^.Damage);
  1237         // let's interrupt before a collision to give portals a chance to catch the bullet
  1237         // let's interrupt before a collision to give portals a chance to catch the bullet
  1238         if (Gear^.Damage = 1) and (Gear^.Tag = 0) and not(CheckLandValue(x, y, lfLandMask)) then
  1238         if (Gear^.Damage = 1) and (Gear^.Tag = 0) and (not CheckLandValue(x, y, lfLandMask)) then
  1239             begin
  1239             begin
  1240             Gear^.Tag := 1;
  1240             Gear^.Tag := 1;
  1241             Gear^.Damage := 0;
  1241             Gear^.Damage := 0;
  1242             Gear^.X := Gear^.X - Gear^.dX;
  1242             Gear^.X := Gear^.X - Gear^.dX;
  1243             Gear^.Y := Gear^.Y - Gear^.dY;
  1243             Gear^.Y := Gear^.Y - Gear^.dY;
  1804     dxdy: hwFloat;
  1804     dxdy: hwFloat;
  1805 begin
  1805 begin
  1806     if (Gear^.dY.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then
  1806     if (Gear^.dY.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then
  1807         SetLittle(Gear^.dY);
  1807         SetLittle(Gear^.dY);
  1808     Gear^.State := Gear^.State or gstAnimation;
  1808     Gear^.State := Gear^.State or gstAnimation;
  1809     if Gear^.Health < cBarrelHealth then Gear^.State:= Gear^.State and not gstFrozen;
  1809     if Gear^.Health < cBarrelHealth then Gear^.State:= Gear^.State and (not gstFrozen);
  1810 
  1810 
  1811     if ((Gear^.dX.QWordValue <> 0)
  1811     if ((Gear^.dX.QWordValue <> 0)
  1812     or (Gear^.dY.QWordValue <> 0))  then
  1812     or (Gear^.dY.QWordValue <> 0))  then
  1813         begin
  1813         begin
  1814         DeleteCI(Gear);
  1814         DeleteCI(Gear);
  1890         with CurrentHedgehog^ do
  1890         with CurrentHedgehog^ do
  1891             if Gear <> nil then
  1891             if Gear <> nil then
  1892                 Gear^.Message := Gear^.Message and (not (gmLJump or gmHJump));
  1892                 Gear^.Message := Gear^.Message and (not (gmLJump or gmHJump));
  1893         exit
  1893         exit
  1894         end;
  1894         end;
  1895     if (k = gtExplosives) and (Gear^.Health < cBarrelHealth) then Gear^.State:= Gear^.State and not gstFrozen;
  1895     if (k = gtExplosives) and (Gear^.Health < cBarrelHealth) then Gear^.State:= Gear^.State and (not gstFrozen);
  1896 
  1896 
  1897     if ((k <> gtExplosives) and (Gear^.Damage > 0)) or ((k = gtExplosives) and (Gear^.Health<=0)) then
  1897     if ((k <> gtExplosives) and (Gear^.Damage > 0)) or ((k = gtExplosives) and (Gear^.Health<=0)) then
  1898         begin
  1898         begin
  1899         x := hwRound(Gear^.X);
  1899         x := hwRound(Gear^.X);
  1900         y := hwRound(Gear^.Y);
  1900         y := hwRound(Gear^.Y);
  2469     doStepFallingGear(Gear);
  2469     doStepFallingGear(Gear);
  2470     if (Gear^.State and gstCollision) <> 0 then
  2470     if (Gear^.State and gstCollision) <> 0 then
  2471         begin
  2471         begin
  2472         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
  2472         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound);
  2473         DeleteGear(Gear);
  2473         DeleteGear(Gear);
       
  2474         {$IFNDEF PAS2C}
  2474         with mobileRecord do
  2475         with mobileRecord do
  2475             if (performRumble <> nil) and (not fastUntilLag) then
  2476             if (performRumble <> nil) and (not fastUntilLag) then
  2476                 performRumble(kSystemSoundID_Vibrate);
  2477                 performRumble(kSystemSoundID_Vibrate);
       
  2478         {$ENDIF}
  2477         exit
  2479         exit
  2478         end;
  2480         end;
  2479     if (GameTicks and $3F) = 0 then
  2481     if (GameTicks and $3F) = 0 then
  2480         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
  2482         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
  2481 end;
  2483 end;
  4613     AmmoShove(Gear, 0, 80);
  4615     AmmoShove(Gear, 0, 80);
  4614     Gear^.dX.isNegative := not Gear^.dX.isNegative;
  4616     Gear^.dX.isNegative := not Gear^.dX.isNegative;
  4615     Gear^.dY.isNegative := not Gear^.dY.isNegative;
  4617     Gear^.dY.isNegative := not Gear^.dY.isNegative;
  4616 
  4618 
  4617     Gear^.doStep := @doStepSineGunShotWork;
  4619     Gear^.doStep := @doStepSineGunShotWork;
       
  4620     {$IFNDEF PAS2C}
  4618     with mobileRecord do
  4621     with mobileRecord do
  4619         if (performRumble <> nil) and (not fastUntilLag) then
  4622         if (performRumble <> nil) and (not fastUntilLag) then
  4620             performRumble(kSystemSoundID_Vibrate);
  4623             performRumble(kSystemSoundID_Vibrate);
       
  4624     {$ENDIF}
  4621 end;
  4625 end;
  4622 
  4626 
  4623 ////////////////////////////////////////////////////////////////////////////////
  4627 ////////////////////////////////////////////////////////////////////////////////
  4624 procedure doStepFlamethrowerWork(Gear: PGear);
  4628 procedure doStepFlamethrowerWork(Gear: PGear);
  4625 var
  4629 var
  5492                     iter := GearsList;
  5496                     iter := GearsList;
  5493                     while iter <> nil do
  5497                     while iter <> nil do
  5494                         begin
  5498                         begin
  5495                         if (iter^.State and gstFrozen = 0) and
  5499                         if (iter^.State and gstFrozen = 0) and
  5496                            ((iter^.Kind = gtExplosives) or (iter^.Kind = gtCase) or (iter^.Kind = gtMine)) and 
  5500                            ((iter^.Kind = gtExplosives) or (iter^.Kind = gtCase) or (iter^.Kind = gtMine)) and 
  5497                            (abs(iter^.X.Round-target.x)+abs(iter^.Y.Round-target.y)+2<2*iceRadius) and (Distance(iter^.X-int2hwFloat(target.x),iter^.Y-int2hwFloat(target.y))<int2hwFloat(iceRadius*2)) then
  5501                            (abs(LongInt(iter^.X.Round) - target.x) + abs(LongInt(iter^.Y.Round) - target.y) + 2 < 2 * iceRadius) 
       
  5502                            and (Distance(iter^.X - int2hwFloat(target.x), iter^.Y - int2hwFloat(target.y)) < int2hwFloat(iceRadius * 2)) then
  5498                             begin
  5503                             begin
  5499                             for t:= 0 to 5 do
  5504                             for t:= 0 to 5 do
  5500                                 begin
  5505                                 begin
  5501                                 vg:= AddVisualGear(hwRound(iter^.X)+random(4)-8, hwRound(iter^.Y)+random(8), vgtDust, 1);
  5506                                 vg:= AddVisualGear(hwRound(iter^.X)+random(4)-8, hwRound(iter^.Y)+random(8), vgtDust, 1);
  5502                                 if vg <> nil then
  5507                                 if vg <> nil then
  5619     gi := GearsList;
  5624     gi := GearsList;
  5620     while gi <> nil do
  5625     while gi <> nil do
  5621         begin
  5626         begin
  5622         with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
  5627         with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac;
  5623         AddRandomness(CheckSum);
  5628         AddRandomness(CheckSum);
  5624         if gi^.Kind = gtGenericFaller then gi^.State:= gi^.State and not gstTmpFlag;
  5629         if gi^.Kind = gtGenericFaller then gi^.State:= gi^.State and (not gstTmpFlag);
  5625         gi := gi^.NextGear
  5630         gi := gi^.NextGear
  5626         end;
  5631         end;
  5627     AddPickup(Gear^.Hedgehog^, a, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y));
  5632     AddPickup(Gear^.Hedgehog^, a, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y));
  5628     DeleteGear(Gear)
  5633     DeleteGear(Gear)
  5629     end;
  5634     end;