nx_world_event.nx
buildroot/runtime/nx_world_event.nx
about
nx_world_event.nx -- dynamic world events: comets hit, volcanoes
erupt, wizards terraform. The DYNAMIC layer that makes procgen
worlds feel ALIVE rather than static.
Per user 2026-05-15: "comets hitting the earth randomly and
volcanoes going off etc our 14 day approach should really drive a
real immersion... even if fantasy where a real powerful wizard or
god could terraform."
Captures the SAME TYPE OF CAUSAL LOGIC that solar-system bodies
have (impacts pock the surface; volcanism builds cones; tectonic
stress lifts mountains; floods carve channels), generalised so a
fantasy world's wizard / god / player can drive the same kinds of
mutations. Not solar-system-specific.
Static landmarks (Olympus Mons, Caloris Basin) live in
nx_anchor_feature + nx_body_anchors. This primitive captures
EVENTS THAT HAPPENED IN THE WORLD'S HISTORY -- with a time stamp
and a decay model so old impacts gradually erode back toward
baseline.
Event record (8 i64 fields):
rec[0] = kind (NX_WORLD_EVENT_*)
rec[1] = time_q14 when the event happened (arbitrary
unit; caller defines the time scale)
rec[2] = cx_q14 position x in world coords
rec[3] = cy_q14 position y in world coords
rec[4] = radius_q14 characteristic affected radius
rec[5] = intensity_q14_m peak elevation change (positive); the
sign is set by the kind (impacts dig
down, eruptions build up)
rec[6] = decay_age_q14 how long the event takes to erode back
to baseline (older than this -> 0
contribution). Setting decay_age to a
very large value gives "permanent"
features.
rec[7] = meta kind-specific extra parameter
(orientation, asymmetry seed, biome
shift kind, etc.)
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_hal.nxnx_tier.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 69 | const NX_MAGIC_11025: i64 = 11025 |
| 70 | const NX_MAGIC_10000: i64 = 10000 |
| 71 | const NX_MAGIC_1100: i64 = 1100 |
| 72 | const NX_MAGIC_7000: i64 = 7000 |
| 73 | const NX_MAGIC_1000000: i64 = 1000000 |
| 74 | const NX_MAGIC_3505: i64 = 3505 |
| 75 | const NX_MAGIC_3495: i64 = 3495 |
| 76 | const NX_MAGIC_22000: i64 = 22000 |
| 77 | const NX_MAGIC_19000: i64 = 19000 |
| 78 | const NX_MAGIC_20000: i64 = 20000 |
| 79 | const NX_MAGIC_16000: i64 = 16000 |
| 80 | const NX_MAGIC_17000: i64 = 17000 |
| 81 | const NX_MAGIC_5000: i64 = 5000 |
| 82 | const NX_MAGIC_2000: i64 = 2000 |
| 83 | const NX_MAGIC_12750: i64 = 12750 |
| 84 | const NX_MAGIC_12850: i64 = 12850 |
| 87 | const NX_WE_Q: nx_int = 16384 |
| 90 | const NX_WE_STRIDE: nx_int = 8 |
| 93 | const NX_WE_OFF_KIND: nx_int = 0 |
| 94 | const NX_WE_OFF_TIME: nx_int = 1 |
| 95 | const NX_WE_OFF_CX: nx_int = 2 |
| 96 | const NX_WE_OFF_CY: nx_int = 3 |
| 97 | const NX_WE_OFF_RADIUS: nx_int = 4 |
| 98 | const NX_WE_OFF_INTENSITY: nx_int = 5 |
| 99 | const NX_WE_OFF_DECAY_AGE: nx_int = 6 |
| 100 | const NX_WE_OFF_META: nx_int = 7 |
| 105 | const NX_WORLD_EVENT_IMPACT: nx_int = 0 // comet / asteroid hit |
| 106 | const NX_WORLD_EVENT_VOLCANIC: nx_int = 1 // eruption builds cone + caldera |
| 107 | const NX_WORLD_EVENT_EARTHQUAKE: nx_int = 2 // fault uplift (bidirectional displacement) |
| 108 | const NX_WORLD_EVENT_FLOOD: nx_int = 3 // sediment deposit in low areas |
| 109 | const NX_WORLD_EVENT_TERRAFORM_RAISE: nx_int = 4 // god/wizard radial uplift |
| 110 | const NX_WORLD_EVENT_TERRAFORM_LOWER: nx_int = 5 // god/wizard radial depression |
| 111 | const NX_WORLD_EVENT_TERRAFORM_SCORCH: nx_int = 6 // biome shift to desert (no height change) |
| 112 | const NX_WORLD_EVENT_TERRAFORM_BLOOM: nx_int = 7 // biome shift to verdant (no height change) |
| 114 | const NX_WORLD_EVENT_KIND_COUNT: nx_int = 8 |
functions
| 117 | func nx_world_event_kind_is_valid(k: nx_int) -> nx_int called by 1: main |
| 132 | func nx_world_event_write( called by 1: main |
| 165 | func nx_world_event_decay_factor_q14( |
| 184 | func _we_impact_shape( called by 1: nx_world_event_contribution |
| 218 | func _we_volcanic_shape( called by 1: nx_world_event_contribution |
| 248 | func _we_radial_parabolic( called by 1: nx_world_event_contribution |
| 266 | func _we_earthquake_shape( called by 1: nx_world_event_contribution |
| 307 | func _we_flood_shape( called by 1: nx_world_event_contribution |
| 326 | func _we_biome_shift_zero_height() -> nx_int |
| 337 | func nx_world_event_biome_at( |
| 385 | func nx_world_event_contribution( |
| 433 | func nx_world_event_sum_contribution( |
| 451 | func main() -> i64 |