mwg API
    Preparing search index...

    Function coneSector

    • Every cell inside a circular sector: an arc of degrees centred on the aim, rays cast across it every 0.5 degrees, each ray clamped to range and stopped by a wall. The union of those rays is the sector, so a wall in the arc shadows everything behind it while the rest of the cone still reaches.

      This is a different shape from coneCells, not a better one. A sector is aimed at an angle and keeps it: a breath weapon, a searchlight, a blast of gas. coneCells snaps the aim to one of the eight directions and widens a linear spray from it, which is what a wand fired down a corridor wants. coneSector needs the level (that is what stops its rays), so it is a plain function rather than one of AreaShape's kinds, whose resolver must work without one; a game calls it wherever it would call resolveAreaOnLevel. The aim's own cell is not in the result, so a caster is never inside its own cone.

      Parameters

      Returns Step[]

      import { coneSector, Level, WALL, FLOOR } from '@datamoc/mw_games/roguelike';

      const level = new Level(20, 20, [WALL, FLOOR], 1);
      // a 60-degree cone, 6 cells deep, aimed east from (4, 10)
      const cells = coneSector(level, { x: 4, y: 10 }, { x: 10, y: 10 }, { degrees: 60, range: 6 });