QC Clean. Individual AI scripts

Discuss Artificial Intelligence and Bot programming.
Post Reply
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

QC Clean. Individual AI scripts

Post by Blackstar1000 »

Hey guys. I'm using a clean base QC. As far as I can tell all of the major monsters in single player all run out of ( ai.qc )

Now I have done some messing around with this but I cannot get to the conclusion I have been looking for.
Also any modifications to the script I do in ai.qc will lead to further problems later on.

Essentially I want to have a few different .qc files that different "characters" in my world can use for their brains.

Guards that will attack on a trigger or when attacked (entering an unauthorized area) - this will use guard.qc
Pedestrians that will attack only when attacked - ped.qc
enemies that will attack on sight - enemy.qc

Can someone give me some advice? How would I start to set this up? How exactly can I dismantle ai.qc into more workable scripts? Is there someone who can tell me how to get to a basic ai that has just brains enough to follow path nodes and perhaps locate a player when needed?

Am I going about this incorrectly? Thanks again.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: QC Clean. Individual AI scripts

Post by frag.machine »

ai.qc is quite simplistic - in a nutshell, "find me a near and visible client".

That said...
Guards that will attack on a trigger or when attacked (entering an unauthorized area)
Pedestrians that will attack only when attacked
Monsters can be activated by triggers like any other entity. It will get mad at the trigger activator.
To implement a very simple "neutral" behavior you could just use notarget = 1 by default, and hack FindTarget() to ignore the flag for some of the monsters:

Code: Select all

float() FindTarget =
{
  (...)
  if (client.flags & FL_NOTARGET)
  {
    // monster_type1 and monster_type2 aren't fooled by notarget hack
    if ((self.classname != "monster_type1") && (self.classname != "monster_type2"))
    {
      return FALSE;
    }
  }

  (...)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: QC Clean. Individual AI scripts

Post by Blackstar1000 »

Thanks it works swimmingly. I was very close to achieving this but taking a much longer rout. Now, what is the easiest way of getting this monster_type1. (the one that is made the exception) into the game?

Simply renaming the entity monster_type1 in worldcraft obviously will not show the monster. I do recall there being a way to add custom entities to worldcraft, though it has been a long while since I have done so.

What is required to get this custom monster to spawn? Do i simply add this to the worldcraft library somehow or do I need to set this guy up somewhere else in the .qc files?

I imagine I have to do both.
Thanks again for all the help, you guys are wonderful.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: QC Clean. Individual AI scripts

Post by Blackstar1000 »

Also I have added

@PointClass base(Monster) size(-16 -16 -24, 16 16 40) = monster_type1 : "Type" []

to the .fgd for worldcraft. still trying to find a way to define this new class.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: QC Clean. Individual AI scripts

Post by frag.machine »

Oh sorry, I should be more clear: there are no such monster_type1 or monster_type2. It was just some names I made up to serve as an example.
Let's say you want that all regular monsters, except, say, rotweillers and fiends, become "neutral" to the player. Replace "monster_type1" in my example with "monster_dog" and "monster_type2" with "monster_demon1".
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: QC Clean. Individual AI scripts

Post by Blackstar1000 »

Haha I understand that. I'll come back to the question later though. I have made some major breakthroughs on my third person camera so I'm going to set aside some of my AI work as of now. Thanks again though, it's a really big help in getting the sort of feeling that I want.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Post Reply