hedgewars/uGearsHedgehog.pas
changeset 9706 5178d2263521
parent 9685 7d925e82e572
child 9731 953197ac43d8
equal deleted inserted replaced
9704:055fee9da6a0 9706:5178d2263521
   758     if ((Gear^.Message and gmLJump ) <> 0) then
   758     if ((Gear^.Message and gmLJump ) <> 0) then
   759         begin
   759         begin
   760         Gear^.Message:= Gear^.Message and (not gmLJump);
   760         Gear^.Message:= Gear^.Message and (not gmLJump);
   761         DeleteCI(Gear);
   761         DeleteCI(Gear);
   762         if TestCollisionYwithGear(Gear, -1) = 0 then
   762         if TestCollisionYwithGear(Gear, -1) = 0 then
   763             if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then
   763             if TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) = 0 then
   764                 Gear^.Y:= Gear^.Y - _2
   764                 Gear^.Y:= Gear^.Y - _2
   765             else
   765             else
   766                 if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then
   766                 if TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) = 0 then
   767                     Gear^.Y:= Gear^.Y - _1;
   767                     Gear^.Y:= Gear^.Y - _1;
   768             if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
   768             if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) = 0) and
   769             or   (TestCollisionYwithGear(Gear, -1) <> 0)) then
   769                (TestCollisionYwithGear(Gear, -1) = 0) then
   770                 begin
   770                 begin
   771                 Gear^.dY:= -_0_15;
   771                 Gear^.dY:= -_0_15;
   772                 if not cArtillery then
   772                 if not cArtillery then
   773                     Gear^.dX:= SignAs(_0_15, Gear^.dX);
   773                     Gear^.dX:= SignAs(_0_15, Gear^.dX);
   774                 Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   774                 Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   852     Gear^.dY:= _0;
   852     Gear^.dY:= _0;
   853     Gear^.dX:= _0;
   853     Gear^.dX:= _0;
   854     Gear^.State:= Gear^.State and (not gstMoving);
   854     Gear^.State:= Gear^.State and (not gstMoving);
   855     exit
   855     exit
   856     end;
   856     end;
   857 isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1));
   857 isFalling:= (Gear^.dY.isNegative) or (TestCollisionYKick(Gear, 1) = 0);
   858 if isFalling then
   858 if isFalling then
   859     begin
   859     begin
   860     if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
   860     if (Gear^.dY.isNegative) and (TestCollisionYKick(Gear, -1) <> 0) then
   861         Gear^.dY:= _0;
   861         Gear^.dY:= _0;
   862     Gear^.State:= Gear^.State or gstMoving;
   862     Gear^.State:= Gear^.State or gstMoving;
   863     if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
   863     if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
   864        (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   864        (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   865         begin
   865         begin
   919    Gear^.dY:= Gear^.dY * _0_999;
   919    Gear^.dY:= Gear^.dY * _0_999;
   920    Gear^.dX:= Gear^.dX * _0_999;
   920    Gear^.dX:= Gear^.dX * _0_999;
   921    end;
   921    end;
   922 
   922 
   923 if (Gear^.State and gstMoving) <> 0 then
   923 if (Gear^.State and gstMoving) <> 0 then
   924     if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then
   924     if TestCollisionXKick(Gear, hwSign(Gear^.dX)) <> 0 then
   925         if not isFalling then
   925         if not isFalling then
   926             if hwAbs(Gear^.dX) > _0_01 then
   926             if hwAbs(Gear^.dX) > _0_01 then
   927                 if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) or
   927                 if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) = 0) and
   928                 (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
   928                     (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
   929                     begin
   929                     begin
   930                     Gear^.X:= Gear^.X + Gear^.dX;
   930                     Gear^.X:= Gear^.X + Gear^.dX;
   931                     Gear^.dX:= Gear^.dX * _0_96;
   931                     Gear^.dX:= Gear^.dX * _0_96;
   932                     Gear^.Y:= Gear^.Y - _1
   932                     Gear^.Y:= Gear^.Y - _1
   933                     end
   933                     end
   934                 else
   934                 else
   935                     if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) or
   935                     if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) = 0) and
   936                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
   936                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
   937                         begin
   937                         begin
   938                         Gear^.X:= Gear^.X + Gear^.dX;
   938                         Gear^.X:= Gear^.X + Gear^.dX;
   939                         Gear^.dX:= Gear^.dX * _0_93;
   939                         Gear^.dX:= Gear^.dX * _0_93;
   940                         Gear^.Y:= Gear^.Y - _2
   940                         Gear^.Y:= Gear^.Y - _2
   941                         end
   941                         end
   942                     else
   942                     else
   943                     if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) or
   943                     if  (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) = 0) and
   944                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
   944                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
   945                         begin
   945                         begin
   946                         Gear^.X:= Gear^.X + Gear^.dX;
   946                         Gear^.X:= Gear^.X + Gear^.dX;
   947                         Gear^.dX:= Gear^.dX * _0_9 ;
   947                         Gear^.dX:= Gear^.dX * _0_9 ;
   948                         Gear^.Y:= Gear^.Y - _3
   948                         Gear^.Y:= Gear^.Y - _3
   949                         end
   949                         end
   950                     else
   950                     else
   951                         if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) or
   951                         if (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) = 0) and
   952                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
   952                            (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
   953                             begin
   953                             begin
   954                             Gear^.X:= Gear^.X + Gear^.dX;
   954                             Gear^.X:= Gear^.X + Gear^.dX;
   955                             Gear^.dX:= Gear^.dX * _0_87;
   955                             Gear^.dX:= Gear^.dX * _0_87;
   956                             Gear^.Y:= Gear^.Y - _4
   956                             Gear^.Y:= Gear^.Y - _4
   957                             end
   957                             end
   958                     else
   958                     else
   959                         if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) or
   959                         if (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) = 0) and
   960                         (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then
   960                            (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1) = 0) then
   961                             begin
   961                             begin
   962                             Gear^.X:= Gear^.X + Gear^.dX;
   962                             Gear^.X:= Gear^.X + Gear^.dX;
   963                             Gear^.dX:= Gear^.dX * _0_84;
   963                             Gear^.dX:= Gear^.dX * _0_84;
   964                             Gear^.Y:= Gear^.Y - _5
   964                             Gear^.Y:= Gear^.Y - _5
   965                             end
   965                             end
  1006     begin
  1006     begin
  1007     Gear^.State:= Gear^.State and (not gstAnimation);
  1007     Gear^.State:= Gear^.State and (not gstAnimation);
  1008 // ARTILLERY but not being moved by explosions
  1008 // ARTILLERY but not being moved by explosions
  1009     Gear^.X:= Gear^.X + Gear^.dX;
  1009     Gear^.X:= Gear^.X + Gear^.dX;
  1010     Gear^.Y:= Gear^.Y + Gear^.dY;
  1010     Gear^.Y:= Gear^.Y + Gear^.dY;
  1011     if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1))
  1011     if (not Gear^.dY.isNegative) and (TestCollisionYKick(Gear, 1) = 0)
  1012     and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
  1012     and (TestCollisionYwithXYShift(Gear, 0, 1, 1) <> 0) then
  1013         begin
  1013         begin
  1014         CheckHHDamage(Gear);
  1014         CheckHHDamage(Gear);
  1015         Gear^.dY:= _0;
  1015         Gear^.dY:= _0;
  1016         Gear^.Y:= Gear^.Y + _1
  1016         Gear^.Y:= Gear^.Y + _1
  1017         end;
  1017         end;
  1155             PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack)
  1155             PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack)
  1156             end;
  1156             end;
  1157 
  1157 
  1158     HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
  1158     HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump));
  1159 
  1159 
  1160     if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
  1160     if (not cArtillery) and wasJumping and (TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) <> 0) then
  1161         SetLittle(HHGear^.dX);
  1161         SetLittle(HHGear^.dX);
  1162 
  1162 
  1163     if Hedgehog^.Gear <> nil then
  1163     if Hedgehog^.Gear <> nil then
  1164         doStepHedgehogMoving(HHGear);
  1164         doStepHedgehogMoving(HHGear);
  1165 
  1165 
  1299 if WorldWrap(Gear) then
  1299 if WorldWrap(Gear) then
  1300     begin
  1300     begin
  1301     if (WorldEdge <> weBounce) and (Gear = CurrentHedgehog^.Gear) and 
  1301     if (WorldEdge <> weBounce) and (Gear = CurrentHedgehog^.Gear) and 
  1302        (CurAmmoGear <> nil) and (CurAmmoGear^.Kind =gtRope) and (CurAmmoGear^.Elasticity <> _0) then
  1302        (CurAmmoGear <> nil) and (CurAmmoGear^.Kind =gtRope) and (CurAmmoGear^.Elasticity <> _0) then
  1303        CurAmmoGear^.PortalCounter:= 1;
  1303        CurAmmoGear^.PortalCounter:= 1;
  1304     if (WorldEdge = weWrap) and (TestCollisionXwithGear(Gear, 1) or TestCollisionXwithGear(Gear, -1))  then
  1304     if (WorldEdge = weWrap) and ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0))  then
  1305         begin
  1305         begin
  1306         Gear^.X:= tX;
  1306         Gear^.X:= tX;
  1307         Gear^.dX.isNegative:= (hwRound(tX) > leftX+Gear^.Radius*2)
  1307         Gear^.dX.isNegative:= (hwRound(tX) > leftX+Gear^.Radius*2)
  1308         end
  1308         end
  1309     end;
  1309     end;