ai_combat()
while(!src.ko || !src.move || active)
set background = 1
if(!src.target)
var/mob/player/m = locate() in oviewers(src , 10)
if(m) src.target = m
world << output("Target Found: [src.target]","playerOutput")
//else if(prob(10))
// var/mob/player/m = locate() in oviewers()
// src.target = m
else
if(locate(src.target) in oviewers(src , 10))
if(!target.ko)
if(get_dist(src , src.target) == 1)
src.dir = get_dir(src , src.target)
src.Attack()
if(prob(tacRate))
/*if(prob(70)) */step_away(src , src.target , 3, src.rundelay)
//else src.loc = locate(pick(src.target.x+1, src.target.x, src.target.x-1) , pick(src.target.y-1, src.target.y+1, \
src.target.y) , src.target.z)
else
if(health.current < health.maximum / 10)
step_away(src , src.target)
else
step_to(src , src.target)
else
src.ai_home()
break
// for(var/obj/projectile/o in oview(1)) if(prob(50))step_away(src , o)
sleep(world.tick_lag * 10 + rand(-2 , -4))
ai_home()
if(src.loc != initial(loc) || src.loc != locate(0,0,0))
spawn(10)
//if(locate(src.target) in oviewers(src , 10)) src.ai_combat()
//else
src.loc = initial(src.loc)
src.ai_heal()
src.active = 0
Problem description: Hello, how you guys doing? I am attempting my own Ai process but I can't seem to reduce how much CPU it takes. CPU sky rockets when multiple(around 5-9) ai are going after their target. Another problem, when ai_home() is called, both the player and the Ai are teleported back to their last location before ai_home() is called.
http://www.byond.com/forum/?post=1447399#comment7868507