YesNoOk
avatar

Super Dash and Air Jump (Read 9057 times)

Started by Hypersayia, August 29, 2024, 06:40:32 pm
Share this topic:
Super Dash and Air Jump
#1  August 29, 2024, 06:40:32 pm
  • avatar
  • *
So, I got the following code for a Super Dash (Think Dragon Ball FighterZ, if that helps)

Code:
; Super Dash Total
; Super Dash Start
[Statedef 300] ; Super Dash Start-up
type = A
movetype = A
physics = A
anim = 300 ; Animation for startup
ctrl = 0 ; Remove control during dash
velset = 1, -5.5 ; Small hop
sprpriority = 2
facep2 = 1

[State 300, Set Var]
type = VarSet
trigger1 = 1
var(10) = 1 ; Set variable to indicate the Super Dash has been used

[State 300, ChangeState]
type = ChangeState
trigger1 = AnimTime = 0 ; Once startup finishes
value = 310 ; Move into the looping Super Dash

; Super Dash Homing
[Statedef 310] ; Homing Dash
type = A
movetype = A
physics = A
anim = 310 ; Looping dash animation
ctrl = 0
sprpriority = 2

[State 310, VelSet]
type = VelSet
trigger1 = 1
; Horizontal velocity
x = 16 * (P2BodyDist X / (abs(P2BodyDist X) + abs(P2BodyDist Y - 30)))
; Vertical velocity
y = 16 * ((P2BodyDist Y - 30) / (abs(P2BodyDist X) + abs(P2BodyDist Y - 30)))

[State 310, HitDef] ; Super Dash HitDef
type = HitDef
trigger1 = time = 0
attr = A, NA
damage = 20, 0
hitflag = MAFD
pausetime = 12,12
sparkno = S1
sparkxy = 10,-30
hitsound = S1,0
guardsound = S1,1
ground.type = High
ground.hittime = 15
air.hittime = 25
fall = 1
fall.recover = 1
fall.recovertime = 30
; Knock the opponent upward to keep them in range for follow-up
ground.velocity = -2, -5.5
air.velocity = -2, -5.5 ; Adjusted vertical knockback to match the character's hop
yaccel = 0.3 ; Slower falling speed to maintain position

[State 310, ChangeState] ; Transition to the ending state after hit/block
type = ChangeState
trigger1 = MoveHit ; On hit
trigger2 = MoveGuarded ; On block
value = 320 ; Transition to the ending state

[State 310, ChangeState On Timeout]
type = ChangeState
trigger1 = Time = 30 ; Timeout after 30 ticks if no hit occurs
value = 320

; Super Dash Ending
[Statedef 320]
type = A ; Air state
movetype = I ; For impact
physics = A ; Air physics to allow falling and aerial movement
anim = 320 ; Animation for ending the Super Dash
velset = 0, 0 ; Stop any existing velocity
ctrl = 0 ; No control yet

; Apply small upward hop after Super Dash impact
[State 320, VelSet]
type = VelSet
trigger1 = Time = 1 ; After the first tick, apply the hop
x = 4 ; No horizontal movement initially
y = -6.5 ; Match the height to keep the opponent in range

; Transition to normal aerial state (jump-like state)
[State 320, ChangeState]
type = ChangeState
trigger1 = AnimTime = 0 ; After the hop, transition to aerial state
value = 51 ; Transition to falling state
ctrl = 1 ; Allow the player to regain control for aerial attacks

And while most of it works as I'd like, there's a minor problem I'm having as with it when it comes to the air jump.
If the Super Dash is preformed in the air, then the air jump is still available, as I'd like. But if the Super Dash is performed on the ground, there seems to be a random chance that the air jump just won't work.
Re: Super Dash and Air Jump
#2  August 30, 2024, 01:49:54 pm
  • *****
  • Shame on you!
    • USA
From what I'm reading, you probably have a trigger in your Statedef -1's ChangeState 300 that's looking at Var(10).
You're setting var 10 but I don't see anything resetting it, or reading it.
You might want to check state 51/landing states to see if they reset it. But the CMD file is probably the culprit.
vVv N00bSaibot & Muramasa RoofTop vVv
Re: Super Dash and Air Jump
#3  August 30, 2024, 05:52:45 pm
  • avatar
  • *
The only reference to Var(10) in the command is the command for the Super Dash

Code:
[State -1, Super Dash]
type = ChangeState
value = 300 ; State for Super Dash
triggerall = command = "c" ; Trigger on Heavy + Special input
triggerall = var(10) = 0 ; Only trigger if Super Dash has not been used
triggerall = roundstate = 2

and Var(10) is reset on standing. The point of it was to prevent from just spamming it over and over and instead limited it to once per jump.

Code:
[State 0, ResetSuperDash]
type = VarSet
trigger1 = statetype = S ; When standing
v = 10
value = 0 ; Reset the flag indicating Super Dash has reset

State 51 is a falling state, mostly to prevent the full jumping animation from triggering when finishing an air move

Code:
[Statedef 51] ; Fall state (for when I don't want the jump animation to play fully)
type    = A
physics = A
sprpriority = 2
anim = 50

[State 51, ChangeState]
type = ChangeState
trigger1 = Time = 60 ;transition to aerial state
value = 50 ; The standard aerial state for jumps (or appropriate aerial state)
ctrl = 1 ; Allow the player to regain control for aerial attacks

(Side note there, I've since more or less figured out how to sidestep that problem with a changeanim when vel y check and am in the process of phasing state 51 out, but beyond that there's nothing I can find in either state 51 or 50 that I can see that explains it.)

As said before though, what's weird is that whatever's going wrong doesn't always do so. Sometimes (roughly 40%) it'll work as intended.
Re: Super Dash and Air Jump
#4  August 31, 2024, 05:19:45 am
  • *****
  • Shame on you!
    • USA
So you have a few options to squash the bug.  Add a varset to State 51 to change Var 10 to 0 with the same triggers as it's changestate
trigger1 = Time = 60 ;transition to aerial state

In Statedef -2, add a VarSet to change Var(10) to 0 if var 10 is 1 and the state = 0.

Those two additions should sort out the issue. You can use DisplayToClipboard to watch Var 10 using Debug Ctrl+D. You might be able to deduce another reason why it's not changing from 1 to 0.
vVv N00bSaibot & Muramasa RoofTop vVv
Re: Super Dash and Air Jump
#5  August 31, 2024, 09:44:04 am
  • avatar
  • *
Ok, I think there has been a mild misunderstanding here.
Var(10) is working as intended. It's changing when it should and fulfilling it's role as "variable to make the player have to land before they can Super Dash again". It has no baring on anything else because only three things look at it, State 300 for setting it to 1, the Command for the Super Dash to check that it's available, and State 0 to reset it on landing/standing.

When I say "air jump", I'm not talking about some property of the Super Dash itself, I mean the literal effect of pressing Up while in the air, assuming that hasn't already been done more times than the airjump.num

Like I said at the start, the idea is based on the same mechanics as Dragon Ball FighterZ. Character would use the Super Dash, do some hits, do a 2H to send the opponent upwards, jump to follow, continue combo.

The thing I'm going to stress is that everything else seems to work fine. The animations, the air attacks, gravity, the Super Dash itself, it's just that, for some reason, when I use the Super Dash on the ground, there is a solid chance I won't be able to jump while in the air afterwards until I land.

(If it helps, the character wasn't made from scratch. I took a KFM (don't recall which) and worked from there to give me something of an outline to work with.)
Re: Super Dash and Air Jump
#6  September 03, 2024, 10:03:17 pm
  • avatar
  • *
Okay, so I'm still stuck on this, but I think I might have an understanding on what the problem is.

Basically, MUGEN is not treating the Super Dash as a jump, which, fine, technically it isn't. But that then means that it doesn't think the character has jumped period when the Super Dash is performed on the ground. But it also registers the state afterwards as an aerial state so maybe that prevents the air jump from working?

But it that's the case then I have no clue how to actually resolve that and my dumb brain refuses to let me actually move on to anything else with the character until I've resolved this one damn issue.
Re: Super Dash and Air Jump
#7  September 03, 2024, 10:56:40 pm
  • **
  • I dress like your Great Great Grandfather.
if the super dash should count as a jump, then the "has jumped" variable should be adjusted in super dash as well.

I hope I read the problem correctly.

Edit: I think I didn't read right. Consider a custom double/jump air jump state instead of relying on the in-engine one.
Last Edit: September 03, 2024, 11:04:39 pm by Nocturnis
Re: Super Dash and Air Jump
#8  September 03, 2024, 11:36:16 pm
  • avatar
  • *
Consider a custom double/jump air jump state instead of relying on the in-engine one.

