IBasicRobotPeer SetFire Method Robocode Robot API for .NET
Sets the gun to Fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call GetBulletDamage(Double) for getting the damage that a bullet with a specific bullet power will do.

The specified bullet power should be between MIN_BULLET_POWER and MAX_BULLET_POWER.

Note that the gun cannot Fire if the gun is overheated, meaning that GetGunHeat  returns a value > 0.

An event is generated when the bullet hits a robot (BulletHitEvent), wall (BulletMissedEvent), or another bullet (BulletHitBulletEvent).


Bullet bullet = null;

// Fire a bullet with maximum power if the gun is ready 
if (GetGunHeat() == 0)
    bullet = SetFireBullet(Rules.MAX_BULLET_POWER);
// Get the velocity of the bullet 
if (bullet != null)
    double bulletVelocity = bullet.Velocity;

Namespace: Robocode.RobotInterfaces.Peer
Assembly: robocode (in robocode.dll) Version:

Bullet SetFire(
	double power


Type: OnlineSystem Double
The amount of energy given to the bullet, and subtracted from the robot's energy.

Return Value

Type: Bullet
See Also