Здравствуйте друзья,я сделал базовый платформер,а вот с модификацией мне и нужна помощь,у меня в платформере есть АИ,он хорошо работает..но я попытался встроить возможность апгрейда для персонажа и не знаю как сделать,чтобы аи стрелял по персу любого уровня...код аи
Шаг
// Гравитация хд..
if place_free(x, y + 1)
{
gravity = 0.5
}
else
{
gravity = 0
}
// Возможность видеть
if have_seen = false
{
if !collision_line(x,y,o_player.x,o_player.y,o_wall,0,1) || distance_to_object(obj_bullet) < 10
{
have_seen = true
}
}
// Меняем спрайты...не работает почему не знаю.
if dir = 1
{
image_index = 0
}
else if dir = -1
{
image_index = 1
}
if hp < 1
{
instance_destroy()
}
if !collision_line(x,y,o_player.x,o_player.y,o_wall,0,1)
{
if have_seen = true
{
if can_attack = true
{
var shoot;
shoot = instance_create(x,y,obj_bullet_enemy)
shoot.direction = point_direction(x,y,o_player.x,o_player.y)
shoot.speed = 15
can_attack = false
alarm[0] = (room_speed / 2)
}
}
}2ой код в шаге:
if have_seen = true
{
if o_player.x > x
{
dir = 1
if place_free(x - 5,y)
{
if distance_to_object(o_player) < 150
{
x -= 3.1
}
}
}
else if o_player.x < x
{
dir = -1
if place_free(x + 5,y)
{
if distance_to_object(o_player) < 150
{
x += 3.1
}
}
}
if o_player.x > x
{
if place_free(x - 5, y)
{
if distance_to_object(o_player) > 149
{
x += 3.1
}
}
}
else if o_player.x < x
{
if place_free(x + 5,y) {
if distance_to_object(o_player) > 149
{
x -= 3.1
}
}
}
if !place_free(x + 15,y)
{
if !place_free(x,y + 1)
{
vspeed= (-6 - random(1))
}
}
else if !place_free(x - 15,y)
{
if !place_free(x,y + 1)
{
vspeed= (-6 - random(1))
}
}
if distance_to_object(obj_bullet) < 75
{
if o_player.x < x
{
if place_free(x + 5,y)
{
x += 8
}
}
else if o_player.x > x
{
if (place_free(x - 5, y))
{
x -= 8
}
}
}
}Отредактировано 3d quattro (2009-12-17 15:26:50)



