Forum

Question regarding AI Cafe tutorial ('pet' monsters)

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Question regarding AI Cafe tutorial ('pet' monsters)

Postby rj » Thu Jul 03, 2008 9:40 pm

hi all.

i've recently been trying to develop my own basic co-op bot for use in a Q1SP episode i'm creating. i'm more of a mapper than a coder at heart so it's not been easy, but i'm getting there slowly.

basically i'd like someone who knows what they're doing with QC to take a look at this tutorial from AI Cafe: http://minion.planetquake.gamespy.com/t ... tutor8.htm

i've completed it in full (replacing monster_demon1 with my own helper_bot entity) and it kind of works. i say kind of, as when my helper bot finds & kills a monster, he just stands & looks at the corpse rather than reverting back to escort mode.

i get that it makes sense for him to do this, as there is nothing in the code to change his goal back once FindTarget has been returned true. and i'm guessing the following code needs to be added again at some point:

Code: Select all
   if (self.classname == "helper_bot")
      {
      self.goalentity = client;
      self.attack_state = ESCORTING;
      self.th_walk();
      return TRUE;
      }


..or something similar. but i can't for the life of me work out where to put it. what part of the code is checked when the monster has defeated its target?

any help appreciated, this one has been giving me a headache for ages!
rj
 
Posts: 5
Joined: Thu Jul 03, 2008 9:23 pm

Postby Electro » Thu Jul 03, 2008 11:15 pm

Haven't done the tutorial myself, but after having a quick look at the code... this this:

Before

beast = findradius(self.origin, 1500);

in FindMonster, put

self.enemy = world;

This will make sure the enemy entity is cleared, so each time when he's looking to find a monster, if he doesn't find anything, it WILL actually return FALSE and never do FoundTarget. Currently I'm guessing it's doing FoundTarget quite a lot, even when you don't want it to.

Of course this could be completely wrong but we'll find out eh? ;)
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia

Postby rj » Fri Jul 04, 2008 1:27 am

many thanks for the suggestion but unfortunately it didn't work. same result :(
rj
 
Posts: 5
Joined: Thu Jul 03, 2008 9:23 pm

Postby rj » Fri Jul 04, 2008 2:00 am

erm. i think i kinda just worked out the answer :lol:

just noticed in this part:

Code: Select all
   if (self.attack_state == ESCORTING)
      return FALSE;

   if (self.classname == "helper_bot")
      {
      self.goalentity = client;
      self.attack_state = ESCORTING;
      self.th_walk();
      return TRUE;
      }



it returns true the first time but false every time after that since the bot remains 'escorting' even when attacking other monsters. i figured if the attack state was changed to something else in FindMonster, it would pass the first argument above and allow itself to be changed again. that *seems* to work.. though if anyone has a tidier way of doing it...


/edit - agh, problem with this method... the bot can't attack one monster after the other, unless it sees the player in between :|
rj
 
Posts: 5
Joined: Thu Jul 03, 2008 9:23 pm

Postby Electro » Fri Jul 04, 2008 4:25 am

Well seeing as there's only 2 states (escorting and attacking) if they're not attacking, then it's safe to assume they're escorting?

If they can't find a target they should just escort, and in the escort state they would be searching for another monster to fight, as well as following the player.
Benjamin Darling
http://www.bendarling.net/

Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
Electro
 
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest