function c_doenemyai(target) { switch target.data.aitype { case AI.AFK: target.waiting = true; break; case AI.KILLER: var dude = c_findnearestunit(ARMY.US); repeat(target.data.mov.val) { var guy = c_gettile(target.pos.x, target.pos.y); if target.pos.x < dude.x { var guy = c_gettile(target.pos.x+1, target.pos.y); } else if target.pos.x > dude.x { var guy = c_gettile(target.pos.x-1, target.pos.y); } if target.pos.y < dude.y { var guy = c_gettile(target.pos.x+1, target.pos.y); } else if target.pos.x > dude.x { var guy = c_gettile(target.pos.x-1, target.pos.y); } if guy.passable { c_moveunit(target, guy); continue; } } target.waiting = true; break; case AI.WAITER: break; case AI.ESCAPER: break; } } function c_findnearestunit(alignment) { var lowest = new vec2(99, 99); var lowestunit = new vec2(99, 99); for (i=0; i