Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Aginor on May 29, 2012, 08:29:11 am

Title: Dynamic waypoint paths for capships?
Post by: Aginor on May 29, 2012, 08:29:11 am
Hi there!
I'm working on the sixth and seventh missions of my Kilrathi mod for Saga at the moment, and there is a scene where a enemy capship is supposed to hunt a friendly one.
The problem is: I am doing something wrong. Neither ai-stay-near-ship nor ai-chase seems to have the desired effect.

Here's the situation:
- The friendly ship (ship A) is on a circle path around a jump point, guarding it. Waves of enemies jump in and are defeated by the player and his wingmen and ship A
- suddenly a bigger (too big) enemy capship (ship B) jumps in. Ship A has to flee. This event is triggered depending on various factors like how good the player is. So I don't know where ship A is when ship B jumps in.

So what I did is set a waypoint far away and as soon as B has jumped in I tell A to clear-goals and add-goal waypoint-once to the far away point. Roughly I know where that one should be. It is not a perfect escape route but it points away from the jump point at least. Looks cool so far.
The problem is that ship B out of the jump point does not point in the right direction, and when I tell it to fly towards the same waypoint as ship A it takes some sort of parallel course where it doesn't come near enough to ship A to be dramatic.

So I wondered if the following works:
- I create a waypoint somewhere (doesn't matter where), I call it "chaseWP"
- as soon as ship B has arrived I set-position of chaseWP to getX, getY, getZ of ship A. The same event tells ship B to ai-waypoint-once chase WP. So regardless of where ship A flies, ship B will head directly in its direction as soon as it arrives. When it reaches the waypoint it turns for the escape WP ship A flies to. It moves faster so it doesn't really matter that this is not the ideal intercept course. It is more of a lag pursuit.

Also I could use a moving waypoint to keep capships in formation maybe. Capships in wings have some strange side effects it seems...

would that work? I tried something similar before but something didn't work.
Or did I just do something wrong with the normal way of giving the ships orders? I tried ai-chase (or was it ai-stay-near-ship?) with capships before and nothing happened. :(
Title: Re: Dynamic waypoint paths for capships?
Post by: mjn.mixael on May 29, 2012, 08:34:45 am
Moving waypoints around in-mission won't work. However, the code (not sure if it made it into WCS though) does support unlimited waypoints now.

You could add plenty of waypoints around the space where Ship A might be. The you could use a when-argument distance check to find the nearest waypoint and set Ship B to go to that one.
Title: Re: Dynamic waypoint paths for capships?
Post by: X3N0-Life-Form on May 29, 2012, 09:11:03 am
Ahhh, dynamic waypoints.

It's up there with the other grails of the SCP, somewhere between shadows and geomod.

Well, shadows already sort of exist, do they still count as a grail?
Title: Re: Dynamic waypoint paths for capships?
Post by: Sushi on May 29, 2012, 09:19:11 am
Moving waypoints around in-mission won't work. However, the code (not sure if it made it into WCS though) does support unlimited waypoints now.

You could add plenty of waypoints around the space where Ship A might be. The you could use a when-argument distance check to find the nearest waypoint and set Ship B to go to that one.

I thought moving waypoints worked, but if a ship was already following a path it wouldn't ever reflect that update?

Also, have you tried using ai-chase?
Title: Re: Dynamic waypoint paths for capships?
Post by: General Battuta on May 29, 2012, 09:31:26 am
Sushi is correct. I've always wanted that fixed, as it would enable some amazing ****.
Title: Re: Dynamic waypoint paths for capships?
Post by: Aginor on May 29, 2012, 10:06:24 am
I *think* I tried ai-chase but it didn't do anything. But then the target was a fighter (the player) when I tried it, and maybe capships don't follow fighters at all...
Moving waypoints around in-mission won't work. However, the code (not sure if it made it into WCS though) does support unlimited waypoints now.

You could add plenty of waypoints around the space where Ship A might be. The you could use a when-argument distance check to find the nearest waypoint and set Ship B to go to that one.

I thought moving waypoints worked, but if a ship was already following a path it wouldn't ever reflect that update?

I think this is what happened. The ship seemed to ignore it.

@mjn.mixael:
Sounds good. I think I'll try that. I just thought moving a waypoint to the ship's position would be the more elegant way.

EDIT:
For fighters I use ghost ships when waypoints don't work, but that means back to square one since I couldn't make a capship follow another ship in the first place.
Title: Re: Dynamic waypoint paths for capships?
Post by: Droid803 on May 29, 2012, 11:54:54 am
You can definitely make capships ai-chase another capship.
Just be sure to cancel the order when they get too close or it will attempt to show you the dance of their people.
Title: Re: Dynamic waypoint paths for capships?
Post by: mjn.mixael on May 29, 2012, 11:55:51 am
You can definitely make capships ai-chase another capship.
Just be sure to cancel the order when they get too close or it will attempt to show you the dance of their people.

 :lol:
Title: Re: Dynamic waypoint paths for capships?
Post by: Aginor on May 29, 2012, 12:35:45 pm
Ok, I'll test that in a minute.
Title: Re: Dynamic waypoint paths for capships?
Post by: Aginor on May 29, 2012, 12:55:41 pm
Hmmm... now it worked.
Is there any difference between setting initial orders to "attack ship A" and giving the orders via SEXP (ai-chase ship A)? I could swear I tried it that way and it didn't work...

Anyway, thanks for your answers, that was a lot easier than expected.
Title: Re: Dynamic waypoint paths for capships?
Post by: Droid803 on May 29, 2012, 01:54:58 pm
There is no difference, both work the same way.
Title: Re: Dynamic waypoint paths for capships?
Post by: Aginor on May 29, 2012, 05:02:08 pm
Ok, thanks. :)