code wiki / _hdl_build / nx_creature_battle.nx
nx_creature_battle.nx
buildroot/runtime/_hdl_build/nx_creature_battle.nx
about
nx_creature_battle.nx -- a REAL, RUNNING, data-driven creature-battle CORE (one honest slice of a Pixelmon-class
backend). NOT a game, NOT s-class -- a working turn-based battle engine: integer Pokemon-style damage formula,
a type-effectiveness chart that is ACTUALLY consulted, STAB, accuracy, speed order, a highest-damage AI, faint
detection, and a text transcript. DATA-DRIVEN = the moddability axis: creatures/moves/types are DATA (i64
fields), so changing the data changes the battle -- no logic is hardcoded to a specific creature. Pure-integer,
deterministic (seeded), sovereign. HONEST SCOPE: this is the battle backend only -- overworld, capture, party,
trainer AI, NETCODE (real multiplayer), sprites/animation, UI, and content volume are NOT here. license_tier: ORIGINAL
dependencies 1 imports · 6 importers
imports: nx_syscalls.nx
imported by: nx_creature_battle_gate.nxnx_creature_game.nxnx_creature_world.nxnx_creature_world_gate.nxnx_game_breed.nxnx_m2d_engine.nx
structs
| none |
consts
| 9 | const K_MAGIC_1103515245: i64 = 1103515245 |
| 10 | const K_MAGIC_12345: i64 = 12345 |
| 11 | const K_MAGIC_32767: i64 = 32767 |
functions
| 14 | func cb_set(c: *i64, t: i64, lvl: i64, hp: i64, atk: i64, def: i64, spd: i64, name: *u8) -> i64 |
| 17 | func cb_addmove(c: *i64, mtype: i64, power: i64, acc: i64) -> i64 { let i: i64 = c[7]; c[8+i*3]=mtype; c[8+i*3+1]=power; c[8+i*3+2]=acc; c[7]=i+1; return 0 } |
| 18 | func cb_rng(s: *i64) -> i64 { var x: i64 = s[0]; x = x*K_MAGIC_1103515245 + K_MAGIC_12345; s[0]=x; return (x >> 16) & K_MAGIC_32767 } |
| 20 | func cb_tname(t: i64) -> *u8 |
| 25 | func cb_eff(at: i64, dt: i64) -> i64 |
| 35 | func cb_damage(atk: *i64, def: *i64, mtype: i64, mpow: i64, s: *i64) -> i64 |
| 48 | func cb_best(atk: *i64, def: *i64) -> i64 |
| 61 | func cb_p(buf: *u8, o: i64, s: *u8) -> i64 { var w: i64=o; var i: i64=0; while s[i]!=(0 as u8){buf[w]=s[i];w=w+1;i=i+1} return w } |
| 62 | func cb_n(buf: *u8, o: i64, v: i64) -> i64 { var w: i64=o; var m: i64=v; if m<0{buf[w]=45 as u8;w=w+1;m=0-m} if m==0{buf[w]=48 as u8;return w+1} let t:*u8=sys_mmap(24); var k:i64=0; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var j:i64=0; while j<k{buf[w]=t[k-1-j];w=w+1;j=j+1} return w } |
| 65 | func cb_turn(atk: *i64, def: *i64, s: *i64, buf: *u8, obox: *i64) -> i64 |
| 89 | func cb_battle(A: *i64, B: *i64, seed: i64, buf: *u8) -> i64 |