This is were I reveal that I'm kinda dumb in that I have no idea how to go about doing that.

So, as previously stated, the CMD and CNS files aren't from scratch, they're me manhandling the files from a KFM. Which works when there's more or less something I can easily see as "Okay, this state/command refers to this situation", but less useful when there's something in engine where there's no direct parallel for me to look at. Such as the jump states existing in the commons cmd but not having an associated command in the cmd, so i assume it's an in-engine thing I need to override or something?
Re: Super Dash and Air Jump
#9  September 09, 2024, 12:15:02 am
  • *****
  • Shame on you!
    • USA
There might be an easy fix for you. If this little fix doesn't work I'll list a 2nd easy fix that is the same idea; just a different set up.
Code:
; Super Dash Total
; Super Dash Start
[Statedef 300] ; Super Dash Start-up
type = A                       <<<<<<<<<<<<<<<<This is whats probably the problem
movetype = A                                                     
physics = A 
anim = 300 ; Animation for startup
ctrl = 0 ; Remove control during dash
velset = 1, -5.5 ; Small hop
sprpriority = 2
facep2 = 1
You need to comment out that line using ;. So like
;type = A                                                      <<<<<<<<<<<<<<<<This is whats probably the problem
Then create
Code:
[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = time = 0 && pos y < 0
statetype = A       ;S,A,C,L
movetype = A        ;I,A,H
physics = A         ;A,C,S,N
[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = time = 0 && pos y >= 0
statetype = S       ;S,A,C,L
movetype = A        ;I,A,H
physics = N         ;A,C,S,N
This is going to tell Mugen that if you do the move on the ground, don't consider it jumping. If it's in the air, act like always.
IF this doesn't work, UNDO THE CHANGES, then Duplicate the entire state and name it like 301 or something NOT used. Change the Type and the Physics in the 2nd state like the statetypeset S A N for standing attack neutral.
Then in the ChangeState in the CMD change to 301 IfElse Pos Y is less than 0.

It seems like your char is thinking you jumped because of the Air in the StateDef I think.
vVv N00bSaibot & Muramasa RoofTop vVv
Re: Super Dash and Air Jump
#10  September 09, 2024, 08:55:28 am
  • avatar
  • *
So, I tried the solution Odb718 suggested and it didn't work.

But, Nocturnis's idea of a custom Air Jump state worked a treat, once I figured out how to go about it.

To anyone curious:
Code:
;Air Jump Custom
[Statedef 51]
type = A
physics = A
velset = 0, 0

[State 51, Jump limit]
type = Varset
trigger1 = Time = 0
var(5) = 1

[State 51, up set]
type = VarSet
trigger1 = var(1) = 0
sysvar(1) = 0

[State 51, forward set]
type = VarSet
trigger1 = var(1) = 1
sysvar(1) = 1

[State 51, backward set]
type = VarSet
trigger1 = var(1) = 2
sysvar(1) = -1

[State 51, Velocity]
type = VelSet
trigger1 = time = 0
x = ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x)))
y = const(velocity.airjump.y)

[State 51, Animation]
type = ChangeAnim
trigger1 = anim != 41 && anim != 42 && anim != 43
value = cond(command = "holdfwd", 42, cond(command = "holdback", 43, 41))

[State 51, Control]
type = CtrlSet
trigger1 = Vel Y > 0
value = 1

[State 51, Land]
type = ChangeState
trigger1 = Pos Y >= 0
value = 52

Basically copy/paste of the Air Jump state but tying things to my own variables rather than the in-engine ones.

var(5) dictates the either or not the air jump is still available an resets on both landing and standing:
Code:
[State 0, Air Jump reset]
type = VarSet
trigger1 = statetype = S
v = 5
value = 0

[State 52, Air Jump reset]
type = VarSet
trigger1 = Time = 0
v = 5
value = 0

And the Air jump operates on the following command:
Code:
[State -1, Air Jump]
type = ChangeState
value = 51
triggerall = statetype = A
triggerall = var(5) = 0
triggerall = pos y <= -35
trigger1 = command = "u"
trigger1 = (var(1) := 0)||1
trigger1 = ctrl
trigger2 = command = "uf"
trigger2 = (var(1) := 1)||1
trigger2 = ctrl
trigger3 = command = "ub"
trigger3 = (var(1) := 2)||1
trigger3 = ctrl

Could it be more refined? Probably, but it works as is.

Thanks for the help.