OK! so you have this problem: You have 1 million A-troops and a million B-troops, and you want to make it so A-troop # 3673 attacks B-troop # 987962! well, I got the deal for ya right here. Well... let's simplify shall we?
Image
So you have 3 A-troops(green), and 3 B-troops(red). And you want 1 of the A-troops to pick any of the B-troops and follow it around. But you want it to be at least a little realistic.. you don't want to be followed by some guy who is on the other side of the rock you're hiding behind.. He can't even see you!
So here's what happens.. see the little yellow guy.. he's our sight Object. So we do this:

Every .10 sec: set alt val A of (A-troop) to random(50)

then,

Pick a (B-troop) at random

Flag 1 of (A-troop) is off

When alt val A of (A-troop) = 1: Shoot (sight object) at (B-troop)

Set Alt val A of (sight object) to Fixed val of (A-troop)

then,

when (sight object) collides with (B-troop): destroy (sight object)

when (sight object) collides with backdrop: destroy (sight object)


Now we've set it so that the A-troops will randomly shoot out small objects to test if a target is in their line of sight. No association can be made with an object that is hiding behind a backdrop object.

Now let's make A-troop obj follow the guys he can see:

Alt val A of (sight object)= Fixed val of (A-troop)

when (sight object) collides with (B-troop): Set Alt val B of (A-troop) to Fixed val of (B-troop) and Set flag 1 of (A-troop) on.


Then:

Pick one (B-troop)

If alt B of (A-troop) = Fixed val of (B-troop): (using the direction calculator) rotate (A-troop) towards (B-troop).


There you go! then you can turn Flag 1 of A-troop off and se the alt val B to 0 and let it roam free again!