Help setting a bot to fire
by Jonny · in Torque Game Engine · 07/25/2006 (4:16 pm) · 10 replies
Hi, I dont yet own the SDK so I have no access to source code or the more detailed parts of this forum. I am one of the many people who mod Realm Wars and I have created a bot (of some description) that I want to be able to shoot. I have a mounted crossbow and I am trying to use
$bot.setImageTrigger(0,true);
in the Bot creation code but it does not seem to work. I also tried it with in a trigger (using %obj) but still no luck. Could the problem be that the bot has no where to Aim? since RW doesnt have a working AI script I cannot use any of the setAimLocation or anything like that. I know it is possible because it has been done before but I can think how it would be done apart from this way?
Id be very grateful if someone could help. Im sure this would help others aswell.
thanks, Jon.
$bot.setImageTrigger(0,true);
in the Bot creation code but it does not seem to work. I also tried it with in a trigger (using %obj) but still no luck. Could the problem be that the bot has no where to Aim? since RW doesnt have a working AI script I cannot use any of the setAimLocation or anything like that. I know it is possible because it has been done before but I can think how it would be done apart from this way?
Id be very grateful if someone could help. Im sure this would help others aswell.
thanks, Jon.
About the author
#2
07/26/2006 (2:30 am)
The bool value didnt work. Any other ideas?
#3
No. The weapon is fired in the direction of the muzzleVector so you do not have to aim, it should still fire.
- are both correct syntax. You're probably not passing the correct bot ID. To make matters a little more simple, give the bot a name. For example:
Then:
If the above does not work for you, then it's probably an error somewhere where you create your AIPlayer, in which case you should post the code here. If the above does work, then you need to take a look at how you passed the ID to $bot.
Have fun!
07/26/2006 (5:00 am)
Quote:
Could the problem be that the bot has no where to Aim?
No. The weapon is fired in the direction of the muzzleVector so you do not have to aim, it should still fire.
$bot.setImageTrigger(0,true); // and Babaganush.setImageTrigger(0,1);
- are both correct syntax. You're probably not passing the correct bot ID. To make matters a little more simple, give the bot a name. For example:
new AIPlayer ( Jonny )
Then:
Jonny.setImageTrigger ( 0, true );
If the above does not work for you, then it's probably an error somewhere where you create your AIPlayer, in which case you should post the code here. If the above does work, then you need to take a look at how you passed the ID to $bot.
Have fun!
#4
Anyway heres the code:
This is in a function called createBot and the local variable %spawnBot is the position returned from picking a random spawnsphere using a function. Hope someone can point out what Iv done wrong here.
07/26/2006 (8:43 am)
Ok I tried what you suggested and still no luck. This is the code I am using to set the bot up, I havnt added the actual spawn code since there was no point. I know the global variable $bot works since Ive used it in a trigger. Could it be that its using the player datablock instead or another one? I can't create another because I dont have the source...Anyway heres the code:
// Create the player object
$bot = new Player() {
dataBlock = orc;
};
$FlagSlot = 2;
// default ammo/weapon gift.
$bot.setInventory(Crossbow,1);
$bot.setInventory(CrossbowAmmo,20);
$bot.setInventory(Flag1,1);
$bot.mountImage(Flag1.image, $FlagSlot);
$bot.use(Crossbow);
//commandToClient(%this,'SetWeaponMappings',"orc");
MissionCleanup.add($bot);
//Bot setup
$bot.setTransform(%spawnBot);
//%bot.setShapeName("");
$bot.setImageTrigger(0,1);This is in a function called createBot and the local variable %spawnBot is the position returned from picking a random spawnsphere using a function. Hope someone can point out what Iv done wrong here.
#5
07/26/2006 (8:50 am)
Thought you were making an AIPlayer, not a new Player()..
#6
07/26/2006 (9:01 am)
Try separating player creation and weapon firing into two separate functions.
#7
setImageTrigger should work no matter if it's a AIPlayer or a Player though you will have some trouble making it work like a bot if you don't use AIPlayer.
Anyway, to your problem:
You're asking the game to fire a weapon on slot 0. You got a flag on slot 2, but nothing on slot 0.
Edit: Incase it's not obvious, you either need to mount something in slot 0, or change your setImageTrigger call to use slot 2 (the flag, in your example).
07/26/2006 (9:02 am)
@Jonny:setImageTrigger should work no matter if it's a AIPlayer or a Player though you will have some trouble making it work like a bot if you don't use AIPlayer.
Anyway, to your problem:
You're asking the game to fire a weapon on slot 0. You got a flag on slot 2, but nothing on slot 0.
Edit: Incase it's not obvious, you either need to mount something in slot 0, or change your setImageTrigger call to use slot 2 (the flag, in your example).
#8
Jon
EDIT: Thanks soo much. Ive now set up a scheduled function to make him fire when I want!
07/26/2006 (12:54 pm)
Ahh that makes alot of sense now I look at it! So I should just use $bot.mountImage("crossbowImage",0);? Will this effect the crossbow which I can already see in game? Unfortunately there is no AI player in RW so I have to use this player class. I dont want it to run around or anything so a player class is fine... Thanks for all the help!Jon
EDIT: Thanks soo much. Ive now set up a scheduled function to make him fire when I want!
#9
07/26/2006 (1:47 pm)
I take it you solved it? Congrats! :)
#10
07/26/2006 (2:20 pm)
Good job. Personally I like to give all my bots names and have them scheduled accordingly though in the long run I'm not sure it's the best way.
Torque Owner Matt Vitelli