hedgewars/GSHandlers.inc
changeset 3094 97c8406acc85
parent 3092 dfeb6fc771f7
child 3096 9330eead14fa
equal deleted inserted replaced
3093:ff59e61346f5 3094:97c8406acc85
   232 //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and
   232 //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and
   233 if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) and
   233 if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) and
   234     (not isFalling) then
   234     (not isFalling) then
   235     Gear^.State:= Gear^.State and not gstMoving
   235     Gear^.State:= Gear^.State and not gstMoving
   236 else
   236 else
   237     Gear^.State:= Gear^.State or      gstMoving
   237     Gear^.State:= Gear^.State or      gstMoving;
       
   238 
       
   239 if ((Gear^.Damage <> 0) or ((Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving))) then
       
   240     if ((Gear^.dX.QWordValue > _0_1.QWordValue)
       
   241     or  (Gear^.dY.QWordValue > _0_1.QWordValue)) then
       
   242         PlaySound(Gear^.ImpactSound);
   238 end;
   243 end;
   239 
   244 
   240 ////////////////////////////////////////////////////////////////////////////////
   245 ////////////////////////////////////////////////////////////////////////////////
   241 procedure doStepBomb(Gear: PGear);
   246 procedure doStepBomb(Gear: PGear);
   242 var i, x, y: LongInt;
   247 var i, x, y: LongInt;
   318 
   323 
   319     if (GameTicks and $3F) = 0 then
   324     if (GameTicks and $3F) = 0 then
   320         if (Gear^.State and gstCollision) = 0 then
   325         if (Gear^.State and gstCollision) = 0 then
   321             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   326             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   322     end;
   327     end;
   323 
       
   324 if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then
       
   325     if (hwAbs(Gear^.dX) > _0_1) or
       
   326        (hwAbs(Gear^.dY) > _0_1) then
       
   327         PlaySound(sndGrenadeImpact)
       
   328 end;
   328 end;
   329 ////////////////////////////////////////////////////////////////////////////////
   329 ////////////////////////////////////////////////////////////////////////////////
   330 procedure doStepMolotov(Gear: PGear);
   330 procedure doStepMolotov(Gear: PGear);
   331 var i: LongInt;
   331 var i: LongInt;
   332     dX, dY: hwFloat;
   332     dX, dY: hwFloat;
   454       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   454       Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
   455       if Gear^.dY > - _1div1024 then
   455       if Gear^.dY > - _1div1024 then
   456          begin
   456          begin
   457          Gear^.Active:= false;
   457          Gear^.Active:= false;
   458          exit
   458          exit
   459          end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact)
   459          end else if Gear^.dY < - _0_03 then PlaySound(Gear^.ImpactSound)
   460       end;
   460       end;
   461 
   461 
   462 Gear^.Y:= Gear^.Y + Gear^.dY;
   462 Gear^.Y:= Gear^.Y + Gear^.dY;
   463 CheckGearDrowning(Gear);
   463 CheckGearDrowning(Gear);
   464 Gear^.dY:= Gear^.dY + cGravity
   464 Gear^.dY:= Gear^.dY + cGravity
  1349         inc(Gear^.Damage, hwRound(Gear^.dX * _50))
  1349         inc(Gear^.Damage, hwRound(Gear^.dX * _50))
  1350     else if Gear^.dY.isNegative and (Gear^.dY < -_0_03) and TestCollisionYwithGear(Gear, -1) then
  1350     else if Gear^.dY.isNegative and (Gear^.dY < -_0_03) and TestCollisionYwithGear(Gear, -1) then
  1351         inc(Gear^.Damage, hwRound(Gear^.dY * -_50))
  1351         inc(Gear^.Damage, hwRound(Gear^.dY * -_50))
  1352     else if Gear^.dX.isNegative and (Gear^.dX < -_0_03) and TestCollisionXwithGear(Gear, -1) then
  1352     else if Gear^.dX.isNegative and (Gear^.dX < -_0_03) and TestCollisionXwithGear(Gear, -1) then
  1353         inc(Gear^.Damage, hwRound(Gear^.dX * -_50));
  1353         inc(Gear^.Damage, hwRound(Gear^.dX * -_50));
  1354     if Gear^.Damage <> 0 then PlaySound(sndGrenadeImpact);
  1354 	
  1355     doStepFallingGear(Gear);
  1355     doStepFallingGear(Gear);
  1356     CalcRotationDirAngle(Gear);
  1356     CalcRotationDirAngle(Gear);
  1357     CheckGearDrowning(Gear)
  1357     CheckGearDrowning(Gear)
  1358     end
  1358     end
  1359 else 
  1359 else 
  1468             for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do 
  1468             for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do 
  1469                 AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
  1469                 AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
  1470         Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
  1470         Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
  1471         if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1471         if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1472             else if Gear^.dY < - _0_03 then
  1472             else if Gear^.dY < - _0_03 then
  1473                 if Gear^.Kind = gtExplosives then
  1473                 PlaySound(Gear^.ImpactSound);
  1474                     PlaySound(sndGrenadeImpact)
       
  1475                 else
       
  1476                     PlaySound(sndGraveImpact);
       
  1477         end;
  1474         end;
  1478     //if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1475     //if Gear^.dY > - _0_001 then Gear^.dY:= _0
  1479     CheckGearDrowning(Gear);
  1476     CheckGearDrowning(Gear);
  1480     end;
  1477     end;
  1481 
  1478