[SOLVED]navigation for nonplayer ship to starbase

This is the location for all mods to collaborate. Anyone making or planning their own mod should post help requests, screen shots and news here.

Moderators: Omega, tillias, Mod Contributor

Post Reply
crome
Explorer
Explorer
Posts: 14
Joined: Wed Mar 18, 2009 6:31 pm

[SOLVED]navigation for nonplayer ship to starbase

Post by crome »

Hello,

I have been creating a mission and I'm kinda stuck right now. I created a ship that needs to be escorted to a specified location. Unlike the built-in escort mission, the ship is NOT supposed to form on your wing. Instead it should navigate to its target destination on its own. But it just won't do it.
I have tried it with the function 'AutoPilotTo(self.destination)' but that does not work. I tried it with 'setTarget(self.destination)' but it does not head to its destination unless I repeatedly tell it to do so every time the 'Execute()' function is called.And when it gets there it stars attacking its destination target. 'DockTo' also does not do the trick. The only halfways acceptable workaround so far I have found out is to set the destination as Flightgroupleader and then have it form-up on its wing. It approaches the destination, drops out of spec, comes within range of 20 to 15 km and then turns away again. Has anyone any ideas how to make it actually fly to its destination without attacking it?
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Re: navigation for nonplayer ship to starbase

Post by ace123 »

Yes, you need to use something called flightgroup directives. I believe what you want is "p" or "f" or "e"--I completely forget which. The default I think is "b" (break and attack). If you search around I made a post where I dug through the code and listed all the directives.

Also, if you capitalize the directive the AI will be forced to stay in that mode--and if you add a "." to the end then the AI is not allowed to change targets. For example, a lot of missions use "A." to force a unit to attack its target no matter what.

So I think what you want is myUnit.setFgDirective("P.") or "F."
crome
Explorer
Explorer
Posts: 14
Joined: Wed Mar 18, 2009 6:31 pm

Re: navigation for nonplayer ship to starbase

Post by crome »

Hello ace123,

I already tried setting the flightgroup directiv to 'F.". It resulted in the ship approaching the base and holding a distance ~20 km. I think this has somthing to do with the size of the target. I still hope I can find a simple workaround. I do not want to have to write my own AI scripts. So if approaching the target is that hard already I guess making it dock might be nearly impossible. But thanks anyway for your ideas.
crome
Explorer
Explorer
Posts: 14
Joined: Wed Mar 18, 2009 6:31 pm

Re: navigation for nonplayer ship to starbase

Post by crome »

UPDATE!
Solved it. The problem is indeed the size of the target. I finally used a navpoint - which is also a unit - as flightgroup leader. I think this approach will also solve the docking issue.
Thoughts on alternative solutions are still welcome though.
Post Reply