Page 1 of 1

Do we have a way to tell the pathfinder this area is a no go?

Posted: 08 May 2015, 22:26
by smoth
Not using the stupid speed maps. Not using a Lua hack like teleport a unit back. I want to tell the pathfinder avoid here

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 00:34
by Silentwings
Afaik "stupid speed maps" (=typemaps?) are the only way.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 02:56
by zwzsg
I have not found any that works.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 05:01
by smoth
Type maps fail because they are based on spring's magical assignment of classes and cannot be touched by Lua(or can they?)

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 05:25
by enetheru
I would also like this.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 07:32
by gajop
Would be nice to have more control over the blocking map via Lua.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 14:49
by qray
Not saying that this is the solution you're looking for, just for completeness:

For my space maps with voidground , I played around and tested a lot terrain types with 0 speed (for all unit classes) and regarding pathfinding it works very well. Only units that get pushed or thrown there are stuck then, which IMHO is a big downside of this method in many use cases. Requires then Lua to solve this...

And
smoth wrote:Type maps ... cannot be touched by Lua(or can they?)
https://springrts.com/wiki/Lua_SyncedCtrl#TerrainTypes

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 09 May 2015, 15:59
by Google_Frog
Do you want units to be completely unable to enter an area or do you just need the pathfinder to treat it as impassible?

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 10 May 2015, 00:27
by smoth
Pathfinder. Units getting bumped thrown etc are a separate issue that I can to some degree control.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 10 May 2015, 01:11
by Kloot

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 10 May 2015, 05:37
by smoth
DUDE! KLOOT! Awesome!!

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 11 May 2015, 03:21
by gajop
How is this used? It's confusing, I can only make guesses..

Here's one:

Code: Select all

-- initialize a path grid (what are the defaults costs, is it even a grid, what should be the values?)
Path.InitPathNodeCostsArray(0, 1024, 1024)
-- use it
Path.SetPathNodeCosts(0)
-- set cost based on grid positions (example position)
local x, z = 5, 12 
local cost = 80
Path.SetPathNodeCost(0, x * 1024 + z, 80) -- is this how array position is calculated? 
-- set cost based on map positions
-- convert mapPosX, mapPosZ to x, z based on grid resolution and then use the above?

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 11 May 2015, 16:48
by Kloot
As the wiki says, overlay cost values are additive which already implies what their default is (0).

The overlay grids are stored in row-major order, so you want z * numNodesX + x to transform grid coordinates (x, z) to the corresponding array index.

Converting from map to grid coordinates should be obvious: downsample them by the map:grid size ratio unless you set numNodes{X,Z} equal to mapSize{X,Z} in both dimensions.

note: it's useless to supply cost grids larger than the heightmap.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 12 May 2015, 09:20
by gajop
Cool, thanks.
I think these are clear now - I'll update the wiki when I test this.

Just to confirm - it's not possible to have a separate cost grid for different units, unitdefs, or movedefs?
That is, there can be only one cost grid for all units?
The reason I ask this is because we may want to use this to make certain units avoid certain areas of the map that are hazardous to them, but still allow other units to walk there. Unit AI is an option, but this is basically a pathfinding issue.

Another thing - does the cost grid override the heightmap-generated values or is it additive to it?
How do we update it?

PS: I'm of the opinion that Path.SetPathNodeCost should provide a slightly different interface:

Code: Select all

Path.SetPathNodeCost(number arrayID, number x, number z, number cost) -> boolean success 
It feels more intuitive and works similar to Path.GetPathNodeCost.

Re: Do we have a way to tell the pathfinder this area is a no go?

Posted: 12 May 2015, 16:49
by Kloot
An active grid will affect all units. Separate per-movedef grids would be possible, the others aren't (the PFS has no concept of units or unitdefs).

Costs are additive only.

To update, just call SetPathNodeCost again and any newly calculated paths will take the changes into account (if they visit the modified nodes).

NB: at present, only the default PFS can use these overlays.