hedgewars/GSHandlers.inc
changeset 3713 f8778904600d
parent 3712 de2026031833
child 3714 c407f00d2851
equal deleted inserted replaced
3712:de2026031833 3713:f8778904600d
  1439     else // gsttmpFlag = 0
  1439     else // gsttmpFlag = 0
  1440         if TurnTimeLeft = 0 then Gear^.State := Gear^.State or gsttmpFlag;
  1440         if TurnTimeLeft = 0 then Gear^.State := Gear^.State or gsttmpFlag;
  1441 end;
  1441 end;
  1442 
  1442 
  1443 ////////////////////////////////////////////////////////////////////////////////
  1443 ////////////////////////////////////////////////////////////////////////////////
  1444 procedure doStepSMine(Gear: PGear);
  1444 procedure doStepSMine(Gear: PGear); forward;
  1445 begin
  1445 procedure doStepSMineSticked(Gear: PGear);
  1446     if (Gear^.State and gstMoving) <> 0 then
  1446 begin
  1447     begin
  1447     if (hwAbs(Gear^.dX) > _0) or (hwAbs(Gear^.dY) > _0) then // moving - "unstick" (better solution?)
  1448         if ((Gear^.State and gstCollision) <> 0) and (Gear^.dX < _0_2) and (Gear^.dY < _0_2) then
  1448     begin
  1449         begin
  1449         Gear^.doStep:= @doStepSMine;
  1450             Gear^.dX := _0;
  1450         Gear^.doStep(Gear);
  1451             Gear^.dY := _0
  1451         exit;
  1452             // TODO: calc attach dir
  1452     end;
  1453         end
       
  1454         else
       
  1455             CalcRotationDirAngle(Gear);
       
  1456 
       
  1457         DeleteCI(Gear);
       
  1458         doStepFallingGear(Gear);
       
  1459         if (Gear^.State and gstMoving) = 0 then
       
  1460             AddGearCI(Gear);
       
  1461         AllInactive := false
       
  1462     end
       
  1463     else
       
  1464     begin
       
  1465         if ((GameTicks and $3F) = 25) then
       
  1466             doStepFallingGear(Gear);
       
  1467     end;
       
  1468 
       
  1469     if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
  1453     if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
  1470         if ((Gear^.State and gstAttacking) = 0) then
  1454         if ((Gear^.State and gstAttacking) = 0) then
  1471         begin
  1455         begin
  1472             if ((GameTicks and $1F) = 0) then
  1456             if ((GameTicks and $1F) = 0) then
  1473                 if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State := Gear^.State or
  1457                 if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State := Gear^.State or
  1485         end;
  1469         end;
  1486         dec(Gear^.Timer);
  1470         dec(Gear^.Timer);
  1487     end
  1471     end
  1488     else // gsttmpFlag = 0
  1472     else // gsttmpFlag = 0
  1489         if TurnTimeLeft = 0 then Gear^.State := Gear^.State or gsttmpFlag;
  1473         if TurnTimeLeft = 0 then Gear^.State := Gear^.State or gsttmpFlag;
       
  1474 end;
       
  1475 
       
  1476 procedure doStepSMine(Gear: PGear);
       
  1477 begin
       
  1478     if ((Gear^.State and gstCollision) <> 0) and (Gear^.dX < _0_2) and (Gear^.dY < _0_2) then
       
  1479     begin
       
  1480         Gear^.dX:= _0;
       
  1481         Gear^.dY:= _0;
       
  1482         Gear^.doStep:= @doStepSMineSticked;
       
  1483         Gear^.doStep(Gear);
       
  1484         exit
       
  1485     end;
       
  1486     if (Gear^.State and gstMoving) <> 0 then
       
  1487     begin
       
  1488         DeleteCI(Gear);
       
  1489         doStepFallingGear(Gear);
       
  1490         if (Gear^.State and gstMoving) = 0 then
       
  1491             AddGearCI(Gear);
       
  1492     end;
       
  1493     CalcRotationDirAngle(Gear);
       
  1494     AllInactive := false
  1490 end;
  1495 end;
  1491 
  1496 
  1492 ////////////////////////////////////////////////////////////////////////////////
  1497 ////////////////////////////////////////////////////////////////////////////////
  1493 procedure doStepDynamite(Gear: PGear);
  1498 procedure doStepDynamite(Gear: PGear);
  1494 begin
  1499 begin
  3877         exit
  3882         exit
  3878     end;
  3883     end;
  3879     dec(Gear^.Timer);
  3884     dec(Gear^.Timer);
  3880     Gear^.X:= Gear^.X + Gear^.dX;
  3885     Gear^.X:= Gear^.X + Gear^.dX;
  3881     Gear^.Y:= Gear^.Y + Gear^.dY;
  3886     Gear^.Y:= Gear^.Y + Gear^.dY;
  3882     Gear^.dX := Gear^.dX + cWindSpeed / 2;
  3887     Gear^.dX := Gear^.dX + cWindSpeed / 4;
  3883     Gear^.dY := Gear^.dY + cGravity / 100;
  3888     Gear^.dY := Gear^.dY + cGravity / 100;
  3884     if (GameTicks mod 250) = 0 then
  3889     if (GameTicks mod 250) = 0 then
  3885         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
  3890         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned);
  3886     AllInactive:= false;
  3891     AllInactive:= false;
  3887 end;
  3892 end;