ExPilot.Items (ExPilot v0.1.1)

Copy Markdown View Source

XPilot's items: what they are, where they appear, and what picking one up does.

Items lie on open tiles and are picked up by flying over them. Each kind has a map option for how often it appears (itemfuelpackprob and the rest, scaled by itemprobmult), and the map's maxitemdensity caps how many lie about at once.

ExPilot.Items.kinds()
ExPilot.Items.pick_up(ship, :afterburner)
ExPilot.Items.kit(arena)
ExPilot.Items.spawn(items, arena, rng, dt, options)

Summary

Functions

What a ship leaves on the floor where it died: each of its items and armour layers, with probability prob, as an item lying at pos.

Whether ship has at least one of kind.

Every kind of item, in XPilot's order.

What every ship starts and respawns with on arena: initialfuel and the initial… counts, in the shape ExPilot.Ship.equip/2 takes.

The map option that sets how often kind appears.

Give ship what kind does.

Let time pass for the items lying on arena: some expire, and with the map's probabilities a new one may appear on an open tile.

Take one of kind from ship; unchanged when it has none.

The item at pos within reach of a ship there, and the rest.

Types

item()

@type item() :: %{pos: {number(), number()}, kind: kind(), ttl: float()}

kind()

@type kind() ::
  :fuel
  | :tank
  | :ecm
  | :armor
  | :mine
  | :missile
  | :cloak
  | :sensor
  | :wideangle
  | :rearshot
  | :afterburner
  | :transporter
  | :mirror
  | :deflector
  | :hyperjump
  | :phasing
  | :laser
  | :emergency_thrust
  | :emergency_shield
  | :tractor_beam
  | :autopilot

Functions

drop(items, ship, prob, rng)

@spec drop([item()], ExPilot.Ship.t(), float(), Cauldron2D.Rng.t()) ::
  {[item()], Cauldron2D.Rng.t()}

What a ship leaves on the floor where it died: each of its items and armour layers, with probability prob, as an item lying at pos.

Returns {items, rng} with the dropped items added to items.

has?(ship, kind)

@spec has?(ExPilot.Ship.t(), kind()) :: boolean()

Whether ship has at least one of kind.

kinds()

@spec kinds() :: [kind()]

Every kind of item, in XPilot's order.

kit(arena)

@spec kit(ExPilot.Map.t()) :: %{
  fuel: float(),
  items: %{required(kind()) => non_neg_integer()}
}

What every ship starts and respawns with on arena: initialfuel and the initial… counts, in the shape ExPilot.Ship.equip/2 takes.

option(kind)

@spec option(kind()) :: atom()

The map option that sets how often kind appears.

pick_up(ship, kind)

@spec pick_up(ExPilot.Ship.t(), kind()) :: ExPilot.Ship.t()

Give ship what kind does.

A fuel pack fills the tank by 500; a tank adds 500 to the tank's capacity and fills it; armour adds a layer that absorbs one shot; every other kind adds one to the ship's count of it.

spawn(items, arena, rng, dt, options)

@spec spawn([item()], ExPilot.Map.t(), Cauldron2D.Rng.t(), float(), map()) ::
  {[item()], Cauldron2D.Rng.t()}

Let time pass for the items lying on arena: some expire, and with the map's probabilities a new one may appear on an open tile.

Returns {items, rng}.

spend(ship, kind)

@spec spend(ExPilot.Ship.t(), kind()) :: ExPilot.Ship.t()

Take one of kind from ship; unchanged when it has none.

take_at(items, arg)

@spec take_at([item()], {number(), number()}) :: {item() | nil, [item()]}

The item at pos within reach of a ship there, and the rest.