Modules / World & ground

cover3dplugin

Where a body can stand out of a threat's sight, behind the solids on the ground.

Putting it in a scene

cover3d has no row, no prefab and nothing drawn. The scene names where its solids come from, and a rule asks it for cover, handing every number with the question.

"world": {
  "cover3d": { "mods": { "solids": "scatter3d" } }
}
import { spots } from '#plugins/cover3d/cover3d.sim.ts'

const hides = spots(w, [me.pos[0], me.pos[2]], [foe.pos[0], foe.pos[2]], { reach: 20, radius: 0.4, low: 1.6 })

Properties

Read from world.cover3d.

.mods : { solids }

The plugin that answers which solids stand near a point (see Mods). A scene that asks for cover without one throws.

Methods

From #plugins/cover3d/cover3d.sim.ts, called by a rule.

spots( w, at, threat, { reach, radius, low } ) : { at, tall, far }[]

Every place within reach metres of at where a solid hides a body from threat, nearest to at first. at and threat are [x, z] in metres.

A spot is on the line from the threat through a solid's centre, past the centre by the solid's radius plus radius, the body's own, so the body stands against the solid's far side. Only solids at least low metres tall whose centre is within reach count.

FieldMeaning
at[x, z] of the spot, in metres.
tallThe height of the solid over the ground, in metres. Infinity for a solid with no height given.
farMetres from at to the spot.

A line from the threat to the spot at any height under tall meets the solid first. The ground between the two is not checked, so a hill can still hide or reveal the body.

Mods

Name them in world.cover3d.mods.

  • scatter3d
    solids: the trees and boulders scatter3d stands on the ground, each a circle with a radius and a height.

In the guide