(I don't know anything about php, so this is written in
something approximating Java...)
void setTarget(){
if (Guy.weapon == "AK-47")
if (Guy.seesGuy() != -1)
Guy.target = Guy.allSeen[Guy.seesGuy()];
else
Guy.target = Guy.allSeen[0];
else
if (Guy.seesTank != -1)
Guy.target = Guy.allSeen[Guy.seesTank()];
else
Guy.target = Guy.allSeen[0];
}
int seesGuy(){
for(x=0; x < Guy.allSeen.length(); x++)
if (Guy.allSeen[x].type() == "guy")
return x;
return -1;
}
... where setTarget() and seesGuy() are methods in the Guy
class, and allSeen in an array of type, um, "targetable
thing" that contains all of the opposing things the guy
can see.
edit: I tried to indent for readability, but apparently the
forum software doesn't like extra spaces... sorry.
another edit: it also doesn't like square brackets... grr...
[i]grudgingly[/i] replace with <>'s
yet another edit: just noticed the plain text checkbox... I am
an idiot...