YesNoOk
avatar

Infinite state change loop when fighting a character's AI. (Read 2730 times)

Started by Funky Fresh Fellow, March 16, 2020, 10:03:20 pm
Share this topic:
Infinite state change loop when fighting a character's AI.
#1  March 16, 2020, 10:03:20 pm
    • USA
I've been having trouble finding the issue in a character I downloaded. The character in question is a 1.0 conversion of Ken Amada & Koromaru from P4A, and the crash only occurs under some pretty specific conditions (but maybe it can happen in other cases as well). When I use a 1.0 conversion of Margaret from P4A, and I use her Ardha grab move on an AI Ken while Koromaru is out, the game gets an infinite state change loop error. The Ken does not have any custom AI from what I know. As for code, I'll just post the state in question that seems to cause the problem according to MUGEN.
Spoiler, click to toggle visibilty

It's a very big state with many different states that it can go to, so I've had a lot of trouble figuring out where to start. I can always post more code from other states, as well as Margaret's code if that helps too. Hopefully it won't be a very difficult error to fix, but I doubt it will be a major issue if a solution can't be found.
Last Edit: March 24, 2020, 07:25:53 am by Odb718
Re: Infinite state change loop when fighting a character's AI.
#2  March 19, 2020, 06:03:22 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
It says stuck in infinite loop in state 4000? Find a changestate that puts it into 4000. I can't see anything in that precise state thatll loop it.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Infinite state change loop when fighting a character's AI.
#3  March 22, 2020, 02:51:52 am
    • USA
Alright, there are quite a few changestates that go to 4000, so I'll just post the parts that are changestates so that there aren't a bunch of chunks of code. I'm also excluding changestates that are from special moves and such, since those most likely aren't the culprits as the AI isn't using those moves when it crashes. I'll also mention that this applies to a helper that's often active, so they work seperately from the actual character.

This is from the state that stops the helper's walk.
Code:
[State 0, ChangeState]
type = ChangeState
trigger1 = AnimTime = 0
value = 4000

This is from the state that makes the helper get up after being hurt, though it's identical to the previous statechange.
Code:
[State 0, ChangeState]
type = ChangeState
trigger1 = AnimTime = 0
value = 4000

This one's interesting, since I have no clue what it does. It's in the -2 states though, so maybe it's important since it's probably always active. It also tells us that the helper's ID is 300, so that can help.
Code:
[State 4000, Koromaru]
type = Helper
trigger1 = !numhelper(300)
helpertype = normal
stateno = 4000
ID = 300
name = "Koromaru"
postype = p1
pos = -100,0

I figure I should give the code for Margaret's move that causes the crash as well, since what it does is probably important considering that other moves that grab Ken don't seem to have the same issue.
Code:
;Ardha
[StateDef 306]
type = S
movetype = A
physics = N
velset = 0,0
facep2 = 1
ctrl = 0
anim = 312
sprpriority = 0

[State 0, AttackDist]
type = AttackDist
trigger1 = 1
value = 0

[State 0, PlayerPush]
type = PlayerPush
trigger1 = Time < 30
value = 1

[State 0]
type = AfterImage
trigger1 = Time = 0
time = 30
length = 7
palcontrast = 126,126,126
paladd = 256,0,0
palmul = 60,0,0
timegap = 1
framegap = 3
trans = add

[State 0, ParentVarSet]
type = ParentVarSet
trigger1 = Time = 0
var(2) = 1

