just makin games
Member
Elo
I'm making a zombie survival game, but for some reason all zombie types but one will hurt the player. In an animation end event I spawn an instance that acts as a kind of bullet that deals damage to the player within 10 pixels of a zombie. But for some reason the code in one of the instances doesn't work!! can someone please give me some guidance as to what might be going on here?
I might take a really long time to reply too sorry guys
thanks
I'm making a zombie survival game, but for some reason all zombie types but one will hurt the player. In an animation end event I spawn an instance that acts as a kind of bullet that deals damage to the player within 10 pixels of a zombie. But for some reason the code in one of the instances doesn't work!! can someone please give me some guidance as to what might be going on here?
GML:
//broken zombie code
//create event
hp = random_range(100,150)
hurtav = true
path = 0
grid = mp_grid_create(0,0,room_width/8,room_height/8,8,8)
path = path_add()
foundplayer = false
//step event
if distance_to_object(player) < 5 {
mp_grid_add_instances(path,owall,1)
mp_grid_add_instances(path,owallfireover,1)
mp_grid_path(grid,path,x,y,player.x,player.y,1)
path_start(path,1,0,false)
sprite_index = szombiemovemil
}
if distance_to_object(player) < 224 and !collision_line(x, y, player.x, player.y, owall, 1, 0){
mp_grid_add_instances(path,owall,1)
mp_grid_add_instances(path,owallfireover,1)
mp_grid_path(grid,path,x,y,player.x,player.y,1)
path_start(path,1,0,false)
sprite_index = szombiemovemil
}
if hurtav and place_meeting(x,y,player) {
sprite_index = szombieatkmil
}
if hp < 1 {
path_delete(path)
instance_create_layer(x,y,layer,ozombiedeadmil)
instance_destroy()
}
if (!place_meeting(x,y,global.activechunk)) {
instance_destroy()
}
if collision_line(x, y, player.x, player.y, owall, 1, 0) {
sprite_index = szombiemil
}
//animation end event
if sprite_index = szombieatkmil {
sprite_index = szombiemil
instance_create_layer(x,y,layer,zombiehurttrace)
}
GML:
//working zombie code
//create event
hp = random_range(50,100)
hurtav = true
path = 0
grid = mp_grid_create(0,0,room_width/8,room_height/8,8,8)
path = path_add()
foundplayer = false
//step event
if distance_to_object(player) < 5 {
mp_grid_add_instances(path,owall,1)
mp_grid_add_instances(path,owallfireover,1)
mp_grid_path(grid,path,x,y,player.x,player.y,1)
path_start(path,1,0,false)
sprite_index = szombiemovefire
}
if distance_to_object(player) < 224 and !collision_line(x, y, player.x, player.y, owall, 1, 0){
mp_grid_add_instances(path,owall,1)
mp_grid_add_instances(path,owallfireover,1)
mp_grid_path(grid,path,x,y,player.x,player.y,1)
path_start(path,1,0,false)
sprite_index = szombiemovefire
}
if hurtav and place_meeting(x,y,player) {
sprite_index = szombieatkfire
}
if hp < 1 {
path_delete(path)
instance_create_layer(x,y,layer,ozombiedeadfire)
instance_destroy()
}
if (!place_meeting(x,y,global.activechunk)) {
instance_destroy()
}
if collision_line(x, y, player.x, player.y, owall, 1, 0) {
sprite_index = szombiefire
}
//animation end event
if sprite_index = szombieatkfire {
sprite_index = szombiefire
instance_create_layer(x,y,layer,zombiehurttrace)
}
thanks