@@ -12,20 +12,20 @@ function IsSteep(x, z)
1212 local mtta = math.acos (1.0 - 0.41221 ) - 0.02 -- http://springrts.com/wiki/Movedefs.lua#How_slope_is_determined & the -0.02 is for safety
1313 local a1 , a2 , a3 , a4 = 0 , 0 , 0 , 0
1414 local d = 5
15- local y = Spring .GetGroundHeight (x , z )
16- local y1 = Spring .GetGroundHeight (x + d , z )
15+ local y = SpringShared .GetGroundHeight (x , z )
16+ local y1 = SpringShared .GetGroundHeight (x + d , z )
1717 if math.abs (y1 - y ) > 0.1 then
1818 a1 = math.atan ((y1 - y ) / d )
1919 end
20- local y2 = Spring .GetGroundHeight (x , z + d )
20+ local y2 = SpringShared .GetGroundHeight (x , z + d )
2121 if math.abs (y2 - y ) > 0.1 then
2222 a2 = math.atan ((y2 - y ) / d )
2323 end
24- local y3 = Spring .GetGroundHeight (x - d , z )
24+ local y3 = SpringShared .GetGroundHeight (x - d , z )
2525 if math.abs (y3 - y ) > 0.1 then
2626 a3 = math.atan ((y3 - y ) / d )
2727 end
28- local y4 = Spring .GetGroundHeight (x , z + d )
28+ local y4 = SpringShared .GetGroundHeight (x , z + d )
2929 if math.abs (y4 - y ) > 0.1 then
3030 a4 = math.atan ((y4 - y ) / d )
3131 end
@@ -54,14 +54,14 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
5454 for i = 1 , # metalSpots do
5555 local spot = metalSpots [i ]
5656 local mx , mz = spot .x , spot .z
57- local my = Spring .GetGroundHeight (mx , mz )
57+ local my = SpringShared .GetGroundHeight (mx , mz )
5858 local isWithinStartBox = (xmin < mx ) and (mx < xmax ) and (zmin < mz ) and (mz < zmax )
5959 local isWithinWalkRadius = (mx >= xmin - walkRadius ) and (mx <= xmax + walkRadius ) and (mz >= zmin - walkRadius ) and (mz <= zmax + walkRadius )
6060
6161 local isFree = true
6262 for _ , startpoint in pairs (startPointTable ) do -- we avoid enemy startpoints too, to prevent unnecessary explosions and to deal with the case of having no startboxes
6363 local sx , sz = startpoint [1 ], startpoint [2 ]
64- local sy = Spring .GetGroundHeight (sx , sz )
64+ local sy = SpringShared .GetGroundHeight (sx , sz )
6565 local isWithinClaimRadius = ((sx - mx ) * (sx - mx ) + (sz - mz ) * (sz - mz ) <= claimRadius * claimRadius )
6666 local isWithinClaimHeight = (math.abs (my - sy ) <= claimHeight )
6767 if isWithinClaimRadius and isWithinClaimHeight then
@@ -116,8 +116,8 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
116116 local jx , jz = freeMetalSpots [j ][1 ], freeMetalSpots [j ][2 ]
117117 if ix ~= jx or iz ~= jz then
118118 local r = math.sqrt ((ix - jx ) ^ 2 + (iz - jz ) ^ 2 )
119- local iy = Spring .GetGroundHeight (ix , iz )
120- local jy = Spring .GetGroundHeight (jx , jz )
119+ local iy = SpringShared .GetGroundHeight (ix , iz )
120+ local jy = SpringShared .GetGroundHeight (jx , jz )
121121 local isWithinClaimRadius = (r <= claimRadius )
122122 local isWithinClaimHeight = (math.abs (iy - jy ) <= claimHeight )
123123 local score -- Magic formula. Assumes all metal spots are of equal production value, TODO...
@@ -134,8 +134,8 @@ function GuessOne(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable)
134134 local jx , jz = walkableMetalSpots [j ][1 ], walkableMetalSpots [j ][2 ]
135135 if ix ~= jx or iz ~= jz then
136136 local r = math.sqrt ((ix - jx ) ^ 2 + (iz - jz ) ^ 2 )
137- local iy = Spring .GetGroundHeight (ix , iz )
138- local jy = Spring .GetGroundHeight (jx , jz )
137+ local iy = SpringShared .GetGroundHeight (ix , iz )
138+ local jy = SpringShared .GetGroundHeight (jx , jz )
139139 local isWithinClaimRadius = (r <= claimRadius )
140140 local isWithinClaimHeight = (math.abs (iy - jy ) <= claimHeight )
141141 local score -- Magic formula. Assumes all metal spots are of equal production value, TODO...
@@ -199,15 +199,15 @@ end
199199
200200function GuessTwo (teamID , allyID , xmin , zmin , xmax , zmax , startPointTable ) -- TODO: make this more efficient, atm it akes 1-2 sec to run
201201 -- search over metal map and find a point with a reasonable amount of non-claimed metal near to it
202- local mmapx , mmapz = Spring .GetMetalMapSize () -- metal map cords * 16 = world coords
202+ local mmapx , mmapz = SpringShared .GetMetalMapSize () -- metal map cords * 16 = world coords
203203 local xres = math.max (1 , math.floor (mmapx / 16 ))
204204 local zres = math.max (1 , math.floor (mmapz / 16 ))
205205
206206 local points = {} -- possible startpoints point[id] = {x,z,metal}, grid over metalmap of sidelength res
207207 local x = xres
208208 local z = zres
209209 while true do -- i hate lua
210- local y = Spring .GetGroundHeight (x * 16 , z * 16 )
210+ local y = SpringShared .GetGroundHeight (x * 16 , z * 16 )
211211 local isWithinStartBox = (xmin < 16 * x ) and (16 * x < xmax ) and (zmin < 16 * z ) and (16 * z < zmax )
212212 if isWithinStartBox then
213213 points [# points + 1 ] = { x = x , y = y , z = z , m = 0 }
@@ -231,8 +231,8 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD
231231 local isFree = true
232232 for _ , startpoint in pairs (startPointTable ) do -- we avoid enemy startpoints too, to prevent unnecessary explosions and to deal with the case of having no startboxes
233233 local sx , sz = startpoint [1 ], startpoint [2 ]
234- local sy = Spring .GetGroundHeight (sx , sz )
235- local y = Spring .GetGroundHeight (x * 16 , z * 16 )
234+ local sy = SpringShared .GetGroundHeight (sx , sz )
235+ local y = SpringShared .GetGroundHeight (x * 16 , z * 16 )
236236 local isWithinClaimRadius = ((sx - x * 16 ) * (sx - x * 16 ) + (sz - z * 16 ) * (sz - z * 16 ) <= claimRadius2 * claimRadius2 )
237237 local isWithinClaimHeight = (math.abs (sy - y ) <= claimHeight )
238238 if isWithinClaimRadius and isWithinClaimHeight then
@@ -242,9 +242,9 @@ function GuessTwo(teamID, allyID, xmin, zmin, xmax, zmax, startPointTable) --TOD
242242 end
243243
244244 -- if it is, add this metal into points
245- local m = Spring .GetMetalAmount (x , z )
245+ local m = SpringShared .GetMetalAmount (x , z )
246246 if isFree and m > 0.1 then
247- local y = Spring .GetGroundHeight (x * 16 , z * 16 )
247+ local y = SpringShared .GetGroundHeight (x * 16 , z * 16 )
248248 for _ , p in ipairs (points ) do
249249 if m and (p .x - x ) * (p .x - x ) + (p .z - z ) * (p .z - z ) <= (claimRadius2 / 16 ) * (claimRadius2 / 16 ) and math.abs (p .y - y ) <= claimHeight then
250250 p .m = p .m + m
0 commit comments