T
TheBlindG
Guest
Hello everyone!
I have a problem, I am trying to make some simple enemies for my turn based game. But the enemy, when it starts attacking me, My character never stops losing HP. I am not sure why he keeps doing that and was hoping any off you could understand my code n see why it's happening.
Here we go!
step event for character objects:
case "attack":
damage = floor((5 + pow) * dmg_mod);
attack_target.cur_hp -= damage;
attack_target = noone;
state = "end attack";
attack_timer = 30;
break;
case "end attack":
attack_timer -= 1;
if(attack_timer <= 0){
state = "end step";
}
break;
The attack player script:
scr_erange_indicator(ctr_combat.current_actor.number, ctr_combat.current_actor.range);
var targets = ds_list_create();
ds_list_add(targets, spot[4].actor);
scr_hit_check(ctr_combat.current_actor);
ctr_combat.current_actor.attack_target = Marcus;
ctr_combat.current_actor.state = "begin attack";
ctr_combat.current_actor.attack_timer = 10;
scr_whipe_spots();
ds_list_destroy(targets);
ctr_combat.current_actor = noone;
the range script and damage scripts work as they should so no need for me too show them.
the combat controller step event:
switch(state){
case "initialize":
state = "roll init";
break;
case "roll init":
temp_init = ds_priority_create();
//Call every actor, add themselves to queue
with(par_actor){
init_roll = irandom_range(1 + scen, 20 + scen);
ds_priority_add(other.temp_init, id, init_roll);
}
while(ds_priority_size(temp_init) > 0){
ds_list_add(turn_order, ds_priority_delete_max(temp_init));
}
turn_max = ds_list_size(turn_order);
ds_priority_destroy(temp_init);
state = "ready";
break;
case "ready":
if (current_actor = noone){
turn_counter++;
if (turn_counter >= turn_max){
turn_counter = 0;
round_counter++;
}
current_actor = ds_list_find_value(turn_order, turn_counter);
if(instance_exists(current_actor)){
if(current_actor.army = PLAYER){
ctr_cursor.selected_actor = current_actor;
}else{
TestAI();
}
}else{
This checks if the current actor is a player or not, if not player, it should do the script and go back to the next character in order.
So somehow after the enemy has acted, my hero never stops losing Hp
current_actor = noone;
}
}
break;
}
Hope someone can see what is going wrong with this.
Thanks in advance!
I have a problem, I am trying to make some simple enemies for my turn based game. But the enemy, when it starts attacking me, My character never stops losing HP. I am not sure why he keeps doing that and was hoping any off you could understand my code n see why it's happening.
Here we go!
step event for character objects:
case "attack":
damage = floor((5 + pow) * dmg_mod);
attack_target.cur_hp -= damage;
attack_target = noone;
state = "end attack";
attack_timer = 30;
break;
case "end attack":
attack_timer -= 1;
if(attack_timer <= 0){
state = "end step";
}
break;
The attack player script:
scr_erange_indicator(ctr_combat.current_actor.number, ctr_combat.current_actor.range);
var targets = ds_list_create();
ds_list_add(targets, spot[4].actor);
scr_hit_check(ctr_combat.current_actor);
ctr_combat.current_actor.attack_target = Marcus;
ctr_combat.current_actor.state = "begin attack";
ctr_combat.current_actor.attack_timer = 10;
scr_whipe_spots();
ds_list_destroy(targets);
ctr_combat.current_actor = noone;
the range script and damage scripts work as they should so no need for me too show them.
the combat controller step event:
switch(state){
case "initialize":
state = "roll init";
break;
case "roll init":
temp_init = ds_priority_create();
//Call every actor, add themselves to queue
with(par_actor){
init_roll = irandom_range(1 + scen, 20 + scen);
ds_priority_add(other.temp_init, id, init_roll);
}
while(ds_priority_size(temp_init) > 0){
ds_list_add(turn_order, ds_priority_delete_max(temp_init));
}
turn_max = ds_list_size(turn_order);
ds_priority_destroy(temp_init);
state = "ready";
break;
case "ready":
if (current_actor = noone){
turn_counter++;
if (turn_counter >= turn_max){
turn_counter = 0;
round_counter++;
}
current_actor = ds_list_find_value(turn_order, turn_counter);
if(instance_exists(current_actor)){
if(current_actor.army = PLAYER){
ctr_cursor.selected_actor = current_actor;
}else{
TestAI();
}
}else{
This checks if the current actor is a player or not, if not player, it should do the script and go back to the next character in order.
So somehow after the enemy has acted, my hero never stops losing Hp
current_actor = noone;
}
}
break;
}
Hope someone can see what is going wrong with this.
Thanks in advance!