News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Button Mash Throw.

Started by BC, March 31, 2009, 02:41:57 PM

Previous topic - Next topic

BC

ive looked at a few examples of how its done, but when it comes to variables i suck lol.

im coding zangiefs biting throw which bites at a steady rate but if you bash a punch button or whatever it bites faster and generates more hits... coding throws themselves are a peice of piss to me anyway, but using variables seems unnecessarily problematic for me.


anyway i attempted the button bash bit but i failed horribly lol.

;hitdef for the throw
[Statedef 830]
type = S
movetype= A
physics = S
juggle = 0
velset = 0,0
ctrl = 0
anim = 800

[State 800, 1]
type = HitDef
Trigger1 = Time = 0
attr = S, NT
hitflag = M
priority = 1, Miss
sparkno = -1
sprpriority = 1
p1facing = ifelse (command = "holdfwd", 1, -1)
p2facing = 1
p1stateno = 840
p2stateno = 849
fall = 1
fall.recover = 0

[State 800, 2]
type = ChangeState
Trigger1 = AnimTime = 0
value = 0
ctrl = 1


;now p1 state grabbing p2 and bringing him in close(2 frames)
[Statedef 840]
type = S
movetype= A
physics = N
anim = 830

[State 0, TargetBind]
type = TargetBind
trigger1 = animelem = 1
time = 10
pos = 55,0

[State 0, TargetBind]
type = TargetBind
trigger1 = animelem = 2
time = 6
pos = 47,0

[State 0, ChangeState]
type = ChangeState
trigger1 = animtime = 0
value = 845
ctrl = 0

;biting state
[Statedef 845]
type = S
movetype= A
physics = N

[State 820] ;setting a variable to 0
type=VarSet
trigger1=time=0
var(7)=0
ignorehitpause=1

[State 820]
type=VarAdd
trigger1=command="rapid punch" ;set as x
var(7)=1 ;set the variable to 1 if the condition above is met
ignorehitpause=1
persistent=0

[State 0, TargetBind]
type = TargetBind
trigger1 = animelemtime(1)>=0
time = 1
pos = 47,0

[State 0, TargetState]
type = TargetState
triggerall = anim = 835
trigger1 = animelemtime(3) = 1
value = 850 ;p2 has 1 frame per anim(this is getting bit)

[State 0, TargetState]
type = TargetState
triggerall = anim = 835
trigger1 = animelemtime(4) = 1
value = 855 ;this is recovering from getting bit.

[State 0, TargetLifeAdd]
type = TargetLifeAdd
trigger1 = animelem = 5
value = -1
kill = 1

[State 845, biting]
type = ChangeAnim
trigger1 = Time = 0
value = 835

[State 820, State End]
type = ChangeState
trigger1=animelemtime(4)>18 ;ok so because frame 4 has -1 time... above 18 gameticks seemed like a
;decent default time to change back to the next bite again
trigger2=var(7)=1 ;this just causes an infinite changestate loop...even if i put persistent = 0
value=845


so yea you prob can tell i suck with variables... but everything else is fine(biting part) just i cant bash buttons to changestate faster.   --;

i have seen how its done but all the variables < blah or >=blah confuse me.



p.s the throw is obviously incomplete like releasing p2 ect but i just wanna nail this bit before i finish the throw.
the damage was set to 1 just for testing purposes.
Accepting commissions

Bastard Mami

Actually, the best way is to code without using variables, for compatibility sake, I think.

Just use several states for the mashing, p1 mashing and p2 mashing.

BC

ok, well i need practice with variables anyway so if this dont work out ill try the alternate way

[State 0, VarSet]
type = VarSet
trigger1 = prevstateno!=845
v = 8
value = 0

[State 0, VarAdd]
type = VarAdd
trigger1 = prevstateno = 845 && !time
v = 8
value = 1


[State 820, State End]
type = ChangeState
trigger1=animelemtime(4)>8
trigger2=var(7)=1 ;why does this causes an infinite loop, because the first trigger works fine going back into the same state
value=845
;persistent = 0 doesnt work for the loop bug

[State 820, State End]
type = ChangeState
trigger1=var( 8 )>=8
value=880 ;end throw state.

2 changestates.... first hasnt changed from the last post....... 2nd one limits the throw to 8 bites.(thanks anjel)

var(7)=1 is when "x" is pressed.... but this causes an infinite changestate loop....

the whole move works can someone just help me with the pressing buttons to speed up the move help.
Accepting commissions

Fallen_angel

you could use 2 anims with different times, and just change them when you press the button

BC

ill use those as last resort.. thanks.

pots and rajaa and warusaki3 have both used the var method... just when reviewing how they did it, sometimes looks a bit complex.
Accepting commissions

Byakko

Quotethis just causes an infinite changestate loop...even if i put persistent = 0
Persistent doesn't matter because you just did a changestate.
You put a changestate, Mugen reads it and changes the state, so it's already not persistent anymore. It just so happens that you go back to the same state, but you start over in that state. So Mugen will then keep reading and find another changestate it hasn't done yet - the same, the one where you put your persistent = 0. So it will do it again, and changestate.
The persistency check is reset as soon as you arrive into a state, even if it's the same as the one you come from.

Quotewhy does this causes an infinite loop, because the first trigger works fine going back into the same state
So Mugen gets in the state for the  first time. It sees "varadd 1 to var 7 if I do this command". You're doing this command, so var 7 goes from 0 to 1.
Now it reads "changestate if animelemtima yadda yadda" no, we're not yet at animelemtime, so this trigger doesn't activate. Now there's a second trigger unrelated to the first that says, change if var 7 is 1. yes, it is, I just used a varadd. So I changestate.
Now I'm at the top again, I see add 1 to var 7 if I do this command, no, I'm not doing this command, keep reading.. Changestate if animelem is over this value, no, I just entered the state so this trigger is false ; another trigger, changestate if var 7 is 1... yeah, var 7 is still 1, I haven't changed it. so I do the changestate.
And loop.

You want the changestate to not occur too early, so you want to add a check on the animmelem for trigger2 too.
Trigger1 = animelemtime....
trigger2 = var(7) = 1
trigger2 = animelemtime...

Well, that's for the loop.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

BC

#6
dude thanks so much lol for the detail in your post in helping me understand what was going on

i changed the varadd to

[State 820]
type=Varset
trigger1=command="punch rapid" ;set as x
v = 7
value =1
ignorehitpause=1
persistent=0

[State 820, State End]
type = ChangeState
trigger1=animelemtime(4)>8
trigger2 = var(7)=1
trigger2 = animelemtime(4)>0
value=845

the above changestate trigger2,2 was the missing code i needed as you stated, and works great now.

Accepting commissions

BC

[Statedef 845]
type = S
movetype= A
physics = N

[State 0, VarSet]
type = VarSet
trigger1 = prevstateno!=845
v = 8
value = 0

[State 0, VarAdd]
type = VarAdd
trigger1 = prevstateno = 845 && !time
v = 8
value = 1

[State 820]
type=VarSet
trigger1=time=0
var(7)=0
ignorehitpause=1

[State 820]
type=Varset
trigger1=command="punch rapid" ;set as x
v = 7
value =1
ignorehitpause=1
persistent=0

[State 0, TargetBind]
type = TargetBind
trigger1 = animelemtime(1)>=0
time = 1
pos = 47,0

[State 0, TargetState]
type = TargetState
triggerall = anim = 835
trigger1 = animelemtime(3) = 0
value = 850

[State 0, TargetState]
type = TargetState
triggerall = anim = 835
trigger1 = animelemtime(4) = 0
value = 855

[State 0, HitAdd]
type = HitAdd
trigger1 = animelem = 3
value = 1
ignorehitpause = 0

[State 0, TargetLifeAdd]
type = TargetLifeAdd
trigger1 = animelemtime(3)=0
value = -13
kill = 1

[State 845, biting]
type = ChangeAnim
trigger1 = Time = 0
value = 835

[State 820, State End]
type = ChangeState
trigger1=animelemtime(4)>8
trigger2 = var(7)=1
trigger2 = animelemtime(4)>0
value=845

[State 820, State End]
type = ChangeState
trigger1=var(8)>=8
value=880

ok one last thing i noticed.

the last changestate......... set the max number of hits to 8 before it ends the throw.

how would i increase that max value if i was tapping the buttons to get more hits.


another changestate? with a triggerall or something... mayb i need to change that varset(for var(7) ) back to varadd or something and use a triggerall when var(7)> a certain number then change...i dunno am i on the right track?
Accepting commissions

BC

figured it out now

[State 820]
type=Varadd
trigger1=command="punch rapid" ;set as x
v = 7
value =1
ignorehitpause=1
persistent=0

[State 820, State End]
type = ChangeState
trigger1=animelemtime(4)>8
trigger2 = var(7)>0
trigger2 = animelemtime(4)>0
value=845

[State 820, State End]
type = ChangeState
triggerall = var(7)>=10
trigger1=var( 8 )=12
value=890

[State 820, State End]
type = ChangeState
triggerall =  var(7)<10
trigger1=var( 8 )=8
value=880

set the varadd to increase when x is pressed(by 1) but i had a varset tht sets 7 back to 0...so i added this to state 840.... so that when it repeats state 845 it doesnt keep setting 7 back to 0

amended trigger 2,1 to var(7)>0 

added 2 changestates one which records if var(7)>= 10.... which allows a max of 12 hits and if var(7)<10 it keeps the hits to 8

so tapping "x" will increase var(7) a value.

if ive explained this wrong i apologise but it really does work now lol

ive labelled the states 820 because i was lazy sorry lol its actually 845...
Accepting commissions