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?
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!
lol duncan, i think i can create some half-decent AI for my update on my WW II screensaver. (there is gonna be ammo limits for each guy, so i wanna have the guys go ballistic with baynets when the run out of ammo)
Its really good!, but instead of having the A value for the random event you could use the compare 2 general values:
every 0.10sec + random(50)=1 then
shoot sight object
Interesting, Morbid I'm gonna use that sometime. Hired, the fixed values work fine in MMF. The only time I think there are problems is when you have a TON of objects. At that point, a lot of things don't work in MMF. In general, the guys in the game i'm workin on, use this, and follow it correctly.