Slope etc question

Slope etc question

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

Moderators: hoijui, Moderators

Post Reply
johanhagelback
Posts: 13
Joined: 17 Sep 2009, 10:49

Slope etc question

Post 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
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Slope etc question

Post 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.
johanhagelback
Posts: 13
Joined: 17 Sep 2009, 10:49

Re: Slope etc question

Post 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?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Slope etc question

Post 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).
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Slope etc question

Post 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.
johanhagelback
Posts: 13
Joined: 17 Sep 2009, 10:49

Re: Slope etc question

Post by johanhagelback »

That seemed to be the thing. Now it works perfectly.

Thanks for the help!
Post Reply

Return to “AI”