With this trick you can extend the functionality of PrevStateno, so you can know which state was previous to the previous state (or any number of ChangeStates back to the past)The code is quite simple, and its applications are mainly used in the AI programming.[mcode];This goes inside state -1 or -2 ;(or -3 if you don't want to perform the check while in custom states)[State -n, 3 States back to the past]type = Varsettrigger1 = time=1var(2) = var(1)[State -n, State previous to the previous state]type = Varsettrigger1 = time=1var(1) = var(0)[State -n, Previous state]type = Varsettrigger1 = time=1var(0) = prevstateno[/mcode]You can also add more "iterations" by adding something like:[mcode][State -n]type = Varsettrigger1 = time=1var(x+1) = var(x)[/mcode]
You should know that this doesn't track all previous state numbers, only the one that Mugen itself tracks via prevStateNo. In any given tick a large number of states can be entered. I should probably do testing, but as each new state gets entered within the same tick, I'm unsure of how or if the negative states get checked to track the states not remarked by prevStateNo.
Didn't thought about that, but given the fact that we check time=1, rather than !time we are already missing the states that change when time=0.
Messatsu:On each tick, the negative states are processed, and then the regular states. There's no going back from the latter to the former within a tick. Well, unless you count using KeyCtrl or Player-type helpers.And yes, PrevStateNo gets updated with each state transition within a tick. So if, in a single tick, you go from State 0 to 1 to 2, and then check the value of PrevStateNo, it'll return 1, not 0 (the previous tick's final StateNo).Anyway, another alternative to Renzo's code, if you don't want to have the "time=1" limitation, and if you want to ignore transitions from one state back into itself, would be the following (completely untested) code:[mcode][State -n, PrevPrevPrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(2) = var(1)IgnoreHitPause = 1[State -n, PrevPrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(1) = var(0)IgnoreHitPause = 1[State -n, PrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(0) = PrevStateNoIgnoreHitPause = 1[/mcode]
Something I just noticed is that prevstateno won't record state 0 as the last state or doesn't appear to after a fight has started at least. In my Cody character, it'll go 500, 0, and then to 505. It can only reach 505 if 500 was the prevstateno.
What? Either I don't understand what you mean, or I've encountered no such problems in my latest mangled KFM.
Winane: Might be worth taking into account if you haven't already, but certain triggers seem unable to function on time = 0 in the minus states and will always return false in such instances...IIRC that includes PrevStateNo.
I remember detecting state 0 as one of the previous states in in at least two character's AI code.I tested it and works perfectly.
[mcode][State -n, PrevPrevPrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(2) = var(1) [State -n, PrevPrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(1) = var(0) [State -n, PrevStateNo]type = Varsettrigger1 = PrevStateNo != var(0)trigger1 = PrevStateNo != StateNovar(0) = PrevStateNo[/mcode]This code was indeed completely untested. Well, I've tested it and it works partially. PrevStateNo works like clock. PrevPrevStateNo doesn't work for all crouching and standing attacks. It displays all aerial states oerfectly though ??? PrevPrevPrevStateNo works even less.
Works fine for me. ??? I've added "IgnoreHitPause = 1" to each VarSet just now, to be safer, though.Are you sure you don't have any overlapping variables?KFM:Good point, thanks, I should've mentioned that. (I wouldn't say they "return false", though.)For anyone wondering what KFM's referring to, there's some more details in this thread at RS:http://randomselect.piiym.net/forum/index.php?topic=1162.0