First of all, you don't need the abs() functions inside the distance formula. When the number is squared it automatically makes it positive.
The answer:
What is object z? In other words, you have object position x(z) and object position z(z). You have verified that object exist(target(z)), but you also need to verify that object exist(z). You must also put me all of your code that involves your objects inside of your if then else endif for those objects.Here is the edited code:
for z=2 to 212
if target(z) > 0 and move(z)=0
if object exist(target(z)) and object exist(z)
distance#(z)=sqrt( (abs(object position x(z) - object position x(target(z)))^2) + (abs(object position z(z) - object position z(target(z)))^2) )
if distance#(z)>object_range(z)
point object z,object position x(target(z)),0,object position z(target(z))
move object z, object_speed(z)
else
if timex(z)<>0 then timex(z)=timex(z)-1
if timex(z)=0 then timex(z)=100 : play sound 14 : object_health(target(z)) = object_health(target(z))-(object_strength(z) - object_defense(target(z)))
endif
else
distance#(z)=0
endif
endif
ignore_target:
if move(z)=1
if cord_X(z) > cord_MX(z)-5 and cord_X(z) < cord_MX(z)+5 and cord_Y(z) > cord_MY(z)-5 and cord_Y(z) < cord_MY(z)+5
move(z) = 0
else
move object z, object_speed(z)
cord_x(z) = object position x(z)
cord_y(z) = object position z(z)
position object 223, cord_x(z), 10, cord_y(z)
Loop Object z,21,46
endif
endif
next z
for quer=2 to 212
if object_health(quer) < 1
if object exist(quer) then delete object quer
for buer=2 to 212
if target(buer) = quer
target(buer) = 0
endif
next buer
endif
next quer
Hope I helped, good luck (I ignored the second part of your code, I will help with that too if it doesn't work)
Xander - Bolt Software
Why do the antagonists always have to look so cool?