Page 1 of 1
Slope etc question
Posted: 23 Oct 2009, 11:22
by johanhagelback
Hi,
I am developing an AI using the Java interface. I cant really get hang on the slope map things.
What I want to do is basically:
I have a unit U at pos (x,y,z)
I plan to move U to pos (x,...,z)
and I want to check if the unit can move between the points or the terrain is too steep.
Tried to get data from the SlopeMap but it doesnt work perfectly...
Anyone know how I can do this?
Cheers,
Johan
Re: Slope etc question
Posted: 23 Oct 2009, 14:19
by hoijui
maybe just request a path form the engine for the specific unit, form where it is to where you want ot go. and if it fails, or the path is too long (eg, > 2*distOfPoints), treat it as not possible.
otherwise you would have to use the MoveData (guess its in UnitDef) of the unit, and compare wiht the slope map.
Re: Slope etc question
Posted: 29 Oct 2009, 09:23
by johanhagelback
For some reason I cant get the built-in pathfinder to work.
I do
Code: Select all
AIFloat3 dest = new AIFloat3(1024, 0, 1024);
int current_pathId = 1;
AIFloat3 start = new AIFloat3(unit.getPos().x, 0, unit.getPos().z);
InitPathAICommand command = new InitPathAICommand(start, dest, unit.getDef().getMoveData().getPathType(), current_pathId);
int res = handleEngineCommand(command);
and a couple of frames later
Code: Select all
AIFloat3 wp = new AIFloat3(0, 0, 0);
GetNextWaypointPathAICommand command = new GetNextWaypointPathAICommand(current_pathId, wp);
int res = handleEngineCommand(command);
if (res == 0) {
log.log(Level.FINE, "Next waypoint: (" + wp.x + "," + wp.z + ") Status=" + wp.z);
}
all I get is (-1,-1,-1) which according to the Javadoc is a failed path. I've tried a lot of variants in the parameters but still get the same error...
I tried to use the return value from the handleEngineCommand initpath as pathId in GetNextWaypoint but still the same error.
Any idea what I am missing?
Re: Slope etc question
Posted: 29 Oct 2009, 11:04
by hoijui
maybe somoene else is using it and has more info, i never used it...
i just cant work on this right now, so if nobody else will naswer, pls report on mantis (make advanced report, then you'll be able to select AI as the section).
Re: Slope etc question
Posted: 29 Oct 2009, 15:34
by Kloot
johanhagelback wrote:
Code: Select all
GetNextWaypointPathAICommand nwpCmd = new GetNextWaypointPathAICommand(current_pathId, wp);
This should be
Code: Select all
GetNextWaypointPathAICommand nwpCmd = new GetNextWaypointPathAICommand(ipCmd.pathId, wp);
where ipCmd is the InitPathAICommand instance created earlier. The initial value of the pathId field of ipCmd is (supposed to be) modified by the handleEngineCommand call.
Re: Slope etc question
Posted: 30 Oct 2009, 10:25
by johanhagelback
That seemed to be the thing. Now it works perfectly.
Thanks for the help!