Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: FUBAR-BDHR on April 19, 2008, 11:29:24 pm

Title: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 19, 2008, 11:29:24 pm
Been trying to do something that seems simple enough.  I have a wing consisting on 1 ship with multiple waves.  I want the ship to do a set of waypoints then stop (play dead).  When it's destroyed an the next wave appears I want it to do the same thing.  The problem I'm running into is that are-waypoints-done seem to evaluate to true for the second wave event before it arrives.  Thus the ship just stops exiting the hanger.  Anyone know a way around this?
Title: Re: Getting a wing's wave to do waypoints
Post by: blowfish on April 19, 2008, 11:50:38 pm
There is a *hackish* solution.  You could make every wave a different ship (using the weird high-ascii character thing, though this is being replace by # things) and have the next one arrive when the previous one has been destroyed.  Other than that, I can't think of anything.

Actually, maybe you could use a every-time distance sexp to trigger the playing dead rather than the waypoints being done...
Title: Re: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 20, 2008, 12:37:08 am
Already tried the everytime distance thing.  I'm trying to use wings to keep the number of ships down so that idea is out.  I wouldn't really even need to use special characters.

I did have it close to working by just using waypoints once but the problem there was that when the ships finished the waypoints they moved to a safe distance form the engines that I'm trying to get them near.  Waypoint and stay still didn't work either even with no dynamic goals.  Play dead seems to be the only way to get them to stay where I need them too. 

Thinking of trying a combination of distance, variables and waypoint speed next. 

Scratch that idea waypoint speed only works for ships not wings.

Tried using waypoints instead of waypoints once and remove goal play dead.  Looks like it's going to work when the second wave arrive it even shows waypoints as the goal but as soon as it gets to the end of the docking bay it stops dead and changes to no orders.

Strange thing is that if I destroy the ship before it gets to the last waypoint or is given a different order the next wave will do the waypoints correctly. 
Title: Re: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 21, 2008, 02:28:17 am
Well I tried getting creative and using when-argument.  I removed all the initial orders and made the following events

when-argument
-->in-sequence
---->Maintenance Bot 1 1
---->Maintenance Bot 1 2
---->Maintenance Bot 1 3
---->etc
-->and
---->=
------>bot1(0)
------>0
---->>
------>num-ships-in-wing
------>0
-->add-goal
----><argument>
---->ai-waypoints-once
------>waypoint path 1
------>89
-->modify-variable
---->bot1(0)
---->1
-->invalidate-argument

when
-->and
---->=
------>bot1(0)
------>1
---->=
------>num-ships-in-wing
------>0
-->modify-variable
---->bot1(0)
---->0


I was surprised it didn't blow up in my face but it still only works for the first ship.    The event fires for the second ship but it still doesn't get any orders.  Now I don't know if it just won't work or I'm using the when-argument incorrectly. 
Title: Re: Getting a wing's wave to do waypoints
Post by: karajorma on April 21, 2008, 02:40:25 am
You can't give individual orders to any ship in a wing other than the first one and expect it to be obeyed. It's one of the odd quirks that has been there since Retail.
Title: Re: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 21, 2008, 01:20:08 pm
So basically my code would be correct if it was possible but I'm beating a dead Shivan trying to get this to work. 

Had another interesting idea.  If I can't change the orders for the second wave in a wing can I change it's speed using cap-waypoint-speed?  Something like

when-argument
-->in-sequence (ship list)
-->distance wing waypoint 1-3 < 50
-->cap-waypoint-speed
----><argument>
---->0

Then just do the same thing for when the next ship in the wing arrives but with the max speed of the ship.

Forgot to add wing orders would be waypoints instead of waypoints-once.
Title: Re: Getting a wing's wave to do waypoints
Post by: karajorma on April 21, 2008, 02:03:31 pm
Never tried that.
Title: Re: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 21, 2008, 02:05:27 pm
Well guess I have something to try tonight.  I didn't copy the mission up to my server for just such an occasion.  Didn't want to spend the day playing with that instead of getting my work done. 
Title: Re: Getting a wing's wave to do waypoints
Post by: FUBAR-BDHR on April 27, 2008, 01:05:25 am
Finally had time to try the speed idea.  Ran into two problems with it.  Cap-waypoint-speed won't take a variable for a ship name and distance won't take a variable for an object.  Modify-variable didn't want to let me assign <argument> to a variable either.  I was able to manually type it in and didn't receive an error when I saved but haven't tried to run it yet.   

Well I finally got cap-waypoint-speed and distance to take the variables by assigning the first ship in the wing to as the default value for the variable.  Mission loads without errors.  Ship flies to the waypoint and my stop message appears and the ship briefly slows down but then takes off again at max speed.  If I kill it off the next ship will do the waypoints which was what I couldn't get the ships to do before.  However the stop message never appears so it looks like the distance is using the default value at mission start instead of the value stored in the variable. 

Here's what I have for this particular wing just in case I'm missing something:

Code: [Select]
$Formula: ( every-time-argument
   ( in-sequence
      "Maintenance Bot 4 1"
      "Maintenance Bot 4 2"
      "Maintenance Bot 4 3"
      "Maintenance Bot 4 4"
      "Maintenance Bot 4 5"
      "Maintenance Bot 4 6"
      "Maintenance Bot 4 7"
      "Maintenance Bot 4 8"
      "Maintenance Bot 4 9"
   )
   ( and
      ( = @Bot4[0] 0 )
      ( >
         ( num-ships-in-wing
            "Maintenance Bot 4"
         )
         0
      )
   )
   ( modify-variable
      "@Bot4s[Maintenance Bot 4 1]"
      <argument>
   )
   ( modify-variable @Bot4[0] 1 )
   ( send-message
      "#Command"
      "High"
      "Arrive 4"
   )
   ( cap-waypoint-speed "<argument>" 99 )
   ( invalidate-argument "<any data>" )
)
+Name: Speed 4
+Repeat Count: 1
+Interval: 1
+Team: 2036422432

$Formula: ( when
   ( <
      ( distance
         "@Bot4s[Maintenance Bot 4 1]"
         "Waypoint path 4:3"
      )
      75
   )
   ( cap-waypoint-speed
      "@Bot4s[Maintenance Bot 4 1]"
      0
   )
   ( send-message
      "#Command"
      "High"
      "Stop 4"
   )
)
+Name: Stop 4
+Repeat Count: 999999999
+Interval: 1
+Team: 840968201

$Formula: ( when
   ( and
      ( =
         ( num-ships-in-wing
            "Maintenance Bot 4"
         )
         0
      )
      ( = @Bot4[0] 1 )
   )
   ( send-message
      "#Command"
      "High"
      "Dead 4"
   )
   ( modify-variable @Bot4[0] 0 )
)
+Name: Dead 4
+Repeat Count: 999999999
+Interval: 1
+Team: 1701667150

Don't know where the heck those team values came from.  I sure didn't put them in there.
Title: Re: Getting a wing's wave to do waypoints
Post by: karajorma on April 27, 2008, 02:44:25 am
Finally had time to try the speed idea.  Ran into two problems with it.  Cap-waypoint-speed won't take a variable for a ship name and distance won't take a variable for an object.  Modify-variable didn't want to let me assign <argument> to a variable either.  I was able to manually type it in and didn't receive an error when I saved but haven't tried to run it yet.   

Yeah it will. I've done all three of those things. Try making sure the default value of the variable is the name of a ship that is actually in the mission.