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
Slope etc question
Moderators: hoijui, Moderators
Re: Slope etc question
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.
otherwise you would have to use the MoveData (guess its in UnitDef) of the unit, and compare wiht the slope map.
-
- Posts: 13
- Joined: 17 Sep 2009, 10:49
Re: Slope etc question
For some reason I cant get the built-in pathfinder to work.
I do
and a couple of frames later
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?
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);
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);
}
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
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).
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
This should bejohanhagelback wrote:Code: Select all
GetNextWaypointPathAICommand nwpCmd = new GetNextWaypointPathAICommand(current_pathId, wp);
Code: Select all
GetNextWaypointPathAICommand nwpCmd = new GetNextWaypointPathAICommand(ipCmd.pathId, wp);
-
- Posts: 13
- Joined: 17 Sep 2009, 10:49
Re: Slope etc question
That seemed to be the thing. Now it works perfectly.
Thanks for the help!
Thanks for the help!