Lugiafan123
Member
Hi so as you can tell by the title I need help coding the named feature for my game. The game in question is a fully turn-based RPG.
Just to get on the same footing with everyone I'll post a sample of the code for my combat system and specifically how the player attacks.
Below follows the code for key press enter:
if my_turn == true{
skill_found = false;
for ( i = 0; i < array_height_2d(Gamestate.skill_function_array); i += 1)
{
current_skill_function_array = (Gamestate.skill_function_array [skill_pos.skill_name]);
current_menu_skill = (string(Gamestate.Set_skills[|menu_index]));
if current_skill_function_array == current_menu_skill
{
if obj_player.currentMP >= Gamestate.skill_function_array[skill_pos.skill_mana_cost]{
script_execute(Gamestate.skill_function_array[skill_pos.skill_function])
Gamestate.Ascend_switch -= 1
if Gamestate.Ascend_switch <= 0{
obj_player.currentMP -= Gamestate.skill_function_array[skill_pos.skill_mana_cost];
}
alarm[0] = 80;
}
else{
show_debug_message("not enough mana");
}
skill_found = true;
break;
}
}
if skill_found == true {
show_debug_message("Skill Found");
}
else {
show_debug_message("Skill not Found");
}
}
---------------------------------------------------------------------------------------------------------------------------
The important thing to note here is the for-loop and the script_execute command. Basically i've coded a different script for all the different attacks in the game and this block of code calls a specific attackscript based on a couple of factors.
Now I'm not sure if this is going to work but the idea I had for enemy coding is to make the enemy a mirror of the player in some ways, in that I make them call a specific script for each time they attack.
How I'm going to do that is beyond me though and as I said I have no idea if this is going to actually work.
For now the enemy's turn is tied to the alarm event
Constructive feedback appreciated.
Just to get on the same footing with everyone I'll post a sample of the code for my combat system and specifically how the player attacks.
Below follows the code for key press enter:
if my_turn == true{
skill_found = false;
for ( i = 0; i < array_height_2d(Gamestate.skill_function_array); i += 1)
{
current_skill_function_array = (Gamestate.skill_function_array [skill_pos.skill_name]);
current_menu_skill = (string(Gamestate.Set_skills[|menu_index]));
if current_skill_function_array == current_menu_skill
{
if obj_player.currentMP >= Gamestate.skill_function_array[skill_pos.skill_mana_cost]{
script_execute(Gamestate.skill_function_array[skill_pos.skill_function])
Gamestate.Ascend_switch -= 1
if Gamestate.Ascend_switch <= 0{
obj_player.currentMP -= Gamestate.skill_function_array[skill_pos.skill_mana_cost];
}
alarm[0] = 80;
}
else{
show_debug_message("not enough mana");
}
skill_found = true;
break;
}
}
if skill_found == true {
show_debug_message("Skill Found");
}
else {
show_debug_message("Skill not Found");
}
}
---------------------------------------------------------------------------------------------------------------------------
The important thing to note here is the for-loop and the script_execute command. Basically i've coded a different script for all the different attacks in the game and this block of code calls a specific attackscript based on a couple of factors.
Now I'm not sure if this is going to work but the idea I had for enemy coding is to make the enemy a mirror of the player in some ways, in that I make them call a specific script for each time they attack.
How I'm going to do that is beyond me though and as I said I have no idea if this is going to actually work.
For now the enemy's turn is tied to the alarm event
Constructive feedback appreciated.