Game Development Community

Spawn Point help

by Tom Biagioni · in Torque Game Engine · 02/10/2009 (11:31 am) · 7 replies

lol ok after a few days of searching the site, i couldnt find anything to solve my problem. How would i go about setting up a spawn point that spawns an AI? I want specific spots and such. I just cannot figure out how to get ai to spawn when game starts. I do know how to set up triggers that spawn then, but i want them to spawn on there own.

#1
02/10/2009 (11:47 am)
I suggest checking out the aiPlayer.cs script in the starter.fps example.

The function AIManager::spawn(%this) should point you in the right direction.
It allows you to spawn an AI player on a named path.
#2
02/10/2009 (12:14 pm)
Hey Bill. How would i go about getting this function executed when the game starts? This is the problem im having, i cant get that function to execute unless i type it in the console. Do i put it somewhere in game.cs?
#3
02/10/2009 (1:04 pm)
maybe i could set a marker and point the spawn to the marker, and place it in the on level loaded fnction in game.cs
#4
02/10/2009 (5:03 pm)
Look for
// Start the AIManager
   new ScriptObject(AIManager) {};
   MissionCleanup.add(AIManager);
   AIManager.think();

It should be located in TGE_1_5_2\example\starter.fps\server\scripts\game.cs in function startGame().

If it is not there then added it to the end of that function and make sure
exec("./aiPlayer.cs");
is in the onServerCreated() function.

If you step through the AIManager code starting at AIManager.think you should get an idea of how a Aiplayer is created.

AIManager has only 2 functions. AIManager.think and AIManager.spawn.

AIManager.think simple checks to see if the aiplayer is an object in the game. If not, it uses AIManager.spawn to crates a new AIplayer with
%player = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");

Which takes 2 arguments, "Kork" and "MissionGroup/Paths/Path1". The first one assigns the name to the AIplayer and the second tells it which path to spawn on and then start to follow that path.
It also mount a weapon and adds some ammo to the AIplayer.

If the AIplayer exist it schedules another AIManager.think to run in about 1/2 a second.
So if you wanted to put some logic to your AIplayer AIManager.think would be a good place to start.


Sorry it took so long to reply. My real life keeps getting in the way of my fun.
#5
02/10/2009 (9:23 pm)
wow thanks for the reply :) I cant get anything to spawn though. Here what i have set for the path function

function AIManager::spawn(%this)
{
%player = AIPlayer::spawnOnPath("Kork","path");
%player.followPath("path",-1);
%player.mountImage(CrossbowImage,0);
%player.setInventory(CrossbowAmmo,1000);
return %player;
}

#6
02/10/2009 (9:30 pm)
well i can get him to spawn in console with
%player = AIPlayer::spawnOnPath("Kork",path);
#7
02/10/2009 (10:30 pm)
http://www.garagegames.com/community/blogs/view/15961

that resourced work good for me. Sets up spawn points. Im gonna build upon it