BlueGit

timfa questward

Give every spell its own magenta projectile sprite.

Replaces shared spell-light/spell-spark frame sheets with spell-<id>.png placeholders, tinted at runtime by element so art can be filled in without new colour variants.

timfa Tim Falken · pushed by timfa

Authored 2026-08-31 · 2 months ago

Hash
018233a2c38a658247c91488917ae3b4bc0ca2db
Parent
5354a541
61 files changed +90 −111
client/assets/fx/projectile/spell-airbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-blaze.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-blight.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-boulder.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-cataclysm.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-cyclone.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-dark.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-darkbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-deluge.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-drain.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-earthbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-eclipse.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-fireball.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-firebolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-flare.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-gale.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-gloom.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-hellfire.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-hurricane.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-inferno.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-judgment.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-landslide.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-light-0.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-light-1.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-light-2.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-light.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-lightbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-maelstrom.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-magic-missile.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-mana-bullet.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-oblivion.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-plague.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-poison.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-poisonbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-quake.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-radiance.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-revitalize.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-shade.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-spark-0.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-spark-1.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-spark-2.png deleted Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-air.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-dark.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-earth.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-fire.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-light.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-poison.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sprite-bolt-water.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-sunbeam.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-tempest.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-tinders.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-torrent.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-toxinburst.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-venomcloud.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-voidlance.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-waterbolt.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/fx/projectile/spell-waterspout.png added Binary file +0 −0

The contents of this binary file are not shown.

