hedgewars/uGearsHandlersMess.pas
branchqmlfrontend
changeset 10922 999d95494fe7
parent 10905 c0919d7e5ce9
child 10952 8ad21fe5d062
equal deleted inserted replaced
10908:1bd7a3a28b18 10922:999d95494fe7
   435             begin
   435             begin
   436             Gear^.dX := tdY*cElastic*Gear^.Friction;
   436             Gear^.dX := tdY*cElastic*Gear^.Friction;
   437             Gear^.dY := tdX*cElastic
   437             Gear^.dY := tdX*cElastic
   438             end;
   438             end;
   439 
   439 
   440         Gear^.dY.isNegative := not tdY.isNegative;
   440         Gear^.dX.isNegative:= tdX.isNegative;
       
   441         Gear^.dY.isNegative:= tdY.isNegative;
       
   442         if (collV > 0) and (collH > 0) and (not tdX.isNegative) and (not tdY.isNegative) then
       
   443             begin
       
   444             Gear^.dX.isNegative := true;
       
   445             Gear^.dY.isNegative := true
       
   446             end
       
   447         else if (collV > 0) and (collH < 0) and (tdX.isNegative or tdY.isNegative) then
       
   448             begin
       
   449             Gear^.dY.isNegative := not tdY.isNegative;
       
   450             if not tdY.isNegative then Gear^.dX.isNegative := false
       
   451             end
       
   452         else if (collV < 0) and (collH > 0) and (not tdX.isNegative) then
       
   453             begin
       
   454             Gear^.dX.isNegative := true;
       
   455             Gear^.dY.isNegative := false
       
   456             end
       
   457         else if (collV < 0) and (collH < 0) and tdX.isNegative and tdY.isNegative then
       
   458             Gear^.dX.isNegative := false;
       
   459        
   441         isFalling := false;
   460         isFalling := false;
   442         Gear^.AdvBounce := 10;
   461         Gear^.AdvBounce := 10;
   443         end;
   462         end;
   444 
   463 
   445     if Gear^.AdvBounce > 1 then
   464     if Gear^.AdvBounce > 1 then
   461         Gear^.State := Gear^.State and (not gstMoving)
   480         Gear^.State := Gear^.State and (not gstMoving)
   462     else
   481     else
   463         Gear^.State := Gear^.State or gstMoving;
   482         Gear^.State := Gear^.State or gstMoving;
   464 
   483 
   465     if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then
   484     if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then
       
   485         begin
   466         Gear^.State := Gear^.State or gstCollision;
   486         Gear^.State := Gear^.State or gstCollision;
       
   487         AddFileLog('no more bounce for you!');
       
   488         end;
   467 
   489 
   468     if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and
   490     if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and
   469        ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then
   491        ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then
   470         begin
   492         begin
   471         AddBounceEffectForGear(Gear);
   493         AddBounceEffectForGear(Gear);
  2514 
  2536 
  2515     HHGear := Gear^.Hedgehog^.Gear;
  2537     HHGear := Gear^.Hedgehog^.Gear;
  2516     if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then
  2538     if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then
  2517         begin
  2539         begin
  2518         Gear^.Tag := hwRound(HHGear^.Y);
  2540         Gear^.Tag := hwRound(HHGear^.Y);
  2519         DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2);
  2541         DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4+2, 2);
  2520         HHGear^.State := HHGear^.State or gstNoDamage;
  2542         HHGear^.State := HHGear^.State or gstNoDamage;
  2521         Gear^.Y := HHGear^.Y;
  2543         Gear^.Y := HHGear^.Y;
  2522         AmmoShove(Gear, 30, 40);
  2544         AmmoShove(Gear, 30, 40);
  2523         HHGear^.State := HHGear^.State and (not gstNoDamage)
  2545         HHGear^.State := HHGear^.State and (not gstNoDamage)
  2524         end;
  2546         end;
  2827     // remember original target location
  2849     // remember original target location
  2828     oy:= Gear^.Target.Y;
  2850     oy:= Gear^.Target.Y;
  2829 
  2851 
  2830     for y:= ty downto ty - ytol do
  2852     for y:= ty downto ty - ytol do
  2831         begin
  2853         begin
  2832         if TryPlaceOnLand(lx, y, sprHHTelepMask, 0, false, not hasBorder, false, 0) then
  2854         if TryPlaceOnLand(lx, y, sprHHTelepMask, 0, false, not hasBorder, false, false, false, false, 0, $FFFFFFFF) then
  2833             begin
  2855             begin
  2834             valid:= true;
  2856             valid:= true;
  2835             break;
  2857             break;
  2836             end;
  2858             end;
  2837         dec(Gear^.Target.Y);
  2859         dec(Gear^.Target.Y);
  3482 
  3504 
  3483     else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) = 0) then
  3505     else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) = 0) then
  3484         begin
  3506         begin
  3485         StopSoundChan(Gear^.SoundChannel);
  3507         StopSoundChan(Gear^.SoundChannel);
  3486         Gear^.Tag := 1;
  3508         Gear^.Tag := 1;
       
  3509         Gear^.AdvBounce:= 50;
  3487         Gear^.doStep := @doStepDrill
  3510         Gear^.doStep := @doStepDrill
  3488         end;
  3511         end;
  3489 
  3512 
  3490     dec(Gear^.Timer);
  3513     dec(Gear^.Timer);
  3491 end;
  3514 end;
  4188 begin
  4211 begin
  4189     doPortalColorSwitch();
  4212     doPortalColorSwitch();
  4190 
  4213 
  4191     // destroy portal if ground it was attached too is gone
  4214     // destroy portal if ground it was attached too is gone
  4192     if (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] <= lfAllObjMask)
  4215     if (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] <= lfAllObjMask)
       
  4216     or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] and lfBouncy <> 0)
  4193     or (Gear^.Timer < 1)
  4217     or (Gear^.Timer < 1)
  4194     or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team)
  4218     or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team)
  4195     or CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  4219     or CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  4196         begin
  4220         begin
  4197         deleteGear(Gear);
  4221         deleteGear(Gear);