code wiki / (root) / nx_world_event.nx

nx_world_event.nx

buildroot/runtime/nx_world_event.nx

27580 B605 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic world
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_hal.nx nx_tier.nx nx_world_event.nx

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

main nx_world_event_kind_is_val nx_hal_exit nx_hal_active_shim nx_hal_exit_linux nx_hal_exit_bare_metal nx_hal_exit_nishi_silicon nx_world_event_decay_facto sys_mmap nx_world_event_write nx_world_event_contributio nx_world_event_decay_facto ↻ _we_impact_shape _we_volcanic_shape _we_radial_parabolic _we_earthquake_shape _we_flood_shape nx_world_event_biome_at nx_world_event_decay_facto ↻ nx_world_event_sum_contrib nx_world_event_contributio ↻

structs

none

consts

69const NX_MAGIC_11025: i64 = 11025
70const NX_MAGIC_10000: i64 = 10000
71const NX_MAGIC_1100: i64 = 1100
72const NX_MAGIC_7000: i64 = 7000
73const NX_MAGIC_1000000: i64 = 1000000
74const NX_MAGIC_3505: i64 = 3505
75const NX_MAGIC_3495: i64 = 3495
76const NX_MAGIC_22000: i64 = 22000
77const NX_MAGIC_19000: i64 = 19000
78const NX_MAGIC_20000: i64 = 20000
79const NX_MAGIC_16000: i64 = 16000
80const NX_MAGIC_17000: i64 = 17000
81const NX_MAGIC_5000: i64 = 5000
82const NX_MAGIC_2000: i64 = 2000
83const NX_MAGIC_12750: i64 = 12750
84const NX_MAGIC_12850: i64 = 12850
87const NX_WE_Q: nx_int = 16384
90const NX_WE_STRIDE: nx_int = 8
93const NX_WE_OFF_KIND: nx_int = 0
94const NX_WE_OFF_TIME: nx_int = 1
95const NX_WE_OFF_CX: nx_int = 2
96const NX_WE_OFF_CY: nx_int = 3
97const NX_WE_OFF_RADIUS: nx_int = 4
98const NX_WE_OFF_INTENSITY: nx_int = 5
99const NX_WE_OFF_DECAY_AGE: nx_int = 6
100const NX_WE_OFF_META: nx_int = 7
105const NX_WORLD_EVENT_IMPACT: nx_int = 0 // comet / asteroid hit
106const NX_WORLD_EVENT_VOLCANIC: nx_int = 1 // eruption builds cone + caldera
107const NX_WORLD_EVENT_EARTHQUAKE: nx_int = 2 // fault uplift (bidirectional displacement)
108const NX_WORLD_EVENT_FLOOD: nx_int = 3 // sediment deposit in low areas
109const NX_WORLD_EVENT_TERRAFORM_RAISE: nx_int = 4 // god/wizard radial uplift
110const NX_WORLD_EVENT_TERRAFORM_LOWER: nx_int = 5 // god/wizard radial depression
111const NX_WORLD_EVENT_TERRAFORM_SCORCH: nx_int = 6 // biome shift to desert (no height change)
112const NX_WORLD_EVENT_TERRAFORM_BLOOM: nx_int = 7 // biome shift to verdant (no height change)
114const NX_WORLD_EVENT_KIND_COUNT: nx_int = 8

functions

117func nx_world_event_kind_is_valid(k: nx_int) -> nx_int
called by 1: main
132func nx_world_event_write(
called by 1: main
165func nx_world_event_decay_factor_q14(
184func _we_impact_shape(
218func _we_volcanic_shape(
248func _we_radial_parabolic(
266func _we_earthquake_shape(
307func _we_flood_shape(
326func _we_biome_shift_zero_height() -> nx_int
337func nx_world_event_biome_at(
385func nx_world_event_contribution(
433func nx_world_event_sum_contribution(
called by 1: main calls 1: nx_world_event_contribution
451func main() -> i64