Author Topic: Still haven't got the hang of when-argument  (Read 2602 times)

0 Members and 1 Guest are viewing this topic.

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Still haven't got the hang of when-argument
Been trying to get multiple ships to arrive via docking bay, do a waypoint, and then play dead.  Sounds easy enough but it's not.  Started off with wings but had to scrap that.  Now I'm using individual ships numbered like wings.  While I could just have 2 events for each ship I'm trying to take a shortcut using when-argument.  It's not working the way I would expect.  Here's what I have:

when-argument
-->any-of
---->ship 1 1
---->ship 1 2
---->ship 1 3
---->ship 1 4
---->ship 1 5
---->ship 1 6
-->are-waypoints-done-delay
----><argument>
---->0
-->clear-goals
----><argument>
-->add-goal
----><argument>
------>ai-play-dead
------>89
--><invalidate-argument>
----><any data>
repeat count 6

I thought that event would fire when any of the ships listed finished the waypoints then remove that ship from the list so it couldn't make the event fire again.  Instead it just repeats 6 times when the first ship finishes the waypoints.  What am I doing wrong?
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
--><invalidate-argument>
----><any data>

You sure that isn't a typo and it wasn't

--><invalidate-argument>
----><argument>

Cause if not that's your problem right there. You didn't invalidate the first ship to complete its waypoints so the next time the event repeats it's still true for the first ship. In about 95% of cases you'll only ever use invalidate-argument with <argument> but the option is given just in case you ever want to say "If ship X does something first invalidate Ship Y but allow X to trigger the event again"
« Last Edit: May 04, 2008, 02:19:42 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
I was thinking about that but it doesn't give you the option in FRED to put <argument> in invalidate-argument.  It only give you the default of <any data> and string.  I'll try changing it to string and typing <argument> in manually.

Well it did let me type it in manually and save with no errors.  I'll test it in the morning, I mean afternoon. 
« Last Edit: May 04, 2008, 03:43:57 am by FUBAR-BDHR »
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Still haven't got the hang of when-argument
You can use every-time-argument and remove the repeat count of 6.
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
You can use every-time-argument and remove the repeat count of 6.

You can. It would be wrong. But you can.

Every-time-argument is NOT a replacement for a repeating when-argument. Every-time flushes the entire SEXP tree every time it is used. As a result events using it will never evaluate to true and will take longer for the CPU to process than When-argument which marks certain branches false if they can never ever come true.

There are only a few cases where you need to use every-time. One example is if you are using ship-create to respawn a ship. In many cases that won't work with the when SEXP as the game will consider the SEXP false the second the original ship died and prevent the SEXP from ever triggering on a respawn.

In short using every-time to avoid a repeat count is like cracking a nut with a sledgehammer.
« Last Edit: May 04, 2008, 05:18:49 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Still haven't got the hang of when-argument
...even if you use invalidate-argument? I have never had problems with every-time-argument and invalidate-argument.
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
Just cause it hasn't caused problems yet doesn't mean it's sensible to do.

Basically you've told someone who has to the correct solution to use your incorrect solution. Just because you've been lucky enough to not find a situation where the difference has bitten you on the arse doesn't mean Fubar won't.
« Last Edit: May 04, 2008, 11:10:24 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Still haven't got the hang of when-argument
Giving his Custom Title, he might have problems

:nervous:
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
Might? Now there is the understatement of the year.   :lol:  Besides I'm pretty sure I already ran into an issue by doing that.  Don't remember what right now but I think it was messing something up when using random-of. 

Another reason I went with when-argument is there are 2 of these one for the waypoints and one to do something when the ship is at the waypoints.  I only want that to happen ever so many seconds.  Without some kind of counting variable I don't think you can do that with everytime. 

Just tried it and it looks like it works with <argument> typed in.  Of course I put the wrong ship names in FRED.  Typed them right in the example but had them backwards in FRED.   Just need to flip the names around and I'm good to go on that event.  Copy it 10 times and I'm half way done. 

« Last Edit: May 04, 2008, 01:59:24 pm by FUBAR-BDHR »
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
A timed delay between repetitions is another big reason to use when-argument over every-time-argument but I wanted to make the point that even without that it's still the wrong choice much of the time. :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

  

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
OK now I have all the right stuff in there but it's still not working right.  First ship plays dead when it finishes the waypoints but the second one doesn't.  I only receive the stop message once so the event is only firing once.  If I change it to everytime-argument it works.  It's almost like it's using up the 6 repeats even though it's not evaluating to true.  Now the second event is pretty much the same as the first one but does a repair subsystem loop with 99999999 repeats at 10 second intervals.  It does fire when the ship gets to the waypoint but since the mission will never go that long it would still be evaluating.

Yea I could just leave it as everytime-argument but it doesn't make sense why it's not working the way it is.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
What happens if you leave it as when-argument and simply increase the repeat count to something very high?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
It works.  Just tried it with repeat set to 9999.   Second ship stopped and I got the the test message that the event fired the second time. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
Any idea why it works with the 9999 repeat but not with the 6 repeat?  I'll probably just leave it as either everytime or a repeating event with 99999999 repeats but I hate these I don't know why it's not working problems.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Still haven't got the hang of when-argument
I'll have to have a look into it actually. I suspect it's due to the way that the argument SEXPs are dealt with internally by the engine.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Still haven't got the hang of when-argument
Giving his Custom Title, he might have problems

:nervous:


And yes I did even doing it the right way. 

Let's see what can I break next........... :pimp:

This does make me wonder if maybe some of my earlier attempts of making this work using wings may have actually worked.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras