Skip to content

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.

Kingdom Rush: the graveyards of the Wastes and the Dark Tower, Vez'nan's fall takes his army, the necromancers' skeletons as the game counts them

Mason363fcb36b1b83f9
diff --git a/games/kingdomrush/src/anim.h b/games/kingdomrush/src/anim.h
index a68df731..b8dff3a1 100644
--- a/games/kingdomrush/src/anim.h
+++ b/games/kingdomrush/src/anim.h
@@ -21,6 +21,7 @@ void egg_lay(struct Enemy *e);
void eggs_step(void);
int skeletons(void);
void summon_skeleton(struct Enemy *e, int k);
+void grave_rise(const struct Enemy *dead);
void demon_explode(struct Enemy *e);
bool boss_power(struct Enemy *e);
bool veznan_power(struct Enemy *e);
diff --git a/games/kingdomrush/src/enemy.c b/games/kingdomrush/src/enemy.c
index c8d36b6b..0ecb4237 100644
--- a/games/kingdomrush/src/enemy.c
+++ b/games/kingdomrush/src/enemy.c
@@ -126,7 +126,18 @@ static void dead_status(Enemy *e) {
void enemy_kill(Enemy *e, int how) {
if (e->dead) return;
+ if (how != 3) grave_rise(e); /* (toGraveyard) */
dead_status(e);
+ if (e->type == EN_VEZNAN) { /* EnemyVeznan.setDeadBasicStatus: the graveyard gone, and every other enemy */
+ B.grave = 0;
+ for (int i = 0; i < MAX_ENEMIES; i++) {
+ Enemy *o = &B.en[i];
+ if (o != e && o->alive && !o->dead) {
+ dead_status(o);
+ fx_add(ST(o)->blood == 1 ? AN_B_BLOODGREEN : ST(o)->blood == 2 ? -1 : AN_B_BLOOD, o->x, o->y + 1, false, true);
+ }
+ }
+ }
if (how == 1) { /* blown up (EnemyExplode*) */
fx_add(e->flying ? AN_FX_EXPLODEAIR : ST(e)->size == SZ_BIG ? AN_FX_EXPLODEBIG : AN_FX_EXPLODENORMAL, e->x, e->y, false, false);
e->alive = 0;
diff --git a/games/kingdomrush/src/enemy2.c b/games/kingdomrush/src/enemy2.c
index 350c862c..0400b94e 100644
--- a/games/kingdomrush/src/enemy2.c
+++ b/games/kingdomrush/src/enemy2.c
@@ -45,7 +45,13 @@ void eggs_step(void) {
}
/* ------------------------------------------------------------------ skeletons */
-int skeletons(void) { return B.skeletons; }
+/* currentSkeletons: the necromancers' skeletons (no gold) still on the field */
+int skeletons(void) {
+ int n = 0;
+ for (int i = 0; i < MAX_ENEMIES; i++)
+ if (B.en[i].alive && (B.en[i].type == EN_SKELETON || B.en[i].type == EN_SKELETONBIG) && B.en[i].gold == 0) n++;
+ return n;
+}
void summon_skeleton(Enemy *e, int k) {
static const int8_t lanes[8] = {1, 2, 0, 1, 2, 0, 1, 2};
@@ -56,12 +62,45 @@ void summon_skeleton(Enemy *e, int k) {
int len = path_len(e->path, lane);
if (node < 11) node = 11;
if (node > len - 12) node = len - 12;
- int j = enemy_spawn(EN_SKELETON, e->path, lane, node);
+ bool big = rnd() < 0.05f; /* (EnemyNecromancer.summonIt) */
+ int j = enemy_spawn(big ? EN_SKELETONBIG : EN_SKELETON, e->path, lane, node);
+ if (j < 0) return;
+ Enemy *s = &B.en[j];
+ s->respawn_t = 33, s->active = 0, s->gold = 0;
+ s->anim = big ? AN_E_SKELETONBIG_RESPAWNING : AN_E_SKELETON_RESPAWNING, s->anim_t = 0;
+}
+
+/* Graveyard (Level10, Level12): whoever dies there rises from a grave as a skeleton, a big one when it had
+ * limitLifeCondition (299) health or more; they walk from the grave to their road */
+static const struct {
+ uint8_t path;
+ int16_t node, pt[5][2];
+} graves[2] = {{0, 110, {{139, 199}, {121, 220}, {141, 215}, {120, 204}, {144, 204}}},
+ {2, 0, {{119, 343}, {95, 353}, {114, 352}, {102, 346}, {121, 352}}}};
+
+static bool can_skeleton(int type) {
+ switch (type) {
+ case EN_DEMONIMP: case EN_DEMONWOLF: case EN_GARGOYLE: case EN_ROCKETEER: case EN_SKELETON: case EN_SKELETONBIG:
+ case EN_SPIDER: case EN_SPIDERSMALL: case EN_SPIDERTINY: case EN_WHITEWOLF: case EN_WOLFSMALL: case EN_WOLF:
+ return false;
+ default:
+ return true;
+ }
+}
+
+void grave_rise(const Enemy *dead) {
+ if (!B.grave || !can_skeleton(dead->type)) return;
+ const int g = B.grave - 1, path = graves[g].path;
+ B.grave_lane = (uint8_t)(B.grave_lane >= 2 ? 0 : B.grave_lane + 1);
+ int lane = B.grave_lane < B.nlanes[path] ? B.grave_lane : 0;
+ bool big = dead->init_health >= 299;
+ int j = enemy_spawn(big ? EN_SKELETONBIG : EN_SKELETON, path, lane, graves[g].node);
if (j < 0) return;
Enemy *s = &B.en[j];
+ s->x = graves[g].pt[B.grave_k][0], s->y = graves[g].pt[B.grave_k][1];
+ B.grave_k = (uint8_t)((B.grave_k + 1) % 5);
s->respawn_t = 33, s->active = 0;
- s->anim = AN_E_SKELETON_RESPAWNING, s->anim_t = 0;
- B.skeletons++;
+ s->anim = big ? AN_E_SKELETONBIG_RESPAWNING : AN_E_SKELETON_RESPAWNING, s->anim_t = 0;
}
/* ------------------------------------------------------------------ demons: their last blast */
diff --git a/games/kingdomrush/src/kr.h b/games/kingdomrush/src/kr.h
index 540d5a5a..1ad02937 100644
--- a/games/kingdomrush/src/kr.h
+++ b/games/kingdomrush/src/kr.h
@@ -224,7 +224,7 @@ typedef struct {
struct { uint8_t on; int16_t t, dur; Pt at; } rain[2];
/* spider eggs (SpiderEgg): where, on which road, when they hatch */
struct { uint8_t on, path, n; int16_t node, t; float x, y; } egg[12];
- int16_t skeletons; /* currentSkeletons */
+ uint8_t grave, grave_lane, grave_k; /* Graveyard: 1 stage 10's, 2 stage 12's; the next lane and grave */
/* the rain of fire's burning ground (ScorchedEarth) */
struct { uint8_t on; int16_t t, dur; Pt at; } burn[8];
int8_t veznan; /* Vez'nan, in the last stage's campaign */
diff --git a/games/kingdomrush/src/level.c b/games/kingdomrush/src/level.c
index 5f32d6c5..ad97c9ce 100644
--- a/games/kingdomrush/src/level.c
+++ b/games/kingdomrush/src/level.c
@@ -121,6 +121,7 @@ void battle_start(int level, int mode) {
}
B.veznan = -1;
if (level == NLEVELS - 1 && mode == MODE_CAMPAIGN) veznan_spawn(); /* (Level12: he waits in his tower) */
+ B.grave = level == 9 ? 1 : level == 11 ? 2 : 0; /* (Level10, Level12: a graveyard) */
}
/* ------------------------------------------------------------------ cash, lives */