I need a little help please

Ok I'm making a game. I'm stuck on how to do the combo system. I have attack, attack_2, and attack_3. Everything is in an array. So for example in the idle state script I have
function player_idle_state(){
//get input
get_input()

//calculate movement
calc_movement()

//check state
if hsp != 0 state = states.WALK

if attack {
state = states.ATTACK
image_index = 0

}
if attack_2 {
state = states.ATTACK_2
image_index = 0

}


if attack_3 {
state = states.ATTACK_3
image_index = 0
}


//apply movent
collision()

//apply animation
anim()
}
So how would I set a combo system up?
 
So how would I set a combo system up?
Short answer: it depends on what you want.
Providing us with as little details (not mentionning the thread title :bash:) is pretty much a guarantee to go nowhere.
What are those attack_x variables? Some bools you are setting where, exactly? You mention an array which does not appear in the code.... I mean, come on, give it a little effort.
That said.
In fighting games à la Street Fighter, every animation has "time windows" (from frame x to frame y), to open the door to combo, blocks, counter-attacks, etc. Setting such things can be done relatively easy right in your sprite animation, with broadcast messages. You'd store some flag in your player's object, like can_combo, and you'd toggle it with broadcast messages. I also use this to spawn hitboxes and hurtboxes, because it's a kid's game to get frame-perfect when working directly in the sprite editor.
 
Short answer: it depends on what you want.
Providing us with as little details (not mentionning the thread title :bash:) is pretty much a guarantee to go nowhere.
What are those attack_x variables? Some bools you are setting where, exactly? You mention an array which does not appear in the code.... I mean, come on, give it a little effort.
That said.
In fighting games à la Street Fighter, every animation has "time windows" (from frame x to frame y), to open the door to combo, blocks, counter-attacks, etc. Setting such things can be done relatively easy right in your sprite animation, with broadcast messages. You'd store some flag in your player's object, like can_combo, and you'd toggle it with broadcast messages. I also use this to spawn hitboxes and hurtboxes, because it's a kid's game to get frame-perfect when working directly in the sprite editor.
 
I'm so sorry for the lack of info and confusion
O_player create event
//speeds
hsp = 0
vsp = 0
max_hsp = 2
walk_spd = 1.5


//frictiom
drag = .3

//facing direction
facing = 1

//movement
left = 0
right = 0
up = 0
down = 0
attack = 0
attack_2 = 0
attack_3 = 0

//states
enum states {
IDLE,
WALK,
JUMP,
ATTACK,
ATTACK_2,
ATTACK_3,
BLOCK,
CROUCH,
CROUCH_BLOCK
}

state = states.IDLE

//create states array
states_array[states.IDLE] = player_idle_state
states_array[states.WALK] = player_walk_state
states_array[states.JUMP] = player_jump_state
states_array[states.ATTACK] = player_attack_state
states_array[states.ATTACK_2] = player_attack_2_state
states_array[states.ATTACK_3] = player_attack_3_state
states_array[states.BLOCK] = player_block_state
states_array[states.CROUCH] = player_crouch_state
states_array[states.CROUCH_BLOCK] = player_crouch_block_state

//create sprites array
sprites_array[states.IDLE] = s_player_idle
sprites_array[states.WALK] = s_player_walk
sprites_array[states.JUMP] = s_player_jump
sprites_array[states.ATTACK] = s_player_attack
sprites_array[states.ATTACK_2] = s_player_attack_2
sprites_array[states.ATTACK_3] = s_player_attack_3
sprites_array[states.BLOCK] = s_player_block
sprites_array[states.CROUCH] = s_player_crouch
sprites_array[states.CROUCH_BLOCK] = s_player_crouch_block
O_player step event
//execute state
script_execute(states_array[state])
get_input script
// Script assets have changed for v2.3.0 see
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
function get_input(){
left = keyboard_check(vk_left)
right = keyboard_check(vk_right)
up = keyboard_check(vk_up)
down = keyboard_check(vk_down)
attack = keyboard_check_pressed(vk_shift)
attack_2 = keyboard_check_pressed(vk_control)
attack_3 = keyboard_check_pressed(vk_alt)
}
 
GML:
//Please make sure you format your code like this, it's muuuuuch easier to deal with
Soooo...now that we got that settled!
There's good news and bad news for you. Good news is you won't have to scrap the whole thing, but the bad news is that you're still missing important parts to make it work.
As it is, you have no "architecture" to store what previous keys were pressed, and no way to trigger when you want to allow combo attacks.
The game is not going to magically know what you want it to remember or do, you gotta tell it everything in a non-ambiguous way.
Consider this ugly flowchart I just did:
Untitled 1.jpg

As it stands, you have no way whatsoever to know the answers in all the blue diamonds, or even ask them. This is a big, big problem.

So, what you'll absolutely need:
1 - A data structure to store the key pressed (could be array or ds_list, this is not really relevant)
2 - A boolean flag that says if it's legal to do a combo on that particular animation frame.
3 - Use that and code the logic of the flowchart above.

What you could improve:
1- You have multiple "attack" variable, I would scratch that for one variable holding the attack type currently happening, or undefined if none
2- Using macros could be less a pain than to type "states.SOMETHING" every single time
3 - Your states are just numbers, this will make it harder to know what's going on in debugging (another reason to use macros, you can store states as strings if you want)

I will also add that I really hope we were talking about chaining attacks together, and not making some special moves when you have a combinaison of button pressed (à la MK, for example), because if that's the case, you'll have to forget all I just told you 😂
 
GML:
//Please make sure you format your code like this, it's muuuuuch easier to deal with
Soooo...now that we got that settled!
There's good news and bad news for you. Good news is you won't have to scrap the whole thing, but the bad news is that you're still missing important parts to make it work.
As it is, you have no "architecture" to store what previous keys were pressed, and no way to trigger when you want to allow combo attacks.
The game is not going to magically know what you want it to remember or do, you gotta tell it everything in a non-ambiguous way.
Consider this ugly flowchart I just did:
View attachment 42970

As it stands, you have no way whatsoever to know the answers in all the blue diamonds, or even ask them. This is a big, big problem.

So, what you'll absolutely need:
1 - A data structure to store the key pressed (could be array or ds_list, this is not really relevant)
2 - A boolean flag that says if it's legal to do a combo on that particular animation frame.
3 - Use that and code the logic of the flowchart above.

What you could improve:
1- You have multiple "attack" variable, I would scratch that for one variable holding the attack type currently happening, or undefined if none
2- Using macros could be less a pain than to type "states.SOMETHING" every single time
3 - Your states are just numbers, this will make it harder to know what's going on in debugging (another reason to use macros, you can store states as strings if you want)

I will also add that I really hope we were talking about chaining attacks together, and not making some special moves when you have a combinaison of button pressed (à la MK, for example), because if that's the case, you'll have to forget all I just told you 😂
Thank you kindly
 
Top