[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - monsters fighting each other

monsters fighting each other

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

monsters fighting each other

Postby ajay » Fri Jul 22, 2005 7:46 pm

Oh boy this is irritating me, and i've hung off posting about it for ages; mostly 'cos I really thought I knew enough by now to work it out for myself.
I want 2 types of monsters fight each other on sight - like they would on seeing the player. I can get an individual monster (e.g. one of a type) but groups of two types just don't work.
It's the kind of thing I would have guessed had a relative simple solution; but it doesn't appear to. I've tinkered (and I'm missing out what i've tried, cos firstly, I'm slightly embaressed byt what I've gone through,a nd secondly, there's too many to list!) all over ai.qc and even fight.qc, but to no avail.
I would really appreciated some nudging in the right direction, it's kind of crucial to my mod.
cheers
ajay
User avatar
ajay
 
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Postby Sajt » Fri Jul 22, 2005 9:13 pm

I haven't really ever looked at the Quake AI code to much extent, but I think the function you're looking for is FindTarget. Be warned however that monsters sighting monsters will be slower than monsters sighting players, because vs players they can use a fast PVS solution, but the Quake builtins don't have a function to check for anything other than clients by PVS. Therefore you must use find() or findradius() (the sighting players code used checkclient()).

checkclient will return a client in the current PVS of 'self'. If there is more than one client in the PVS, it will cycle through them each time it is called, or each frame, or every 0.1 seconds or something (not sure), so every time you call checkclient() you will get the next player in the PVS.

Instead of that you will probably have to do something such as

ent = findradius (self, 1024);
while (ent != world)
{
if ((ent.flags & FL_MONSTER || ent.classname == "player") && ent.classname != self.classname)
{
// traceline for line of sight, check dot-product for FOV/facing, whatever else you want to do
// if true, set the target or whatever the ai does
}
ent = ent.chain;
}

You can change the 1024 to a higher number for a longer-range vision, but it may be slower. The MAIN thing to remember when using findradius like this is to call it as sparsely as possible, and try not to have 10 guys calling it at once. Perhaps make them check for opponents every 0.2 - 0.5 seconds or so. And try to spread out think times by setting the initial thinktime with an additional random factor. This may take some modifications to the AI code though, because I think currently AI is tied to animation (i.e. animation calls ai_stand() which calls FindTarget if there is no enemy). Perhaps you could make only every other stand frame, and every other walk frame, etc, call ai_stand/ai_walk.

Not sure if that helped at all...
Last edited by Sajt on Sat Jul 23, 2005 7:07 am, edited 1 time in total.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby Spike » Fri Jul 22, 2005 9:15 pm

Monsters 'look' for enemies via the checkclient builtin. They only check it once, and it cycles through one, one client per frame.
Which means that coop gives slightly slower monsters.

That means you can't just test to see if it's a monster that you've got, because it'll only check client slots.
you'll have to use a findradius instead. Don't use classnames to identify things and it should run fast enough, but you might have to make them even slower at noticing, to help the cpu a bit. Seeing other monsters isn't as important as seeing the player.

It's somewhere in ai.qc, look for the checkclient. Enjoy.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Urre » Fri Jul 22, 2005 9:53 pm

I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Urre » Fri Jul 22, 2005 9:55 pm

I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby Urre » Fri Jul 22, 2005 10:00 pm

Both Sajt and Spike have very valid points, the stuff I did was really just a quick hack, it's probably way too slow to actually use, but like I said, haven't tried it, so I don't really know.
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby ajay » Sat Jul 23, 2005 7:35 pm

User avatar
ajay
 
Posts: 559
Joined: Fri Oct 29, 2004 6:44 am
Location: Swindon, UK

Postby Urre » Sun Jul 24, 2005 12:50 am

I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 2 guests