Game Development Community

Questions on creating an FPS scenario

by Jinnie Ong · in Torque 3D Professional · 08/03/2009 (3:32 am) · 1 replies

Hi all, I'm new to Torque 3D and have been browsing around online, forums and documentations looking for a substantial tutorial that covers the creation of an FPS scenario from scratch (including bots etc). However there doesn't seem to be any complete guide as of yet.

Most tutorials usually cover the creation of terrain but stops short of teaching how to go about the scripting process, for example creating and executing a script that creates bots in the game. Some tutorials simply mention typing

"%bot = new AIPlayer(){datablock = ForgeSoldierData;position = "59.2549 -155.93 44.5792";};"

in the console, however, doesn't state how to integrate it into the scenario without using the console.

Can anyone please recommend some links/books that will be able to aid with the learning process? Or perhaps shed some light on the process of creating bots? Thank you!

#1
08/03/2009 (6:51 am)
Protip:
In the editor place markers/spawnspheres around the area to use as a guide for AI spawnpoints, and name them accordingly so you know why they are there. That way you use the getposition() of the marker, which is shorter and easier than the XYZ numbers.

%bot=new AIPlayer(){datablock = ForgeSoldierData;position = botspawnpoint1.getposition();};

Throw in some triggers, have them set so that only the human player activates them. Using the function getclassname() can determine whether it's a human or AI controlled player in the trigger.
%checkclass = %obj.getclassname();
   if(%checkclass $= "player")
	{
echo("Human PLAYER in trigger");
//do something here
         }
         else
         {
echo("NOT Human PLAYER in trigger");
//do nothing
}
That way everytime the human player enters the trigger, a bot would spawn. But maybe you don't want the player running back and forth through the trigger, repeatedly spawning the same bot. Maybe you only want one bot at a time. Give the bot a name when it spawns, and then check to see if it is already alive using the function isObject().

if(!isObject(bot1))
                  {
                   %bot=new AIPlayer(bot1){datablock = ForgeSoldierData;position =botspawnpoint1.getposition();};
                   echo("bot1 spawning");
                   }
                   else
	           {
                   echo("bot1 already exists - No spawning");
                    //and do nothing
	            }

And bring it all together thus:

function aispawn1::onEnterTrigger(%this,%trigger,%obj)
{
%checkclass = %obj.getclassname();
   if(%checkclass $= "player")
	{
echo("Human PLAYER in trigger aispawn1");
         {
         if(!isObject(bot1))
			   {
                            %bot=new AIPlayer(bot1){datablock = ForgeSoldierData;position = botspawnpoint1.getposition();};
                            echo("bot1 spawning");
                            }
	                    else
	                    {
                            echo("bot1 already exists - No spawning");
                            //and do nothing
	                    }

	}
	else
	{
echo("NOT Human PLAYER in trigger");
//and do nothing
	}
   Parent::onEnterTrigger(%this,%trigger,%obj);
}

I'm on my first cuppa tea of the day, though this should all work.