YesNoOk
avatar

CODING: Confuse on purpose of Persistent (Read 4558 times)

Started by Redash, February 20, 2018, 10:46:45 am
Share this topic:
CODING: Confuse on purpose of Persistent
#1  February 20, 2018, 10:46:45 am
  • avatar
  • **
    • Singapore
Hi i notice all scrtl has ignorehitpause and persistent.

After reading the docs and testing them on various sctrl, i understood how ignorehitpause works, but i still do not understand the purpose of persistent, it seems to make no difference regardless of value 1 or 0.

Tried it on sctrl: changestate, hitdef, posadd, velset, velmul, changeanim, changeanim2, targetstate, selfstate

Need veterans advices on "persistent" application
Last Edit: March 01, 2018, 01:50:52 pm by Redash
Re: CODING: Confuse on purpose of Persistent
#2  February 20, 2018, 12:55:32 pm
  • **
  • I got tired of waiting for someone to do it for me
    • Argentina
Re: CODING: Confuse on purpose of Persistent
#3  February 20, 2018, 02:26:58 pm
  • ******
    • www.justnopoint.com/
It can be any number. If 0 everything triggers only one time. If 1 everything triggers over and over per tick. 2 would make it trigger every 2 ticks. 48 would make it trigger every 48th tick!
Re: CODING: Confuse on purpose of Persistent
#4  February 21, 2018, 07:14:04 am
  • *****
  • Shame on you!
    • USA
It can be any number. If 0 everything triggers only one time. If 1 everything triggers over and over per tick. 2 would make it trigger every 2 ticks. 48 would make it trigger every 48th tick!
Not exactly. There are a ton of instances where what would activate the first go around may change however many tics later.


"In this case, setting persistent to 2 means the controller will be activated once of every two times the trigger is true. Setting persistent to 3 activates the controller every 3rd time, and so on."
Think of a Yo-Yo, and you want an explod to happen every 5th time it reached the bottom. Instead of wasting a variable you could just set it to 5. except that it'll activate the first time it reached the bottom.... Not the best example...

It's basically a way of counting each time the triggers would work. Just No Point is correct if the triggers fire off every tic, but if something changes back and forth, it wont count the tics. Just the times the triggers would have activated.
vVv Ryuko718 Updated 10/31/22 vVv
Re: CODING: Confuse on purpose of Persistent
#5  February 24, 2018, 12:52:37 pm
  • avatar
  • **
    • Singapore
Thanks for above my understanding had improved.

1 thing: i dun understand
"something changes back and forth, it wont count the tics. "

Can elborate further?
Re: CODING: Confuse on purpose of Persistent
#6  February 25, 2018, 09:30:48 am
  • *****
  • Shame on you!
    • USA
So the game works on tics. 60 tics a second.  Each tic the entire statedef is read from top to bottom, and each active state works top to bottom.

This is just an example of what I mean. There are countless ways this could be different and still be a similar idea, but
If you make say a helper, and it can move around. If you have an explod that activates in the helper when it gets close to P2, but persistent = 5, The explod will show up the first time the helper gets close to P2, and the 6th time.
But say you have it set up where the helper goes to P2 and locks on. Now, because the game reads the state 60 times a second and persistent = 5, the explod will show up 12 times. Because 60/5=12.

So the second way, Just No Point is correct, but if the helper moves out of the distance the trigger needs to work, it wont count for those particular tics of the game. If the helper goes back and forth it wont count the tics, only the amount of times it got close to P2.

But just to clarify something. Each tic of the game the helper is close will count in the persistent. It'd be extremely unlikely that the helper would get within the body distance for EXACTLY 1 tic and move out of the distance so the next tic didn't register for the explod. Each tic that the helper is close to P2 WILL count to the persistent. So if the helper got close to P2 for say 17 tics, the explod would fire off 4 times. tics 1, 6, 11, 16. Even though it looks like the helper got close to P2 just 1 time, the game counted it as 17 times. If the helper moved away for say 182 tics, and got close to P2 for 23 more tics, the explod would show up only 4 times. Because the game counted that tic 17 towards the persistent. At tics 21, 26, 31, & 36 the explod would activate. Even though 23 is 6 more tics than 17, you'd still only get 4 explods.
vVv Ryuko718 Updated 10/31/22 vVv
Re: CODING: Confuse on purpose of Persistent
#7  March 01, 2018, 01:50:43 pm
  • avatar
  • **
    • Singapore
Ah thanks much Odb718. After re-reading yr post twice and some code testing i get what u mean. Interesting concept. Learnt something mew again :^)