Does anyone have aiplayers spawned from script??
by Mike Wigand · in Torque Game Engine · 02/07/2002 (8:12 am) · 38 replies
If so how would I go about scripting aiPlayers to show up when the Player connects to the game?
#2
02/07/2002 (1:42 pm)
Thank you...
#3
Sorry to cross-link this-- missed Mike's post at www.garagegames.com/index.php?sec=mg&mod=forums&page=edit.post&qid=37702
06/27/2002 (11:05 pm)
EDITSorry to cross-link this-- missed Mike's post at www.garagegames.com/index.php?sec=mg&mod=forums&page=edit.post&qid=37702
#4
also, the function aiAddPlayer seems kinda limiting since the only feild it passes is the name of the character... is there another function which would let me pass what type of character I'd like the bot to be (like pass the characters datablock or something)? this seems to creat the type of player the user is.
sorry if all this just sounded dumb, this is my first day looking at AI
06/21/2003 (8:13 pm)
Xavier, when I tried to call aiAddPlayer from GameConnection::onclientEnterGame, it froze my game up while loading the level, I used "$myBot01 = aiAddPlayer("Bill Gates");" like stefan has in his tutorial. This thread is a year old, did something change in the engine with the aiplayer class that wont let me do this anymore? Am I just doing it wrong?also, the function aiAddPlayer seems kinda limiting since the only feild it passes is the name of the character... is there another function which would let me pass what type of character I'd like the bot to be (like pass the characters datablock or something)? this seems to creat the type of player the user is.
sorry if all this just sounded dumb, this is my first day looking at AI
#5
06/21/2003 (10:02 pm)
Ok, after a couple hours of looking through code and scripts I figured out how to change the type of player, but my first question still remains (I'm currently stuck messing with bots strictly through the console)
#6
06/22/2003 (2:20 am)
Yup, just tried aiAddPlayer in a fresh copy of torque... still locks it up... so I guess its not just my project
#7
so if u want an aiplayer then u have to declare the object just like any other object and set its transforms to the position u want.
like:
%player = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
};
06/22/2003 (4:33 am)
AiAddPlayer doesn't work in the head because it doesn't use "aiConnection" class any more". It uses new aiplayer class.so if u want an aiplayer then u have to declare the object just like any other object and set its transforms to the position u want.
like:
%player = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
};
#8
ok, I kinda thought it might be something like that so since writing this I've come this far...
I put that in GameConnection::onclientEnterGame... when I load up the game I get a message in the console that the bot was added (from the onAdd function in aiplayer.cs) and $enemy does exist as an aiplayer object and I can modify its variables and call methods and such, but I cant see a player (I've also tried setting its visibility to true with no results). Any idea what I'm doing wrong?
06/22/2003 (4:39 am)
Yay! someone responded!ok, I kinda thought it might be something like that so since writing this I've come this far...
$enemy = new AIPlayer() {
dataBlock = Sputnik;
// dataBlock = $pref::Player::playerClass;
aiPlayer = true;
};
// MissionCleanup.add($enemy);
// Player setup...
$enemy.onAdd("yourmom");I put that in GameConnection::onclientEnterGame... when I load up the game I get a message in the console that the bot was added (from the onAdd function in aiplayer.cs) and $enemy does exist as an aiplayer object and I can modify its variables and call methods and such, but I cant see a player (I've also tried setting its visibility to true with no results). Any idea what I'm doing wrong?
#9
06/22/2003 (7:08 am)
You have to set it's transform so it's someplace you can see it. Otherise it's at comethign silly like 0,0,0
#10
I added a couple lines that should pick a spawnpoint and then set up the enemies position to that point. Then when the enemy is added it should show up there right? cuz that doesnt seem to work. I also tried adding the line "$enemy.spawnPlayer();" but that doesnt seem to be using the $enemy object, as it ignores the enemies player datablock and just uses the users player datablock... so... what now?
06/22/2003 (7:25 am)
Ahhh, that makes sense... ok, heres what I did now$enemy = new AIPlayer() {
dataBlock = Robot;
// dataBlock = $pref::Player::playerClass;
aiPlayer = true;
};
// MissionCleanup.add($enemy);
// Player setup...
%spawnPoint = pickSpawnPoint();
$enemy.setTransform(%spawnPoint);
// $enemy.onAdd("yourmom");
$enemy.spawnPlayer();I added a couple lines that should pick a spawnpoint and then set up the enemies position to that point. Then when the enemy is added it should show up there right? cuz that doesnt seem to work. I also tried adding the line "$enemy.spawnPlayer();" but that doesnt seem to be using the $enemy object, as it ignores the enemies player datablock and just uses the users player datablock... so... what now?
#12
06/22/2003 (9:21 am)
If I remember correctly, spawnPlayer() automatically calls pickspawnpoint(), so you shouldn't have to call it again... hmmm... pickspawnpoint() simply chooses a random spawnpoint from the mission editor. If none can be found (perhaps the name of your spawn group has been changed), it will simply return a point 0,0,300. So, I would go into your mission editor and make a spawnpoint for your bot, put it in a MissionGroup by itself called "BotSpawnPoints", and make a funciton called pickBotSpawnPoint() which points to "BotSpawnPoints" to have your bot(s) spawn from. Hope this helps.
#13
@Will: thats a good idea, I'll go ahead and implement that since I will be needing it in the future anyway
06/22/2003 (10:37 am)
@Sabrecyd: I tried that, "return $enemy;" doesnt seem to do anything... what should it be doing?@Will: thats a good idea, I'll go ahead and implement that since I will be needing it in the future anyway
#14
$enemy.setTransform(%spawnPoint);
apparantly setTransform is not a valid function for an aiplayer object... so what should I be using?
06/22/2003 (10:46 am)
Hmmm, I was palying a bit more and realised that I'm getting a an error in the game script when it gets to $enemy.setTransform(%spawnPoint);
apparantly setTransform is not a valid function for an aiplayer object... so what should I be using?
#15
06/22/2003 (12:14 pm)
Hmmmm, in the script setTransform() should definately work for any child of ShapeBase. Post the exact error or email me parts of your code and I can get to the bottom of it. I have made bot-specific spawns in a few of my maps.
#16
06/22/2003 (12:47 pm)
Thanks for the offer Will! would it be cool if I zipped up my whole project and sent it to you? that would probably be the easiest way to see what I'm doing wrong (and I'd really like to get some feedback on how my games shaping up... that is if you dont mind of course). If you dont really want to mess around with all that then I'd be happy to email you portions of the scripts along with the full error report, just let me know
#17
setTransform is for the Instance not the datablock.
and why is $enemy global?
06/22/2003 (12:49 pm)
Eric, in your code are you Sure $enemy is not the datablock?setTransform is for the Instance not the datablock.
and why is $enemy global?
#18
$enemy = new AIPlayer()
I'm still getting used to this whole datablock thing and I'm still not always positive what is and isnt a datablock, but I believe that enemy is an instance of an AIPlayer object which is assigned the value of a player datablock right? Although if I was making it a datablock that would expain why setTransform is not working
as for enemy being global... I just kinda took that over from beffy's tutorial on bots. I'm still not exactly sure the reach of local variables in the scripting system, I wanted to make sure I'd have controll of the bot in the game so I left it global (also, I'm not planning on having more than one or two (three max) bots at a time, so I didnt think dealing with global variables would be a big deal... is it?). I dont really see any drawbacks to making it global (except it might be unecesary and thats just bad programming practice)... are there any?
06/22/2003 (12:58 pm)
Badguy, just look at my code up there, enemy is assigned to a new AIPlayer object isnt it? $enemy = new AIPlayer()
I'm still getting used to this whole datablock thing and I'm still not always positive what is and isnt a datablock, but I believe that enemy is an instance of an AIPlayer object which is assigned the value of a player datablock right? Although if I was making it a datablock that would expain why setTransform is not working
as for enemy being global... I just kinda took that over from beffy's tutorial on bots. I'm still not exactly sure the reach of local variables in the scripting system, I wanted to make sure I'd have controll of the bot in the game so I left it global (also, I'm not planning on having more than one or two (three max) bots at a time, so I didnt think dealing with global variables would be a big deal... is it?). I dont really see any drawbacks to making it global (except it might be unecesary and thats just bad programming practice)... are there any?
#19
I was just asking.
Im a fan of datalists.
so I like to keep like objects together
that is what I would do.
and I hate goto and global's so ..
heh anyhow its not important.
as for the $enemy yea he should be a AIPlayer instance
which has a DataBlock to store data.
so him being a player Should have that function.
something must have happened to your enemy variable.
you'll need to $enemy.dump();
and check what he is After the function call tells you he does not have the function.
and maybe before if you feel energetic.
06/22/2003 (1:18 pm)
Naw I dont think so..I was just asking.
Im a fan of datalists.
so I like to keep like objects together
that is what I would do.
and I hate goto and global's so ..
heh anyhow its not important.
as for the $enemy yea he should be a AIPlayer instance
which has a DataBlock to store data.
so him being a player Should have that function.
something must have happened to your enemy variable.
you'll need to $enemy.dump();
and check what he is After the function call tells you he does not have the function.
and maybe before if you feel energetic.
#20
and check what he is After the function call tells you he does not have the function.
and maybe before if you feel energetic.
not really sure what you meant by that, I tried dumping the variable and there wasnt a setTransform method, but there were other AIPlayer methods (like move destination and aiming and junk) and I was able to acess the aiPlayer script through the variable, so I think its a normal variable for aiPlayer... what do you think? how would I go about testing it further?
06/22/2003 (1:32 pm)
You'll need to $enemy.dump();and check what he is After the function call tells you he does not have the function.
and maybe before if you feel energetic.
not really sure what you meant by that, I tried dumping the variable and there wasnt a setTransform method, but there were other AIPlayer methods (like move destination and aiming and junk) and I was able to acess the aiPlayer script through the variable, so I think its a normal variable for aiPlayer... what do you think? how would I go about testing it further?
Torque 3D Owner Xavier "eXoDuS" Amado
Default Studio Name