Game Development Community

Firing a burst in script

by Lee Latham · in Torque Game Engine · 11/27/2007 (11:58 pm) · 4 replies

I'm sorry to ask such a silly question, but studying the scripts and forums yields no answer, and the trigger system continues to befuddle me.

I have a bot I would like to fire a 4 round burst. I know that to get him to fire once I can do something like:

%obj.setImageTrigger(0,true);

But how can I get, say, a 4 round burst? I tried:

%obj.setImageTrigger(0,true);
%obj.setImageTrigger(0,false);
%obj.setImageTrigger(0,true);
%obj.setImageTrigger(0,false);
%obj.setImageTrigger(0,true);
%obj.setImageTrigger(0,false);

Which does not work--I think because the function is executing within a single process tick. And it's a bit ugly, anyway. Is there an elegant way to do this?

Any input would be greatly appreciated!

#1
11/28/2007 (5:56 am)
Take a look at the state machine in crossbow.cs. Just add a few more firing states to it making sure each one points to the next in the sequence and the last one returns to the ready state.

If you need to be able to do single shot and burst then take a look at this.
#2
11/28/2007 (11:37 am)
Hmmm, thanks for that. I guess what I'm looking for is not exactly a new mode of fire, but a way for the bot to emulate holding the mouse button down for a bit, though. Or is this what you're trying to tell me?
#3
11/29/2007 (3:28 am)
Well, somewhere in your AIPlayer scripts there should be a call to setImageTrigger(0,true), like you have above. The trigger will be held down as long as you don't call it again with false. If you go into the console and type [AIPlayer].setImageTrigger(0,true);, then they'll just keep firing until you tell them to stop.
If you want them to fire a burst in script, simply call your setImageTrigger(0,true) ad normal, then schedule the false call however long you want your burst to be.
#4
11/30/2007 (4:33 pm)
@Daniel: Oooookay. I see it now. I think I was confused because the true and false settings were in different functions, so I didn't realize they were directly related.

I think I get it now--thanks!