client/scripts/write-spell-projectile-template.mjs +48 −63
@@ -1,74 +1,59 @@
1 import { mkdirSync, writeFileSync } from "node:fs";
2 import { deflateSync } from "node:zlib";
1 #!/usr/bin/env node
2 /**
3 * Magenta placeholder projectile art: one PNG per spell under
4 * client/assets/fx/projectile/spell-<spellId>.png
5 *
6 * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element).
7 * Replace any file with hand-drawn art; keep magenta for tintable regions.
8 *
9 * node client/scripts/write-spell-projectile-template.mjs
10 */
11 import { unlinkSync, existsSync } from "node:fs";
12 import { join, dirname } from "node:path";
13 import { fileURLToPath } from "node:url";
14 import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";
15 import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";
3 16
4 const spells = [
5 { id: "spell-light", rgb: [255, 248, 192] },
6 { id: "spell-spark", rgb: [255, 144, 64] }
7 ];
8
9 mkdirSync(new URL("../assets/fx/projectile/", import.meta.url), { recursive: true });
17 const SIZE = 8;
18 const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile");
10 19
11 for (const spell of spells)
12 {
13 for (let frame = 0; frame < 3; frame++)
14 {
15 const png = buildPng5(spell.rgb);
16 writeFileSync(
17 new URL(`../assets/fx/projectile/${spell.id}-${frame}.png`, import.meta.url),
18 png
19 );
20 }
21 }
20 /** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */
21 const MAGENTA = [220, 0, 220, 255];
22 const MAGENTA_HI = [255, 120, 255, 255];
22 23
23 function buildPng5 ([r, g, b])
24 const legacy = [
25 "spell-light-0.png",
26 "spell-light-1.png",
27 "spell-light-2.png",
28 "spell-spark-0.png",
29 "spell-spark-1.png",
30 "spell-spark-2.png"
31 ];
32 for (const name of legacy)
24 33 {
25 const row = Buffer.alloc(1 + 5 * 4);
26 row[0] = 0;
27 for (let x = 0; x < 5; x++)
34 const path = join(OUT_DIR, name);
35 if (existsSync(path))
28 36 {
29 const i = 1 + x * 4;
30 row[i] = r;
31 row[i + 1] = g;
32 row[i + 2] = b;
33 row[i + 3] = x === 0 || x === 4 ? 0 : 255;
37 unlinkSync(path);
38 console.log(`Removed legacy ${name}`);
34 39 }
35 const raw = Buffer.concat(Array.from({ length: 5 }, () => row));
36 return encodePng(5, 5, deflateSync(raw));
37 40 }
38 41
39 function encodePng (w, h, idat)
42 let wrote = 0;
43 for (const def of Object.values(SPELL_DEFINITIONS))
40 44 {
41 const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
42 const ihdr = chunk("IHDR", (() =>
43 {
44 const buf = Buffer.alloc(13);
45 buf.writeUInt32BE(w, 0);
46 buf.writeUInt32BE(h, 4);
47 buf[8] = 8; buf[9] = 6;
48 return buf;
49 })());
50 return Buffer.concat([signature, ihdr, chunk("IDAT", idat), chunk("IEND", Buffer.alloc(0))]);
45 const file = join(OUT_DIR, `spell-${def.spellId}.png`);
46 const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);
47 // Diamond body
48 fillRect(image, 3, 1, 2, 1, MAGENTA);
49 fillRect(image, 2, 2, 4, 1, MAGENTA);
50 fillRect(image, 1, 3, 6, 2, MAGENTA);
51 fillRect(image, 2, 5, 4, 1, MAGENTA);
52 fillRect(image, 3, 6, 2, 1, MAGENTA);
53 // Center highlight
54 fillRect(image, 3, 3, 2, 2, MAGENTA_HI);
55 writeRgbaPng(file, SIZE, SIZE, image.pixels);
56 wrote += 1;
51 57 }
52 58
53 function chunk (type, data)
54 {
55 const len = Buffer.alloc(4);
56 len.writeUInt32BE(data.length, 0);
57 const t = Buffer.from(type);
58 const crc = crc32(Buffer.concat([t, data]));
59 const c = Buffer.alloc(4);
60 c.writeUInt32BE(crc >>> 0, 0);
61 return Buffer.concat([len, t, data, c]);
62 }
63
64 function crc32 (buf)
65 {
66 let c = ~0;
67 for (let i = 0; i < buf.length; i++)
68 {
69 c ^= buf[i];
70 for (let k = 0; k < 8; k++)
71 { c = (c >>> 1) ^ (c & 1 ? 0xedb88320 : 0); }
72 }
73 return ~c;
74 }
59 console.log(`Wrote ${wrote} magenta spell projectile placeholders in ${OUT_DIR}`);
@@ -1,74 +1,59 @@
1import { mkdirSync, writeFileSync } from "node:fs";
1#!/usr/bin/env node
2import { deflateSync } from "node:zlib";
2/**
3 * Magenta placeholder projectile art: one PNG per spell under
4 * client/assets/fx/projectile/spell-<spellId>.png
5 *
6 * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element).
7 * Replace any file with hand-drawn art; keep magenta for tintable regions.
8 *
9 * node client/scripts/write-spell-projectile-template.mjs
10 */
11import { unlinkSync, existsSync } from "node:fs";
12import { join, dirname } from "node:path";
13import { fileURLToPath } from "node:url";
14import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";
15import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";
3
16
4const spells = [
17const SIZE = 8;
5 { id: "spell-light", rgb: [255, 248, 192] },
18const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile");
6 { id: "spell-spark", rgb: [255, 144, 64] }
7];
8
9mkdirSync(new URL("../assets/fx/projectile/", import.meta.url), { recursive: true });
10
19
11for (const spell of spells)
20/** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */
12{
21const MAGENTA = [220, 0, 220, 255];
13 for (let frame = 0; frame < 3; frame++)
22const MAGENTA_HI = [255, 120, 255, 255];
14 {
15 const png = buildPng5(spell.rgb);
16 writeFileSync(
17 new URL(`../assets/fx/projectile/${spell.id}-${frame}.png`, import.meta.url),
18 png
19 );
20 }
21}
22
23
23function buildPng5 ([r, g, b])
24const legacy = [
25 "spell-light-0.png",
26 "spell-light-1.png",
27 "spell-light-2.png",
28 "spell-spark-0.png",
29 "spell-spark-1.png",
30 "spell-spark-2.png"
31];
32for (const name of legacy)
24{
33{
25 const row = Buffer.alloc(1 + 5 * 4);
34 const path = join(OUT_DIR, name);
26 row[0] = 0;
35 if (existsSync(path))
27 for (let x = 0; x < 5; x++)
28 {
36 {
29 const i = 1 + x * 4;
37 unlinkSync(path);
30 row[i] = r;
38 console.log(`Removed legacy ${name}`);
31 row[i + 1] = g;
32 row[i + 2] = b;
33 row[i + 3] = x === 0 || x === 4 ? 0 : 255;
34 }
39 }
35 const raw = Buffer.concat(Array.from({ length: 5 }, () => row));
36 return encodePng(5, 5, deflateSync(raw));
37}
40}
38
41
39function encodePng (w, h, idat)
42let wrote = 0;
43for (const def of Object.values(SPELL_DEFINITIONS))
40{
44{
41 const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
45 const file = join(OUT_DIR, `spell-${def.spellId}.png`);
42 const ihdr = chunk("IHDR", (() =>
46 const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);
43 {
47 // Diamond body
44 const buf = Buffer.alloc(13);
48 fillRect(image, 3, 1, 2, 1, MAGENTA);
45 buf.writeUInt32BE(w, 0);
49 fillRect(image, 2, 2, 4, 1, MAGENTA);
46 buf.writeUInt32BE(h, 4);
50 fillRect(image, 1, 3, 6, 2, MAGENTA);
47 buf[8] = 8; buf[9] = 6;
51 fillRect(image, 2, 5, 4, 1, MAGENTA);
48 return buf;
52 fillRect(image, 3, 6, 2, 1, MAGENTA);
49 })());
53 // Center highlight
50 return Buffer.concat([signature, ihdr, chunk("IDAT", idat), chunk("IEND", Buffer.alloc(0))]);
54 fillRect(image, 3, 3, 2, 2, MAGENTA_HI);
55 writeRgbaPng(file, SIZE, SIZE, image.pixels);
56 wrote += 1;
51}
57}
52
58
53function chunk (type, data)
59console.log(`Wrote ${wrote} magenta spell projectile placeholders in ${OUT_DIR}`);
54{
55 const len = Buffer.alloc(4);
56 len.writeUInt32BE(data.length, 0);
57 const t = Buffer.from(type);
58 const crc = crc32(Buffer.concat([t, data]));
59 const c = Buffer.alloc(4);
60 c.writeUInt32BE(crc >>> 0, 0);
61 return Buffer.concat([len, t, data, c]);
62}
63
64function crc32 (buf)
65{
66 let c = ~0;
67 for (let i = 0; i < buf.length; i++)
68 {
69 c ^= buf[i];
70 for (let k = 0; k < 8; k++)
71 { c = (c >>> 1) ^ (c & 1 ? 0xedb88320 : 0); }
72 }
73 return ~c;
74}
client/src/render/worldView.js +13 −30
@@ -34,7 +34,7 @@ import
34 34 resolveDimensionDarknessFactor,
35 35 resolveDimensionSeasonId
36 36 } from "/shared/world/dimensions.js";
37 import { SPELL_PROJECTILE_FRAME_MS } from "/shared/spells/constants.js";
37 import { spellDefinition, spellProjectileTint } from "/shared/definitions/spells.js";
38 38 import { skullTintColor } from "/shared/combat/skull.js";
39 39
40 40 const LAYER_GROUND = 0;
@@ -1646,13 +1646,18 @@ export class WorldView
1646 1646 });
1647 1647 }
1648 1648
1649 /** Bloom-layer spell projectiles — unlit, animated travel. */
1649 /** Bloom-layer spell projectiles — magenta-tinted, unique art per spell. */
1650 1650 spawnSpellProjectileFx (payload)
1651 1651 {
1652 const baseSprite = payload.sprite ?? "fx:projectile:spell-light";
1653 const image = this.#spellProjectileImage(baseSprite, 0);
1652 const spellId = payload.spellId ?? null;
1653 const def = spellId != null ? spellDefinition(spellId) : null;
1654 const spriteName = payload.sprite
1655 ?? def?.projectileSprite
1656 ?? "fx:projectile:spell-mana-bullet";
1657 const image = this.game.images[spriteName];
1654 1658 if (!image)
1655 1659 { return; }
1660 const tint = spellProjectileTint(def?.element);
1656 1661 const fromPivot = this.#projectileLaunchPoint(
1657 1662 payload.casterId ?? null,
1658 1663 payload.fromTileX,
@@ -1668,6 +1673,7 @@ export class WorldView
1668 1673 const object = new GameObject(0, 0, image, SORT_FX);
1669 1674 object.renderer.layer = RENDER_LAYER_BLOOM;
1670 1675 this.#markUnlit(object);
1676 this.#syncUnlitTintSprite(object, tint);
1671 1677 if (object.transform)
1672 1678 { object.transform.rotation = angle; }
1673 1679 this.scene.addObject(object);
@@ -1681,7 +1687,7 @@ export class WorldView
1681 1687 durationMs,
1682 1688 lerp: true,
1683 1689 spellProjectile: true,
1684 baseSprite,
1690 tint,
1685 1691 fromTileX: payload.fromTileX,
1686 1692 fromTileY: payload.fromTileY,
1687 1693 tileX: payload.tileX,
@@ -1752,24 +1758,6 @@ export class WorldView
1752 1758 );
1753 1759 }
1754 1760
1755 #spellProjectileImage (baseSprite, frameIndex)
1756 {
1757 const frame = Math.max(0, Math.min(2, frameIndex | 0));
1758 const stem = baseSprite.split(":").pop() ?? "spell-light";
1759 const names = [
1760 `${baseSprite}-${frame}`,
1761 `fx:projectile:${stem}-${frame}`,
1762 baseSprite,
1763 `fx:projectile:${stem}`
1764 ];
1765 for (const name of names)
1766 {
1767 if (this.game.images[name])
1768 { return this.game.images[name]; }
1769 }
1770 return null;
1771 }
1772
1773 1761 addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 })
1774 1762 {
1775 1763 this.dynamicLights.push({
@@ -4254,13 +4242,8 @@ export class WorldView
4254 4242 toPivot.x - fromPivot.x
4255 4243 ) * (180 / Math.PI);
4256 4244 }
4257 if (swipe.spellProjectile && swipe.baseSprite)
4258 {
4259 const frame = Math.floor((now - swipe.started) / SPELL_PROJECTILE_FRAME_MS) % 3;
4260 const image = this.#spellProjectileImage(swipe.baseSprite, frame);
4261 if (image && swipe.object?.renderer)
4262 { swipe.object.renderer.sprite = image; }
4263 }
4245 if (swipe.spellProjectile && swipe.tint)
4246 { this.#syncUnlitTintSprite(swipe.object, swipe.tint); }
4264 4247 this.#placePivoted(swipe.object, x, y, sortY, SORT_FX);
4265 4248 if (!swipe.spellProjectile)
4266 4249 {
@@ -34,7 +34,7 @@ import
34 resolveDimensionDarknessFactor,
34 resolveDimensionDarknessFactor,
35 resolveDimensionSeasonId
35 resolveDimensionSeasonId
36} from "/shared/world/dimensions.js";
36} from "/shared/world/dimensions.js";
37import { SPELL_PROJECTILE_FRAME_MS } from "/shared/spells/constants.js";
37import { spellDefinition, spellProjectileTint } from "/shared/definitions/spells.js";
38import { skullTintColor } from "/shared/combat/skull.js";
38import { skullTintColor } from "/shared/combat/skull.js";
39
39
40const LAYER_GROUND = 0;
40const LAYER_GROUND = 0;
@@ -1646,13 +1646,18 @@ export class WorldView
1646 });
1646 });
1647 }
1647 }
1648
1648
1649 /** Bloom-layer spell projectiles — unlit, animated travel. */
1649 /** Bloom-layer spell projectiles — magenta-tinted, unique art per spell. */
1650 spawnSpellProjectileFx (payload)
1650 spawnSpellProjectileFx (payload)
1651 {
1651 {
1652 const baseSprite = payload.sprite ?? "fx:projectile:spell-light";
1652 const spellId = payload.spellId ?? null;
1653 const image = this.#spellProjectileImage(baseSprite, 0);
1653 const def = spellId != null ? spellDefinition(spellId) : null;
1654 const spriteName = payload.sprite
1655 ?? def?.projectileSprite
1656 ?? "fx:projectile:spell-mana-bullet";
1657 const image = this.game.images[spriteName];
1654 if (!image)
1658 if (!image)
1655 { return; }
1659 { return; }
1660 const tint = spellProjectileTint(def?.element);
1656 const fromPivot = this.#projectileLaunchPoint(
1661 const fromPivot = this.#projectileLaunchPoint(
1657 payload.casterId ?? null,
1662 payload.casterId ?? null,
1658 payload.fromTileX,
1663 payload.fromTileX,
@@ -1668,6 +1673,7 @@ export class WorldView
1668 const object = new GameObject(0, 0, image, SORT_FX);
1673 const object = new GameObject(0, 0, image, SORT_FX);
1669 object.renderer.layer = RENDER_LAYER_BLOOM;
1674 object.renderer.layer = RENDER_LAYER_BLOOM;
1670 this.#markUnlit(object);
1675 this.#markUnlit(object);
1676 this.#syncUnlitTintSprite(object, tint);
1671 if (object.transform)
1677 if (object.transform)
1672 { object.transform.rotation = angle; }
1678 { object.transform.rotation = angle; }
1673 this.scene.addObject(object);
1679 this.scene.addObject(object);
@@ -1681,7 +1687,7 @@ export class WorldView
1681 durationMs,
1687 durationMs,
1682 lerp: true,
1688 lerp: true,
1683 spellProjectile: true,
1689 spellProjectile: true,
1684 baseSprite,
1690 tint,
1685 fromTileX: payload.fromTileX,
1691 fromTileX: payload.fromTileX,
1686 fromTileY: payload.fromTileY,
1692 fromTileY: payload.fromTileY,
1687 tileX: payload.tileX,
1693 tileX: payload.tileX,
@@ -1752,24 +1758,6 @@ export class WorldView
1752 );
1758 );
1753 }
1759 }
1754
1760
1755 #spellProjectileImage (baseSprite, frameIndex)
1756 {
1757 const frame = Math.max(0, Math.min(2, frameIndex | 0));
1758 const stem = baseSprite.split(":").pop() ?? "spell-light";
1759 const names = [
1760 `${baseSprite}-${frame}`,
1761 `fx:projectile:${stem}-${frame}`,
1762 baseSprite,
1763 `fx:projectile:${stem}`
1764 ];
1765 for (const name of names)
1766 {
1767 if (this.game.images[name])
1768 { return this.game.images[name]; }
1769 }
1770 return null;
1771 }
1772
1773 addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 })
1761 addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 })
1774 {
1762 {
1775 this.dynamicLights.push({
1763 this.dynamicLights.push({
@@ -4254,13 +4242,8 @@ export class WorldView
4254 toPivot.x - fromPivot.x
4242 toPivot.x - fromPivot.x
4255 ) * (180 / Math.PI);
4243 ) * (180 / Math.PI);
4256 }
4244 }
4257 if (swipe.spellProjectile && swipe.baseSprite)
4245 if (swipe.spellProjectile && swipe.tint)
4258 {
4246 { this.#syncUnlitTintSprite(swipe.object, swipe.tint); }
4259 const frame = Math.floor((now - swipe.started) / SPELL_PROJECTILE_FRAME_MS) % 3;
4260 const image = this.#spellProjectileImage(swipe.baseSprite, frame);
4261 if (image && swipe.object?.renderer)
4262 { swipe.object.renderer.sprite = image; }
4263 }
4264 this.#placePivoted(swipe.object, x, y, sortY, SORT_FX);
4247 this.#placePivoted(swipe.object, x, y, sortY, SORT_FX);
4265 if (!swipe.spellProjectile)
4248 if (!swipe.spellProjectile)
4266 {
4249 {
shared/definitions/spells.js +29 −17
@@ -1,6 +1,6 @@
1 1 import { spellDifficultyFromTier } from "../spells/constants.js";
2 2 import { MATERIAL_TIER_ORDER, tierStatBonus, tierMinSkillLevel } from "./materialTiers.js";
3 import { MagicElement } from "./attackTypes.js";
3 import { MagicElement, MAGIC_ELEMENT_TINT, magicElementTint } from "./attackTypes.js";
4 4
5 5 /**
6 6 * @typedef {object} SpellDefinition
@@ -12,13 +12,29 @@ import { MagicElement } from "./attackTypes.js";
12 12 * @property {boolean} [autoRepeat] Auto-cast repeats while target stays in range
13 13 * @property {number} [minMagicLevel] Minimum Magic level to cast / favourite
14 14 * @property {string} description In-world spell description
15 * @property {string} [projectileSprite] fx:projectile:spell-* base name
15 * @property {string} [projectileSprite] fx:projectile:spell-<spellId> magenta art
16 16 * @property {string} [effect] Server impact kind (defaults to spellId)
17 17 * @property {boolean} [starter] Known by default; no spellbook required
18 18 * @property {boolean} [mobOnly] Not offered on player spellbooks
19 19 * @property {boolean} [damageTree] Part of an elemental damage progression
20 20 */
21 21
22 /** Catalog image name for a spell's unique magenta projectile art. */
23 export function spellProjectileSprite (spellId)
24 {
25 return `fx:projectile:spell-${spellId}`;
26 }
27
28 /** Runtime tint for magenta projectile art (element colour, or white for none/holy). */
29 export function spellProjectileTint (element)
30 {
31 if (element === "holy")
32 { return Object.freeze({ r: 1, g: 0.92, b: 0.75 }); }
33 if (!element || element === "none")
34 { return Object.freeze({ r: 1, g: 1, b: 1 }); }
35 return magicElementTint(element) ?? MAGIC_ELEMENT_TINT[MagicElement.fire];
36 }
37
22 38 /**
23 39 * Elemental damage trees (tiers 3–7), plus utility / special spells.
24 40 * Legacy `spark` was removed — unknown ids are dropped on load/normalize.
@@ -86,10 +102,6 @@ export const SpellId = Object.freeze({
86 102 spriteBoltPoison: "sprite-bolt-poison"
87 103 });
88 104
89 /** Shared projectile art for damage bolts (tinted by element on cast later if needed). */
90 const BOLT_PROJECTILE = "fx:projectile:spell-spark";
91 const LIGHT_PROJECTILE = "fx:projectile:spell-light";
92
93 105 /**
94 106 * Damage progression per element — mirrors the fire ladder (tiers 3–7).
95 107 * @type {ReadonlyArray<{ element: string, spells: ReadonlyArray<{ id: string, name: string, description: string }> }>}
@@ -345,7 +357,7 @@ function buildDamageTreeDefinitions ()
345 357 target: "entity",
346 358 autoRepeat: true,
347 359 minMagicLevel: spellMinMagicLevelFromTier(tier),
348 projectileSprite: BOLT_PROJECTILE,
360 projectileSprite: spellProjectileSprite(entry.id),
349 361 effect: "damage",
350 362 damageTree: true,
351 363 description: entry.description
@@ -366,7 +378,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
366 378 autoRepeat: false,
367 379 minMagicLevel: spellMinMagicLevelFromTier(1),
368 380 starter: true,
369 projectileSprite: LIGHT_PROJECTILE,
381 projectileSprite: spellProjectileSprite(SpellId.light),
370 382 effect: "light",
371 383 description: "A whisper of radiance that settles on stone or grass, holding back the dark for a while."
372 384 }),
@@ -378,7 +390,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
378 390 target: "entity",
379 391 autoRepeat: true,
380 392 minMagicLevel: spellMinMagicLevelFromTier(1),
381 projectileSprite: BOLT_PROJECTILE,
393 projectileSprite: spellProjectileSprite(SpellId.manaBullet),
382 394 effect: "damage",
383 395 description: "A small shot of raw mana, swift and simple, for those just learning to strike."
384 396 }),
@@ -390,7 +402,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
390 402 target: "tile",
391 403 autoRepeat: false,
392 404 minMagicLevel: spellMinMagicLevelFromTier(2),
393 projectileSprite: LIGHT_PROJECTILE,
405 projectileSprite: spellProjectileSprite(SpellId.dark),
394 406 effect: "dark",
395 407 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
396 408 }),
@@ -402,7 +414,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
402 414 target: "entity",
403 415 autoRepeat: true,
404 416 minMagicLevel: spellMinMagicLevelFromTier(2),
405 projectileSprite: BOLT_PROJECTILE,
417 projectileSprite: spellProjectileSprite(SpellId.magicMissile),
406 418 effect: "damage",
407 419 description: "A plain dart of force that flies true and strikes without favour of the elements."
408 420 }),
@@ -415,7 +427,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
415 427 target: "entity",
416 428 autoRepeat: true,
417 429 minMagicLevel: spellMinMagicLevelFromTier(3),
418 projectileSprite: BOLT_PROJECTILE,
430 projectileSprite: spellProjectileSprite(SpellId.poison),
419 431 effect: "poison",
420 432 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
421 433 }),
@@ -427,7 +439,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
427 439 target: "entity",
428 440 autoRepeat: true,
429 441 minMagicLevel: spellMinMagicLevelFromTier(4),
430 projectileSprite: LIGHT_PROJECTILE,
442 projectileSprite: spellProjectileSprite(SpellId.drain),
431 443 effect: "drain",
432 444 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
433 445 }),
@@ -439,7 +451,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
439 451 target: "tile",
440 452 autoRepeat: true,
441 453 minMagicLevel: spellMinMagicLevelFromTier(3),
442 projectileSprite: BOLT_PROJECTILE,
454 projectileSprite: spellProjectileSprite(SpellId.tinders),
443 455 effect: "tinders",
444 456 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
445 457 }),
@@ -451,7 +463,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
451 463 target: "tile",
452 464 autoRepeat: false,
453 465 minMagicLevel: spellMinMagicLevelFromTier(6),
454 projectileSprite: LIGHT_PROJECTILE,
466 projectileSprite: spellProjectileSprite(SpellId.shade),
455 467 effect: "shade",
456 468 description: "A summoned shadow that fights beside you until the magic frays."
457 469 }),
@@ -463,7 +475,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
463 475 target: "entity",
464 476 autoRepeat: false,
465 477 minMagicLevel: spellMinMagicLevelFromTier(5),
466 projectileSprite: LIGHT_PROJECTILE,
478 projectileSprite: spellProjectileSprite(SpellId.revitalize),
467 479 effect: "revitalize",
468 480 description: "A gentle current of life that mends wounds one breath at a time."
469 481 }),
@@ -486,7 +498,7 @@ function spriteBoltDef (spellId, displayName, element)
486 498 target: "entity",
487 499 autoRepeat: true,
488 500 minMagicLevel: 1,
489 projectileSprite: BOLT_PROJECTILE,
501 projectileSprite: spellProjectileSprite(spellId),
490 502 effect: "damage",
491 503 mobOnly: true,
492 504 description: `A flickering ${element} mote cast by a sprite.`
@@ -1,6 +1,6 @@
1import { spellDifficultyFromTier } from "../spells/constants.js";
1import { spellDifficultyFromTier } from "../spells/constants.js";
2import { MATERIAL_TIER_ORDER, tierStatBonus, tierMinSkillLevel } from "./materialTiers.js";
2import { MATERIAL_TIER_ORDER, tierStatBonus, tierMinSkillLevel } from "./materialTiers.js";
3import { MagicElement } from "./attackTypes.js";
3import { MagicElement, MAGIC_ELEMENT_TINT, magicElementTint } from "./attackTypes.js";
4
4
5/**
5/**
6 * @typedef {object} SpellDefinition
6 * @typedef {object} SpellDefinition
@@ -12,13 +12,29 @@ import { MagicElement } from "./attackTypes.js";
12 * @property {boolean} [autoRepeat] Auto-cast repeats while target stays in range
12 * @property {boolean} [autoRepeat] Auto-cast repeats while target stays in range
13 * @property {number} [minMagicLevel] Minimum Magic level to cast / favourite
13 * @property {number} [minMagicLevel] Minimum Magic level to cast / favourite
14 * @property {string} description In-world spell description
14 * @property {string} description In-world spell description
15 * @property {string} [projectileSprite] fx:projectile:spell-* base name
15 * @property {string} [projectileSprite] fx:projectile:spell-<spellId> magenta art
16 * @property {string} [effect] Server impact kind (defaults to spellId)
16 * @property {string} [effect] Server impact kind (defaults to spellId)
17 * @property {boolean} [starter] Known by default; no spellbook required
17 * @property {boolean} [starter] Known by default; no spellbook required
18 * @property {boolean} [mobOnly] Not offered on player spellbooks
18 * @property {boolean} [mobOnly] Not offered on player spellbooks
19 * @property {boolean} [damageTree] Part of an elemental damage progression
19 * @property {boolean} [damageTree] Part of an elemental damage progression
20 */
20 */
21
21
22/** Catalog image name for a spell's unique magenta projectile art. */
23export function spellProjectileSprite (spellId)
24{
25 return `fx:projectile:spell-${spellId}`;
26}
27
28/** Runtime tint for magenta projectile art (element colour, or white for none/holy). */
29export function spellProjectileTint (element)
30{
31 if (element === "holy")
32 { return Object.freeze({ r: 1, g: 0.92, b: 0.75 }); }
33 if (!element || element === "none")
34 { return Object.freeze({ r: 1, g: 1, b: 1 }); }
35 return magicElementTint(element) ?? MAGIC_ELEMENT_TINT[MagicElement.fire];
36}
37
22/**
38/**
23 * Elemental damage trees (tiers 3–7), plus utility / special spells.
39 * Elemental damage trees (tiers 3–7), plus utility / special spells.
24 * Legacy `spark` was removed — unknown ids are dropped on load/normalize.
40 * Legacy `spark` was removed — unknown ids are dropped on load/normalize.
@@ -86,10 +102,6 @@ export const SpellId = Object.freeze({
86 spriteBoltPoison: "sprite-bolt-poison"
102 spriteBoltPoison: "sprite-bolt-poison"
87});
103});
88
104
89/** Shared projectile art for damage bolts (tinted by element on cast later if needed). */
90const BOLT_PROJECTILE = "fx:projectile:spell-spark";
91const LIGHT_PROJECTILE = "fx:projectile:spell-light";
92
93/**
105/**
94 * Damage progression per element — mirrors the fire ladder (tiers 3–7).
106 * Damage progression per element — mirrors the fire ladder (tiers 3–7).
95 * @type {ReadonlyArray<{ element: string, spells: ReadonlyArray<{ id: string, name: string, description: string }> }>}
107 * @type {ReadonlyArray<{ element: string, spells: ReadonlyArray<{ id: string, name: string, description: string }> }>}
@@ -345,7 +357,7 @@ function buildDamageTreeDefinitions ()
345 target: "entity",
357 target: "entity",
346 autoRepeat: true,
358 autoRepeat: true,
347 minMagicLevel: spellMinMagicLevelFromTier(tier),
359 minMagicLevel: spellMinMagicLevelFromTier(tier),
348 projectileSprite: BOLT_PROJECTILE,
360 projectileSprite: spellProjectileSprite(entry.id),
349 effect: "damage",
361 effect: "damage",
350 damageTree: true,
362 damageTree: true,
351 description: entry.description
363 description: entry.description
@@ -366,7 +378,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
366 autoRepeat: false,
378 autoRepeat: false,
367 minMagicLevel: spellMinMagicLevelFromTier(1),
379 minMagicLevel: spellMinMagicLevelFromTier(1),
368 starter: true,
380 starter: true,
369 projectileSprite: LIGHT_PROJECTILE,
381 projectileSprite: spellProjectileSprite(SpellId.light),
370 effect: "light",
382 effect: "light",
371 description: "A whisper of radiance that settles on stone or grass, holding back the dark for a while."
383 description: "A whisper of radiance that settles on stone or grass, holding back the dark for a while."
372 }),
384 }),
@@ -378,7 +390,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
378 target: "entity",
390 target: "entity",
379 autoRepeat: true,
391 autoRepeat: true,
380 minMagicLevel: spellMinMagicLevelFromTier(1),
392 minMagicLevel: spellMinMagicLevelFromTier(1),
381 projectileSprite: BOLT_PROJECTILE,
393 projectileSprite: spellProjectileSprite(SpellId.manaBullet),
382 effect: "damage",
394 effect: "damage",
383 description: "A small shot of raw mana, swift and simple, for those just learning to strike."
395 description: "A small shot of raw mana, swift and simple, for those just learning to strike."
384 }),
396 }),
@@ -390,7 +402,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
390 target: "tile",
402 target: "tile",
391 autoRepeat: false,
403 autoRepeat: false,
392 minMagicLevel: spellMinMagicLevelFromTier(2),
404 minMagicLevel: spellMinMagicLevelFromTier(2),
393 projectileSprite: LIGHT_PROJECTILE,
405 projectileSprite: spellProjectileSprite(SpellId.dark),
394 effect: "dark",
406 effect: "dark",
395 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
407 description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim."
396 }),
408 }),
@@ -402,7 +414,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
402 target: "entity",
414 target: "entity",
403 autoRepeat: true,
415 autoRepeat: true,
404 minMagicLevel: spellMinMagicLevelFromTier(2),
416 minMagicLevel: spellMinMagicLevelFromTier(2),
405 projectileSprite: BOLT_PROJECTILE,
417 projectileSprite: spellProjectileSprite(SpellId.magicMissile),
406 effect: "damage",
418 effect: "damage",
407 description: "A plain dart of force that flies true and strikes without favour of the elements."
419 description: "A plain dart of force that flies true and strikes without favour of the elements."
408 }),
420 }),
@@ -415,7 +427,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
415 target: "entity",
427 target: "entity",
416 autoRepeat: true,
428 autoRepeat: true,
417 minMagicLevel: spellMinMagicLevelFromTier(3),
429 minMagicLevel: spellMinMagicLevelFromTier(3),
418 projectileSprite: BOLT_PROJECTILE,
430 projectileSprite: spellProjectileSprite(SpellId.poison),
419 effect: "poison",
431 effect: "poison",
420 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
432 description: "A venomous curse that sinks in without a wound, then eats at the body over time."
421 }),
433 }),
@@ -427,7 +439,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
427 target: "entity",
439 target: "entity",
428 autoRepeat: true,
440 autoRepeat: true,
429 minMagicLevel: spellMinMagicLevelFromTier(4),
441 minMagicLevel: spellMinMagicLevelFromTier(4),
430 projectileSprite: LIGHT_PROJECTILE,
442 projectileSprite: spellProjectileSprite(SpellId.drain),
431 effect: "drain",
443 effect: "drain",
432 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
444 description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover."
433 }),
445 }),
@@ -439,7 +451,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
439 target: "tile",
451 target: "tile",
440 autoRepeat: true,
452 autoRepeat: true,
441 minMagicLevel: spellMinMagicLevelFromTier(3),
453 minMagicLevel: spellMinMagicLevelFromTier(3),
442 projectileSprite: BOLT_PROJECTILE,
454 projectileSprite: spellProjectileSprite(SpellId.tinders),
443 effect: "tinders",
455 effect: "tinders",
444 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
456 description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would."
445 }),
457 }),
@@ -451,7 +463,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
451 target: "tile",
463 target: "tile",
452 autoRepeat: false,
464 autoRepeat: false,
453 minMagicLevel: spellMinMagicLevelFromTier(6),
465 minMagicLevel: spellMinMagicLevelFromTier(6),
454 projectileSprite: LIGHT_PROJECTILE,
466 projectileSprite: spellProjectileSprite(SpellId.shade),
455 effect: "shade",
467 effect: "shade",
456 description: "A summoned shadow that fights beside you until the magic frays."
468 description: "A summoned shadow that fights beside you until the magic frays."
457 }),
469 }),
@@ -463,7 +475,7 @@ export const SPELL_DEFINITIONS = Object.freeze({
463 target: "entity",
475 target: "entity",
464 autoRepeat: false,
476 autoRepeat: false,
465 minMagicLevel: spellMinMagicLevelFromTier(5),
477 minMagicLevel: spellMinMagicLevelFromTier(5),
466 projectileSprite: LIGHT_PROJECTILE,
478 projectileSprite: spellProjectileSprite(SpellId.revitalize),
467 effect: "revitalize",
479 effect: "revitalize",
468 description: "A gentle current of life that mends wounds one breath at a time."
480 description: "A gentle current of life that mends wounds one breath at a time."
469 }),
481 }),
@@ -486,7 +498,7 @@ function spriteBoltDef (spellId, displayName, element)
486 target: "entity",
498 target: "entity",
487 autoRepeat: true,
499 autoRepeat: true,
488 minMagicLevel: 1,
500 minMagicLevel: 1,
489 projectileSprite: BOLT_PROJECTILE,
501 projectileSprite: spellProjectileSprite(spellId),
490 effect: "damage",
502 effect: "damage",
491 mobOnly: true,
503 mobOnly: true,
492 description: `A flickering ${element} mote cast by a sprite.`
504 description: `A flickering ${element} mote cast by a sprite.`
shared/spells/constants.js +0 −1
@@ -20,7 +20,6 @@ export const LIGHT_FADE_MS = 3000;
20 20 export const LIGHT_OWNER_DISTANCE_CAP_MS = 5000;
21 21
22 22 export const CAST_FLASH_MS = 500;
23 export const SPELL_PROJECTILE_FRAME_MS = 250;
24 23
25 24 /**
26 25 * Magic contest die size from spell tier.
@@ -20,7 +20,6 @@ export const LIGHT_FADE_MS = 3000;
20export const LIGHT_OWNER_DISTANCE_CAP_MS = 5000;
20export const LIGHT_OWNER_DISTANCE_CAP_MS = 5000;
21
21
22export const CAST_FLASH_MS = 500;
22export const CAST_FLASH_MS = 500;
23export const SPELL_PROJECTILE_FRAME_MS = 250;
24
23
25/**
24/**
26 * Magic contest die size from spell tier.
25 * Magic contest die size from spell tier.