@@ -1894,24 +1894,23 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
1894
1894
local TmpWpts = {};
1895
1895
table.insert (TmpWpts , {Pos = Owner .Pos });
1896
1896
1897
- local Origin ;
1898
1897
local LastPos = PathDump [1 ];
1899
1898
local index = 1 ;
1900
1899
for _ , WptPos in pairs (PathDump ) do
1901
- Origin = TmpWpts [index ].Pos ;
1902
- local Dist = SceneMan :ShortestDistance (Origin , WptPos , false );
1903
- if math.abs (Dist .Y ) > 30 or Dist :MagnitudeIsGreaterThan (80 ) or -- skip any waypoint too close to the previous one
1904
- SceneMan :CastStrengthSumRay (Origin , WptPos , 3 , rte .grassID ) > 5
1905
- then
1900
+ -- Origin = TmpWpts[index].Pos;
1901
+ -- local Dist = SceneMan:ShortestDistance(Origin, WptPos, false);
1902
+ -- if math.abs(Dist.Y) > 30 or Dist:MagnitudeIsGreaterThan(80) or -- skip any waypoint too close to the previous one
1903
+ -- SceneMan:CastStrengthSumRay(Origin, WptPos, 3, rte.grassID) > 5
1904
+ -- then
1906
1905
table.insert (TmpWpts , {Pos = LastPos });
1907
1906
index = index + 1 ;
1908
- end
1907
+ -- end
1909
1908
1910
1909
LastPos = WptPos ;
1911
1910
end
1912
1911
1913
1912
-- No path
1914
- if # PathDump == 0 then
1913
+ if # TmpWpts == 0 then
1915
1914
break ;
1916
1915
end
1917
1916
@@ -1922,50 +1921,6 @@ function HumanBehaviors.GoToWpt(AI, Owner, Abort)
1922
1921
while TmpWpts [1 ] do
1923
1922
local NextWpt = table.remove (TmpWpts , 1 );
1924
1923
1925
- if Lower (NextWpt , StartWpt , 30 ) then -- scan for sharp drops
1926
- local Dist = SceneMan :ShortestDistance (StartWpt .Pos , NextWpt .Pos , false );
1927
- if math.abs (Dist .X ) < Dist .Y then -- check the slope
1928
- if SceneMan :CastObstacleRay (StartWpt .Pos , Dist , Vector (), Vector (), Owner .ID , Owner .IgnoresWhichTeam , rte .grassID , 4 ) < 0 then
1929
- NextWpt .Type = " drop" ; -- LOS from StartWpt to NextWpt
1930
- end
1931
-
1932
- local GapList = {};
1933
- for j , JumpWpt in pairs (TmpWpts ) do -- look for the other side
1934
- local Gap = SceneMan :ShortestDistance (StartWpt .Pos , JumpWpt .Pos , false );
1935
- if Gap :MagnitudeIsGreaterThan (400 - Gap .Y ) then -- TODO: use actor properties here
1936
- break ; -- too far
1937
- end
1938
-
1939
- if Gap .Y > - 40 then -- no more than 2m above
1940
- table.insert (GapList , {Wpt = JumpWpt , score = math.abs (Gap .X / Gap .Y ), index = j });
1941
- end
1942
- end
1943
-
1944
- table.sort (GapList , function (A , B ) return A .score > B .score end ); -- sort largest first
1945
-
1946
- for _ , LZ in pairs (GapList ) do
1947
- -- check if we can jump
1948
- local Trace = SceneMan :ShortestDistance (StartWpt .Pos , LZ .Wpt .Pos , false );
1949
- if SceneMan :CastObstacleRay (StartWpt .Pos , Trace , Vector (), Vector (), Owner .ID , Owner .IgnoresWhichTeam , rte .grassID , 4 ) < 0 then
1950
- -- find a point mid-air
1951
- local TestPos = StartWpt .Pos + Trace * 0.6 ;
1952
- local Free = Vector ();
1953
- if 0 ~= SceneMan :CastObstacleRay (TestPos , Vector (0 , - math.abs (Trace .X )/ 2 ), Vector (), Free , Owner .ID , Owner .IgnoresWhichTeam , rte .grassID , 2 ) then -- TODO: check LOS? what if 0?
1954
- table.insert (WptList , {Pos = Free + Vector (0 ,Owner .Height / 3 ), Type = " air" }); -- guide point in the air
1955
- NextWpt = LZ .Wpt ;
1956
-
1957
- -- delete any waypoints between StartWpt and the LZ
1958
- for i = LZ .index , 1 , - 1 do
1959
- table.remove (TmpWpts , i );
1960
- end
1961
-
1962
- break ;
1963
- end
1964
- end
1965
- end
1966
- end
1967
- end
1968
-
1969
1924
table.insert (WptList , NextWpt );
1970
1925
StartWpt = NextWpt ;
1971
1926
end
0 commit comments