Author Topic: Help! Event Only Firing Once  (Read 1792 times)

0 Members and 1 Guest are viewing this topic.

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Help! Event Only Firing Once
So, I've been slowly freding a campaign over the past ... who knows how long ... during my spare time.  However, I cannot seem to get any configuration of an important event to work as designed.  However, according to everything I know about sexps, it should be firing just fine.

Here is the event in question:

Code: [Select]
$Formula: ( when-argument
   ( random-of
      "a"
      "b"
      "c"
      "d"
      "e"
      "f"
      "g"
      "h"
      "i"
      "j"
      "k"
      "l"
      "m"
      "n"
      "o"
      "p"
      "q"
      "r"
      "s"
      "t"
   )
   ( or
      ( = 1 @myleto[0] )
      ( has-arrived-delay 0 "GTT Leto" )
   )
   ( ship-unstealthy "<argument>" )
   ( invalidate-argument "<argument>" )
   ( modify-variable @myleto[0] 1 )
)

The letters are hostile ships that are hidden from sensors but also start off stealthy.  They are basically there to simulate sensor errors, but whenever I run the mission, no matter what repeat and trigger count I use, I can only get the event to fire once (I think).  If it fires with invalidate-argument included, only one ship is made unstealthy.  If I try it without invalidate argument, they all appear at the same time.  I want them to appear one ship at a time, and I'm not sure what I'm doing wrong.  Anyone have an idea?

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Help! Event Only Firing Once
random-of picks the same argument every time it's evaluated; if you want a new random item each time, you need to use random-multiple-of. If everything seems to be showing up at once, then you need to make sure the interval is set high enough so that it won't just re-evaluate every frame and effectively unstealthy all of them simultaneously.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Event Only Firing Once
If it fires with invalidate-argument included, only one ship is made unstealthy.  If I try it without invalidate argument, they all appear at the same time.

Are you sure that's not the other way round? Cause if you invalidate the current argument, it should then pick a new one. Random-of is meant to pick the same argument repeatedly and only pick a new one if the currently selected argument is invalid.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: Help! Event Only Firing Once
The interval is set to the default of 1.  The only way I could see that I would make a mistake with that is if the interval is by frame or by millisecond.  I will post the mission, since it's still in such an early stage.  I tediously made a chain of events last time, but I wanted to learn a better way of doing it, since I will probably be repeating this process at least a couple times.

Also, if I use any-of, the senor dots also appears all at once.

The way I see it, the event should

1 Make one of them visible
2 Invalidate that one
3 Wait a second
4 Repeat until all 20 are visible on the radar

[attachment deleted by nobody]

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: Help! Event Only Firing Once
Nevermind.  Random-Multiple-Of does work.  Turns out Random-Of only works for the first argument it chooses, even if the argument is invalidated. 

  

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Help! Event Only Firing Once
Also, if I use any-of, the senor dots also appears all at once.

That's not surprising. Your event doesn't contain <argument> anywhere in the trigger, you only use it in the action part of the event.

If you use <argument> in the trigger somewhere (for instance in a has-arrived-delay <argument> SEXP) the game checks which arguments the trigger evaluates to true for. Without that, any-of and every-of do the same thing, trigger for every single argument on the list.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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