Spawn points?
by John Bolten · in Technical Issues · 10/12/2008 (4:13 am) · 6 replies
Hi, sorry if this is the wrong section....Im very new with torque i've managed to get my way around things hardly knowing any c++ ( I LOVE TORQUE) , I figured out the basic commands for the A.I... Like moving towards the player shooting at him reloding .... but before I start programming more advanced A.I .
I really need to figure out a method of spawn points.... This may be a dumb question but... what I want to do...
Is have my "spawn shape" or "node" to placed within the world editor inside a sim group (spawnpts) " or similer" anyway .. I want to be able to make multiple spawn points.. each one having its own dynamic arguments something like.. oh I dont know ... %botwep ( this doesnt have to be in it)
this then (Somehow) calls the ai spawn command
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
then assigns a bot a new script if the players distance to the object is so far ( I have no idea what the function for distance to object check is "
so something like
if (distance to object < 300)
{
thebot.setMoveDestination(spawnPoint.getTransform());
}
then the rest is pretty much the same if distance is like < 100 - start shooting
To really sum it up... is there a way to assign a script to a object when its create
like when I add a spawn point into the world creator... can I make it spawn 1 bot?
to get into even more ... in other terms....
spawnShape create event:
Hi, sorry if this is the wrong section....Im very new with torque i've managed to get my way around things hardly knowing any c++ ( I LOVE TORQUE) , I figured out the basic commands for the A.I... Like moving towards the player shooting at him reloding .... but before I start programming more advanced A.I .
I really need to figure out a method of spawn points.... This may be a dumb question but... what I want to do...
Is have my "spawn shape" or "node" to placed within the world editor inside a sim group (spawnpts) " or similer" anyway .. I want to be able to make multiple spawn points.. each one having its own dynamic arguments something like.. oh I dont know ... %botwep ( this doesnt have to be in it)
this then (Somehow) calls the ai spawn command
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
then assigns a bot a new script if the players distance to the object is so far ( I have no idea what the function for distance to object check is "
so something like
if (distance to object < 300)
{
thebot.setMoveDestination(spawnPoint.getTransform());
}
then the rest is pretty much the same if distance is like < 100 - start shooting
To really sum it up... is there a way to assign a script to a object when its create
like when I add a spawn point into the world creator... can I make it spawn 1 bot?
to get into even more ... in other terms....
spawnShape create event:
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
thebot.target = player's position;
thebot.setMoveDestination (player position);
keep moving
Sorry if this is confusing im very tired i've been up all night trying to figure it out.
I really need to figure out a method of spawn points.... This may be a dumb question but... what I want to do...
Is have my "spawn shape" or "node" to placed within the world editor inside a sim group (spawnpts) " or similer" anyway .. I want to be able to make multiple spawn points.. each one having its own dynamic arguments something like.. oh I dont know ... %botwep ( this doesnt have to be in it)
this then (Somehow) calls the ai spawn command
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
then assigns a bot a new script if the players distance to the object is so far ( I have no idea what the function for distance to object check is "
so something like
if (distance to object < 300)
{
thebot.setMoveDestination(spawnPoint.getTransform());
}
then the rest is pretty much the same if distance is like < 100 - start shooting
To really sum it up... is there a way to assign a script to a object when its create
like when I add a spawn point into the world creator... can I make it spawn 1 bot?
to get into even more ... in other terms....
spawnShape create event:
Hi, sorry if this is the wrong section....Im very new with torque i've managed to get my way around things hardly knowing any c++ ( I LOVE TORQUE) , I figured out the basic commands for the A.I... Like moving towards the player shooting at him reloding .... but before I start programming more advanced A.I .
I really need to figure out a method of spawn points.... This may be a dumb question but... what I want to do...
Is have my "spawn shape" or "node" to placed within the world editor inside a sim group (spawnpts) " or similer" anyway .. I want to be able to make multiple spawn points.. each one having its own dynamic arguments something like.. oh I dont know ... %botwep ( this doesnt have to be in it)
this then (Somehow) calls the ai spawn command
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
then assigns a bot a new script if the players distance to the object is so far ( I have no idea what the function for distance to object check is "
so something like
if (distance to object < 300)
{
thebot.setMoveDestination(spawnPoint.getTransform());
}
then the rest is pretty much the same if distance is like < 100 - start shooting
To really sum it up... is there a way to assign a script to a object when its create
like when I add a spawn point into the world creator... can I make it spawn 1 bot?
to get into even more ... in other terms....
spawnShape create event:
new AIPlayer(thebot) { datablock = "PlayerBody"; position = spawnPoint.getPosition(); }
thebot.target = player's position;
thebot.setMoveDestination (player position);
keep moving
Sorry if this is confusing im very tired i've been up all night trying to figure it out.
#2
10/12/2008 (12:52 pm)
Thank you!
#3
10/12/2008 (3:06 pm)
You are quite welcome.
#4
11/02/2008 (10:40 am)
Here is a question for the same topic... Random spawnpoints between x,y of set node with multiple spawns as well as random times? Something to fill up like a forest of monsters? Instead of having a huge list of spawn points.
#5
replace this:
%i++;
%player = AIGuard::spawnAtMarker("Guard" @ %i, %targetobject);
with this:
%i++;
%title = %targetobject.getName();
%player = AIGuard::spawnAtMarker(%title, %targetobject);
and in the editor in any marker give a name '10xx: StaticShape(John)',
with this you can see the AI name in game :)
11/03/2008 (2:35 pm)
And if you like ... Johnreplace this:
%i++;
%player = AIGuard::spawnAtMarker("Guard" @ %i, %targetobject);
with this:
%i++;
%title = %targetobject.getName();
%player = AIGuard::spawnAtMarker(%title, %targetobject);
and in the editor in any marker give a name '10xx: StaticShape(John)',
with this you can see the AI name in game :)
#6
Use something like this
for(%spawns; %spawns<10; %spawns++) // 10 spawns
{
%MyXpos= getRandom(1,100); // 100 is a number, use your terrain X cordinates
%MyYpos= getRandom(1,100); // 100 is a number, use your terrain Y cordinates
%MyZpos = 50; // your ground or little up of ground
%spawnPoint = %MyXpos SPC %MyYpos SPC %MyZpos;
%player = new AiPlayer();
dataBlock = your AI Datablock;
%player.setShapeName= "IamMonster" @ %spawns;
%player.setTransform(%spawnPoint SPC "0 0 0");
return %player;
}
11/03/2008 (3:04 pm)
Kely this is easyUse something like this
for(%spawns; %spawns<10; %spawns++) // 10 spawns
{
%MyXpos= getRandom(1,100); // 100 is a number, use your terrain X cordinates
%MyYpos= getRandom(1,100); // 100 is a number, use your terrain Y cordinates
%MyZpos = 50; // your ground or little up of ground
%spawnPoint = %MyXpos SPC %MyYpos SPC %MyZpos;
%player = new AiPlayer();
dataBlock = your AI Datablock;
%player.setShapeName= "IamMonster" @ %spawns;
%player.setTransform(%spawnPoint SPC "0 0 0");
return %player;
}
Torque Owner Mike Rowley
Mike Rowley
To answer your question directly tho, yes, there is a way.
datablock StaticShapeData(AIGuardMarker) { // Mission editor category, this datablock will show up in the // specified category under the "shapes" root category. category = "AIMarker"; // Basic Item properties shapeFile = "~/data/shapes/player/player.dts"; };//The LoadEntities function replaces the markers placed in the map with the AI bots during the //mission loading. function AIGuard::LoadEntities() { //Check to see if the AIGuards are to be loaded. if ($AI_GUARD_ENABLED == true) { echo("Loading Guard entities..."); //This performs a search for all items within the radius from the starting point. //All of the items that match "AIGuardMarker" trigger a bot to be placed at the //position of the marker found. %position = "0 0 0"; %radius = 100000.0; InitContainerRadiusSearch(%position, %radius, $TypeMasks::StaticObjectType); %i=0; while ((%targetObject = containerSearchNext()) != 0) { if(%targetobject.getclassname() $= "StaticShape") { if (%targetobject.getDataBlock().getName() $= "AIGuardMarker") { %i++; %player = AIGuard::spawnAtMarker("Guard" @ %i, %targetobject); } } } } else { //echo("Guard entities disabled..."); }This is the basic setup that aiguard uses. Type aiGuard in the search bar and download the 2 resources. (guard and patrol). After reading thru them, you will have a better understanding of basic ai in torque. Of course, there are other ai resources as well. Some use A* pathfinding. Lots of things to learn from. :-)