hedgewars/uGearsHandlersMess.pas
changeset 10679 5989c293955a
parent 10676 7111b4a46b5c
child 10736 5b7cf9fcb47e
equal deleted inserted replaced
10678:73545fd91efa 10679:5989c293955a
  1659 
  1659 
  1660 ////////////////////////////////////////////////////////////////////////////////
  1660 ////////////////////////////////////////////////////////////////////////////////
  1661 procedure doStepMine(Gear: PGear);
  1661 procedure doStepMine(Gear: PGear);
  1662 var vg: PVisualGear;
  1662 var vg: PVisualGear;
  1663     dxdy: hwFloat;
  1663     dxdy: hwFloat;
       
  1664     dmg: LongWord;
  1664 begin
  1665 begin
  1665     if Gear^.Health = 0 then dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY);
  1666     if Gear^.Health = 0 then dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY);
  1666     if (Gear^.State and gstMoving) <> 0 then
  1667     if (Gear^.State and gstMoving) <> 0 then
  1667         begin
  1668         begin
  1668         DeleteCI(Gear);
  1669         DeleteCI(Gear);
  1679     else if (GameTicks and $3F) = 25 then
  1680     else if (GameTicks and $3F) = 25 then
  1680         doStepFallingGear(Gear);
  1681         doStepFallingGear(Gear);
  1681     if (Gear^.Health = 0) then
  1682     if (Gear^.Health = 0) then
  1682         begin
  1683         begin
  1683         if (dxdy > _0_4) and (Gear^.State and gstCollision <> 0) then
  1684         if (dxdy > _0_4) and (Gear^.State and gstCollision <> 0) then
  1684             inc(Gear^.Damage, hwRound(dxdy * _50));
  1685             begin
       
  1686             dmg:= hwRound(dxdy * _50);
       
  1687             inc(Gear^.Damage, dmg);
       
  1688             ScriptCall('onGearDamage', Gear^.UID, dmg)
       
  1689             end;
  1685 
  1690 
  1686         if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then
  1691         if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then
  1687             begin
  1692             begin
  1688             vg:= AddVisualGear(hwRound(Gear^.X) - 4  + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke);
  1693             vg:= AddVisualGear(hwRound(Gear^.X) - 4  + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke);
  1689             if vg <> nil then
  1694             if vg <> nil then
  1818 
  1823 
  1819 ///////////////////////////////////////////////////////////////////////////////
  1824 ///////////////////////////////////////////////////////////////////////////////
  1820 
  1825 
  1821 procedure doStepRollingBarrel(Gear: PGear);
  1826 procedure doStepRollingBarrel(Gear: PGear);
  1822 var
  1827 var
  1823     i: LongInt;
  1828     i, dmg: LongInt;
  1824     particle: PVisualGear;
  1829     particle: PVisualGear;
  1825     dxdy: hwFloat;
  1830     dxdy: hwFloat;
  1826 begin
  1831 begin
  1827     if (Gear^.dX.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then
  1832     if (Gear^.dX.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then
  1828         SetLittle(Gear^.dY);
  1833         SetLittle(Gear^.dY);
  1846                     particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,vgtDust);
  1851                     particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,vgtDust);
  1847                     if particle <> nil then
  1852                     if particle <> nil then
  1848                         particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480)
  1853                         particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480)
  1849                     end
  1854                     end
  1850                 end;
  1855                 end;
  1851             inc(Gear^.Damage, hwRound(dxdy * _50))
  1856             dmg:= hwRound(dxdy * _50);
       
  1857             inc(Gear^.Damage, dmg);
       
  1858             ScriptCall('onGearDamage', Gear^.UID, dmg)
  1852             end;
  1859             end;
  1853         CalcRotationDirAngle(Gear);
  1860         CalcRotationDirAngle(Gear);
  1854         //CheckGearDrowning(Gear)
  1861         //CheckGearDrowning(Gear)
  1855         end
  1862         end
  1856     else
  1863     else