Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Hollow Knight: arena waves and summoners; enemies wake near the camera
Mason Chen3f7bbec722ed
diff --git a/games/hollowknight/src/data.bin b/games/hollowknight/src/data.binindex ae5295e6..07ab3b38 100644Binary files a/games/hollowknight/src/data.bin and b/games/hollowknight/src/data.bin differdiff --git a/games/hollowknight/src/enemy.c b/games/hollowknight/src/enemy.cindex 6bc6fce4..1f436eb2 100644--- a/games/hollowknight/src/enemy.c+++ b/games/hollowknight/src/enemy.c@@ -1098,7 +1098,8 @@ static void spitter_update(Enemy *e) {switch (e->st) {case SP_IDLE:face_direction(e, &e->pause0, CLIP(e, R_A2));- if (e->can_see && e->in_alert) spitter_distance_fly(e);+ /* (ALERT: it sees the Knight in its alert range, or it starts alert) */+ if ((e->can_see && e->in_alert) || (e->ent != NO_ENT && (ent_at(e->ent)->s1 & EF_START))) spitter_distance_fly(e);break;case SP_DISTANCE_FLY:spitter_face(e, true);@@ -3622,6 +3623,107 @@ static void gfly_corpse_draw(void) {}}+/* its FSMs start */+static void enemy_fsm_start(Enemy *e, const Ent *d) {+ if (FSM(e) == EF_CRAWLER) crawler_start(e, d);+ else if (FSM(e) == EF_BUZZER) buzzer_start(e, d);+ else if (FSM(e) == EF_HUSK) husk_start(e);+ else if (FSM(e) == EF_CLIMBER) climber_start(e);+ else if (FSM(e) == EF_BOUNCER) bouncer_start(e);+ else if (FSM(e) == EF_SPITTER) spitter_start(e, d);+ else if (FSM(e) == EF_ROLLER) roller_start(e);+ else if (FSM(e) == EF_BLOCKER) blocker_start(e);+ else if (FSM(e) == EF_LEAPER) leaper_start(e);+ else if (FSM(e) == EF_GUARD) guard_start(e);+ else if (FSM(e) == EF_FK) fk_start(e);+ else if (FSM(e) == EF_FKHEAD) fk_head_start(e);+ else if (FSM(e) == EF_GFLY) gfly_start(e);+}++/* ActiveRegion (a 50 by 35 box round the camera) meets its collider: FSMActivator turns its FSMs on */+static void enemy_dormant_check(Enemy *e) {+ float x0, y0, x1, y1;+ enemy_box(e, &x0, &y0, &x1, &y1);+ if (x1 > g_cam_x - 25 && x0 < g_cam_x + 25 && y1 > g_cam_y - 17.5f && y0 < g_cam_y + 17.5f) {+ e->flags &= (uint8_t)~64;+ e->anim.paused = false;+ enemy_fsm_start(e, ent_at(e->ent));+ }+}++/* ---------------------------------------------------------------- summoners (summon: an enemy brought in from the+ * background as its wave starts) */+#define MAX_SUMMONS 2+enum { SM_IDLE, SM_PAUSE, SM_ENTER, SM_DONE };+typedef struct {+ uint8_t st;+ uint16_t ent; /* its record */+ float t, tween, sx;+ Anim anim;+} Summon;+static Summon summons[MAX_SUMMONS];++static void summons_enter(void) {+ memset(summons, 0, sizeof summons);+ int n, k = 0;+ const Ent *es = room_ents(&n);+ for (int i = 0; i < n && k < MAX_SUMMONS; i++)+ if (es[i].type == ENT_OBJ && es[i].flags == OK_SUMMON && es[i].p0 >= 0) summons[k].ent = (uint16_t)i, summons[k++].st = SM_IDLE;+ else if (es[i].type == ENT_OBJ && es[i].flags == OK_SUMMON) summons[k++].st = SM_DONE;+ for (; k < MAX_SUMMONS; k++) summons[k].st = SM_DONE;+}++void enemies_summon(void) {+ for (int k = 0; k < MAX_SUMMONS; k++)+ if (summons[k].st == SM_IDLE) summons[k].st = SM_PAUSE, summons[k].t = rand_range(0.25f, 1); /* (Random Pause) */+}++void enemies_battle_start(void) {+ /* (BATTLE START: no kind of a plain arena's listens yet; the False Knight's arena is its own) */+}++static void summons_tick(void) {+ for (int k = 0; k < MAX_SUMMONS; k++) {+ Summon *s = &summons[k];+ if (s->st == SM_PAUSE && (s->t -= DT) <= 0) {+ /* Enter: from the background, facing the Knight, out of the dark */+ const Ent *e = ent_at(s->ent), *d = ent_at((int)e->p0);+ s->sx = hero_x() > e->x0 ? -fabsf(e->y1) : fabsf(e->y1);+ s->tween = rand_range(0.75f, 1.2f), s->t = 0;+ anim_play(&s->anim, kinds[d->a].clip[R_A1]);+ s->st = SM_ENTER;+ } else if (s->st == SM_ENTER) {+ s->anim.events = 0;+ anim_update(&s->anim, DT);+ if ((s->t += DT) >= s->tween) {+ /* Summon: the enemy there, its way, alerted; the summoner gone */+ const Ent *e = ent_at(s->ent);+ for (int i = 0; i < MAX_ENEMIES; i++) {+ Enemy *q = &en[i];+ if (q->mode != EM_ALIVE || q->ent != (uint16_t)e->p0) continue;+ set_scale_x(q, s->sx);+ q->body.x = e->x0, q->body.y = e->y0;+ if (FSM(q) == EF_SPITTER && q->st == SP_IDLE && !(q->flags & 64)) spitter_distance_fly(q); /* (ALERT) */+ }+ s->st = SM_DONE;+ }+ }+ }+}++static void summons_draw(void) {+ for (int k = 0; k < MAX_SUMMONS; k++) {+ if (summons[k].st != SM_ENTER || summons[k].anim.sprite < 0) continue;+ const Ent *e = ent_at(summons[k].ent);+ /* (iTweenMoveBy, easeOutSine, from 8 up and 17 back; its colour from black to white over a second) */+ float f = sinf(summons[k].t / summons[k].tween * (float)M_PI / 2), c = summons[k].t < 1 ? summons[k].t : 1;+ uint8_t v = (uint8_t)(c * 255), tint = gfx_dyn_tint(11 + 4 * k, v, v, v, 255);+ Inst in;+ sprite_inst(summons[k].anim.sprite, e->x0, e->y0 + 8 - 8 * f, e->x1 + 16.996f - 16.99f * f, summons[k].sx, 1, tint, &in);+ gfx_actor(&in, SORT_KEY(0, 0));+ }+}+void enemies_enter(void) {memset(en, 0, sizeof en);memset(geo, 0, sizeof geo);@@ -3631,7 +3733,7 @@ void enemies_enter(void) {for (int i = 0; i < n && k < MAX_ENEMIES; i++) {const Ent *d = &es[i];if (d->type != ENT_OBJ || d->flags != OK_ENEMY) continue;- if (persist_get(d->persist) || ((d->s1 & EF_ARENA_GONE) && arena_done())) {+ if (persist_get(d->persist) || ((d->s1 & EF_ARENA_GONE) && arena_done()) || ((d->s1 & EF_ARENA_LATER) && !arena_done())) {enemy_terrain_off(d);continue;}@@ -3654,19 +3756,13 @@ void enemies_enter(void) {e->rc_base = rc ? rc->x0 : 15, e->rc_dur = rc ? rc->y0 : 0.5f, e->rc_flags = rc ? (uint8_t)rc->a : RF_NONE;const Ent *wk = enemy_rec(e, ET_WALKER);e->wk_rec = wk ? (uint16_t)(wk - room_ents(&n)) : 0;- if (FSM(e) == EF_CRAWLER) crawler_start(e, d);- else if (FSM(e) == EF_BUZZER) buzzer_start(e, d);- else if (FSM(e) == EF_HUSK) husk_start(e);- else if (FSM(e) == EF_CLIMBER) climber_start(e);- else if (FSM(e) == EF_BOUNCER) bouncer_start(e);- else if (FSM(e) == EF_SPITTER) spitter_start(e, d);- else if (FSM(e) == EF_ROLLER) roller_start(e);- else if (FSM(e) == EF_BLOCKER) blocker_start(e);- else if (FSM(e) == EF_LEAPER) leaper_start(e);- else if (FSM(e) == EF_GUARD) guard_start(e);- else if (FSM(e) == EF_FK) fk_start(e);- else if (FSM(e) == EF_FKHEAD) fk_head_start(e);- else if (FSM(e) == EF_GFLY) gfly_start(e);+ if (d->s1 & EF_DORMANT) {+ /* (its FSMs off till the active region round the camera meets it: FSMActivator; its sprite still) */+ int c = CLIP(e, R_IDLE) >= 0 ? CLIP(e, R_IDLE) : CLIP(e, R_A1) >= 0 ? CLIP(e, R_A1) : CLIP(e, R_WALK);+ if (c >= 0) anim_play(&e->anim, c), e->anim.paused = true;+ e->flags |= 64;+ } else+ enemy_fsm_start(e, d);for (int h = 0; h < 8; h++) {const Ent *r = hitbox_rec(e, h);if (!r) break;@@ -3686,6 +3782,7 @@ void enemies_enter(void) {memset(waves, 0, sizeof waves);memset(spurts, 0, sizeof spurts);memset(&gm, 0, sizeof gm);+ summons_enter();shade_spawn_check();}@@ -3714,7 +3811,8 @@ void enemies_fixed(void) {continue;}if (e->mode == EM_ALIVE) {- if (FSM(e) == EF_CRAWLER) crawler_fixed(e);+ if (e->flags & 64) {} /* (dormant: its FSMs off) */+ else if (FSM(e) == EF_CRAWLER) crawler_fixed(e);else if (FSM(e) == EF_BUZZER) buzzer_fixed(e);else if (FSM(e) == EF_HUSK) husk_fixed(e);else if (FSM(e) == EF_BOUNCER) bouncer_fixed(e);@@ -3759,6 +3857,7 @@ void enemies_fixed(void) {fk_arena_tick();fk_head_place();gfly_corpse_tick();+ summons_tick();}/* Update: the FSMs' every-frame actions, the animations, the timers */@@ -3773,7 +3872,9 @@ void enemies_update(void) {frame_collider(e);if (e->evasion > 0) e->evasion -= DT;if (e->ar_r > 0) sight_update(e);- if (FSM(e) == EF_BUZZER) buzzer_update(e, ent_at(e->ent));+ if (e->flags & 64) enemy_dormant_check(e);+ if (e->flags & 64) {} /* (dormant) */+ else if (FSM(e) == EF_BUZZER) buzzer_update(e, ent_at(e->ent));else if (FSM(e) == EF_SHADE) shade_update(e);else if (FSM(e) == EF_HUSK) husk_update(e);else if (FSM(e) == EF_CLIMBER) climber_update(e);@@ -3828,6 +3929,7 @@ void enemies_draw(void) {spurts_draw();fk_arena_draw();gfly_corpse_draw();+ summons_draw();for (int i = 0; i < MAX_BALLS; i++) {const Ball *b = &balls[i];if (!b->on) continue;diff --git a/games/hollowknight/src/game.h b/games/hollowknight/src/game.hindex e99c549c..3e55d2fa 100644--- a/games/hollowknight/src/game.h+++ b/games/hollowknight/src/game.h@@ -53,11 +53,13 @@ void save_set_respawn(const char *marker, bool facing_right); /* (Bench Controenum { ENT_CAMLOCK = 1, ENT_GATE, ENT_HAZARD_MARKER, ENT_RESPAWN, ENT_HAZARD_TRIGGER, ENT_MASK, ENT_DAMAGE, ENT_SHAPE,ENT_BOX, ENT_OBJ, ENT_PIECE, ENT_SHADE_MARKER }; /* (shape, box, piece: more of the record before) */enum { OK_BREAKABLE = 1, OK_ENEMY, OK_GREAT_DOOR, OK_GEO_ROCK, OK_CHEST, OK_BENCH, OK_BATTLE, OK_FK_FLOOR, OK_BGATE,- OK_ARENA, OK_EVENT }; /* objects (ENT_OBJ's flags) */-/* an enemy record's s1: one of an arena's Pre Battle Enemies; its death counts for its arena; gone once its arena's- * fight is over; spawned by its mother's burster; then its death's effects (EF_DEATH_SHIFT: enemyDeathType, and- * 12-13: which EnemyDeathEffects) */-enum { EF_PREBATTLE = 4, EF_BATTLE = 8, EF_ARENA_GONE = 16, EF_SPAWNED = 32 };+ OK_ARENA, OK_EVENT, OK_SUMMON }; /* objects (ENT_OBJ's flags) */+/* an enemy record's s1: starts alert (or first); startles; one of an arena's Pre Battle Enemies; its death counts for its arena; gone once its arena's+ * fight is over; spawned by its mother's burster; there only once its arena's fight is over; its FSMs off till near+ * the camera (FSMActivator); then its death's effects+ * (EF_DEATH_SHIFT: enemyDeathType, and 12-13: which EnemyDeathEffects) */+enum { EF_START = 1, EF_STARTLES = 2, EF_PREBATTLE = 4, EF_BATTLE = 8, EF_ARENA_GONE = 16, EF_SPAWNED = 32, EF_ARENA_LATER = 64,+ EF_DORMANT = 128 };#define EF_DEATH_SHIFT 8/* battle gates (BG Control: their events) and arenas (Battle Control: obj.c) */enum { BG_CLOSE, BG_QUICK_CLOSE, BG_OPEN, BG_QUICK_OPEN, BG_DESTROY };@@ -66,6 +68,8 @@ void arena_start(void); /* START (sent by an enemy) */void arena_enemy_died(void); /* (one it counts) */void arena_set_activated(void); /* Activated: its fight over (and saved) */bool arena_done(void);+void enemies_summon(void); /* SUMMON: the summoners bring their enemies */+void enemies_battle_start(void); /* BATTLE START */enum { HB_BOUNCE = 1, HB_RECOIL = 2 }; /* a hit box (ENT_BOX's flags): a down slash bounces off it, a slash recoils */enum { HAZ_NONE, HAZ_NORMAL, HAZ_SPIKES, HAZ_ACID, HAZ_LAVA, HAZ_PIT }; /* DamageHero.hazardType */enum { MK_SECRET = 1, MK_REMASK = 2, MK_SIMPLE = 4 }; /* masks: the unmasker, remasker and inverse FSMs */diff --git a/games/hollowknight/src/obj.c b/games/hollowknight/src/obj.cindex a49f5c8d..bd5cf921 100644--- a/games/hollowknight/src/obj.c+++ b/games/hollowknight/src/obj.c@@ -382,8 +382,8 @@ void gates_event(int ev) {}/* ---------------------------------------------------------------- arenas (Battle Control; the False Knight's is enemy.c's) */-enum { ARF_TRIGGER = 1, ARF_DESTROY_GATES = 2, ARF_QUICK_OPEN = 4 };-enum { AR_DETECT, AR_FIGHT, AR_END_WAIT, AR_DONE };+enum { ARF_TRIGGER = 1, ARF_DESTROY_GATES = 2, ARF_QUICK_OPEN = 4, ARF_WAVES = 8, ARF_NO_START = 16 };+enum { AR_DETECT, AR_FIGHT, AR_WAVE_PAUSE, AR_WAVE2, AR_END_WAIT, AR_DONE };static struct {int16_t ent; /* (-1: none) */uint8_t st;@@ -417,14 +417,15 @@ static void arena_enter(void) {if (e->a & ARF_DESTROY_GATES) gates_event(BG_DESTROY);else if (e->a & ARF_QUICK_OPEN) gates_event(BG_QUICK_OPEN);} else- arena.st = AR_DETECT;+ arena.st = (e->a & ARF_NO_START) ? AR_FIGHT : AR_DETECT; /* (no start: counting at once) */}void arena_start(void) {if (arena.ent < 0 || arena.st != AR_DETECT) return;const Ent *e = ent_at(arena.ent);- /* Start: BATTLE START, the gates shut, its camera lock on */+ /* Start (Wave 1): BATTLE START, the gates shut, its camera lock on */arena.count = (int16_t)e->p2;+ enemies_battle_start();gates_event(BG_CLOSE);if (e->p0 >= 0) ent_set_enabled((int)e->p0, true);arena.st = AR_FIGHT;@@ -450,6 +451,16 @@ static void arena_tick(void) {}break;case AR_FIGHT:+ if ((e->a & ARF_WAVES) && arena.count <= (int)e->s1) arena.st = AR_WAVE_PAUSE, arena.t = 0;+ else if (!(e->a & ARF_WAVES) && arena.count <= 0) {+ if (e->a & ARF_NO_START) persist_set(e->persist); /* (Complete: Activated, the gates open after a while) */+ arena.st = AR_END_WAIT, arena.t = 0;+ }+ break;+ case AR_WAVE_PAUSE:+ if ((arena.t += DT) >= e->s0 * 0.01f) enemies_summon(), arena.st = AR_WAVE2; /* (Wave 2: SUMMON) */+ break;+ case AR_WAVE2:if (arena.count <= 0) arena.st = AR_END_WAIT, arena.t = 0;break;case AR_END_WAIT:@@ -474,7 +485,8 @@ void obj_enter(void) {const Ent *es = room_ents(&n);for (int i = 0; i < n && nobjs < MAX_OBJS; i++) {if (es[i].type != ENT_OBJ) continue;- if (es[i].flags == OK_ENEMY || es[i].flags == OK_BENCH || es[i].flags == OK_ARENA || es[i].flags == OK_EVENT)+ if (es[i].flags == OK_ENEMY || es[i].flags == OK_BENCH || es[i].flags == OK_ARENA || es[i].flags == OK_EVENT ||+ es[i].flags == OK_SUMMON)continue; /* (enemy.c's, npc.c's; below) */Obj *o = &objs[nobjs++];memset(o, 0, sizeof *o);diff --git a/games/hollowknight/tools/ents.py b/games/hollowknight/tools/ents.pyindex f146cfce..ecb5c0f5 100644--- a/games/hollowknight/tools/ents.py+++ b/games/hollowknight/tools/ents.py@@ -9,14 +9,15 @@ ENT_CAMLOCK, ENT_GATE, ENT_HAZARD_MARKER, ENT_RESPAWN, ENT_HAZARD_TRIGGER, ENT_MENT_OBJ, ENT_PIECE, ENT_SHADE_MARKER = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12# objects (ENT_OBJ's flags: src/obj.c)OK_BREAKABLE, OK_ENEMY, OK_GREAT_DOOR, OK_GEO_ROCK, OK_CHEST, OK_BENCH, OK_BATTLE, OK_FK_FLOOR, OK_BGATE, OK_ARENA, \- OK_EVENT = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11+ OK_EVENT, OK_SUMMON = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12# the battle gates' events (src/game.h: BG_*)BG_EVENTS = ["BG CLOSE", "BG QUICK CLOSE", "BG OPEN", "BG QUICK OPEN", "BG DESTROY"]# battle gates (BG Control: OK_BGATE's s0): closed at first, the bone ones' clips, gone once a PlayerData bool is setBGF_START_CLOSED, BGF_BONE, BGF_PD = 1, 2, 4# arenas (Battle Control, but the False Knight's: OK_ARENA's a): started by its trigger (else by an enemy), its-# Activate destroys the gates (else opens them at once)-ARF_TRIGGER, ARF_DESTROY_GATES, ARF_QUICK_OPEN = 1, 2, 4+# Activate destroys the gates (else opens them at once), two waves (the second summoned), or no start (counting from+# the first)+ARF_TRIGGER, ARF_DESTROY_GATES, ARF_QUICK_OPEN, ARF_WAVES, ARF_NO_START = 1, 2, 4, 8, 16# enemies (an OK_ENEMY's a: src/enemy.c), by their FSM and animation libraryimport actors as _actors# enemies: by the FSM (or component) that runs them and their animation library -> their kind (actors.ENEMY_KINDS)@@ -32,8 +33,10 @@ ENEMY_VARS = {"Zombie Swipe": (["Lunge Speed", "Idle Time"], ["Coward"]),ET_COLLIDER, ET_ALERT, ET_RANGE, ET_WALKER, ET_RECOIL, ET_CORPSE, ET_VARS, ET_TERRAIN, ET_HITBOX, ET_ZONE = \0, 1, 2, 3, 4, 5, 6, 7, 8, 9# (FSM bools: First Crawler or Start Alert; Startles; one of an arena's Pre Battle Enemies; its death counts for its-# arena (HealthManager.battleScene); gone once its arena's fight is over; spawned by its mother's burster (Fly Spawn))-EF_START, EF_STARTLES, EF_PREBATTLE, EF_BATTLE, EF_ARENA_GONE, EF_SPAWNED = 1, 2, 4, 8, 16, 32+# arena (HealthManager.battleScene); gone once its arena's fight is over; spawned by its mother's burster (Fly Spawn);+# there only once its arena's fight is over; its FSMs off till near the camera: FSMActivator)+EF_START, EF_STARTLES, EF_PREBATTLE, EF_BATTLE, EF_ARENA_GONE, EF_SPAWNED, EF_ARENA_LATER, EF_DORMANT = \+ 1, 2, 4, 8, 16, 32, 64, 128EF_DEATH_SHIFT = 8 # (bits 8-11: its enemyDeathType; 12-13: EnemyDeathEffects (0), Uninfected, NoEffect, BlackKnight)# the layers the nail's slashes touch (Physics2D's collision matrix, layer 17 Attack)ATTACK_HITS = {3, 6, 7, 8, 11, 12, 17, 19, 20, 21, 25, 31}@@ -370,12 +373,15 @@ def _enemy(o, by_id, persist, name, d=None, strings=None, owners=None):sx, sy = o["lscale"][0], o["lscale"][1]var = fsm.get("vars", {})fl = 0- if (var.get("First Crawler") or var.get("Start Alert") or [0, False])[1]:+ if (var.get("First Crawler") or var.get("Start Alert") or var.get("startAlert") or [0, False])[1]:fl |= EF_STARTif (var.get("Startles") or [0, False])[1]:fl |= EF_STARTLESif hm.get("battleScene"):fl |= EF_BATTLE+ fc = next((c for c in o["c"] if c.get("fsm") is fsm), None) if fsm else None+ if fc is not None and fc.get("enabled") is False and any(c.get("class") == "FSMActivator" for c in o["c"]):+ fl |= EF_DORMANT# (its death's effects: EnemyDeathEffects' enemyDeathType, and which of its kinds runs them)dcls = next((c.get("class") for c in o["c"] if (c.get("class") or "").startswith("EnemyDeathEffects")), None)dv = next((c.get("v") for c in o["c"] if c.get("class") == dcls and c.get("v")), None) or {}@@ -586,8 +592,8 @@ def _go_var(d, o, f, var, by_id):def _arenas(d, by_id):"""The arenas (Battle Control, but the False Knight's) -> (the objects their Activate destroys or hides, the enemies- they count: SetBattleScene's)."""- gone, counted = set(), set()+ they count: SetBattleScene's, those their Detect hides: there only once the fight is over)."""+ gone, counted, later = set(), set(), set()for o in d["objects"]:f = _fsm(o, ("Battle Control",)) if o["active"] else Noneif not f or "False Knight" in f["vars"]:@@ -604,6 +610,13 @@ def _arenas(d, by_id):i = todo.pop()gone.add(i)todo += by_id[i].get("children", [])+ det = _state(f, "Detect")+ for a in det["actions"] if det else []:+ if a.get("enabled", True) and a["name"] == "ActivateGameObject" and _param(a, "activate") is False:+ g = _param(a, "gameObject")+ q = _go_var(d, o, f, g[1:], by_id) if isinstance(g, str) and g.startswith("$") else None+ if q is not None:+ later.add(q)for st in f["states"]:for a in st["actions"]:if a["name"] == "SetBattleScene" and a.get("enabled", True):@@ -611,7 +624,7 @@ def _arenas(d, by_id):q = _go_var(d, o, f, g[1:], by_id) if isinstance(g, str) and g.startswith("$") else Noneif q is not None:counted.add(q)- return gone, counted+ return gone, counted, laterdef _gate(d, o, owners):@@ -654,7 +667,8 @@ def room(d, rooms, strings, persist, name, sprites=None, owners=None, rec_base=0marker_index = {}objs = [o for o in d["objects"] if o["active"]]by_id = {o["id"]: o for o in d["objects"]}- arena_gone, arena_counted = _arenas(d, by_id)+ arena_gone, arena_counted, arena_later = _arenas(d, by_id)+ enemy_rec_of, summons = {}, [] # (enemies' records; summoners, to point at theirs)def subtree(oid, g):groups[oid] = g@@ -752,13 +766,28 @@ def room(d, rooms, strings, persist, name, sprites=None, owners=None, rec_base=0count = next((_param(a, "intValue") for a in acts("Start") + acts("Wave 1") if a["name"] == "SetIntValue"),(f["vars"].get("Battle Enemies") or [0, 0])[1])wait = next((_param(a, "time") for a in acts("End Wait") if a["name"] == "Wait"), 2)- for k in ("Wave 2", "Complete", "Kill Zombies"):- if _state(f, k):- print("ents: %s: %s: arena state %s not handled" % (name, o["path"], k))+ pause, next_at = 0, 0+ if _state(f, "Wave 2"):+ # (the second wave once the first is down to so many, after a pause)+ fl |= ARF_WAVES+ next_at = next((_param(a, "integer2") for a in acts("Wave 1") if a["name"] == "IntCompare"), 0)+ pause = next((_param(a, "time") for a in acts("Wave Pause") if a["name"] == "Wait"), 0)+ if _state(f, "Complete") and not _state(f, "Start"):+ # (no start: done once its count is down, the gates opening a while after)+ fl |= ARF_NO_START+ wait = next((_param(a, "delay") for a in acts("Complete") if a["name"] == "SendEventByName"), 0)+ if _state(f, "Kill Zombies"):+ print("ents: %s: %s: arena state Kill Zombies not handled" % (name, o["path"]))persistent = any(c.get("class") == "PersistentBoolItem" for c in o["c"])battles.append((len(recs), _go_var(d, o, f, "Camera Lock", by_id), None))recs.append(rec(ENT_OBJ, OK_ARENA, _trigger(o) or (0, 0, 0, 0), (-1, -1, count, wait), a=fl,- persist=persist.id(name, o["path"]) if persistent else NO_PERSIST))+ persist=persist.id(name, o["path"]) if persistent else NO_PERSIST,+ s0=int(round(pause * 100)), s1=int(next_at)))+ f = _fsm(o, ("summon",))+ if f and _go_var(d, o, f, "Buzzer", by_id) is not None:+ # a summoner: its place and way; the enemy it brings (fixed up below)+ summons.append((len(recs), _go_var(d, o, f, "Buzzer", by_id)))+ recs.append(rec(ENT_OBJ, OK_SUMMON, (o["pos"][0], o["pos"][1], o["pos"][2], o["lscale"][0]), (-1, 0, 0, 0)))g = _gate(d, o, owners)if g:recs.append(g)@@ -799,7 +828,9 @@ def room(d, rooms, strings, persist, name, sprites=None, owners=None, rec_base=0en = _enemy(o, by_id, persist, name, d, strings, owners) or _props(d, o, by_id, rooms, strings, persist, sprites, owners, name)if en:if en[0][1] == OK_ENEMY:+ enemy_rec_of[o["id"]] = len(recs)fl = EF_PREBATTLE if o["id"] in prebattle else 0+ fl |= EF_ARENA_LATER if o["id"] in arena_later else 0fl |= EF_BATTLE if o["id"] in arena_counted else 0fl |= EF_ARENA_GONE if o["id"] in arena_gone else 0fl |= EF_SPAWNED if by_id.get(o.get("parent"), {}).get("name") == "Fly Spawn" else 0@@ -907,6 +938,11 @@ def room(d, rooms, strings, persist, name, sprites=None, owners=None, rec_base=0b = bytearray(recs[i])struct.pack_into("<2f", b, 24, cam_rec[c1] + rec_base if c1 in cam_rec else -1, cam_rec[c2] + rec_base if c2 in cam_rec else -1)recs[i] = bytes(b)+ # (summoners: their enemies' records)+ for i, target in summons:+ b = bytearray(recs[i])+ struct.pack_into("<f", b, 24, enemy_rec_of[target] + rec_base if target in enemy_rec_of else -1)+ recs[i] = bytes(b)# (an object that sends HIT to another: that one's record + 1 in its box's y1)for i, target in receivers:if target in rec_of: