Author Topic: Staggering when-argument events  (Read 2826 times)

0 Members and 1 Guest are viewing this topic.

Offline Sushi

  • Art Critic
  • 211
Staggering when-argument events
Example scenario: I have three dozen ships that I want to warp out, randomly staggered within a 3 second interval. I have a when-argument SEXP as follows (forgive the butchered syntax, hopefully it conveys the idea):

- when-argument
   - (big long list of ships)
   - is-event-true-msecs
        - myEvent
        - rand-multiple 0 3000
   - add-goal
        - <argument>
        - ai-warp

(trigger-count 999999, interval 0)

This doesn't work the way I would have hoped. Everything still happens for all of the ships at the same time. What should I be doing instead?


 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Staggering when-argument events
I don't know the answer off the top of my head right now.. (been UVing the Arcadia for a few hours and my brain is fried).. but I'm pretty sure the answer is somewhere in this tutorial.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Sushi

  • Art Critic
  • 211
Re: Staggering when-argument events
Just thought of something that might work, I'll try it when I get home. Basically, use random-of to choose one ship at a time, and use a variable to keep track of when to trigger the next one.

So basically:

- when-argument
    - random-multiple-of
        (big list of ships)
    - is-event-true-msecs
        - myEvent
        - $nextTime
    -add-goal
        - <argument>
        - <ai-warp>
    -modify-variable
        - $nextTime
        - +
            - rand-multiple(0, 300)
            - $nextTime
     -invalidate-argument
        - <argument>

Assuming this works the way I expect, it would mean the time to launch everything would be somewhere between (millis-per-frame * number of ships) and (300 * number of ships) milliseconds.

If I wanted to do them all in order (with random gaps between), i could just use in-sequence instead of random-multiple-of, right?

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Staggering when-argument events
Assuming this works the way I expect, it would mean the time to launch everything would be somewhere between (millis-per-frame * number of ships) and (300 * number of ships) milliseconds.

If I wanted to do them all in order (with random gaps between), i could just use in-sequence instead of random-multiple-of, right?

This might be the case regardless.. but trigger count should work, barring that an every-time might be warranted and do the same thing without a variable.

This is an intriguing event.. I think I'll play around with it and let you know what I come up with.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Sushi

  • Art Critic
  • 211
Re: Staggering when-argument events
Thanks for that link... the "Under the hood" section at the list explains exactly why I'm seeing the behavior I am with my first attempt.

It also looks like my second attempt is likely to work (using either random-multiple-of or in-sequence). Woohoo!

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Staggering when-argument events
Thanks for that link... the "Under the hood" section at the list explains exactly why I'm seeing the behavior I am with my first attempt.

It also looks like my second attempt is likely to work (using either random-multiple-of or in-sequence). Woohoo!

It does, I just checked.  :)
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: Staggering when-argument events
Just a note: the expected time for all the ships to be given order to jump out will be something like (0 + 300/2)*(number of ships).  If the number of ships is really is 36, then the expected value for that random-multiple sexp will end up being 5.4 seconds.  The total range is pretty extreme as well.  It can be anywhere from 36 microseconds (maybe?...) to 10.8 seconds.  You might want to try something like 50 and 116.  The expected time is 3 seconds and it has a smaller possible range. Between 1.8 and 4.16 seconds.  It's probably more realistic.

 

Offline Sushi

  • Art Critic
  • 211
Re: Staggering when-argument events
Yeah, I just picked that "300" number out of a hat. And three dozen was just for an example.

What I really want this for is having properly-staggered launches for Diaspora vipers and raiders (from launch tubes and raider racks, respectively). Can't wait to get home and try this.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Staggering when-argument events
Thanks for that link... the "Under the hood" section at the list explains exactly why I'm seeing the behavior I am with my first attempt.

Actually it would be possible to get the behaviour you want with any-of or number-of. What was preventing them from working was that the trigger for your SEXP didn't use <argument> in it anywhere. When that happens the game just assumes you want to do everything to all the ships on the list.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Staggering when-argument events
Thanks for that link... the "Under the hood" section at the list explains exactly why I'm seeing the behavior I am with my first attempt.

Actually it would be possible to get the behaviour you want with any-of or number-of. What was preventing them from working was that the trigger for your SEXP didn't use <argument> in it anywhere. When that happens the game just assumes you want to do everything to all the ships on the list.

Well... loosely speaking, yes. However if we didn't want/need to use <argument> in the trigger, then we need random-of.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Staggering when-argument events
Absolutely.

I just wanted to clarify exactly why the first version Sushi posted hadn't worked. I prefer a complete answer in any thread for next time someone stumbles across the same problem. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Staggering when-argument events
Hmm true... I admit that I was confused with a similar use of any-of for a while until I figured it out by trial and error.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

  

Offline Sushi

  • Art Critic
  • 211
Re: Staggering when-argument events
For the record, this works brilliantly well using random-of and a variable to keep track of the next trigger time.