GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizgame/mount

Universal mount and vehicle projectile stepping with real target and terrain hit detection.

gizlang
import * as Mount from "gizgame/mount";

Types

MountShot

gizlang
type MountShot = { pos: Point3; vel: Point3; life: f64; kind: string; damage: i64; radius: f64; }

An active projectile fired from a mount or vehicle.

  • pos: gizlang_geometry.Point3
  • vel: gizlang_geometry.Point3
  • life: f64
  • kind: string
  • damage: i64
  • radius: f64

ShotTarget

gizlang
type ShotTarget = { id: i64; pos: Point3; radius: f64; }

A targetable entity in world space.

  • id: i64
  • pos: gizlang_geometry.Point3
  • radius: f64

ShotHit

gizlang
type ShotHit = { targetId: i64; pos: Point3; damage: i64; kind: string; }

A confirmed projectile hit on a target.

  • targetId: i64
  • pos: gizlang_geometry.Point3
  • damage: i64
  • kind: string

ShotStep

gizlang
type ShotStep = { shots: Vec<MountShot>; hits: Vec<ShotHit>; groundHits: Vec<Point3>; }

Result of stepping all active mount projectiles by dt.

  • shots: Vec<M233.MountShot>
  • hits: Vec<M233.ShotHit>
  • groundHits: Vec<gizlang_geometry.Point3>

Functions

fireMountShot

gizlang
function fireMountShot(origin: Point3, dirX: f64, dirZ: f64, pitch: f64, speed: f64, kind: string, damage: i64 = 25, radius: f64 = 1.6, life: f64 = 1.8): MountShot

Constructs a projectile fired from origin along forward (dirX, dirZ) and pitch angle.

Effects: fail.

stepMountShots

gizlang
function stepMountShots(shots: Vec<MountShot>, targets: Vec<ShotTarget>, dt: f64, groundY: (x: f64, z: f64) => f64): ShotStep

Advances mount projectiles and detects hits against targets and ground height.

Effects: fail, read, write, console, io, alloc.