Jihl
Member
Hey there everyone
I hope this is a simple question for you to understand, I will do my best to explain it
First of all, I am dealing with player states, I save all the states in a ds_list so I can have more than 1 state (E.G moving and casting) that would be naturally possible in my game.
I am struggling when I need to delete the states
I am using script_execute(script) to execute in the step event the state of a player
In the step event of obj_player
Initialization of the player:
Step event of the player
scr_player_move_state:
The thing is that I sometime have to change the state of the player:
scr_player_attack:
but I need to delete the state of the script that was being executed before, so I can handle the states cohesively.
So, is there any way of doing this?
Or any way around it that would accomplish the same thing?
EDIT:
Further explanation
For example I would like to save this list for the player in case I need to check if a specific state is active
that would be. If the player gets hit and it is moving (scr_state_check(lf_state.moving)) then apply a hindered_movement debuff
but the player could be moving and also dashing, so I would first check if it is dashing (scr_state_check(lf_state.dash)) so that way the debuff would not apply to him
In this case I need to know about these 2 states. If the player is dashing then it must be moving, but if the player is moving it is not neccesarily dashing
Thank you everyone!
I hope this is a simple question for you to understand, I will do my best to explain it
First of all, I am dealing with player states, I save all the states in a ds_list so I can have more than 1 state (E.G moving and casting) that would be naturally possible in my game.
I am struggling when I need to delete the states
I am using script_execute(script) to execute in the step event the state of a player
In the step event of obj_player
Initialization of the player:
Code:
// Set initial state
scr_state_add(lf_state.idle)
// Set initial state
state = scr_player_move_state
// PD: Move state does actually support idle = no movement
Code:
// Execute states
script_execute(state)
Code:
...
If player starts to walk
// Add walk state
scr_state_add(lf_state.walk)
scr_player_attack:
Code:
// Add State and set melee attack cooldown
scr_state_add(lf_state.attack)
// Change State
state = scr_player_attack_state
So, is there any way of doing this?
Code:
// Inside scr_player_move_state
If script was canceled or stopped running
scr_state_del(lf_state.walk)
EDIT:
Further explanation
For example I would like to save this list for the player in case I need to check if a specific state is active
that would be. If the player gets hit and it is moving (scr_state_check(lf_state.moving)) then apply a hindered_movement debuff
but the player could be moving and also dashing, so I would first check if it is dashing (scr_state_check(lf_state.dash)) so that way the debuff would not apply to him
In this case I need to know about these 2 states. If the player is dashing then it must be moving, but if the player is moving it is not neccesarily dashing
Thank you everyone!
Last edited: