Jump to content

Recommended Posts

made this chunk of code to reveal a big circle on the map but it's super clunky and inefficient. having trouble finding any other way to do this though. Is there any way to just configure the size of RevealArea?

 

   for angle = 0, 2*math.pi, math.pi/10 do
                    for radius = 0, 150, 30 do
                        local revealx = radius * math.cos(angle)
                        local revealz = radius * math.sin(angle)
 
                        inst.last_attacker.player_classified.MapExplorer:RevealArea(revealx + x, 0, revealz + z)
                    end
   end

I don't believe you can, no. However, the revealing can indeed be improved. You need more calls for larger radii or, conversely, less calls for smaller radii. For example, for radius 0 you'd need 1 call (or 0), instead of 20. If you're not bothered if the resulting area revealed is not quite a circle, maybe a hexagon-ish? It's more efficient, see this and this. In particular, the cases for n=1, 7, and 19 and, continuing the series, 37 and 61 and so on, each cover an increasingly large hexagon. Which reminded me of this post; while not quite the same problem, the solution is related and probably reworkable. Considering performance again, p and q should be cached.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...