LightVelox
Member
Hello everyone,
i'm programming an simple ai for a dragon ball fangame i'm doing,he is very similar to another dbz fangame called DBZ Budokai X(actually,my game is a fangame of this fangame,double fangame),the problem is,it's impossible to land a hit in my ai,since he has perfect attack timing,in the exact frame that he can attack me,he does and i can't attack him since he attacks first,here's the code that i use for the AI:
and this is the script that changes the state,it's very simple:
the problem is as i already said,it's impossible to land a hit on the bot since he instantly attack the player when he is in range,the only way to defend is by dodging since i didn't make a blocking state yet,can someone say me a way to make it more natural instead of having "perfect reflexes" and attacking as soon as it's possible
i'm programming an simple ai for a dragon ball fangame i'm doing,he is very similar to another dbz fangame called DBZ Budokai X(actually,my game is a fangame of this fangame,double fangame),the problem is,it's impossible to land a hit in my ai,since he has perfect attack timing,in the exact frame that he can attack me,he does and i can't attack him since he attacks first,here's the code that i use for the AI:
switch(state)
{
case state_stand:
check_state()
break;
case state_hurt:
//nothing,these codes are at Alarm[2],scr_gethit e check_step
break;
case state_attack:
var attack;
attack=choose(1,2)
if attack=1 and can_atk=true
{
can_atk=false
frame=irandom_range(3,5)
alarm[1]=25
var attack;
attack=instance_create(x,y,obj_colission)
attack.team=team
attack.image_xscale=image_xscale
}
if attack=2 and can_atk=true
{
can_atk=false
frame=irandom_range(6,8)
alarm[1]=25
var attack;
attack=instance_create(x,y,obj_colission)
attack.team=team
attack.image_xscale=image_xscale
}
check_state()
break;
case state_flying:
//didn't make it yet
break;
case state_following:
move_towards_point(near.x,near.y,max_speed)
if distance_to_object(near)<25
{
check_state()
}
break;
case state_charging:
//didn't make that too
break;
case state_special:
//well... that too
break;
case state_ranged:
if can_atk=true
{
can_atk=false
frame=irandom_range(12,13)
alarm[1]=15
var ki;
ki=instance_create(x,y,obj_kiblast)
ki.team=team
if chara=spr_vegeta{ki.color=c_purple}
if chara=spr_goku{ki.color=c_blue}
if instance_exists(near)
{
ki.direction=point_direction(x,y,near.x,near.y)
}
else
{
ki.direction=0
}
ki.speed=12
}
check_state()
break;
}
{
case state_stand:
check_state()
break;
case state_hurt:
//nothing,these codes are at Alarm[2],scr_gethit e check_step
break;
case state_attack:
var attack;
attack=choose(1,2)
if attack=1 and can_atk=true
{
can_atk=false
frame=irandom_range(3,5)
alarm[1]=25
var attack;
attack=instance_create(x,y,obj_colission)
attack.team=team
attack.image_xscale=image_xscale
}
if attack=2 and can_atk=true
{
can_atk=false
frame=irandom_range(6,8)
alarm[1]=25
var attack;
attack=instance_create(x,y,obj_colission)
attack.team=team
attack.image_xscale=image_xscale
}
check_state()
break;
case state_flying:
//didn't make it yet
break;
case state_following:
move_towards_point(near.x,near.y,max_speed)
if distance_to_object(near)<25
{
check_state()
}
break;
case state_charging:
//didn't make that too
break;
case state_special:
//well... that too
break;
case state_ranged:
if can_atk=true
{
can_atk=false
frame=irandom_range(12,13)
alarm[1]=15
var ki;
ki=instance_create(x,y,obj_kiblast)
ki.team=team
if chara=spr_vegeta{ki.color=c_purple}
if chara=spr_goku{ki.color=c_blue}
if instance_exists(near)
{
ki.direction=point_direction(x,y,near.x,near.y)
}
else
{
ki.direction=0
}
ki.speed=12
}
check_state()
break;
}
if instance_exists(near)
{
if distance_to_object(near)<25
{
state=state_attack
}
if distance_to_object(near)>25
{
var chance;
chance=choose(1,1,1,1,1,3)
if chance=1{state=state_following}
if chance=2{state=state_charging}
if chance=3{state=state_ranged}
}
}
{
if distance_to_object(near)<25
{
state=state_attack
}
if distance_to_object(near)>25
{
var chance;
chance=choose(1,1,1,1,1,3)
if chance=1{state=state_following}
if chance=2{state=state_charging}
if chance=3{state=state_ranged}
}
}
the problem is as i already said,it's impossible to land a hit on the bot since he instantly attack the player when he is in range,the only way to defend is by dodging since i didn't make a blocking state yet,can someone say me a way to make it more natural instead of having "perfect reflexes" and attacking as soon as it's possible