Game Development Community

Behavior: Timer Shoots bug

by Steven S · in Torque Game Builder · 10/05/2007 (9:36 pm) · 3 replies

I have found what I consider to be a bug in the Timer Shoots behavior. Inside of onAddToScene the line should read:

%this.schedule(%this.fireRate * 1000, "fire");

The current code does not have the 1000, so it essentially fires immediately the first time. This results in the object getting off a round of firing before the game has really even started. I was working on an AI turret which just faces the player and uses Timer Shoots (fire rate = 5 seconds). Without the update, the player was shot at before the game even started.

I'd update the wiki, but maybe people like it this way.

I may eventually add a new behavior like Timer Shoots, but with an initial delay. Once I get a bit more familiar with TGB, I hope to add some new behaviors. I really like them and have been fiddling around with some ideas.

#1
10/06/2007 (10:41 am)
How about modifying TimerShoots to add InitialDelay as an optional parameter with a default of zero?
#2
10/06/2007 (2:52 pm)
That's what I proposed in my last paragraph. I can see, though, I wasn't very clear. Thanks for the clarification. I will definitely be implementing it that way.

I still think the stock code is incorrect. schedule() should either pass a '0' or pass the 'fireRate * 1000', but not just fireRate. Of course, the delay value will be used for my update.

I'm spending this month trying to learn TGB and get familiar with it. I'm challenging myself to learn at least ONE new thing a day. This morning I looked over the behavior callbacks and it really got me excited. After I'm done with this month long challenge, I hope to spend some specific time working on behaviors. I'd like to actually figure out a way for the turret to not shoot until the enemy is within a certain distance and other ways of adding some better realism to the AI.
#3
10/10/2007 (2:46 pm)
Hmm - I guess that was my fault. I wrote the prototype timerShoots behavior for descending space invader-type enemies, which were on a spawner, so they weren't in the scene until after the game had started. I guess whoever ported the behaviors to the release version didn't notice it either ;)

Good call, though - hopefully Matt or something will see this.