hedgewars/GSHandlers.inc
changeset 3717 d88719b0f0dc
parent 3714 c407f00d2851
child 3720 b2b108a6fae8
equal deleted inserted replaced
3716:3a2ee9533e3e 3717:d88719b0f0dc
  1443 ////////////////////////////////////////////////////////////////////////////////
  1443 ////////////////////////////////////////////////////////////////////////////////
  1444 procedure doStepSMine(Gear: PGear);
  1444 procedure doStepSMine(Gear: PGear);
  1445 begin
  1445 begin
  1446     DeleteCI(Gear);
  1446     DeleteCI(Gear);
  1447     // TODO: do real calculation?
  1447     // TODO: do real calculation?
  1448     if TestCollisionXwithGear(Gear, 2) and TestCollisionYwithGear(Gear, -2) then
  1448     if TestCollisionXwithGear(Gear, 2) or TestCollisionYwithGear(Gear, -2) or TestCollisionXwithGear(Gear, -2) or TestCollisionYwithGear(Gear, 2) then
  1449     begin
  1449     begin
       
  1450         if (hwAbs(Gear^.dX) > _0) or (hwAbs(Gear^.dY) > _0) then
       
  1451             PlaySound(sndRopeAttach);
  1450         Gear^.dX:= _0;
  1452         Gear^.dX:= _0;
  1451         Gear^.dY:= _0;
  1453         Gear^.dY:= _0;
  1452         Gear^.DirAngle:= 225
       
  1453     end
       
  1454     else if TestCollisionXwithGear(Gear, -2) and TestCollisionYwithGear(Gear, -2) then
       
  1455     begin
       
  1456         Gear^.dX:= _0;
       
  1457         Gear^.dY:= _0;
       
  1458         Gear^.DirAngle:= 135
       
  1459     end
       
  1460     else if TestCollisionXwithGear(Gear, 2) and TestCollisionYwithGear(Gear, 2) then
       
  1461     begin
       
  1462         Gear^.dX:= _0;
       
  1463         Gear^.dY:= _0;
       
  1464         Gear^.DirAngle:= 315
       
  1465     end
       
  1466     else if TestCollisionXwithGear(Gear, -2) and TestCollisionYwithGear(Gear, 2) then
       
  1467     begin
       
  1468         Gear^.dX:= _0;
       
  1469         Gear^.dY:= _0;
       
  1470         Gear^.DirAngle:= 45
       
  1471     end
       
  1472     else if TestCollisionYwithGear(Gear, -2) then
       
  1473     begin
       
  1474         Gear^.dX:= _0;
       
  1475         Gear^.dY:= _0;
       
  1476         Gear^.DirAngle:= 180
       
  1477     end
       
  1478     else if TestCollisionYwithGear(Gear, 2) then
       
  1479     begin
       
  1480         Gear^.dX:= _0;
       
  1481         Gear^.dY:= _0;
       
  1482         Gear^.DirAngle:= 0
       
  1483     end
       
  1484     else if TestCollisionXwithGear(Gear, -2) then
       
  1485     begin
       
  1486         Gear^.dX:= _0;
       
  1487         Gear^.dY:= _0;
       
  1488         Gear^.DirAngle:= 90
       
  1489     end
       
  1490     else if TestCollisionXwithGear(Gear, 2) then
       
  1491     begin
       
  1492         Gear^.dX:= _0;
       
  1493         Gear^.dY:= _0;
       
  1494         Gear^.DirAngle:= 270
       
  1495     end
  1454     end
  1496     else
  1455     else
  1497     begin
  1456     begin
  1498         doStepFallingGear(Gear);
  1457         doStepFallingGear(Gear);
  1499         AllInactive := false;
  1458         AllInactive := false;
  3918     Gear^.dY := Gear^.dY + cGravity / 100;
  3877     Gear^.dY := Gear^.dY + cGravity / 100;
  3919     if (GameTicks mod 250) = 0 then
  3878     if (GameTicks mod 250) = 0 then
  3920         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
  3879         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
  3921     AllInactive:= false;
  3880     AllInactive:= false;
  3922 end;
  3881 end;
       
  3882 
       
  3883 ////////////////////////////////////////////////////////////////////////////////
       
  3884 procedure doStepHammer(Gear: PGear);
       
  3885 var HHGear, tmp: PGear;
       
  3886          t: PGearArray;
       
  3887          i: LongInt;
       
  3888          dust: PVisualGear;
       
  3889 begin
       
  3890 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
       
  3891 HHGear^.State:= HHGear^.State or gstNoDamage;
       
  3892 DeleteCI(HHGear);
       
  3893 
       
  3894 t:= CheckGearsCollision(Gear);
       
  3895 i:= t^.Count;
       
  3896 while i > 0 do
       
  3897     begin
       
  3898     dec(i);
       
  3899     tmp:= t^.ar[i];
       
  3900     if (tmp^.State and gstNoDamage) = 0 then
       
  3901         if (tmp^.Kind = gtHedgehog) then
       
  3902             begin
       
  3903             //tmp^.State:= tmp^.State or gstFlatened;
       
  3904             ApplyDamage(tmp, tmp^.Health div 2, dsUnknown);
       
  3905             DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
       
  3906             for i:= 5 downto 0 do
       
  3907                 dust := AddVisualGear(hwRound(tmp^.X) - 5 + Random(10), hwRound(tmp^.Y) + 12, vgtDust);
       
  3908             SetAllToActive
       
  3909             end
       
  3910         else
       
  3911             begin
       
  3912             end
       
  3913     end;
       
  3914 
       
  3915 HHGear^.State:= HHGear^.State and not gstNoDamage;
       
  3916 Gear^.Timer:= 250;
       
  3917 Gear^.doStep:= @doStepIdle
       
  3918 end;