1425 else if (GameTicks and $3F) = 25 then |
1425 else if (GameTicks and $3F) = 25 then |
1426 doStepFallingGear(Gear); |
1426 doStepFallingGear(Gear); |
1427 if (Gear^.Health = 0) then |
1427 if (Gear^.Health = 0) then |
1428 begin |
1428 begin |
1429 dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY); |
1429 dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY); |
1430 if (dxdy > _0_35) and |
1430 if (dxdy > _0_4) and (Gear^.State and gstCollision <> 0) then |
1431 ((TestCollisionYwithGear(Gear, 1) <> 0) or |
1431 inc(Gear^.Damage, hwRound(dxdy * _50)); |
1432 TestCollisionXwithGear(Gear, 1) or |
|
1433 (TestCollisionYwithGear(Gear, -1) <> 0) or |
|
1434 TestCollisionXwithGear(Gear, -1)) then |
|
1435 inc(Gear^.Damage, hwRound(dxdy * _25)); |
|
1436 |
1432 |
1437 if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then |
1433 if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then |
1438 begin |
1434 begin |
1439 vg:= AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); |
1435 vg:= AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); |
1440 if vg <> nil then |
1436 if vg <> nil then |
1580 or (Gear^.dY.QWordValue <> 0)) then |
1576 or (Gear^.dY.QWordValue <> 0)) then |
1581 begin |
1577 begin |
1582 DeleteCI(Gear); |
1578 DeleteCI(Gear); |
1583 AllInactive := false; |
1579 AllInactive := false; |
1584 dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY); |
1580 dxdy:= hwAbs(Gear^.dX)+hwAbs(Gear^.dY); |
1585 if (dxdy > _0_35) then |
1581 doStepFallingGear(Gear); |
|
1582 if (Gear^.State and gstCollision <> 0) and(dxdy > _0_4) then |
1586 begin |
1583 begin |
1587 if (TestCollisionYwithGear(Gear, 1) <> 0) then |
1584 if (TestCollisionYwithGear(Gear, 1) <> 0) then |
1588 begin |
1585 begin |
1589 Gear^.State := Gear^.State or gsttmpFlag; |
1586 Gear^.State := Gear^.State or gsttmpFlag; |
1590 inc(Gear^.Damage, hwRound(dxdy * _25)); |
|
1591 for i:= min(12, hwRound(dxdy*_10)) downto 0 do |
1587 for i:= min(12, hwRound(dxdy*_10)) downto 0 do |
1592 begin |
1588 begin |
1593 particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,vgtDust); |
1589 particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,vgtDust); |
1594 if particle <> nil then |
1590 if particle <> nil then |
1595 particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) |
1591 particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) |
1596 end |
1592 end |
1597 end |
1593 end; |
1598 else if TestCollisionXwithGear(Gear, 1) or (TestCollisionYwithGear(Gear, -1) <> 0) or TestCollisionXwithGear(Gear, -1) then |
1594 inc(Gear^.Damage, hwRound(dxdy * _50)) |
1599 inc(Gear^.Damage, hwRound(dxdy * _25)) |
1595 end; |
1600 end; |
|
1601 doStepFallingGear(Gear); |
|
1602 CalcRotationDirAngle(Gear); |
1596 CalcRotationDirAngle(Gear); |
1603 //CheckGearDrowning(Gear) |
1597 //CheckGearDrowning(Gear) |
1604 end |
1598 end |
1605 else |
1599 else |
1606 begin |
1600 begin |
1635 else |
1629 else |
1636 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); |
1630 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); |
1637 dec(Gear^.Health, Gear^.Damage); |
1631 dec(Gear^.Health, Gear^.Damage); |
1638 Gear^.Damage := 0; |
1632 Gear^.Damage := 0; |
1639 if Gear^.Health <= 0 then |
1633 if Gear^.Health <= 0 then |
1640 Gear^.doStep := @doStepCase; |
1634 doStepCase(Gear); |
1641 // Hand off to doStepCase for the explosion |
|
1642 |
|
1643 end; |
1635 end; |
1644 |
1636 |
1645 procedure doStepCase(Gear: PGear); |
1637 procedure doStepCase(Gear: PGear); |
1646 var |
1638 var |
1647 i, x, y: LongInt; |
1639 i, x, y: LongInt; |
1648 k: TGearType; |
1640 k: TGearType; |
1649 exBoom: boolean; |
|
1650 dX, dY: HWFloat; |
1641 dX, dY: HWFloat; |
1651 hog: PHedgehog; |
1642 hog: PHedgehog; |
1652 sparkles: PVisualGear; |
1643 sparkles: PVisualGear; |
1653 gi: PGear; |
1644 gi: PGear; |
1654 begin |
1645 begin |
1655 k := Gear^.Kind; |
1646 k := Gear^.Kind; |
1656 exBoom := false; |
|
1657 |
1647 |
1658 if (Gear^.Message and gmDestroy) > 0 then |
1648 if (Gear^.Message and gmDestroy) > 0 then |
1659 begin |
1649 begin |
1660 DeleteGear(Gear); |
1650 DeleteGear(Gear); |
1661 FreeActionsList; |
1651 FreeActionsList; |
1665 if Gear <> nil then |
1655 if Gear <> nil then |
1666 Gear^.Message := Gear^.Message and (not (gmLJump or gmHJump)); |
1656 Gear^.Message := Gear^.Message and (not (gmLJump or gmHJump)); |
1667 exit |
1657 exit |
1668 end; |
1658 end; |
1669 |
1659 |
|
1660 if ((Gear^.Kind <> gtExplosives) and (Gear^.Damage > 0)) or (Gear^.Health<=0) then |
|
1661 begin |
|
1662 x := hwRound(Gear^.X); |
|
1663 y := hwRound(Gear^.Y); |
|
1664 hog:= Gear^.Hedgehog; |
|
1665 |
|
1666 DeleteGear(Gear); |
|
1667 // <-- delete gear! |
|
1668 |
|
1669 if k = gtCase then |
|
1670 begin |
|
1671 doMakeExplosion(x, y, 25, hog, EXPLAutoSound); |
|
1672 for i:= 0 to 63 do |
|
1673 AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1674 end |
|
1675 else if k = gtExplosives then |
|
1676 begin |
|
1677 doMakeExplosion(x, y, 75, hog, EXPLAutoSound); |
|
1678 for i:= 0 to 31 do |
|
1679 begin |
|
1680 dX := AngleCos(i * 64) * _0_5 * (getrandomf + _1); |
|
1681 dY := AngleSin(i * 64) * _0_5 * (getrandomf + _1); |
|
1682 AddGear(x, y, gtFlame, 0, dX, dY, 0); |
|
1683 AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0); |
|
1684 end |
|
1685 end; |
|
1686 exit |
|
1687 end; |
|
1688 |
1670 if k = gtExplosives then |
1689 if k = gtExplosives then |
1671 begin |
1690 begin |
1672 //if V > _0_03 then Gear^.State:= Gear^.State or gstAnimation; |
1691 //if V > _0_03 then Gear^.State:= Gear^.State or gstAnimation; |
1673 if (hwAbs(Gear^.dX) > _0_15) or ((hwAbs(Gear^.dY) > _0_15) and (hwAbs(Gear^.dX) > _0_02)) then |
1692 if (hwAbs(Gear^.dX) > _0_15) or ((hwAbs(Gear^.dY) > _0_15) and (hwAbs(Gear^.dX) > _0_02)) then |
1674 begin |
1693 begin |
1675 Gear^.doStep := @doStepRollingBarrel; |
1694 Gear^.doStep := @doStepRollingBarrel; |
1676 exit; |
1695 exit; |
1677 end |
1696 end |
1678 else Gear^.dX:= _0; |
1697 else Gear^.dX:= _0; |
1679 |
1698 |
1680 if (Gear^.Health > 0) and ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then |
1699 if ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then |
1681 if (cBarrelHealth div Gear^.Health) > 2 then |
1700 if (cBarrelHealth div Gear^.Health) > 2 then |
1682 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke) |
1701 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke) |
1683 else |
1702 else |
1684 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); |
1703 AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); |
1685 dec(Gear^.Health, Gear^.Damage); |
1704 dec(Gear^.Health, Gear^.Damage); |
1686 Gear^.Damage := 0; |
1705 Gear^.Damage := 0; |
1687 if Gear^.Health <= 0 then |
|
1688 exBoom := true; |
|
1689 end |
1706 end |
1690 else |
1707 else |
1691 begin |
1708 begin |
1692 if (Gear^.Pos <> posCaseHealth) and (GameTicks and $1FFF = 0) then // stir 'em up periodically |
1709 if (Gear^.Pos <> posCaseHealth) and (GameTicks and $1FFF = 0) then // stir 'em up periodically |
1693 begin |
1710 begin |
1735 AllInactive:= false; |
1752 AllInactive:= false; |
1736 exit |
1753 exit |
1737 end |
1754 end |
1738 end; |
1755 end; |
1739 |
1756 |
1740 if (Gear^.Damage > 0) or exBoom then |
|
1741 begin |
|
1742 x := hwRound(Gear^.X); |
|
1743 y := hwRound(Gear^.Y); |
|
1744 hog:= Gear^.Hedgehog; |
|
1745 |
|
1746 DeleteGear(Gear); |
|
1747 // <-- delete gear! |
|
1748 |
|
1749 if k = gtCase then |
|
1750 begin |
|
1751 doMakeExplosion(x, y, 25, hog, EXPLAutoSound); |
|
1752 for i:= 0 to 63 do |
|
1753 AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1754 end |
|
1755 else if k = gtExplosives then |
|
1756 begin |
|
1757 doMakeExplosion(x, y, 75, hog, EXPLAutoSound); |
|
1758 for i:= 0 to 31 do |
|
1759 begin |
|
1760 dX := AngleCos(i * 64) * _0_5 * (getrandomf + _1); |
|
1761 dY := AngleSin(i * 64) * _0_5 * (getrandomf + _1); |
|
1762 AddGear(x, y, gtFlame, 0, dX, dY, 0); |
|
1763 AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0); |
|
1764 end |
|
1765 end; |
|
1766 exit |
|
1767 end; |
|
1768 |
1757 |
1769 if (Gear^.dY.QWordValue <> 0) |
1758 if (Gear^.dY.QWordValue <> 0) |
1770 or (TestCollisionYwithGear(Gear, 1) = 0) then |
1759 or (TestCollisionYwithGear(Gear, 1) = 0) then |
1771 begin |
1760 begin |
1772 AllInactive := false; |
1761 AllInactive := false; |