YesNoOk
avatar

Trigger Persistency (CNS) (Read 1591 times)

Started by Ricepigeon, September 30, 2015, 08:01:23 pm
Share this topic:
Trigger Persistency (CNS)
#1  September 30, 2015, 08:01:23 pm
  • *****
  • Gaps? Where we're going, we don't need gaps...
    • USA
    • ricepigeon.neocities.org
In the case where you do not want the trigger to activate every single time the condition is true, you will need to add a persistent parameter. Let us begin with an example:

Code:
[State 310, 1]
type = PosAdd
trigger1 = Vel Y > 1
x = 10

This state controller moves P1 forwards by 10 pixels for every tick of game time where P1's y-velocity is greater than 1. That is, the controller is being activated everytime the trigger condition is true. If we want the controller to be activated only once, we will need to add a line:

Code:
[State 310, 1]
type = PosAdd
trigger1 = Vel Y > 1
persistent = 0       ;<-- Added this line
x = 10

persistent has a default value of 1, meaning that the controller is activated everytime the trigger is true. Setting persistent to 0 allows the controller to be activated only once during that state. This holds true until P1 leaves that state. If P1 returns to that state later, the controller can be activated once again.

The persistent parameter can also take values other than 0 and 1:

Code:
[State 310, 1]
type = PosAdd
trigger1 = Vel Y > 1
persistent = 2       ;<-- Modified this line
x = 10

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.

Additional Notes:
To better illustrate the effects of persistency with values greater than 1, consider the following two statements;

Code:
[State 200, PSND]
type = playsnd
trigger1 = time%2 = 0
value = 40,0

[State 200, PSND]
trigger1 = 1
persistent = 2
value = 40,0

The above state controllers are both equivalent to each other. This can be useful for effects that you want to occur in specific intervals after a certain time, but do not want to do unnecessary calculations with the time trigger.

Another practical application for persistency is when you want an effect to trigger the moment a move makes contact with the opponent, without waiting for hitpause to end. Consider the following state controller:

Code:
[State 2000, Explod]
type = explod
trigger1 = movehit = 1
...
ignorehitpause = 1

The problem with the above is that with ignorehitpause=1, movehit=1 will return true as long as Player1 is affected by hitpause, causing the explod to appear multiple times, yet setting ignorehitpause to 0 will cause the explod to appear only after Player1's hitpause is over. Adding persistent=0 will ensure that the explod only appears once. This is useful if you wish to use Explods as hitsparks instead of Mugen's default hitspark system.
Re: Trigger Persistency (CNS)
#2  September 30, 2015, 08:07:32 pm
  • ******
    • www.justnopoint.com/
Quote
The problem with the above is that with ignorehitpause=1, movehit=1 will return true as long as Player1 is affected by hitpause, causing the explod to appear multiple times, yet setting ignorehitpause to 0 will cause the explod to appear only after Player1's hitpause is over. Adding persistent=0 will ensure that the explod only appears once. This is useful if you wish to use Explods as hitsparks instead of Mugen's default hitspark system.
Oh thank you!
I was having this issue with Ryu and no one could seem to help me so I went back to using the default hitspark system.
Re: Trigger Persistency (CNS)
#3  September 30, 2015, 08:17:00 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Also worth mentioning:

The "persistent" parameter has no effect in States -1, -2, and -3

Re: Trigger Persistency (CNS)
#4  October 01, 2015, 10:04:21 am
  • *****
  • Shame on you!
    • USA
Additional Notes:
To better illustrate the effects of persistency with values greater than 1, consider the following two statements;

Code:
[State 200, PSND]
type = playsnd
trigger1 = time%2 = 0
value = 40,0

[State 200, PSND]
trigger1 = 1
persistent = 2
value = 40,0

The above state controllers are both equivalent to each other. This can be useful for effects that you want to occur in specific intervals after a certain time, but do not want to do unnecessary calculations with the time trigger.

I dont think they're exactly the same.
trigger1= 1 will activate on the very first tic. Persistent 2 will make it activate every other tic. 1,3,5.... on and on will be active
trigger1 = time%2 = 0 will activate the first time when the time = 2. It will only activate on even numbers. 2,4,6.... on and on.
In order for them to be the same wouldnt you need a triggerall = time >=2 in the second group?
vVv Wheat Stage Released vVv
Re: Trigger Persistency (CNS)
#5  October 01, 2015, 06:41:15 pm
  • **
    • Brazil
    • thundermugen.com/
Additional Notes:
To better illustrate the effects of persistency with values greater than 1, consider the following two statements;

Code:
[State 200, PSND]
type = playsnd
trigger1 = time%2 = 0
value = 40,0

[State 200, PSND]
trigger1 = 1
persistent = 2
value = 40,0

The above state controllers are both equivalent to each other. This can be useful for effects that you want to occur in specific intervals after a certain time, but do not want to do unnecessary calculations with the time trigger.

I dont think they're exactly the same.
trigger1= 1 will activate on the very first tic. Persistent 2 will make it activate every other tic. 1,3,5.... on and on will be active
trigger1 = time%2 = 0 will activate the first time when the time = 2. It will only activate on even numbers. 2,4,6.... on and on.
In order for them to be the same wouldnt you need a triggerall = time >=2 in the second group?

I think they are the same because Time can be 0
So, trigger1 = 1 with persistent = 2 will make it activate every other tic, but starting at 0, insteade of 1, making it activate when time = 0, 2, 4...
trigger1 =time%2 = 0 will activate when time = 0, 2, 4...
Re: Trigger Persistency (CNS)
New #6  October 01, 2015, 10:47:14 pm
  • *****
  • Shame on you!
    • USA
hhmmm, I see your point. I always thought trigger1 = 1 triggered at time = 1. 
I might try to set up a little test and report back what I find.

----

[State 0, ChangeAnim]
type = ChangeAnim
triggerall = time <= 0
trigger1 = 1
value = 0

This does trigger the anim change. How many years have I been wrong lol. I guess in the long run it barely even matters.
vVv Wheat Stage Released vVv
Last Edit: October 01, 2015, 10:59:18 pm by Odb718