AI checking for nearest AI

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

AI checking for nearest AI

Post 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?
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post 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
}
}
}
hope this helps, prob not cos it's all foreign 2 me :-/
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post 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 !
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

trigger

Post 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?
Tom Trude,

Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

well couldnt u bind the origin to the 2nd ai's head?
Image
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post 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:
Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post 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.
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

couldn't you just have a trigger multiple bound to each person
hope this helps, prob not cos it's all foreign 2 me :-/
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

I'd like to make a Ai look to the other Ai..I'll try these tips :D ! Thanks
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post 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... :?
hope this helps, prob not cos it's all foreign 2 me :-/
Krane
Lieutenant General
Posts: 782
Joined: Sat May 31, 2003 4:18 pm
Location: California, USA
Contact:

Post by Krane »

Thanks nuggets. Yeah, IF this is possible, then the problem is solved...I'll talk to him!
Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

well couldnt u put them all in a set and give the set that command, or does that not work.
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post 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
hope this helps, prob not cos it's all foreign 2 me :-/
Post Reply