YesNoOk
avatar

problem with adding a DASH/run system (pots style) (Read 2605 times)

Started by Momotaro, December 09, 2020, 12:09:54 am
Share this topic:
problem with adding a DASH/run system (pots style)
#1  December 09, 2020, 12:09:54 am
  • *****
  • A.K.A. NED
  • I like to draw fighting game characters...
I'm trying to update and custom on some characters (exemple with DW's Mai)

I try to give her a dash forward. (DW only gave her a run in his version)

I used DW code as a base.
I added the Dash code and transition from dash to run from JMorphman's Benimaru.
Then adding some AI stuffs from POTS Geese

Run works perfectly. (I think)
The only problem right now is the command input for cancelling into dash (= release FWD) is really picky.
To do a dash you have to do the FWD FWD input really fast, (hop bak is perfect, Benimaru hop forward and run is perfect as well)

I don't know what is wrong in my version.
Any help is welcome.

CMD used for the code
Code:
[Command]
name = "holdfwd";Required (do not remove)
command = /$F
time = 1

[Command]
name = "holdupfwd"
command = /$UF
time = 1

[Command]
name = "holdup" ;Required (do not remove)
command = /$U
time = 1

[Command]
name = "holddown";Required (do not remove)
command = /$D
time = 1

AIR used for run and dash (I precised when character actually dash (leave the ground)
Code:
; Run forwards
[Begin Action 100]
Clsn2: 2
  Clsn2[0] = -6, -90, 15, -65
  Clsn2[1] = -20, -71, 20, 0
100,0, 0,0, 3;<---------------------ready pose
Clsn2Default: 2
  Clsn2[0] = -25, -50, 24, 0
  Clsn2[1] = -2, -72, 52, -31
Loopstart;<-----------------------------------the actual run
100,1, 0,0, 4,
100,2, 0,0, 4,
100,3, 0,0, 4,
100,4, 0,0, 4,
100,5, 0,0, 4,
100,6, 0,0, 4,

; Run Stop
[Begin Action 101]
Clsn2Default: 2
  Clsn2[0] = -6, -90, 15, -65
  Clsn2[1] = -20, -71, 20, 0
100,7, 0,0, 3
100,8, 0,0, 3

;Dash Forward
[Begin Action 110]
Clsn2: 2
 Clsn2[0] = -18,-74, 21,  0
 Clsn2[1] =  -4,-84, 17,-64
10,0,0,0,1;<---------------------ready pose
Clsn2Default: 2
 Clsn2[0] = -14,-83, 21,-30
 Clsn2[1] =   0,-95, 21,-75
100,0,0,0,2;<---------------------ready pose
110,0,0,0,9;<-----------------------------------start to Dash(jump) forward
110,1,0,0,-1

;Dash Forward (Stopping)
[Begin Action 111]
Clsn2Default: 2
 Clsn2[0] = -18,-74, 21,  0
 Clsn2[1] =  -4,-84, 17,-64
100,7, 0,0, 4
110,2, 0,0, 3
100,8, 0,0, 3
0,15, 0,0, 3

CNS Run and Dash/hop forward states
Code:
;------------------------------------
;Running
[Statedef 100]
type    = S
movetype = I
physics = S
ctrl = 0
VelSet = 0,0

[State 100, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 100

[State 100, Velocity]
type = VelSet
trigger1 = AnimElem = 2 >= 0
x = Const(velocity.run.fwd.x)

[State 100, Change to Run Stop]
type = ChangeState
triggerall = Time >= 10
;;;;trigger1 = Command != "holdfwd" && Time >= 10
trigger1 = !AIlevel && command != "holdfwd";De POTS Geese
trigger2 = AIlevel && p2bodydist x <= 90;De POTS Geese
value = 101
ctrl = 1

[State 100, Change to Jump]
type = ChangeState
trigger1 = Command = "holdupfwd"
value = 40
;
[State 100, jump];De POTS Geese
type = changestate
trigger1 = AIlevel && random < 25
value = 40

[State 110, Dust Helper]
type = Helper
trigger1 = AnimElem = 2
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

[State 105, Starting Step Snd]
type = PlaySnd
trigger1 = !Time
value = 102, 0
channel = 5

[State 105, Step1 Snd]
type = PlaySnd
trigger1 = AnimElem = 4
value = 100, 0
channel = 5

[State 105, Step2 Snd]
type = PlaySnd
trigger1 = AnimElem = 7
value = 100, 1
channel = 5

[State 100, No Walk During Run]
type = AssertSpecial
trigger1 = 1
flag = NoWalk
;------------------------
;Run Stop
[Statedef 101]
type = S
movetype = I
physics = S

[State 101, Skid Snd]
type = PlaySnd
trigger1 = !Time
value = 101,0

[State 101, Skid Dust]
type = Explod
trigger1 = !Time
anim = 8104
sprPriority=3
posType = P1
pos = -15,0
vel = 0,0
scale = 0.5,0.5
pauseMovetime = -1
superMoveTime = -1
ownpal = 1

[State 101, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 101

[State 101, jump];Ajout de POTS Geese
type = changestate
trigger1 = !AIlevel && command = "holdup"
value = 40

[State 101, End]
type = ChangeState
trigger1 = !AnimTime
;value = 0
value = ifelse(command = "holddown", 10, 0);;;;;Ajout de POTS Geese(aller vers crouch ou stand)
ctrl = 1
Last Edit: December 21, 2020, 12:30:20 am by Nedflandeurse
Re: problem with adding a DASH/run system (pots style)
#2  December 09, 2020, 09:23:59 am
  • avatar
  • **
    • USA
Maybe you just made a mistake, but the code for hop/dash is not here.  There are some different ways to accomplish this.  You can check if the player is holding forward for some duration in the run statedef and, if not, go to the hop/dash statedef.  Or you might be able to hijack the double tap command with a statedef that just immediately goes to run or hop depending on if you are holding forward or not.  I can't think of a character in my roster that has this feature, so I'm not sure of a good example.
Re: problem with adding a DASH/run system (pots style)
#3  December 09, 2020, 10:21:22 am
  • *****
  • A.K.A. NED
  • I like to draw fighting game characters...
Oops, I feel stupid.
I forgot to post the actual Dash states.

the CMD send player directly to Dash states, then it decides if it cancels into run instead.

Code:
;=================<DASH FORWARD>=================
[StateDef 110]
type = A
physics = N
moveType = I
anim = 110
ctrl = 0
sprPriority = 1

[State 110, Dash Sound]
type = PlaySnd
trigger1 = AnimElem = 3;2
value = 105,0;110,0

[State 110, Dust Helper]
type = Helper
trigger1 = AnimElem = 3;2
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

;[State 110, VarSet -> Running]
;type = VarSet
;trigger1 = !Time
;sysvar(1) = 1
;
;[State 110, VarSet -> Not Running]
;type = VarSet
;triggerAll = AnimElemTime(2) <= 0 && !AILevel
;trigger1 = !NumExplod(94646464) && !NumExplod(92468246)
;trigger1 = command != "holdfwd"
;trigger2 = NumExplod(94646464) || NumExplod(92468246)
;trigger2 = command != "holdback"
;sysvar(1) = 0
;
;[State 110, ChangeState to Running]
;type = ChangeState
;trigger1 = AnimElemTime(2) = 0 && sysvar(1)
;value = 100

;From POTS GEESE (pots system)
[State 110, Run]
type = varset
trigger1 = !time
sysvar(1) = 1
;
[State 102, Run]
type = varset
triggerall = AnimElemTime(3) <= 0
trigger1 = !AIlevel && command != "holdfwd"
sysvar(1) = 0
;
[State 102, Run]
type = changestate
trigger1 = AnimElemTime(3) = 0 && sysvar(1)
value = 100

[State 110, VelSet];;;;values de Benimaru...(finalement modif en se basant + ou - sur hopback values de mai)
type = VelSet
trigger1 = AnimElem = 3;2
;x = 8.125
;y = -5.625
x = 6.7;6
y = -4

;[State 110, VelAdd];;;;values de Benimaru...(pour freiner)
;type = VelAdd
;trigger1 = AnimElemTime(3) > 0
;x = -0.09765625
;y = 0.78125

[State 105,VelAdd];de CVS2 Mai, finalement MODIF pour gravité par défaut + ou -
type = VelAdd
trigger1 = AnimElemTime(3) > 0
;trigger1 = AnimElem = 3, > 0
y = .585;58;;;;.6
;
;[State 105, VelMul];de CVS2 Mai, finalement NON
;type = VelMul
;trigger1 = AnimElem = 2, > 0
;x = .94



[State 110, End]
type = ChangeState
trigger1 = AnimElemTime(3) >= 0
trigger1 = pos y > -vel y
value = 111


;Stop Dashing Forward
[StateDef 111]
type = S
physics = S
ctrl = 1
anim = 111
velSet = 0,0

[State 111, PosSet]
type = PosSet
trigger1 = 1
y = 0

[State 111, Dash End Sound]
type = PlaySnd
trigger1 = !Time
value = 52,0;100,0

[State 111, Landing Dust Explod]
type = Explod
trigger1 = !Time
anim = 8102
sprPriority = -3
posType = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 111, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

BTW after making some tests, the imput seems to work better if the starting frames of hop / dash forward are long enough

Code:
;---------------------------------------------------------------------
;Dash Forward
[Begin Action 110]
Clsn2: 2
 Clsn2[0] = -18,-74, 21,  0
 Clsn2[1] =  -4,-84, 17,-64
10,0,0,0,2;1<----------longer = hop FWD easier
Clsn2Default: 2
 Clsn2[0] = -14,-83, 21,-30
 Clsn2[1] =   0,-95, 21,-75
100,0,0,0,2;3;2<----------longer = hop FWD easier
110,0,0,0,9
110,1,0,0,-1

But now, the problem is that the starting frames makes her run longer to start. Not instant run feeling (a bit weird for a ninja ^^; )

But I think this one cannot be changed.
Re: problem with adding a DASH/run system (pots style)
#4  December 09, 2020, 11:14:30 am
  • avatar
  • **
    • USA
So here is a crazy idea.  Not sure if this will actually help, but it won't break anything.

Code:
[State 102, Run]
type = varset
;triggerall = AnimElemTime(3) <= 0 ;; Comment out this line because YOLO?
trigger1 = !AIlevel && command != "holdfwd"
sysvar(1) = 0
; Leave this the same.  I just want to reference it.
[State 102, Run]
type = changestate
trigger1 = AnimElemTime(3) = 0 && sysvar(1)
value = 100

Sysvar(1) is immediately set to 1 with a trigger of !time, and the changestate doesn't occur until frame 3.  So maybe with the tiniest bit of hope, you can change sysvar(1) to 0 slightly faster by doing it as soon as the sctrl is parsed?   You really don't need any other condition for this input check because you have already changed to the dash/hop statedef.
Re: problem with adding a DASH/run system (pots style)
#5  December 09, 2020, 11:42:57 am
  • ***
  • Non est hoc propter hoc sed propter est hoc
    • USA
    • doubletrend-zeta.neocities.org/
^^ this will probably work, but as an additional answer, Wild Ambition does the same thing, which I worked with here by sending the F,F to the 102 state, after which if it's not held down within 6 ticks goes to the end of the hop state, otherwise stays as the run state (copied from my common so ignore the out of order states :p).

Code:
;---------------------------------------------------------------------------
; Hop forward
[Statedef 100]
type    = A
physics = A
ctrl = 0
anim = 100
sprpriority = 1

[State 105, 1]
type = VelSet
trigger1 = Time = 0
x = const(velocity.walk.fwd.x)
y = -2.663229389/2

[State 105, 2]
type = CtrlSet
trigger1 = Time = 2
value = 1

[State 105, 3] ; yamazaki move
type = ChangeState
trigger1 = command="a"||command="b"||command="c"
value = 230

[State 105, 3]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 101

;---------------------------------------------------------------------------
; Run forward
[Statedef 102]
type    = S
physics = S
anim = 102
sprpriority = 1

[State 100, 1]
type = VelSet
trigger1 = 1
x = const(velocity.run.fwd.x)

[State 100, 2] ;Prevent run from canceling into walk
type = AssertSpecial
trigger1 = 1
flag = NoWalk

[State 100, 3] ;Prevent from turning
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn

[State 100, 4]
type = ChangeState
trigger1 = command != "holdfwd"
value = cond(time<6,100,101)

;----------------------------------
[Statedef 101]
type = S
physics = S
sprpriority = 0

[State 0, 1]
type = ChangeAnim
trigger1 = time = 0
value = 101

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < Const(movement.stand.friction.threshold)
trigger2 = Time = 4
x = 0

[State ss]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

Though I don't code AI so the answer brought up by notagoodname might be better if you wanted that.
Re: problem with adding a DASH/run system (pots style)
#6  December 21, 2020, 12:29:46 am
  • *****
  • A.K.A. NED
  • I like to draw fighting game characters...
Thanks to both of you guys.
And sorry for the late reply.

IRL took me my motivation for several days.

Then I decided to come to it again.

OK, I checked my states and what you guys suggested.
It seems to work.

But he main problem was an animation problem.

I removed some unnecessary starting frame from run animation before the loop.
This frame was the reason this run anim delay looked too long.
because, before run anim dash start anim was already played, and this dash start is enough.

Code:
; Run forwards
[Begin Action 100]
;Clsn2: 2
;  Clsn2[0] = -6, -90, 15, -65
;  Clsn2[1] = -20, -71, 20, 0
;100,0, 0,0, 1;3
Clsn2Default: 2
  Clsn2[0] = -25, -50, 24, 0
  Clsn2[1] = -2, -72, 52, -31
;Loopstart
100,1, 0,0, 4,
100,2, 0,0, 4,
100,3, 0,0, 4,
100,4, 0,0, 4,
100,5, 0,0, 4,
100,6, 0,0, 4,

I took inspiration from Jmorphman's code.
The reference was perfect to fix it.

Again, thanks for the support!