;Damaged
[State 200, 7];Margaret's Hit
type = ChangeState
TriggerAll = (Parent,Stateno != [150,155])
trigger1 = Parent,MoveType = H
value = 1501
ignorehitpause = 1
[State 0, ReversalDef]
type = ReversalDef
trigger1 = Time < 31
reversal.attr = SCA,NA,SA,HA,NP,SP,HP
pausetime = 3,8
sparkno = S4005
sparkxy = 10,-60
hitsound = S3,0
[State 3504];Ardha's Hit
type = HitOverride
trigger1 = Time >= 31
attr = SCA,NA,SA,HA,NP,SP,HP
time = 1
stateno = 1501
ignorehitpause = 1
[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = ,NT,ST,HT
time = 1

[State 0, Trans]
type = Trans
TriggerAll = !PrevStateNo
trigger1 = Time < 13
trans = addalpha
alpha = 10+20*(time-1),240-20*(time-1)

[State 0, PlaySnd]
type = PlaySnd
trigger1 = Time = 22
value = S6,15

[State 0, PosAdd]
type = PosAdd
trigger1 = Time < 31
x = 2.5

[State 800,HitDef]
type = HitDef
trigger1 = AnimElem = 11
attr = S, NT
hitflag = M
priority = 1,hit
damage = 0
getpower = 0
givepower = 0,0
pausetime = 0,0
sparkno = -1
sparkxy = -10,-40
hitsound = s2,11
p1stateno = 307
p2stateno = 308
id = 305
guard.dist = 0
palfx.time = ifelse(var(56)=1,11,0)
palfx.add = 256,0,0
palfx.mul = 185,40,10
palfx.sinadd = 150,150,150,13
palfx.invertall = 0
palfx.color = 256
envshake.time = ifelse(var(56)=1,13,0)
envshake.freq = 80
envshake.ampl = -3
[State 0, PlaySnd]
type = PlaySnd
TriggerAll = Root,Var(56) = 1
trigger1 = MoveHit
value = S9999,4
ignorehitpause = 1
persistent = 0

[State 3603, end]
type = ChangeState
trigger1 =!(Parent,StateNo=305||Parent,StateNo=402||Parent,StateNo=404||Parent,StateNo=505)
trigger1 = Time >= 79
trigger2 = (Parent,StateNo=502||Parent,StateNo=1015||Parent,StateNo=1018||Parent,StateNo=1019||Parent,StateNo=1020||Parent,StateNo=1022||Parent,StateNo=1023||Parent,StateNo=2000||Parent,StateNo=2005||Parent,StateNo=2006||Parent,StateNo=2007||Parent,StateNo=2008||Parent,StateNo=2009||Parent,StateNo=2010||Parent,StateNo=2012||Parent,StateNo=2013||Parent,StateNo=6002)
value = 1500

;Catch
[StateDef 307]
type = S
movetype = A
physics = N
ctrl = 0

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 0, Explod]
type = Explod
trigger1 = Time = 0
pos = 66,-129
anim = 808
scale = .335,.335
postype = p1
bindtime = -1
sprpriority = 90
ownpal = 1
supermovetime = 999

[State 0, TargetBind]
type = TargetBind
trigger1 = Time < 43
time = 1
pos = 66,-129

[State 0, PlaySnd]
type = PlaySnd
trigger1 = Time = 18
value = S6,16
[State 0, Explod]
type = Explod
trigger1 = Time = 18
anim = 314
pos = -14,-171
scale = .335,.335
postype = p1
sprpriority = 2
ownpal = 1
removetime = 20
[State 0, Explod]
type = Explod
trigger1 = Time = 18
trigger2 = Time = 20
anim = 8100
angle = random
pos = -14,-171
random = 20,20
scale = .275,.275
postype = p1
sprpriority = 3
ownpal = 1
[State 2000, Helper]
type = Helper
trigger1 = Time = 18
pos = -14,-171
postype = P1
ID = 306
stateno = 3013
helpertype = normal
name = "Scatter FX"
keyctrl = 0
ownpal = 1
pausemovetime = 9999
supermovetime = 9999
[State 0, Explod]
type = Explod
TriggerAll = Time = [18,37]
trigger1 = Time%4 = 0
anim = 8102
pos = -14,-171
random = 15,15
vel = 0,-2
accel = 0,.125
scale = .335,.335
postype = p1
sprpriority = 3
ownpal = 1

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = Time = 38
value = 313

[State 0, PlaySnd]
type = PlaySnd
trigger1 = Time = 38
value = S6,17

[State 0, PosAdd]
type = PosAdd
trigger1 = Time = [38,42]
x = 3

[State 200, 1]
type = HitDef
trigger1 = AnimElem = 2
attr = S, NT
damage = 140*ifelse(Var(56)=1,1.1,1),58
animtype = Back
air.animtype = Back
guardflag =
hitflag = MAFD
priority = 8, Hit
pausetime = 12,13
getpower = 560*fvar(7)
givepower = 112
sparkno = s4033
sparkxy = -10, -120
hitsound = s2,12
guardsound = S3,0
ground.type = Low
ground.slidetime = 17*ifelse(Var(56)=1,1.4,1)+Ifelse(EnemyNear,StateType=C,2,0)
ground.hittime  = 17*ifelse(Var(56)=1,1.4,1)+Ifelse(EnemyNear,StateType=C,2,0)
ground.velocity = -7,-5
air.velocity     = -7,-5
fall = 1
fall.recover = 0
ground.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
air.cornerpush.veloff = 0
yaccel = .6
id = 305
down.bounce = 1
p2facing = 1
palfx.time = 52
palfx.add = 240,30,0
palfx.mul = 250,224,0
palfx.sinadd = 210,155,185,10
palfx.invertall = 1
palfx.color = 0
snap = 66,-30
envshake.time = ifelse(var(56)=1,13,0)
envshake.freq = 80
envshake.ampl = -3

