var mx, mxid; mx = -1; with (enemy) { if (aggro > mx) { if (collision_circle(x, y, 400, player, 0, 1)) { if (collision_line(x, y, player.x, player.y, nopass, 0, 1)) { mx = aggro; mxid = id; } } } } //Now mxid has the ID of the instance with the highest aggro //It has a line of sight and is within range. //I'm not sure how it will tie into the below code yet if collision_circle(x, y, 400, player, 0, 1) and not collision_line(x, y, player.x, player.y, nopass, 0, 1) { mp_potential_step(player.x, player.y, 4, solid) } else mp_potential_step(random(x), random(y), 2, checkall);