207 gi := GearsList; |
207 gi := GearsList; |
208 while gi <> nil do |
208 while gi <> nil do |
209 begin |
209 begin |
210 if (gi^.Kind = gtHedgehog) then |
210 if (gi^.Kind = gtHedgehog) then |
211 begin |
211 begin |
212 d := r - hwRound(Distance(gi^.X - x, gi^.Y - y)); |
212 d := r - hwRound(PointDistance(gi^.X, x, gi^.Y, y, true)); |
213 if (d > 1) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) and (GetRandom(2) = 0) then |
213 if (d > 1) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) and (GetRandom(2) = 0) then |
214 begin |
214 begin |
215 if (CurrentHedgehog^.Gear = gi) then |
215 if (CurrentHedgehog^.Gear = gi) then |
216 PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) |
216 PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) |
217 |
217 |
1806 end; |
1806 end; |
1807 |
1807 |
1808 procedure doStepAirMine(Gear: PGear); |
1808 procedure doStepAirMine(Gear: PGear); |
1809 var i,t,targDist,tmpDist: LongWord; |
1809 var i,t,targDist,tmpDist: LongWord; |
1810 targ, tmpG: PGear; |
1810 targ, tmpG: PGear; |
1811 trackSpeed, airFriction, tX, tY: hwFloat; |
1811 trackSpeed, airFriction: hwFloat; |
1812 isUnderwater: Boolean; |
1812 isUnderwater: Boolean; |
1813 begin |
1813 begin |
1814 isUnderwater:= CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y) + Gear^.Radius); |
1814 isUnderwater:= CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y) + Gear^.Radius); |
1815 if Gear^.Pos > 0 then |
1815 if Gear^.Pos > 0 then |
1816 begin |
1816 begin |
1833 end |
1833 end |
1834 else if Gear^.Hedgehog <> nil then |
1834 else if Gear^.Hedgehog <> nil then |
1835 targ:= Gear^.Hedgehog^.Gear; |
1835 targ:= Gear^.Hedgehog^.Gear; |
1836 if targ <> nil then |
1836 if targ <> nil then |
1837 begin |
1837 begin |
1838 tX:=Gear^.X-targ^.X; |
|
1839 tY:=Gear^.Y-targ^.Y; |
|
1840 // allow escaping - should maybe flag this too |
1838 // allow escaping - should maybe flag this too |
1841 if (GameTicks > Gear^.FlightTime+10000) or |
1839 if (GameTicks > Gear^.FlightTime+10000) or |
1842 ((tX.Round+tY.Round > Gear^.Angle*6) and |
1840 (hwRound(PointDistance(Gear^.X, targ^.X, Gear^.Y, targ^.Y, true)) > Gear^.Angle*6) then |
1843 (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*6))) then |
|
1844 targ:= nil |
1841 targ:= nil |
1845 end; |
1842 end; |
1846 |
1843 |
1847 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
1844 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
1848 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
1845 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
1858 ((GameTicks and $FF) = 17) and |
1855 ((GameTicks and $FF) = 17) and |
1859 (GameTicks > Gear^.FlightTime) then // recheck hunted hog |
1856 (GameTicks > Gear^.FlightTime) then // recheck hunted hog |
1860 begin |
1857 begin |
1861 gear^.State:= gear^.State or gstChooseTarget; |
1858 gear^.State:= gear^.State or gstChooseTarget; |
1862 if targ <> nil then |
1859 if targ <> nil then |
1863 targDist:= Distance(Gear^.X-targ^.X,Gear^.Y-targ^.Y).Round |
1860 targDist:= PointDistance(Gear^.X, targ^.X, Gear^.Y, targ^.Y, true).Round |
1864 else targDist:= 0; |
1861 else targDist:= 0; |
1865 for t:= 0 to Pred(TeamsCount) do |
1862 for t:= 0 to Pred(TeamsCount) do |
1866 with TeamsArray[t]^ do |
1863 with TeamsArray[t]^ do |
1867 for i:= 0 to cMaxHHIndex do |
1864 for i:= 0 to cMaxHHIndex do |
1868 if Hedgehogs[i].Gear <> nil then |
1865 if Hedgehogs[i].Gear <> nil then |
1869 begin |
1866 begin |
1870 tmpG:= Hedgehogs[i].Gear; |
1867 tmpG:= Hedgehogs[i].Gear; |
1871 tX:=Gear^.X-tmpG^.X; |
|
1872 tY:=Gear^.Y-tmpG^.Y; |
|
1873 if (Gear^.Angle = $FFFFFFFF) or |
1868 if (Gear^.Angle = $FFFFFFFF) or |
1874 ((tX.Round+tY.Round < Gear^.Angle) and |
1869 (hwRound(PointDistance(Gear^.X, tmpG^.X, Gear^.Y, tmpG^.Y, true)) < Gear^.Angle) then |
1875 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Angle))) then |
|
1876 begin |
1870 begin |
1877 if targ <> nil then tmpDist:= Distance(tX,tY).Round; |
1871 if targ <> nil then tmpDist:= PointDistance(Gear^.X, tmpG^.X, Gear^.Y, tmpG^.Y, true).Round; |
1878 if (targ = nil) or (tmpDist < targDist) then |
1872 if (targ = nil) or (tmpDist < targDist) then |
1879 begin |
1873 begin |
1880 if targ = nil then targDist:= Distance(tX,tY).Round |
1874 if targ = nil then targDist:= PointDistance(Gear^.X, tmpG^.X, Gear^.Y, tmpG^.Y, true).Round |
1881 else targDist:= tmpDist; |
1875 else targDist:= tmpDist; |
1882 Gear^.Hedgehog:= @Hedgehogs[i]; |
1876 Gear^.Hedgehog:= @Hedgehogs[i]; |
1883 targ:= tmpG; |
1877 targ:= tmpG; |
1884 end |
1878 end |
1885 end |
1879 end |
1892 if isUnderwater then |
1886 if isUnderwater then |
1893 trackSpeed.QWordValue:= Gear^.Power div 2 |
1887 trackSpeed.QWordValue:= Gear^.Power div 2 |
1894 else |
1888 else |
1895 trackSpeed.QWordValue:= Gear^.Power; |
1889 trackSpeed.QWordValue:= Gear^.Power; |
1896 if (Gear^.X < targ^.X) and (Gear^.dX < _0_1) then |
1890 if (Gear^.X < targ^.X) and (Gear^.dX < _0_1) then |
1897 Gear^.dX:= Gear^.dX+trackSpeed // please leave as an add. I like the effect |
1891 if (WorldEdge = weWrap) and ((targ^.X - Gear^.X) > ((Gear^.X - int2hwFloat(LeftX)) + (int2hwFloat(RightX) - targ^.X))) then |
|
1892 Gear^.dX:= Gear^.dX-trackSpeed |
|
1893 else |
|
1894 Gear^.dX:= Gear^.dX+trackSpeed // please leave as an add. I like the effect |
1898 else if (Gear^.X > targ^.X) and (Gear^.dX > -_0_1) then |
1895 else if (Gear^.X > targ^.X) and (Gear^.dX > -_0_1) then |
1899 Gear^.dX:= Gear^.dX-trackSpeed; |
1896 if (WorldEdge = weWrap) and ((Gear^.X - targ^.X) > ((targ^.X - int2hwFloat(LeftX)) + (int2hwFloat(RightX) - Gear^.X))) then |
|
1897 Gear^.dX:= Gear^.dX+trackSpeed |
|
1898 else |
|
1899 Gear^.dX:= Gear^.dX-trackSpeed; |
1900 if (Gear^.Y < targ^.Y) and (Gear^.dY < _0_1) then |
1900 if (Gear^.Y < targ^.Y) and (Gear^.dY < _0_1) then |
1901 Gear^.dY:= Gear^.dY+trackSpeed |
1901 Gear^.dY:= Gear^.dY+trackSpeed |
1902 else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then |
1902 else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then |
1903 Gear^.dY:= Gear^.dY-trackSpeed |
1903 Gear^.dY:= Gear^.dY-trackSpeed |
1904 end |
1904 end |
1910 begin |
1910 begin |
1911 if ((GameTicks and $1F) = 0) then |
1911 if ((GameTicks and $1F) = 0) then |
1912 begin |
1912 begin |
1913 if targ <> nil then |
1913 if targ <> nil then |
1914 begin |
1914 begin |
1915 tX:=Gear^.X-targ^.X; |
1915 if (hwRound(PointDistance(Gear^.X, targ^.X, Gear^.Y, targ^.Y, true)) < Gear^.Karma) then |
1916 tY:=Gear^.Y-targ^.Y; |
|
1917 if (tX.Round+tY.Round < Gear^.Karma) and |
|
1918 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Karma)) then |
|
1919 Gear^.State := Gear^.State or gstAttacking |
1916 Gear^.State := Gear^.State or gstAttacking |
1920 end |
1917 end |
1921 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Karma, Gear^.Karma) <> nil) then |
1918 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Karma, Gear^.Karma) <> nil) then |
1922 Gear^.State := Gear^.State or gstAttacking |
1919 Gear^.State := Gear^.State or gstAttacking |
1923 end |
1920 end |
1930 if Gear^.Timer = 0 then |
1927 if Gear^.Timer = 0 then |
1931 begin |
1928 begin |
1932 // recheck |
1929 // recheck |
1933 if targ <> nil then |
1930 if targ <> nil then |
1934 begin |
1931 begin |
1935 tX:=Gear^.X-targ^.X; |
1932 if (hwRound(PointDistance(Gear^.X, targ^.X, Gear^.Y, targ^.Y, true)) < Gear^.Karma) then |
1936 tY:=Gear^.Y-targ^.Y; |
|
1937 if (tX.Round+tY.Round < Gear^.Karma) and |
|
1938 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Karma)) then |
|
1939 begin |
1933 begin |
1940 Gear^.Hedgehog:= CurrentHedgehog; |
1934 Gear^.Hedgehog:= CurrentHedgehog; |
1941 tmpG:= FollowGear; |
1935 tmpG:= FollowGear; |
1942 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Karma, Gear^.Hedgehog, EXPLAutoSound); |
1936 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Karma, Gear^.Hedgehog, EXPLAutoSound); |
1943 FollowGear:= tmpG; |
1937 FollowGear:= tmpG; |