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.
Slope
Moderators: hoijui, Moderators
Re: Slope
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.
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.
Re: Slope
Unfortunately that only works if the unitdef's maxSlope is the same as the movetype's. Which it often isn't.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.
ud->maxSlope is the unit's max slope /1.5 in degrees. Presumably the decimal values given are the tangent of the angle.
Re: Slope
So basically:
Code: Select all
bool CanBuildAt(float mapslope, const UnitDef* u){
float unitslope = tan(u->maxslope/1.5);
return unitslope < mapslope;
}