YesNoOk
avatar

Anyone know how to make a timer for a system for your char? (Read 4184 times)

Started by Fluttershy555, November 15, 2017, 11:56:00 pm
Share this topic:
Anyone know how to make a timer for a system for your char?
#1  November 15, 2017, 11:56:00 pm
  • avatar
  • *
    • USA
I made a character and what i mean is for example in KOF you have max mode for a limit of time. How do you do that on something like mugen? I am not really making max mode but i have a supermove where my char goes into that stance and fights different but i want it for a limited time but if i try making a timer like selfstate, but when she starts walking the timer resets. I even tried a varable but dont know the right code to do this so when i tried doing the timer in a varable in statedef -2 it still resets when i move but was buggy. Instead of being in the super coming out i was out of the super and when time ran out I went into the super. I alwaysed wanted to do something like this. I dont know the code to do a timer like this where even though i move it doesn't reset and it will go out eventually. Anyone know how to do this? :/
Re: Anyone know how to make a timer for a system for your char?
#2  November 16, 2017, 06:25:41 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
type = VarSet
trigger1 = time = 0
var(59) = GameTime


trigger1 = GameTime = var(59) + 1000

(1000 ticks have elapsed)

Re: Anyone know how to make a timer for a system for your char?
#3  November 16, 2017, 02:10:07 pm
  • avatar
  • *
    • USA
It didnt work. I put the varset in [statedef -2] So i think i did it wrong, here is what i put.
[State 0, VarSet]
type = VarSet
trigger1 = time = 0
trigger1 = gametime = var(59) + 1000
Var(59) = gametime
value = 0

I have to put value 0 or any number or it will crash. Here is my code for when i have her in the super.

[Statedef 445]
type = S
movetype = A
physics = S
ctrl = 0
anim = 445
velset = 0,0

[State 445, Turn]
type = Turn
trigger1 = p2dist X < Const720p(-20)
trigger1 = animelem = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "holdfwd"
value = 446
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "holdback"
value = 447
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "x"
value = 448
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "y"
triggerall = P2StateType != A
trigger1 = p2stateno != 49999
value = 449
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "skick1"
value = 4450
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "holdup"
value = 4452
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "upfwd"
value = 4454
ctrl = 1

[State 0, SelfState]
type = SelfState
trigger1 = var(59)
value = 4456
;---------------------------------------------------------------------------
[Statedef 446]
type    = S
physics = S
sprpriority = 0
ctrl = 0

[State 445, Turn]
type = Turn
trigger1 = p2dist X < Const720p(-20)
trigger1 = animelem = 1

[State 446, ChangeState]
type = ChangeState
trigger1 = animtime = 0
value = 445
ctrl = 1

[State 446, VelSet]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 446 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 446

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "x"
value = 448
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "y"
triggerall = P2StateType != A
trigger1 = p2stateno != 49999
value = 449
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "skick1"
value = 4450
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "holdup"
value = 4452
ctrl = 1
;---------------------------------------------------------------------------
[Statedef 447]
type    = S
physics = S
sprpriority = 0
ctrl = 0

[State 445, Turn]
type = Turn
trigger1 = p2dist X < Const720p(-20)
trigger1 = animelem = 1

[State 447, ChangeState]
type = ChangeState
trigger1 = animtime = 0
value = 445
ctrl = 1

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 447 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 447

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "x"
value = 448
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "y"
triggerall = P2StateType != A
trigger1 = p2stateno != 49999
value = 449
ctrl = 1

[State 445, ChangeState]
type = ChangeState
trigger1 = command = "skick1"
value = 4450
ctrl = 1

Code is really long so i wont paste the other movements but she is basic so she is pretty much done because i got the
attacks and stuff, this is just her stand and movements i pasted here. But no matter what still no timer.
Did i put the varset wrong? I have a feeling i guess maybe i dont need a selfstate? It just has no timer now.
Re: Anyone know how to make a timer for a system for your char?
#4  November 16, 2017, 03:21:52 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
That's not what I meant :)

For sake of example, let's say you want the timer to begin when you enter state 445.  Well, in this case you should really just use the VarSet controller in State 445... but if you insist on State -2 it should look like this:

[State -2, VarSet]
type = VarSet
trigger1 = StateNo = 445
trigger1 = Time = 0
Var(59) = gametime

