O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Raven Weapons
There are four weapons available. They are:
n
The Blaster: This is a bot’s default weapon. It fires green bolts of
electricity at the rate of three per second. This weapon automatically
recharges so it can never run out of ammo. It inflicts only one unit of
damage per hit.
n
The Shotgun: A shotgun can only be fired once per second. Each
cartridge contains ten balls of shot, which spread out as they leave
the gun. This means the shotgun is far more accurate and deadly at
close to medium distances than it is at long range. Each ball of shot
inflicts one unit of damage.
n
The Rocket Launcher: The rocket launcher has a firing rate of 1.5
rockets per second. The rockets travel fairly slowly and explode on
impact. Any entity caught in a rocket’s blast radius will incur ten
units of damage. Because rockets travel fairly slowly and can be eas-
ily dodged, the rocket launcher is best used as a medium range
weapon.
n
The Railgun: A railgun fires slugs at the rate of one per second. The
slugs travel almost instantaneously to the target, making this weapon
ideal for sniping and long-distance shots. (Railgun shots are only
stopped by walls, so if several bots standing in a line are hit, the slug
will penetrate all of them.)
A Raven bot starts each game holding a blaster and gains possession of the
other types of weapons by locating them on the map and running over
them. If a bot already has a weapon of the type it has run over, only the
weapon’s ammo is added to the inventory.
Each of the weapon types inherit from the
Raven_Weapon class. The pub
-
lic interface of the class looks like this:
class Raven_Weapon
{
public:
Raven_Weapon(unsigned int TypeOfGun
unsigned int DefaultNumRounds,
unsigned int MaxRoundsCarried,
double RateOfFire,
double IdealRange,
double ProjectileSpeed,
Raven_Bot* OwnerOfGun);
virtual ~Raven_Weapon(){}
//this method aims the weapon at the given target by rotating the weapon's
//owner's facing direction (constrained by the bot's turning rate). It
//returns true if the weapon is directly facing the target.
Raven: An Overview
| 301
Overview of the Game Architecture

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required