Jump to content
  • 0

Continuing an attack


Tyler

Question

I want to make an attack where you continuously press a button to keep attacking

basically i want to keep the character in the same state as long as the player is continuing to press the A key (or whatever button)

how would i do that?

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

This may help you.

 

basically instead of different attacks you would have it loop back into the same state, so you can keep attacking with the attack.

UNLESS you want it to go to another attack/state.

Link to comment
Share on other sites

  • 0

got it to work pretty much like i wanted

 

a question though, how can i force the state to end after a certain amount of time?

 

i tried time > but it looks like the time keeps resetting when i loop back into the state.

Link to comment
Share on other sites

  • 0

I tried

 

[state 0, ChangeState]

type = ChangeState

trigger1 = time = 50

value = 234

ctrl = 0

 

but its not working because i have

 

[state 0, ChangeState]

type = ChangeState

triggerall = time > 14

trigger1 = command = "a"

value = 231

ctrl = 1

 

resetting the state at > 14

 

so it never gets high enough for that one to work.

 

is there a better trigger to use?

Link to comment
Share on other sites

  • 0

Maybe you could create a helper with a blank animation at the beginning of your state and reference it's state time to end the move, and then destroy the helper?

The other thing you could try is just loop back the animation and retrigger the hitdef per animelem, rather than looping back into the state itself.

Link to comment
Share on other sites

  • 0
; Start
[Statedef 230]
type = S
movetype = A
physics = S
ctrl = 0
anim = 230
poweradd = 0
 
[State 0, VelSet]
type = VelSet
trigger1 = time > 9
x = 0.3
y = 0
 
[State 230, 1]
type = HitDef
trigger1 = AnimElem = 4 || AnimElem = 6 || AnimElem = 8 || AnimElem = 10 || AnimElem = 12 || AnimElem = 14
attr = S, NA
damage = 5,2
getpower = 30, 15
givepower = 15, 7
guardflag = MA
pausetime = 5,4
sparkno = -1
guard.sparkno = s7000
hitsound = S0,5
guardsound = S0,8
ground.type = High
ground.slidetime = 12
ground.hittime = 15
ground.velocity = -2
air.velocity = -2,-2
 
 
[State 0, ChangeState]
type = ChangeState
Triggerall = time > 20
trigger1 = command = "a"
value = 231
ctrl = 1
 
 
[State 0, ChangeState]
type = ChangeState
trigger1 = Animtime = 0
value = 234
ctrl = 0
 
;--------------------------------
; Continue
[Statedef 231]
type = S
movetype = A
physics = S
ctrl = 0
anim = 231
poweradd = 0
 
[State 0, VelSet]
type = VelSet
trigger1 = time >= 0
x = 0.3
y = 0
 
 
[State 231, 1]
type = HitDef
trigger1 = AnimElem = 1 || AnimElem = 3 || AnimElem = 5 || AnimElem = 7 || AnimElem = 9 || AnimElem = 11
attr = S, NA
damage = 5,2
getpower = 30, 15
givepower = 15, 7
guardflag = MA
pausetime = 5,4
sparkno = -1
guard.sparkno = s7000
hitsound = S0,5
guardsound = S0,8
ground.type = High
ground.slidetime = 12
ground.hittime = 15
ground.velocity = -2
air.velocity = -2,-2
 
 
 
[State 231, ChangeState]
type = ChangeState
triggerall = time > 14
trigger1 = command = "a"
value = 231
ctrl = 1
 
 
 
[State 231, ChangeState]
type = ChangeState
;trigger1 = Animtime = 0
trigger1 = time > 100
value = 234
ctrl = 0
 
;--------------------------------
; Finish
[Statedef 234]
type = S
physics = N
juggle = 0
poweradd = 0
ctrl = 1
anim = 234
sprpriority = 2
velset = 0,0
 
 
[State 234, 3]
type = Changestate
trigger1 = animtime = 0
value = 0
ctrl = 1
Link to comment
Share on other sites

  • 0

Tex, I hope I'm not stepping on your toes or anything here, I just figure multiple suggestions won't hurt.

Tyler, here's how I would go about that:

 

 

;_____/ Add this to State -1 in the CMD file

[state -1, Repeat Attack 231 Per Button Hit]

type = ChangeAnim

trigger1 = (command = "a") && (stateno = 231)

trigger1 = time > 14

value = 231

 

 

;_____/ Remove this from state 231
[State 231, ChangeState]
type = ChangeState
triggerall = time > 14
trigger1 = command = "a"
value = 231
ctrl = 1

 

 

;_____/ Then in state 231, Change this....
[State 231, ChangeState]
type = ChangeState
;trigger1 = Animtime = 0
trigger1 = time > 100
value = 234
ctrl = 0


;_____/ ...to this.
 [State 231, ChangeState]
type = ChangeState
trigger1 = Animtime = 0
trigger2 = time > 100
value = 234
ctrl = 0


Hope this helps.

Link to comment
Share on other sites

  • 0

Great, no prob!

Just for the sake of your own learning, here's a quick explanation of it.  The issue with restarting the attack state from within itself is two fold.  1st you loose the ability to end the state by a time check.  2nd, normally you don't have control while in the attack state (ctrl = 0) so any command checks inside the state won't work.  Unless of course you have control on (ctrl =1) in which case you'll be able to walk, or jump or do basically anything else right in the middle of the attack.  So what you need to do is have ctrl = 0 in the attack state itself, and then check for the command from outside of it, in the cmd file (state -1).  From there, instead of restarting the whole attack state, all you have to do is restart its animation, because the hitdef is re-triggered every time the animation is on a certain frame (1,3,5,7,9).  This allows you to check for the overall time of the move from within the attack state itself, while only being able to press that certain button to re-trigger the attack as many times a possible within a given time frame.










 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...