View topic - Slope etc question



All times are UTC + 1 hour


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Slope etc question
PostPosted: 23 Oct 2009, 10:22 

Joined: 17 Sep 2009, 09:49
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


Top
 Offline Profile  
 
 Post subject: Re: Slope etc question
PostPosted: 23 Oct 2009, 13:19 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
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.


Top
 Offline Profile  
 
 Post subject: Re: Slope etc question
PostPosted: 29 Oct 2009, 09:23 

Joined: 17 Sep 2009, 09:49
For some reason I cant get the built-in pathfinder to work.

I do
Code:
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:
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?


Top
 Offline Profile  
 
 Post subject: Re: Slope etc question
PostPosted: 29 Oct 2009, 11:04 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
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).


Top
 Offline Profile  
 
 Post subject: Re: Slope etc question
PostPosted: 29 Oct 2009, 15:34 
Spring Developer

Joined: 08 Oct 2006, 15:58
johanhagelback wrote:
Code:
GetNextWaypointPathAICommand nwpCmd = new GetNextWaypointPathAICommand(current_pathId, wp);



This should be

Code:
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.


Top
 Offline Profile  
 
 Post subject: Re: Slope etc question
PostPosted: 30 Oct 2009, 10:25 

Joined: 17 Sep 2009, 09:49
That seemed to be the thing. Now it works perfectly.

Thanks for the help!


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.