Pedestrians and Patrons

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

Pedestrians and Patrons

Post by Blackstar1000 »

I have been attempting to make a change in the AI for the knight. I have been unable to figure a solution for making a pedestrian-like character to inhabit the environments I have made ( think the peds in grand theft auto. ) and patrons/ customers( Fallout ) I want them to act neutral, not hostile. , maybe roam/ stand / or face you. Perhaps in a bar. And if you shoot a gun off in the area. Or at one of them. They all will attack. I'm still new to quake C, perhaps this is a lot to ask. But I could fumble around for months on my own or seek your advice.

Thanks!
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Electro
Posts: 312
Joined: Wed Dec 29, 2004 11:25 pm
Location: Brisbane, Australia
Contact:

Post by Electro »

I'd look at seeing if you can do the easy stuff first, like stopping them from attacking. Have them just roaming around using path_corner and ignoring the player for starters. Then you can worry about doing things like once you're in range they turn to look at you.

Here's a tip :)

Look in fight.qc
In CheckAttack

There is:

Code: Select all

if (enemy_range == RANGE_MELEE)
See if you can get a start by playing around in there. RANGE_MELEE might be a good range already for them to look at the player. This function can also be the good place to stop them being hostile towards you.

Good luck!
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/
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re:

Post by Cobalt »

What is path_corner doing anyway? Could bots also use it as supplimental navigation ?
Electro wrote:Have them just roaming around using path_corner and ignoring the player for starters. Then you can worry about doing things
like once you're in range they turn to look at you.
Good luck!
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Pedestrians and Patrons

Post by Cobalt »

Well I just learned the path_corners are not just nav markers for AI. They also tell the large BSP func_plats like on e1M5 the directions to move (push ) back and fourth to and from.
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: Pedestrians and Patrons

Post by Blackstar1000 »

Oh yeah? I assume this is how you would have a platform go all the way around a room and back? This was one of the next things I was going to tackle once my schedule frees up again.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Alex
Posts: 24
Joined: Sun Feb 13, 2011 6:24 pm

Re: Pedestrians and Patrons

Post by Alex »

If you're still looking into this kind of thing, definitely look into the CheckAttack function as was mentioned earlier. You can also check out FindTarget() in the ai.qc. In terms of firing of a gun and having them turn on you, I'm not sure what the float show_hostile does, but you may want to look into it. A weird roundabout way that I've been able to this was by modifying the T_RadiusDamage in combat.cq. Originally I used it for pedestrians to "call for help", and if a guard heard them he would come looking for you.

Essentially, whenever they would call for help, they'd send out T_AlarmDamage (my modified function), which works more or less the same way as radius damage, except it's set to only take off 1 damage and only affects other non-alarmed monsters. It works off the general notion that when a monster takes damage, if the player is the attacker then he'll start searching for you.

Code: Select all

void (entity inflictor, entity attacker, float damage, entity ignore) T_AlarmDamage =
{
   local float points;
   local entity head;
   local vector org;

   head = findradius(inflictor.origin, damage); //the damage in this case only specifies the range of the sound

   while (head) {

      if (head != ignore) {

         if (head.takedamage) {
            org = (head.origin) + (((head.mins) + (head.maxs)) * 0.5);
            points = 0.5 * (vlen((inflictor.origin) - org));

            if (points < FALSE) {
               points = FALSE;
               }
            points = damage - points;

            if (head == attacker) {
               points = points * 0.5;
               }

            if (points > -1) {

               if (CanDamage(head, inflictor)) {

                  if ((head.classname) == "player") {  //so it doesn't effect other players
                     }
                  else {

                  if ((head.targetname) == "good") {
                     }
                  else {

                  if ((head.alarmed) > 0){             //so it doens't keep alarming/hurting the same monsters
                     }
                  else {
			   head.alarmed = 1;
                     T_DamageAlarm(head, inflictor, attacker, 1); //note how the "damage" specified when the function is called is only for range.
                     }
 			   }
			  }
                  }
               }
            }
         }
      head = head.chain;
      }
};
In your case you could probably put something like this along with W_Attack or something

T_AlarmDamage(self, self, 500, world);

The cool part is that because it has range built into the damage part (ie. 500), you could make differences for silenced and unsilenced weapons. So when you shoot your unsilenced rifled the "damage" is 1000, but when it's silenced it's only 100. You can also put it in the final death frame of any dead body so that guards or people freak out when they find one

Also, I could be wrong but I don't think this goes through walls.

Anyway, that should help.

Alex
Post Reply