AdvancedRobot 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 Rules.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 GunHeat returns a value > 0.

An event is generated when the bullet hits a robot, wall, or another bullet.

Examples

// Fire a bullet with maximum power if the gun is ready 
if (GunGeat == 0)
{
    SetFire(Rules.MAX_BULLET_POWER);
}
...
Execute();

Namespace: Robocode
Assembly: robocode (in robocode.dll) Version: 1.9.3.0
Syntax

public void SetFire(
	double power
)

Parameters

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