ExPilot.Weapons (ExPilot v0.1.1)

Copy Markdown View Source

What a ship can throw besides its cannon shot: torpedoes, smart and heat missiles, mines, and the laser.

A missile is a shot with a :kind:torpedo flies straight, :smart turns toward the nearest enemy, :heat toward the nearest ship that is thrusting — and a mine is a shot that never moves and explodes on any ship but its owner's, once armed. steer/4 turns a missile each tick; laser/3 finds the first ship along a ship's heading.

ExPilot.Weapons.missile(ship, :smart, next_id, settings)
ExPilot.Weapons.mine(ship, next_id)
ExPilot.Weapons.laser(ship, ships, grid)

Summary

Functions

Whether shot is a mine that has had its second to arm.

The beam ship fires along its heading: {from, to, hit} where hit is the first living ship on the line within range, or nil, and to is where the beam stops — at that ship, at a wall, or at full range.

A mine dropped where ship is, armed after fuse seconds (a second by default).

A missile of kind leaving ship along its heading.

Turn a homing missile toward its target for dt seconds; other shots are unchanged.

Types

kind()

@type kind() :: :shot | :torpedo | :smart | :heat | :mine

Functions

armed?(arg1)

@spec armed?(map()) :: boolean()

Whether shot is a mine that has had its second to arm.

laser(ship, ships, grid)

The beam ship fires along its heading: {from, to, hit} where hit is the first living ship on the line within range, or nil, and to is where the beam stops — at that ship, at a wall, or at full range.

mine(ship, id, fuse \\ 1.0)

@spec mine(ExPilot.Ship.t(), pos_integer(), float()) :: map()

A mine dropped where ship is, armed after fuse seconds (a second by default).

missile(ship, kind, id, settings)

@spec missile(ExPilot.Ship.t(), :torpedo | :smart | :heat, pos_integer(), map()) ::
  map()

A missile of kind leaving ship along its heading.

steer(missile, ships, dt, speed)

@spec steer(map(), [ExPilot.Ship.t()], float(), float()) :: map()

Turn a homing missile toward its target for dt seconds; other shots are unchanged.