AI()
while(src)
if(!Combat())
Walk()
Get_target()
for(var/mob/Minion/M in oview(5,src))
if(M.Side!=src.Side)
src.target=M
return 1
return 0
Combat()
if(!src.target) if(!Get_target()) return 0
if(get_dist(src,src.target)<=1)
src.dir=get_dir(src,src.target)
src.Attack()
sleep(5)
return 1
else
if(!step_to(src,src.target)) Dodge()
sleep(5)
return 1
Attack()
for(var/mob/M in get_step(src,src.dir))
if(M!=src)
var/Damage=max(0,src.Str-M.Def)
if(src.client)src<<"You hit [M] for [Damage] damage!"
M.TakeDamage(Damage,src)
Problem description:
I am making a simple AI routine. Combat and Movement. Movement is destination based. So NPCs move from destination to destination. I am using step_towards proc because the destination is too far away for step_to proc to handle. I had to write my own Dodge system as step_towards doesnt handle obstacles and its working pretty well.
My first question is, is there any better way to do this? (long distance travel)
My second point. I tried to implement a combat system (code at the top). But the NPCs seem to have trouble working together at larger numbers. They position themselves wrong and get stuck even though i am using step_to proc! I even tried to use my Dodge() proc as a possible solution, but it didn't help.
So my second question is: Can you see an obvious mistake in my logic, or did I approach this problem by a wrong way?
Thank you for your replies. All help is appreciated!