If you want things to happen when the timer reaches 1000 you use this trigger

trigger1 = GameTime = var(59) + 1000


So, if you want to ChangeState when the timer reaches 1000, you would use this:

[State -2, ChangeState]
type = ChangeState
trigger1 = GameTime = var(59) + 1000
value = 4454
ctrl = 1

Re: Anyone know how to make a timer for a system for your char?
#5  November 16, 2017, 04:33:45 pm
  • avatar
  • *
    • USA
I tried it and it still resets timer. So i guess i did it wrong. I put this in -2
[State 0, VarSet]
type = VarSet
trigger1 = stateno = 445
trigger1 = time = 0
Var(59) = gametime
value = 0


[State 0, ChangeState]
type = ChangeState
trigger1 = gametime = var(59) + 1000
value = 4456
ctrl = 1

She will switch back if i sit there but when i move around it still resets. Is there something i should code in the state
of 445? Because i have the movements where i have holdfwd and she will go into the state of 446 and walk forward. And after it resets timer the timer stops and wont work anymore.
Re: Anyone know how to make a timer for a system for your char?
#6  November 16, 2017, 07:16:53 pm
  • ***
  • More blood and gore please.
    • USA
    • johncrystal00@embarqmail.com
Yes he said put this:

[State -2, VarSet]
type = VarSet
trigger1 = StateNo = 445
trigger1 = Time = 0
Var(59) = gametime

in statedef 445 not in statedef -2. Put this:

[State 0, ChangeState]
type = ChangeState
trigger1 = gametime = var(59) + 1000
value = 4456
ctrl = 1

in statedef -2.
Re: Anyone know how to make a timer for a system for your char?
#7  November 16, 2017, 07:39:45 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Err I think I know what's happening.  If your character goes into and out of State 445, it the VarSet triggers again and resets the timer.

So the timer must only be triggered one time, when performing the Super move.

Set the Var like this instead: In the Commands (State -1), where you activate the Super, set the Var(59) there so it occurs simultaneously as the move is being performed.

Here's an example of how that can be done, using a move from my Jailbot character

Spoiler: In State -1 (click to see content)

So, you want to add this as a trigger, at the end of each trigger chain (trigger1, trigger2, etc)
triggerX = var(59) := GameTime

The var will be set as the code is evaluated.


The ChangeState controller will work in State -2 as is, but that trigger will work in any state. (checking GameTime against Var(59) + GameTime)

Re: Anyone know how to make a timer for a system for your char?
New #8  November 21, 2017, 09:12:08 pm
  • avatar
  • *
    • USA
I might give up on it. :/ Its way too hard i dont know what i am doing wrong but when i put it like this

[State -1, magic show]
type = ChangeState
value = 444
triggerall = command = "magic show"
triggerall = !var(59)
trigger1 = (statetype = s) && ctrl
trigger2 = (hitdefattr = SC, NA, SA) && movecontact
trigger2 = var(59) = gametime

It still does not work. :( I also have the varset in my 445 state which is the start of the animation because 444 goes
into that state because 444 just starts it and i have it like this.
[State 0, VarSet]
type = VarSet
trigger1 = stateno = 445
trigger1 = time = 0
Var(59) = gametime
value = 0
and i have the changestate in the statedef -2 and it doesnt work right. When i am not into it after the time runs out it puts me in the
super then back out then the timer doesnt work ever again. It just doesn't work at all. Its really hard. I dont know
why it isn't working. :/
[State 0, ChangeState]
type = ChangeState
trigger1 = gametime = var(59) + 1000
value = 4456
ctrl = 1
Oh and sorry it took so long for me to reply. Honestly i got no notifications XD I thought everyone just forgot about this. XD Then i decided to check and turns out i did get replies. But anyway i dont know what i am doing wrong. Nothing i do works. The timer either doesn't work or it just is glitchy like what i just mentioned about the whole puts me in the super thing.


     Posted: November 22, 2017, 01:46:39 am
I wont give up on it. It works great. Just need to make the timer work properly and make it where when she gets hit she dont go back to her original hit state out of super. I have a hit animation for her when she is in her super. It looks good. But she is going great. So i will still try to get the timer working.
Last Edit: November 22, 2017, 01:46:39 am by Fluttershy555