Game Development Community

AiGuard is invensable

by Mike Rowley · in Torque Game Engine · 04/01/2006 (7:05 pm) · 1 replies

Most of the problems I've had have been fixed by eather searching this site, or by asking you. Thankyou for all the help. :-)

I've looked at the aiGuard tutorial, tried it in the console and it worked as expected. I have tried using the aiGuard.cs that came with the tutorial, but it doesn't work unless you modify the engine. I'm not ready to modify it yet. :-/

I took the aiGuard.cs from koob and added it. I have 2 guards as expected, and where they are supposed to be. They act like expected, eccept, they never shoot at you, and they don't lock on. Also, I can shoot them all I want, but they never lose any life.

I have included the console log, and the aiGuard.cs in Here------- so that you can look at them. I turned the debug on, and if you look at the console log, you can see that the Guard is doing just what it's supposed to. It sees the 2 KorkBots running around, and it sees me. But that's all it does. I don't know how to fix these problems.
Any help would be greatly appreciated. I've spent 2 whole days on this (and a couple other) problem.
Thanks.

#1
04/03/2006 (1:09 pm)
I've been looking thru the ai code to see if I can figure out where my problem lies.
Looking at the debug print, the "DoScan()" method is only half working.
I did notice this part of the code, and what I need to know is if it is proper syntax.

function AIGuardDB::DoScan(%this,%obj)
{
  DebugPrint("%this:"@%this@"~AIGuardDB::DoScan (from:"@%obj@")", "DoScan");
  if(!isObject(%obj))
    return;
  cancel(%this.scheduledCheck);
  if (%obj.attentionLevel<=0)  // if attentionLevel is non-zero, keep looking in same direction
    %obj.attentionLevel=0;
  else
    %obj.attentionLevel--;
  if (%obj.attentionLevel==0)  // if attentionLevel is non-zero, keep looking in same direction
  {
   %look = getRandom($NUM_CARDINALS-1);

   if (%this.look != %look)
      %this.look = %look;
   else
   {
      %this.look = %look + 1;
      if (%this.look < $NUM_CARDINALS-1)
         %this.look++;
      else
         %this.look = 0;
   }
  }
  %obj.setAimLocation($cardinalDirection[%this.look]);

Shouldn't those if statements be in brackets??
There are 3 if statements and 1 else statement all inside one set of brackets. Is this correct?