YesNoOk
avatar

Custom Knockback / Knockdown states. (Read 632 times)

Started by Hypersayia, September 12, 2024, 08:41:43 pm
Share this topic:
Custom Knockback / Knockdown states.
#1  September 12, 2024, 08:41:43 pm
  • avatar
  • *
Hello again.

Right, cutting to the chase, for the purposes of what I'm doing (IE recreating mechanics from Dragon Ball FighterZ), I need some custom knockbacks and knockdowns because... Well, generally speaking, there are 3 different types of each.

For knockbacks, we have what I'm going to call "fall", "splat" and "bounce" knockbacks, based on how they interact with the wall.
For knockdowns, we have "soft", "sliding" and "hard" knockdowns. soft being the default, sliding being a "you're stuck here and vulnerable to Off the Ground attacks for a bit" and hard being "no recovery, only stand"

Anyhow, here be my code for such things

Code:
;Knockback
[Statedef 5400]
type = A
movetype = H
physics = N
velset = 0,0
ctrl = 0

[State 5400, ChangeAnim2]
type = ChangeAnim2
trigger1 = !time
value = 5012
persistent = 0

[State 5400, Velocity]
type = VelSet
triggerall = anim = 5012
trigger1 = hitshakeover = 1
trigger1 = time <= 30
x = hitvel x
y = hitvel y / 2

[State 5400, Gravity]
type = VelAdd
triggerall = hitshakeover = 1
trigger1 = time >= 25
y = 0.35

[State 5400, No scroll]
type = ScreenBound
triggerall = Pos y < -15
trigger1 = BackEdgeBodyDist < 65
trigger2 = FrontEdgeBodyDist < 65
value = 1
movecamera = 0,1

; Wall Splat Transition
[State 5400, Wall Splat]
type = ChangeState
triggerall = var(10) = 1
trigger1 = BackEdgeBodyDist <= 10 || FrontEdgeBodyDist <= 10
value = 5401

; Wall Bounce Transition
[State 5400, Wall Bounce]
type = ChangeState
triggerall = var(10) = 2
trigger1 = BackEdgeBodyDist <= 10 || FrontEdgeBodyDist <= 10
value = 5402

; Hit ground
[State 5400, Hit ground]
type = SelfState
trigger1 = hitshakeover = 1
trigger1 = (Vel y > 0) && (Pos y >= 0)
value = 5100

;---------------------------------------------------------------------------
; Wall Splat
[Statedef 5401]
type = A
movetype = H
physics = N
velset = 0,0
ctrl = 0

[State 5401, EnvShake]
type = EnvShake
trigger1 = !time
time = 10
freq = 60
ampl = -8
phase = 90

[State 5401, Spark]
type = Explod
trigger1 = Time = 0
anim = F72
pos = 0, floor (screenpos y) - 50
postype = back
facing = 1
sprpriority = 3

[State 5401, Sound]
type = PlaySnd
trigger1 = Time = 0
value = F7,0

[State 5401, ChangeAnim2]
type = ChangeAnim
trigger1 = time = 10
value = 5061

[State 5401, VelSet]
type = VelSet
trigger1 = time = 12
x = 0
y = 0

[State 5401, Gravity]
type = VelAdd
trigger1 = time >=12
y = 0.5

[State 5401, Hit ground]
type = SelfState
trigger1 = Vel y > 0 && Pos y >= 0
value = 5100
;---------------------------------------------------------------------------
; Wall Bounce
[Statedef 5402]
type = A
movetype = H
physics = N
velset = 0,0
ctrl = 0

[State 5402, EnvShake]
type = EnvShake
trigger1 = !time
time = 10
freq = 60
ampl = -8
phase = 90

[State 5402, Spark]
type = Explod
trigger1 = Time = 0
anim = F72
pos = 0, floor (screenpos y) - 50
postype = back
facing = 1
sprpriority = 3

[State 5402, Sound]
type = PlaySnd
trigger1 = Time = 0
value = F7,0

[State 5402, ChangeAnim2]
type = ChangeAnim
trigger1 = time = 10
value = 5061

[State 5402, VelSet]
type = VelSet
trigger1 = time = 12
x = 4
y = -3

[State 5402, Gravity]
type = VelAdd
trigger1 = time >=12
y = 0.5

