![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
Tip #3 - Weapon Noise |
Ever wanted robots which can hear you fire your gun and react, but only within a certain range? Well here it is.
The inspiration for this engine came from Goldeneye on the N64. A "weapon noise" engine like this could add a nice, realistic touch to your action game. It will feel more realistic if you can't pummel an enemy with a rocket launcher from 5 spaces away, and will make your AI seem much more intelligent with only a few simple additions. Making a weapon noise engine is actually fairly simple, as long as you know how to corrolate the Robotic together. Our first robot is the weapon. As far as the engine is concerned, it just sets the noise value in a counter (SET "weapon noise" #). The next robot is the enemy itself, which isn't quite that simple. Its first loop will check to see if the player is pressing all the appropriate keys for shooting:
: "lp" IF spacepressed "lp-a" WAIT 1 GOTO "lp" : "lp-a" IF leftpressed "psht" IF rightpressed "psht" IF uppressed "psht" IF downpressed "psht" WAIT 1 IF spacepressed "lp-a" GOTO "lp" Now that the player has shot a bullet, we check to see if the enemy "heard" it (by seeing if "playerdist" is less than or equal to "weapon noise"):
Now we fill in the enemy AI under the "attack" label... but that's another tip-of-the-week. :) |