Game Development Community

Advanced: Chapter 8 - endless loop bug

by Paul Jan · in Torque Game Engine · 09/20/2005 (8:59 pm) · 5 replies

AITServer.cs, starting line 86: function serverCmdAITContact:

while(!%ai.aiPlayer)
{
%hit = ContainerRayCast (%start, %end, $TypeMasks::PlayerObjectType, %player);
%ai = GetWord(%hit,0);
if(!%ai.aiPlayer)
%player = %player SPC %found;
}

if the player isn't facing the AI player, the game gets locked into this loop!

I'm not entirely sure why the loop is there, so I'm leaving it alone for now, just limit the number of iterations:

%oops = 0;
while(!%ai.aiPlayer && %oops<100)
{
%oops++;
%hit = ContainerRayCast (%start, %end, $TypeMasks::PlayerObjectType, %player);
%ai = GetWord(%hit,0);
if(!%ai.aiPlayer)
%player = %player SPC %found;
}

#1
09/20/2005 (10:18 pm)
More bugs: empty responses need to be added to the elf.rsp file -
GetResponse works by finding %responseNumber serveral times (%queryNumber), but in the original file, <7> only appeared once when its queryNumber was 3.

GotoQuery(2)
<1> KillPlayer()
<2> DamagePlayer(10)
<3> MoveTo("0 0 0")
<4> TeleportPlayer("0 0 500")
<5> GotoQuery(3)
<6> CloseDialog()
<7>
<1> RenameSender("Inhuman")
<2> GotoQuery(1)
<3> RenamePlayer("Goofball")
<4>
<5>
<6>
<7>
<1> ChangeStartQuery(3)
<2> ChangeMugShot("default.png")
<3> ChangeMugShotAndGoto("default.png",3)
<4> ChangeAITScript("orc",1)
<5> ChangeAITScriptAndOpen("orc",1)
<6> GotoQuery(1)
<7> ChangeStartQueryAndOpen(1)
<->
#2
09/20/2005 (10:33 pm)
The CD file Orc.rsp needs to be changed from

<1>ChangeScript("elf",1)
<2>ChangeScriptAndOpen("elf",3)
<3>CloseDialog()

to

<1> ChangeAITScript("elf",1)
<2> ChangeAITScriptAndOpen("elf",3)
<3> CloseDialog()

in order to be parsed and run correctly.

Also in AITCommands.cs, line 83

function ChangeStartQueryAndGoto(%NewStartQuery,%GoTo,%client,%sender,%npcFile)

should be

function ChangeStartQueryAndGoto(%NewQuery,%GoTo,%client,%sender,%npcFile)

but it doesn't get used in the course of the demo, so its not critical.
#3
09/21/2005 (6:16 am)
Paul, are these in the book code, or the CD code? I'm at work right now, so I can't easily look them up...
#4
09/21/2005 (4:12 pm)
The first two are in the book and CD.

The book doesn't have an orc.rsp, so its CD only.

the ChangeStartQueryAndGoto is in the book and CD.
#5
12/04/2005 (12:48 pm)
Also, I don't see where the local variable %found in the first while loop is coming from...

Edit: there is an animated door resource which has a little simpler and easier to understand mechanism that does a search for a door in front of the player and if found, opens it. It may be able to be implemented in this case as well. Simple Scripted Doors.