Bots /AI
by Bryce Kaminsky · in Torque Game Engine · 08/28/2004 (12:25 am) · 14 replies
Im looking to make a game like rts meets turnbased but i need to know how to go about it. I want to use the aiPlayer routine because they have physics and such but i dont know how to spawn the bots. I looked at the tutorial but i cant seem to have them added it tells me there is no such function. I'm using the release_1_1_2 i think, which ever is that latest release build 1.22 or something. Any help on this issue would be really cool.
-=Ice Out=-
-=Ice Out=-
#2
08/31/2004 (8:23 pm)
Kinda helps but im still lost.
#3
09/01/2004 (6:52 am)
What seems to be the problem ?
#4
09/01/2004 (8:02 am)
I would recommend the book 3D Game Programming All in One by Kenneth C. Finney
#5
do i need to write a script then init the script or do i type that in the console.
Alex where would i look in The book?
10/05/2004 (1:45 pm)
I have the book. But i get errors when i try to spawn the botdo i need to write a script then init the script or do i type that in the console.
Alex where would i look in The book?
#6
10/06/2004 (12:53 am)
What kind of errors do you get?
#7
10/06/2004 (11:49 am)
Something to the effect that there is no spawn function for the bot. Im not at home right now so i cannot paste it in here but basicly it tells me that it doesnt have / can't find the spawn function fo aiplayer.
#8
course mine isnt default torque but you should get the idea.
Note if you spawn all your bots to path 1 it will look like only one bot till you maually move them , you can open up the .mis and copy the the code block fro path1 paste it under path1 and the rename the new path1 to path2, then go in game and manualy move path2 in f11
hope that helps
10/06/2004 (12:15 pm)
Look, the default torque already spawns a bot for you in aimanager in aiplayer.cs, just add in more like so://ace
//this is for the aimanager
function AISpider::aiSpawnSpider(%name,%spawnPoint)
{
// Create the demo player object
%player = new AiSpider() {
dataBlock = Spider;
path = "";
};
MissionCleanup.add(%player);
%player.setSite(20);
%player.setShapeName(%name);
%player.setTransform(%spawnPoint);
return %player;
}
function AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.aiSpawnSpider ();
%this.schedule(100,think);
}
function AIManager::aiSpawnSpider(%this)
{
// An example function which creates a new AISpider object
// using the the example player datablock.
//spider5
%player = AISpider::spawnOnPath("Spider","MissionGroup/Paths/Path5");
// Player setup
%player.setMoveSpeed(1);
%player.setSite(20);
%player.setEnergyLevel(10);
%player.mountImage(noweaponImage,0);
%player.setInventory(CrossBowAmmo,10);
%player.setScanningPlayers(true);
//spider4
%player = AISpider::spawnOnPath("Spider","MissionGroup/Paths/Path4");
// Player setup
%player.setMoveSpeed(1);
%player.setSite(20);
%player.setEnergyLevel(10);
%player.mountImage(noweaponImage,0);
%player.setInventory(CrossBowAmmo,10);
%player.setScanningPlayers(true);
//spider3
%player = AISpider::spawnOnPath("Spider","MissionGroup/Paths/Path3");
// Player setup
%player.setMoveSpeed(1);
%player.setSite(20);
%player.setEnergyLevel(10);
%player.mountImage(noweaponImage,0);
%player.setInventory(CrossBowAmmo,10);
%player.setScanningPlayers(true);
//spider2
%player = AISpider::spawnOnPath("Spider","MissionGroup/Paths/Path2");
// Player setup
%player.setMoveSpeed(1);
%player.setSite(20);
%player.setEnergyLevel(10);
%player.mountImage(noweaponImage,0);
%player.setInventory(CrossBowAmmo,10);
%player.setScanningPlayers(true);
//spider1
%player = AISpider::spawnOnPath("BigSpider","MissionGroup/Paths/Path1");
// Player setup
%player.setMoveSpeed(1);
%player.setSite(20);
%player.setEnergyLevel(10);
%player.mountImage(noweaponImage,0);
%player.setInventory(CrossBowAmmo,10);
%player.setScanningPlayers(true);
return %player;
}
//end ace spawn the aiSpiderscourse mine isnt default torque but you should get the idea.
Note if you spawn all your bots to path 1 it will look like only one bot till you maually move them , you can open up the .mis and copy the the code block fro path1 paste it under path1 and the rename the new path1 to path2, then go in game and manualy move path2 in f11
hope that helps
#10
10/06/2004 (8:05 pm)
See i was looking over that i did download it but i could never figure out how you spawned them. do you need the path to be down before you can spawn the bot?
#11
copy this much of it (all i did was eliminate the running part/markers.
And paste it right under the first blocks 2 braces //};// and change path1 to path2, then go into torque and choose the .mis you edited and run it
once you get in game find the spot where path1 is, remember path2 is a duplcate, so it will be right on path one exactly the same. press f11 to open the editor, press f3 for the world inspector then find path2 on the right hand side in the list, highlight it, then press f3 for the creator , then manualy move the path2 away from path1. Then up in the left hand corner click on File, then save mission as, and save your change to the mission that you are in. Then exit torque compleatly , the next time you enter that mission your changes would be right where you left them.
10/07/2004 (5:01 am)
Yes befor you start the mission, in stronghold.mis, there is the path1, i shortened it like sonew SimGroup(Paths) {
new Path(Path1) {
isLooping = "1";
new Marker() {
position = "-167.079 -192.805 152.543";
rotation = "0.00796238 0.00220365 0.999966 74.4864";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
};copy this much of it (all i did was eliminate the running part/markers.
new Path(Path1) {
isLooping = "1";
new Marker() {
position = "-167.079 -192.805 152.543";
rotation = "0.00796238 0.00220365 0.999966 74.4864";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
};And paste it right under the first blocks 2 braces //};// and change path1 to path2, then go into torque and choose the .mis you edited and run it
once you get in game find the spot where path1 is, remember path2 is a duplcate, so it will be right on path one exactly the same. press f11 to open the editor, press f3 for the world inspector then find path2 on the right hand side in the list, highlight it, then press f3 for the creator , then manualy move the path2 away from path1. Then up in the left hand corner click on File, then save mission as, and save your change to the mission that you are in. Then exit torque compleatly , the next time you enter that mission your changes would be right where you left them.
#12
Any idea how i could get them to spawn mid game by pressing a GUI
I'm thinking i'm gonna have to make a function that spawns them and call that from the button.
10/07/2004 (4:08 pm)
Cool thanks i'll give this a shot.Any idea how i could get them to spawn mid game by pressing a GUI
I'm thinking i'm gonna have to make a function that spawns them and call that from the button.
#13
I may look into it again later on.
10/08/2004 (5:28 am)
I looked into spawning bots from the editor a while back , but could only get the player models to spawn, and not the AI part, so at this point i dont have your answer.I may look into it again later on.
#14
10/16/2004 (9:07 pm)
Thanks for all your help ace.
Torque Owner Bruno Grieco
$bot = new AIplayer()
{
position = " 0 0 0";
.... insert other properties here...
}
then you should have a think() method or similar to control it ]
$bot.think();
HTH