How to get bot to shoot
by Jim Klein · in Technical Issues · 04/25/2006 (1:48 pm) · 11 replies
How do I get my bot to shoot?? I followed a tutorial that makes one bot follow another bot with a crossbow and he supposed to shoot at him. It doesn't work. Here's the code, could someone tell me what I'm doing wrong. Thanks.
function AIManager::spawn( %this )
{
// Bot_1 simply spawns without a path to follow. Since he has no path to
// follow, he'll simply spawn at the same spot that you do. This means that
// you'll have to move around to see him when the game first starts because
// he'll be right on top of you.
%bot = AIPlayer::spawn( "Bot_1", pickSpawnPoint() );
%bot.setName(ono);
%bot.mountImage(CrossbowImage,0);
%bot.incInventory(CrossbowAmmo, 50 );
// Bot_2 has a path to follow, so we'll help him out by having him spawn
// by the Path's first Path Marker. Once he spawns, he'll begin to follow
// the path using the A.I. helper functions defined here in this file.
// %bot = AIPlayer::spawn( "Bot_2", pickSpawnPoint() );
%bot = AIPlayer::spawnOnPath( "Bot_2", "MissionGroup/myPath" );
%bot.followPath( "MissionGroup/myPath", -1 );
%bot.setName(Dirk);
ono.setAimObject(Dirk); //ono looks at Dirk
ono.setImageTrigger(0,1); //ono fires at Dirk??
function AIManager::spawn( %this )
{
// Bot_1 simply spawns without a path to follow. Since he has no path to
// follow, he'll simply spawn at the same spot that you do. This means that
// you'll have to move around to see him when the game first starts because
// he'll be right on top of you.
%bot = AIPlayer::spawn( "Bot_1", pickSpawnPoint() );
%bot.setName(ono);
%bot.mountImage(CrossbowImage,0);
%bot.incInventory(CrossbowAmmo, 50 );
// Bot_2 has a path to follow, so we'll help him out by having him spawn
// by the Path's first Path Marker. Once he spawns, he'll begin to follow
// the path using the A.I. helper functions defined here in this file.
// %bot = AIPlayer::spawn( "Bot_2", pickSpawnPoint() );
%bot = AIPlayer::spawnOnPath( "Bot_2", "MissionGroup/myPath" );
%bot.followPath( "MissionGroup/myPath", -1 );
%bot.setName(Dirk);
ono.setAimObject(Dirk); //ono looks at Dirk
ono.setImageTrigger(0,1); //ono fires at Dirk??
#2
04/25/2006 (3:51 pm)
Do search for AIGuard, that real good source to start with. It work like charm.
#3
04/26/2006 (8:01 pm)
Pasting ono.setImageTrigger(0,1); in console does nothing. As for AIGuard , I have tried that tutorial but oculdn't get it to work. I think I needed to recompile but I have no idea how to do that/what it is talking about. Could someone point me in the right direction as far as recompiling goes? If I get the A.I. guard to work, I think all of my problems will be solved.
#4
04/26/2006 (9:09 pm)
For recompiling, you need an IDE like Torsion or TorqueDev - you open the code you want to recompile in one of those programs and make the changes you want to make. You should be able to easily find the compile button.
#5
And then when I want to recompile my code at runtime I just open the console enter "qe" and press enter.
04/26/2006 (11:45 pm)
Script... is compiled by the engine and you don't need an IDE, though it's veryily recommended. You can recompile script at runtime by calling exec("~/myscript location") just like in the .cs files. When debugging or tweaking code on the fly, I often write a small function that exec's my working files like:function qe(){
exec("./player.cs");
}And then when I want to recompile my code at runtime I just open the console enter "qe" and press enter.
#6
"The instruction at "0x0057a7e2" referenced memory at "0x00000000c". The memory could not be "read".
I assume this is because I have not recompiled, but I don't understand how or what needs to be recompiled!!
05/02/2006 (1:44 pm)
I still cannot figure out how to recompile. All I know is, I followed the steps in the A.I. guard tutorial up to where it tells you to open the game. When I try and load the mission, and error window pops up saying "The instruction at "0x0057a7e2" referenced memory at "0x00000000c". The memory could not be "read".
I assume this is because I have not recompiled, but I don't understand how or what needs to be recompiled!!
#7
05/02/2006 (1:45 pm)
Also, Torsion does not work- when I load some script and press the recompile button I get an error message similar to the one messaged above. So frustrating...
#8
05/02/2006 (2:02 pm)
Ok so I tried altering the starter.fps folder and now the engine actually loads. I followed the steps and placed an AIGuard marker (2 actually) into the game. I saved, exited, and then reloaded the game and went to the spot where I placed the markers. There was no A.I. no models nothing. What's going on??
#9
05/02/2006 (2:10 pm)
All I want to do is to have a bot that shoots at the player why is it so hard to do/to find the answer to?! Nothing is simple for someone who has never used Torque before, why is it so difficult to have the bot shoot at the player? Give him a gun and ammo from the start and the setImage trigger (0,1) for weapon in slot 0 fire, why doesn't that work? It's much easier and more simple that AIGuard...
#10
05/07/2006 (5:50 am)
Found out what the problem was- there was no "inventory" script in my game. So I had the gun there but it wasn't in slot "0" so when I triggere slot 0 nothing would happen because nothing was in slot 0 let alone there was no slot 0! Thank God someone finally helped me with that.
#11
Can anyone help????
05/08/2006 (8:52 pm)
Ok yeah, I'm still not able to get the bot to shoot. I know it has to be something with the inventory thing.Can anyone help????
Torque Owner Cinder Games
ono.setImageTrigger(0,1);
see what happens.
the way that code is laid out, he'd befiring the instant he was spawned.