[State 0, Helper]
type = Helper
trigger1 = MoveHit && NumTarget
helpertype = normal
name = "Ouch Hot"
ID = 2010
postype = p2
stateno = 8100
persistent = 0
ignorehitpause = 1

[State 3603, end]
type = ChangeState
trigger1 =!(Parent,StateNo=305||Parent,StateNo=402||Parent,StateNo=404||Parent,StateNo=505)
trigger1 = Time >= 82
trigger2 = (Parent,StateNo=502||Parent,StateNo=1015||Parent,StateNo=1018||Parent,StateNo=1019||Parent,StateNo=1020||Parent,StateNo=1022||Parent,StateNo=1023||Parent,StateNo=2000||Parent,StateNo=2005||Parent,StateNo=2006||Parent,StateNo=2007||Parent,StateNo=2008||Parent,StateNo=2009||Parent,StateNo=2010||Parent,StateNo=2012||Parent,StateNo=2013||Parent,StateNo=6002)
value = 1500

; P2 State
[Statedef 308]
type    = A
movetype= H
physics = N
velset = 0,0
sprpriority = 0

[State 0, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 0
movecamera = 1,0

[State 820, 1]
type = ChangeAnim2
trigger1 = !SelfAnimExist(80056)
value = 806
[State 820, 1]
type = ChangeAnim
trigger1 = SelfAnimExist(80056)
value = 80056

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = ,NA,SA,HA,NP,SP,HP,ST,HT
time = 1

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State ]
type = SelfState
trigger1 = Time > 60
value = 5050

If there's something in here that you'd like more code for, feel free to ask.
Re: Infinite state change loop when fighting a character's AI.
#4  March 22, 2020, 11:46:07 am
  • *****
  • Shame on you!
    • USA
I figure State 4000 is the Helper's standing/idle state?
I'm not seeing anything in her state that should cause a loop.
You may just need to edit 
anim = ifelse(Root,StateNo=191&&Root,Time=0,99999,3500)
to
anim = 3500
and create a change anim to be

triggerall = time = 0
trigger1 = (Root,StateNo=191) && (Root,Time=0)
vlue = 99999
 
vVv Ryuko718 Updated 10/31/22 vVv
Last Edit: March 22, 2020, 11:49:27 am by Odb718
Re: Infinite state change loop when fighting a character's AI.
#5  March 24, 2020, 06:04:40 am
    • USA
Yeah, State 4000 is the helper's idle state. I tried using what you suggested, but it unfortunately didn't work.
Re: Infinite state change loop when fighting a character's AI.
#6  March 24, 2020, 07:35:21 am
  • *****
  • Shame on you!
    • USA
Did it make any difference?

Try adding,
triggerall = time%3 = 0 
to
[State 4000, Koromaru]
type = Helper
trigger1 = !numhelper(300)
helpertype = normal

I don't think that'll be it, but a slight possibility.
It could be in your hit reaction states. But if it's caught in a loop it's usually that state that's the cause.

One thing I could imagine is since P2 is attacking you, it could be the state P1 is in is conflicting with all of your changestates.
triggerall = ROOT, movetype != H
Add that to your changestates. Unless you can imagine a situation where you'd want that to happen??
vVv Ryuko718 Updated 10/31/22 vVv
Re: Infinite state change loop when fighting a character's AI.
#7  April 06, 2020, 08:17:52 pm
    • USA
Hey, it actually seems to work! Probably because that's the movetype of the grab. I'll just keep it and hope that it doesn't mess anything else up then. Thanks for the help!
Re: Infinite state change loop when fighting a character's AI.
#8  April 07, 2020, 08:03:20 am
  • *****
  • Shame on you!
    • USA
Ok so if the Time % is what worked, it seems it could be an order issue.
I think if you reorder the states that should help it out also. Mugen goes down the list of states and reads what's active. Then if something deactivates it it gets deactivated. Then if there's a spawn that happens even lower, well there's your loop.

You might want to add IsHelper checks to some of your states also.
vVv Ryuko718 Updated 10/31/22 vVv