Author Topic: Everytime and directives  (Read 2573 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
Everytime and directives
Tried out a new idea today.  Started working on a TvT gauntlet style mission for TBP and finally got around to doing some testing on it today.  Since it was a TvT I wanted to incorporate a more random aspect to the mission so I made all the wings arrive in random order.  To save a step I combined the directive and loop if the wing was already destroyed into one event for each wing.  Like this:

Wing
-->every-time
---->=
------>wing(0)
------>0
-->modify-variable
---->wing(0)
---->rand-multi
------->1
------->7 (number of wings currently in the mission)
-->modify-variable
---->delay(0)  (this is for delay in arrival between wings)
---->mission-time 

Zephyr
-->every-time
---->and
------>=
-------->wing(0)
-------->1
------>is-destroyed-delay
-------->0
-------->Zephyr
-->modify-variable
---->wing(0)
---->0
Destroy Zephyr

One event for each wing.

Works fine except when the 6th & 7th wings arrives the directives don't show up.  I added messages to see how the whole thing was processing and it seems to work correctly.  Even when it has to run through the loop a few times it still hits the right event last.  Even if the previous directives are showing up a second time the active wing should be the last on the list as it would be the only one not evaluating to true.  Either I'm missing something stupid, doing something that I should be, or found another quark/bug.    Yes I know it would be easy to get around the problem using a separate directive event but I like to know why things aren't working before I work around them.
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: Everytime and directives
Why are you using every-time in the second event?

To me it seems that you're using it to rescue yourself from the poor design choice of having use rand-multiple for picking ships. Rand multiple will often pick a ship wing that has already been destroyed, forcing you to stick the directive into a repeating event (and one which uses every-time at that!) in order to correct for it.

If instead you had used the random-of argument SEXP and a list of the wings in your mission I suspect the problem wouldn't have occurred as you could simply invalidate the arguments whenever they came true.

I suspect that the reason why you're having trouble with the 6th and 7th directives is because the game only allows you 5 and due to the way you have the SEXP the game figures that any of them could be true due to your use of every-time. A good rule of thumb is to never use every-time when a repeated when (delay 0) would work. Every-time has its uses but a lot of people seem to think it's an easy alternative to repeated when SEXPs not realising that there are consequences arising from the fact that every-time can never evaluate to true or false at any time in the mission.
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: Everytime and directives
Alright I understand the reason now.  Every time not evaluating to true is most likely causing all the directives to be active over and over again.  I stole the logic from an old retail mission I wrote which used a repeating when but changed the when to everytime and used rand-multi instead of rand.  It was fun just trying to get anything working with rand in retail.    Took several events just to pick 3 random ships. 

I never tried to use random-of before and the instructions for using it are vague to say the least.  Heck it just took me 10 minutes to figure out how to even get it to not be a grayed out operator.  Apparently you have to use it with when-argument which doesn't' make sense to me since I've never seen it used before.  All I want is a random order of numbers (or wings) from 1 to x.  I may also want them to evaluate to the same number more than once.  Haven't played with it yet but I was going to try to split the wings using their arrival cue.  Don't even know if that is possible but the eventual idea is to have the first wave show up randomly the next wave either be the first from any other wave or the second wave etc. until all waves of all wings are used up.  Was just trying to knock out the simple part first and apparently trying to take too many shortcuts. 

Do you have an example of how to use random-of and random-multiple-of somewhere?  If I see it used it will only take me a few minutes to figure out how to use it.  If I read about how to use it I'll probably never get it. 
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: Everytime and directives
Ah, if you want the wings to be evaluated more than once then you can try simply switching the second event to a repeated when rather than every-time. It also explains why you did things in such an odd fashion in the first place. :D

To use random-of or random-multiple-of you use them like this.


Wing
-->every-time-argument
---->Random-Multiple-Of
------>1
------>2
------>3
------>4
------>5
------>6
------>7
---->=
------>wing(0)
------>0
-->modify-variable
---->wing(0)
----> <Argument>
-->modify-variable
---->delay(0)  (this is for delay in arrival between wings)
---->mission-time 
-->Invalidate-Argument


That won't work for what you're actually trying as it would remove each wing from the event as it was used up. You might be able to get away with changing that by adding the numbers 1-7 in a second time but I've not tried duplicating an argument before so I've got no idea if it would work.

For something like this you must use random-multiple-of. The difference is like the rand/rand-multiple SEXPs, random-of evaluates at the start of the mission and will always call the same argument. You use it for events where for instance you wanted to pick a random ship at the start of a mission but wanted the event to repeat using the same ship for the rest of the mission.
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: Everytime and directives
Thanks.  That makes about 90% more sense now.  Actually trying it in FRED should take care of the other 10%.  I couldn't grasp how the variable was going to get assigned the value but seeing an example it becomes pretty clear.

I could also do a rand-multiple-of 1-14 for seven wings of 2 waves.  1 or 2 for wing 1, 2 or 3 for wing 2, etc. 
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: Everytime and directives
Yeah, I can see that working quite well if you alter the arrival cue to look for ranges of numbers rather than just a number.
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: Everytime and directives
Well I was right I crashed it.   :D  Think I know what the problem is.  <argument> seems to be a string and as soon as I tried to store it to wing(0) which is defined numeric FRED took a dump. 
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: Everytime and directives
Use the String-to-Int SEXP which for some reason seems to be lurking in the training section. I'll move that soon enough.
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: Everytime and directives
I looked just about everywhere for something to do that last night.  Even looked in training but missed it.  Of course I was looking for something like value-of. 
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: Everytime and directives
Well after playing with this I think both ways will work but are a pain in the arse.  For what I am doing I think I'm going to stick to original way of doing it.  Have some other neat things I want to do with it that would just be impossible with the random-multiple-of.  I would almost need a numerical version with a range option to make it work the way I want.  Well not for this mission but for the next one. 

I did get the split wing arrival working in a test so I know it's possible now just to make it work randomly. 
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