Author Topic: Turret to stop firing when event is true  (Read 1843 times)

0 Members and 1 Guest are viewing this topic.

Offline wistler

  • 28
Turret to stop firing when event is true
Hi,
I have a mission where beam turrets are continuously firing on a target as a beam-fire SEXP.

I have this SEXP set to repeat and it works fine. My problem is when I want the turret to stop firing once an event becomes true.

The beam keeps firing because the repeat number is high, I’ve tried disabling the turret, beam-lock-all, everything.

As an alternative, what’s tthe easiest way of having an event repeat itself every x number of seconds until another event becomes true?

Any advise would be appreciated.

  
Re: Turret to stop firing when event is true
Use trigger instead of repeat, set that "number" to something super high (99999) and intervals to the rate of fire.
As condition, take (and (is event true delay x) not (is event true delay y)).

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: Turret to stop firing when event is true
Can't see if I haven't seen the event proper, but Nightmare is correct: You need limiting condition which is always a good idea with repeating events.

[attachment eaten by a Shivan]
« Last Edit: August 23, 2019, 01:33:46 am by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline wistler

  • 28
Re: Turret to stop firing when event is true
That's worked a treat, thanks guys.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Turret to stop firing when event is true
Use trigger instead of repeat

I'm wondering why that was needed. I can't see how it makes any difference in this case. The event 0rph3u5 posted for instance should work either way.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Turret to stop firing when event is true
If it is triggered (when the condition becomes true once) it will fire until the turret is destroyed when using repeat. Triggered looks each time whether the condition is still true.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Turret to stop firing when event is true
Nope, that's not actually true. The difference between Repeat Count and Trigger Count is a little more subtle than that.

Both will check if the event's trigger evaluates to true every time they fire. The difference is WHEN they check. Let's take 0rph3u5's event as an example. As the event will wait until triggered the first time. Then it will wait 30 seconds and check if the trigger evaluates to true. This occurs whether using a repeat or trigger count. The difference manifests if the event evaluates to false. With trigger count, the game will treat the event like every other event and evaluate it again every frame until it triggers again. With repeat count it will wait the interval count (i.e 30 seconds) and only then will it evaluate it again.

It is actually possible to use both together at the same time in fact.

There's a more detailed explanation here.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 
Re: Turret to stop firing when event is true
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".

Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.

 
Re: Turret to stop firing when event is true
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".

Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.
^This. I next to never encountered something where Repeat was doing any good.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Turret to stop firing when event is true
Kara you've explained this difference many times, and probably very well, but I gotta tell you, I have no ****ing idea what it is and cannot retain your explanations for more than a couple seconds. My brain just grunts 'trigger count good, repeat count bad'

e: Let me see if I can get it down

Repeat: do it, then keep doing it until the repeat delay is up, and then start evaluating again do it until it becomes false, then wait the repeat delay and check again; if still false, wait that delay again and check; ad infinitum when it becomes true, do it once, then wait the repeat delay and check whether to do it again; if not, wait the repeat delay and check; ad infinitum

Trigger: do it once, wait the trigger delay, and start evaluating every frame again
« Last Edit: August 29, 2019, 08:42:15 pm by General Battuta »

 

Offline wistler

  • 28
Re: Turret to stop firing when event is true
The mad thing about the repeat is that there was no stopping the turrets from firing, even locking the turrets and beam-lock-all doesn’t make a difference.

I can’t imagine repeat has many practical uses.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Turret to stop firing when event is true
tl;dr version : When in doubt, always use trigger count because "repeat count doesn't do what a lot of people think it does".

Over the years, I've met very, very few situations where repeat count both did what I wanted and couldn't be substituted with trigger count.

Yep. Repeat Count is the original Volition creation and once I discovered it doesn't work the way people thought it did, I coded up trigger count which does work that way. For the most part, the reason I didn't simply replace one with the other was because of backwards compatibility. I suspect I could have replaced one with the other without much of a change. They are virtually identical in most cases.

As you said, there are some rare cases (timer related for the most part) where you'd only want things to be tested every x seconds where repeat count would be better. For example, suppose you were doing a mission near a pulsar and you decided if the player didn't have enough shields the screen would white out or EMP for a second or two. Trigger Count would need a separate timer variable but you could simply tell Repeat Count to check the shield strength every 20 seconds.

But yes, there is nothing Repeat Count can do that Trigger Count + Variables can't.
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: Turret to stop firing when event is true
I finally understand. Once the event is false the game foolishly decides to wait the whole repeat interval to try again, unless you use trigger count, where it will check every frame, regardless.