[State 5402, Hit ground]
type = SelfState
trigger1 = Vel y > 0 && Pos y >= 0
value = 5100

;---------------------------------------------------------------------------
;Knockdown Fall
[Statedef 5450]
type = A
movetype = H
physics = N
velset = 0,0
ctrl = 0

[State 5450, ChangeAnim2]
type = ChangeAnim2
trigger1 = !time
value = 5061
persistent = 0

[State 5450, Velocity]
type = VelSet
triggerall = anim = 5061
trigger1 = hitshakeover = 1
trigger1 = time <= 30
x = hitvel x
y = 1.5 * hitvel y

[State 5450, Gravity]
type = VelAdd
triggerall = hitshakeover = 1
trigger1 = Time >= 25
y = 0.35

; Knockdown Landing Logic
[State 5450, Soft Knockdown]
type = SelfState
trigger1 = var(10) = 0
trigger1 = Vel y > 0 && Pos y >= 0
value = 5100

; Sliding Knockdown
[State 5450, Sliding Knockdown]
type = SelfState
trigger1 = var(10) = 1
trigger1 = Vel y > 0 && Pos y >= 0
value = 5451

; Hard Knockdown
[State 5450, Hard Knockdown]
type = SelfState
triggerall = var(10) = 2
trigger1 = Vel y > 0 && Pos y >= 0
value = 5452

;---------------------------------------------------------------------------
;Sliding Knockdown Land
[Statedef 5451]
type = L
movetype = H
physics = N
velset = 0,0
ctrl = 0

[State 5451, SlideBack]
type = VelSet
trigger1 = time = 0
x = -12

[State 5451, Slideslow]
type = VelAdd
trigger1 = time > 10
x = 0.3

[State 5451, End Slide]
type = ChangeState
trigger1 = Time = 50
value = 5100
ctrl = 1

;---------------------------------------------------------------------------
; Hard Knockdown Land
[Statedef 5452]
type = L
movetype = H
physics = N
velset = 0,0
ctrl = 0


[State 5452, Hit Ground]
type = SelfState
trigger1 = Vel y > 0 && Pos y >= 0
trigger1 = time >= 30
value = 5120
ctrl = 1

Var(10) is assigned on move hit for a relevant move, for example:

Code:
[State 220, HitDef] 
type = HitDef
trigger1 = AnimElem = 3
(mostly not relevant stuff here as far as the knockback is concerned)
ground.velocity = -5, -1 ; Knockback for wall bounce
envshake.time = 10
envshake.ampl = 8 ; Stronger screen shake for heavy attack
p2stateno = 5400 ; Custom state for wall bounce
p2facing = 1 ; Force the opponent to face the player after hit

[State 220, Knockback set]
type = VarSet
trigger1 = MoveHit = 1
var(10) = 1

Now, my issue is twofold, mostly. I think. Basically
A: As far as the knockback is concerned, it doesn't like looking at var(10).  (The thought did occur to me as I'm writing this that I could have different knockback states for each wall interaction, but I'd prefer not to do that if I can get the var(10) check to work, I don't have to copy the thing several times.)
and B: The knockdown landings just don't work.

N_N

Re: Custom Knockback / Knockdown states.
#2  September 12, 2024, 09:43:49 pm
  • **
  • ViktorVaughN_N
    • USA
The issue here is that you're trying to make P2 look at your var(10), but you're only changing your var(10) and not P2's, so they don't react. You probably don't wanna change P2's variables for stability reasons. Fortunately there is a way of getting around this while managing to keep the variables:

Use the playeridexist method. Basically what you wanna do is put something like "fall.envshake.ampl = id" into the same Hitdef you want to inflict the custom state (make sure you're not using fall.envshake.time). Then in States 5400 and 5450 add "playeridexist(gethitvar(fall.envshake.ampl))" triggers to the transition states and replace the "var(10)" checks with "(playerid(gethitvar(fall.envshake.ampl)), var(10))". So for example, "var(10) = 1" would become "(playerid(gethitvar(fall.envshake.ampl)), var(10) = 1)". A little cramped-looking, but it's worth it. This will let P2 read your var(10) and react accordingly.
More info here: https://mugenguild.com/forum/msg.2335693
Re: Custom Knockback / Knockdown states.
#3  September 12, 2024, 10:10:11 pm
  • avatar
  • *
Cramped-looking, but man does it work.

Thanks dude.