1745 else // gsttmpFlag = 0 |
1748 else // gsttmpFlag = 0 |
1746 if (TurnTimeLeft = 0) |
1749 if (TurnTimeLeft = 0) |
1747 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) |
1750 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) |
1748 or (Gear^.Hedgehog^.Gear = nil) then |
1751 or (Gear^.Hedgehog^.Gear = nil) then |
1749 Gear^.State := Gear^.State or gsttmpFlag; |
1752 Gear^.State := Gear^.State or gsttmpFlag; |
|
1753 end; |
|
1754 |
|
1755 (* |
|
1756 Just keeping track for my own benefit. |
|
1757 Every second, locate new target. Clear if target radius has been set to 0 or no target in range. |
|
1758 Every... 16 milliseconds? Update vector to target. |
|
1759 *) |
|
1760 |
|
1761 procedure doStepAirMine(Gear: PGear); |
|
1762 var i,t,targDist,tmpDist: LongWord; |
|
1763 targ, tmpG: PGear; |
|
1764 trackSpeed, airFriction, tX, tY: hwFloat; |
|
1765 begin |
|
1766 if Gear^.Pos > 0 then |
|
1767 begin |
|
1768 airFriction:= _1; |
|
1769 dec(airFriction.QWordValue,Gear^.Pos); |
|
1770 Gear^.dX:= Gear^.dX*airFriction; |
|
1771 Gear^.dY:= Gear^.dY*airFriction |
|
1772 end; |
|
1773 doStepFallingGear(Gear); |
|
1774 if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then |
|
1775 AllInactive := false; |
|
1776 |
|
1777 if (TurnTimeLeft = 0) or (Gear^.Angle = 0) or (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Gear = nil) then |
|
1778 begin |
|
1779 Gear^.Hedgehog:= nil; |
|
1780 targ:= nil; |
|
1781 end |
|
1782 else if Gear^.Hedgehog <> nil then |
|
1783 targ:= Gear^.Hedgehog^.Gear; |
|
1784 if targ <> nil then |
|
1785 begin |
|
1786 tX:=Gear^.X-targ^.X; |
|
1787 tY:=Gear^.Y-targ^.Y; |
|
1788 // allow escaping - should maybe flag this too |
|
1789 if (GameTicks > Gear^.FlightTime+10000) or |
|
1790 ((tX.Round+tY.Round > Gear^.Angle*6) and |
|
1791 (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*6))) then |
|
1792 targ:= nil |
|
1793 end; |
|
1794 |
|
1795 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
|
1796 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
|
1797 // then we aren't hunting |
|
1798 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
|
1799 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
|
1800 (Gear^.State and gsttmpFlag = 0) or |
|
1801 (Gear^.Angle = 0) then |
|
1802 gear^.State:= gear^.State and (not gstHHChooseTarget) |
|
1803 else if |
|
1804 // todo, allow not finding new target, set timeout on target retention |
|
1805 (Gear^.State and gstAttacking = 0) and |
|
1806 ((GameTicks and $FF) = 17) and |
|
1807 (GameTicks > Gear^.FlightTime) then // recheck hunted hog |
|
1808 begin |
|
1809 gear^.State:= gear^.State or gstHHChooseTarget; |
|
1810 if targ <> nil then |
|
1811 targDist:= Distance(Gear^.X-targ^.X,Gear^.Y-targ^.Y).Round |
|
1812 else targDist:= 0; |
|
1813 for t:= 0 to Pred(TeamsCount) do |
|
1814 with TeamsArray[t]^ do |
|
1815 for i:= 0 to cMaxHHIndex do |
|
1816 if Hedgehogs[i].Gear <> nil then |
|
1817 begin |
|
1818 tmpG:= Hedgehogs[i].Gear; |
|
1819 tX:=Gear^.X-tmpG^.X; |
|
1820 tY:=Gear^.Y-tmpG^.Y; |
|
1821 if (Gear^.Angle = $FFFFFFFF) or |
|
1822 ((tX.Round+tY.Round < Gear^.Angle) and |
|
1823 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Angle))) then |
|
1824 begin |
|
1825 if targ <> nil then tmpDist:= Distance(tX,tY).Round; |
|
1826 if (targ = nil) or (tmpDist < targDist) then |
|
1827 begin |
|
1828 if targ = nil then targDist:= Distance(tX,tY).Round |
|
1829 else targDist:= tmpDist; |
|
1830 Gear^.Hedgehog:= @Hedgehogs[i]; |
|
1831 targ:= tmpG; |
|
1832 end |
|
1833 end |
|
1834 end; |
|
1835 if targ <> nil then Gear^.FlightTime:= GameTicks + 5000 |
|
1836 end; |
|
1837 if targ <> nil then |
|
1838 begin |
|
1839 trackSpeed:= _0; |
|
1840 trackSpeed.QWordValue:= Gear^.Power; |
|
1841 if (Gear^.X < targ^.X) and (Gear^.dX < _0_1) then |
|
1842 Gear^.dX:= Gear^.dX+trackSpeed |
|
1843 else if (Gear^.X > targ^.X) and (Gear^.dX > -_0_1) then |
|
1844 Gear^.dX:= Gear^.dX-trackSpeed; |
|
1845 if (Gear^.Y < targ^.Y) and (Gear^.dY < _0_1) then |
|
1846 Gear^.dY:= Gear^.dY+trackSpeed |
|
1847 else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then |
|
1848 Gear^.dY:= Gear^.dY-trackSpeed |
|
1849 end |
|
1850 else Gear^.Hedgehog:= nil; |
|
1851 |
|
1852 if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then |
|
1853 begin |
|
1854 if ((Gear^.State and gstAttacking) = 0) then |
|
1855 begin |
|
1856 if ((GameTicks and $1F) = 0) then |
|
1857 begin |
|
1858 if targ <> nil then |
|
1859 begin |
|
1860 tX:=Gear^.X-targ^.X; |
|
1861 tY:=Gear^.Y-targ^.Y; |
|
1862 if (tX.Round+tY.Round < Gear^.Karma) and |
|
1863 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Karma)) then |
|
1864 Gear^.State := Gear^.State or gstAttacking |
|
1865 end |
|
1866 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Karma, Gear^.Karma) <> nil) then |
|
1867 Gear^.State := Gear^.State or gstAttacking |
|
1868 end |
|
1869 end |
|
1870 else // gstAttacking <> 0 |
|
1871 begin |
|
1872 AllInactive := false; |
|
1873 if (Gear^.Timer and $FF) = 0 then |
|
1874 PlaySound(sndMineTick); |
|
1875 if Gear^.Timer = 0 then |
|
1876 begin |
|
1877 // recheck |
|
1878 if targ <> nil then |
|
1879 begin |
|
1880 tX:=Gear^.X-targ^.X; |
|
1881 tY:=Gear^.Y-targ^.Y; |
|
1882 if (tX.Round+tY.Round < Gear^.Karma) and |
|
1883 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Karma)) then |
|
1884 begin |
|
1885 Gear^.Hedgehog:= CurrentHedgehog; |
|
1886 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Karma, Gear^.Hedgehog, EXPLAutoSound); |
|
1887 DeleteGear(Gear); |
|
1888 exit |
|
1889 end |
|
1890 end |
|
1891 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Karma, Gear^.Karma) <> nil) then |
|
1892 begin |
|
1893 Gear^.Hedgehog:= CurrentHedgehog; |
|
1894 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Karma, Gear^.Hedgehog, EXPLAutoSound); |
|
1895 DeleteGear(Gear); |
|
1896 exit |
|
1897 end; |
|
1898 Gear^.State:= Gear^.State and (not gstAttacking); |
|
1899 Gear^.Timer:= Gear^.WDTimer |
|
1900 end; |
|
1901 dec(Gear^.Timer); |
|
1902 end |
|
1903 end |
|
1904 else // gsttmpFlag = 0 |
|
1905 if (TurnTimeLeft = 0) |
|
1906 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) |
|
1907 or (CurrentHedgehog^.Gear = nil) then |
|
1908 begin |
|
1909 Gear^.FlightTime:= GameTicks; |
|
1910 Gear^.State := Gear^.State or gsttmpFlag |
|
1911 end |
1750 end; |
1912 end; |
1751 |
1913 |
1752 //////////////////////////////////////////////////////////////////////////////// |
1914 //////////////////////////////////////////////////////////////////////////////// |
1753 procedure doStepSMine(Gear: PGear); |
1915 procedure doStepSMine(Gear: PGear); |
1754 var land: Word; |
1916 var land: Word; |