Slope

Slope

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Slope

Post by Petah »

NM, I was looking at the value from modinfo.adune.nl and it seems to be inconsistent with the value you get in spring.

Using the com.springrts.ai.oo.Map.getSlopeMap() how can I check if a position is less than a unit maxslope property.

Units maxslope is normally an integer between 0-80 but the float values returned from getSlopeMap() are small decimal values.

In other words how do I tell if a position is passable by a unit.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Slope

Post by AF »

Normally you can do CanBuild() on a position, and if a mobile unit can be built there, it can move there, but you could have to do a very finegrained iteration repeatedly calling it along a path or area.

Its not a very efficient approach and Id like to know how to use the slope values and the unitdef values to figure out what you get when you press f2 ingame.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Re: Slope

Post by Peet »

AF wrote:Normally you can do CanBuild() on a position, and if a mobile unit can be built there, it can move there, but you could have to do a very finegrained iteration repeatedly calling it along a path or area.
Unfortunately that only works if the unitdef's maxSlope is the same as the movetype's. Which it often isn't.


ud->maxSlope is the unit's max slope /1.5 in degrees. Presumably the decimal values given are the tangent of the angle.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Slope

Post by AF »

So basically:

Code: Select all

bool CanBuildAt(float mapslope, const UnitDef* u){
    float unitslope = tan(u->maxslope/1.5);
    return unitslope < mapslope;
}
Post Reply

Return to “AI”