News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

CODING: Confuse on purpose of Persistent

Started by Redash, February 20, 2018, 10:46:45 AM

Previous topic - Next topic

Redash

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

Fausto Mugen


JustNoPoint

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!

Odb718

Quote from: Just No Point on February 20, 2018, 02:26:58 PMIt 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 Gouken718 vVv SabreTooth718 vVv


Redash

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?

Odb718

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 Gouken718 vVv SabreTooth718 vVv


Redash

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 :^)