Page 1 of 1

AI checking for nearest AI

Posted: Mon Mar 01, 2004 1:00 am
by Krane
There's any way a AI check for the nearest bot? ...er... without using targetname...? :?

I have an AI, he stays waiting for another Ai to come and start the animation. I cannot use targetname coz other AIs can be there also...I was thinking about something like:

if(vector_length (self.origin - $otherguy.origin) > 16)

But I'm using a targetname... There's any OTHER way to get an AI?

Posted: Mon Mar 01, 2004 4:34 am
by nuggets
are you just doing this though script and unable to change targetnames?

if not... you could use a for loop and check for someone of a certain #set

for (local.i=1; local.i<=$otherguy.size; local.i++)
{
if ($otherguy[local.i].set == 1)
{
if (vector_length (self.origin - $otherguy[local.i].origin) > 16)
{
//do what you need
}
}
}

Posted: Tue Mar 02, 2004 5:20 am
by Krane
I don't want to use targetnames coz other bots can use this thread too...One bot goes to a place and waits for the other bot. They start talking, I figured out a way to make this happen, it's working :D !

The problem is that I want bot1 to lookat bot2. I putted a script origin right above the node where all this happen and bot1 look to it. But, sometimes, bot2 is in a slightly different positon, which makes bot1 looks strange...

But that's allright, I was just wondering...

Thanks nuggets :D !

trigger

Posted: Tue Mar 02, 2004 8:42 am
by tltrude
Could you put in a trigger that reads the targetname of any bot that walks into it? Doesn't the bot script assign names to them when they spawn?

Posted: Wed Mar 03, 2004 12:14 am
by omniscient
well couldnt u bind the origin to the 2nd ai's head?

Posted: Wed Mar 03, 2004 6:23 am
by Krane
tltrude: I can use:

if((vector_lenght (self.origin - $thatstheproblem.origin) < 16))
{
bla bla
}
which works better than a trigger... but $thatsthepbroblem is still a problem...

omniscient: bind? how? i mean, how to "get" the nearest AI w/o using targetname?

U know m8s, I solved the problem!!! (...er...not really :oops: )

The problem is that my brain is not working properly :shock: I had this "flea" in my head all these days and I finally figured out:

I had mapping for Neverwinter Nights (that was my first attempt in scripting, don't laugh...) and, in their engine, they have "GetNearestPC" condition!!! This is what was poking my brain cells all this time...I was trying to find a way to have such condition...I'm affraid this is not possible in Q3 engine :( ...

Or it is? :shock:

Posted: Thu Mar 04, 2004 1:11 am
by omniscient
well u said that u have ai dailouge but sometimes the ai doesnt look in the right place. bind what he looks at to the si's head that hes talking to.
like:
$aitarget bind $ai_talked_to
then have the ai talker talk to the $aitarget
something like that.

Posted: Thu Mar 04, 2004 1:39 am
by nuggets
couldn't you just have a trigger multiple bound to each person

Posted: Thu Mar 04, 2004 3:48 am
by Krane
I'd like to make a Ai look to the other Ai..I'll try these tips :D ! Thanks

Posted: Thu Mar 04, 2004 5:55 pm
by nuggets
i haven't used the bots pak at all but i'm presuming from what your saying all the bots have different targetnames

i'm presuming still that the bots have names like gunner or runner or climber etc...

with this, there is no way that it is possible for you to check other bots in the area without MONSTERS triggering a single players own trigger_multiple

but if you speak to JV nicely, (haven't heard from him recently) he could change it so they all have the same targetname (e.g. $bot) and then give them a .activity variable so $bot[1].activity = "gunner"

then you could use
while (isAlive self)
{
for (local.i=1; local.i<=$player.size;local.i++)
{
if (self cansee $player[local.i] 32 64)
{
self lookat $player[local.i]
wait 2
}
else
{
for (local.i=1; local.i<=$bot.size;local.i++)
{
if (self can see $bot[(local.i]
{
self lookat $bot[local.i]
wait 2
}
}
}
}
waitframe
}

you could still use this method IF everyone has a targetname and you check for every possibility of targetname
if (self cansee $man_running_away) etc... :?

Posted: Thu Mar 04, 2004 8:05 pm
by Krane
Thanks nuggets. Yeah, IF this is possible, then the problem is solved...I'll talk to him!

Posted: Fri Mar 05, 2004 12:14 am
by omniscient
well couldnt u put them all in a set and give the set that command, or does that not work.

Posted: Fri Mar 05, 2004 3:07 am
by nuggets
yes and no
many people use set for other tasks in scripting and using that would possibly interfere with what they need,

so creating a new variable will make sure that wouldn't happen