Game Development Community

T3D 1.1 Final - Ai Cannot Start AiPath w/Fix - RESOLVED (THREED-1975)

by Steve Acaster · in Torque 3D Professional · 06/06/2011 (10:45 am) · 4 replies

T3D 1.1 Final

win7 32bit

target:
AiPaths, script

Issue:
Aipaths have historically started with "0" on the seqNum, but this has now changed to start with "1" (loading a path marker with a "0" seqNum seems to get auto replaced "1" and the others bumped up into the correct order) - however the script has not been updated.

Repeat:
Make the standard, stock AiManager and paths combination and look at the Ai freak out on the spot not knowing where to go.

Suggest:
scripts/server/aiplayer.cs, change the starting moveToNode(0) to moveToNode(1).
function AIPlayer::followPath(%this,%path,%node)
{
   // Start the player following a path
   %this.stopThread(0);
   if (!isObject(%path))
   {
      %this.path = "";
      return;
   }

  if (%node > %path.getCount() - 1)
    %this.targetNode = %path.getCount() - 1;
   else
      %this.targetNode = %node;

   if (%this.path $= %path)
      %this.moveToNode(%this.currentNode);
   else
   {
      %this.path = %path;
      %this.moveToNode(1);// <--- yorks changed from 0
   }
}

And that seems fine, "0" in moveToNext node does not appear to require updating as "0" seems to now represent none/false (eg: path finished).

#1
06/06/2011 (10:51 am)
Logged as THREED-1975.
#2
08/08/2011 (12:28 pm)
Hey Steve,

I looked into the history of the involved files, and it actually looks as if
Quote:loading a path marker with a "0" seqNum seems to get auto replaced "1" and the others bumped up into the correct order
is a bug itself...

I couldn't find any changes to the documentation or Marker code that would imply this was intentionally done, so could you try the following fix for me?

In Engine/source/scene/simPath.cpp...
void Marker::onGroupAdd()
{
   mSeqNum = getGroup()->size() - 1; //<--LINE CHANGED
}

Make sure that doesn't blow anything else up. I'm going to comb it over with a couple of other T3D devs to make sure I'm right on this one. Especially since a C++ change has more potential to break things than one in script.
#3
08/08/2011 (3:52 pm)
That makes a lot more sense now and works as stock intended. Haven't noticed any obvious issues.
#4
10/08/2011 (10:44 am)
Fixed in 1.2.