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.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -1,74 +1,59 @@
import { mkdirSync, writeFileSync } from "node:fs";
import { deflateSync } from "node:zlib";
#!/usr/bin/env node
/**
* Magenta placeholder projectile art: one PNG per spell under
* client/assets/fx/projectile/spell-<spellId>.png
*
* Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element).
* Replace any file with hand-drawn art; keep magenta for tintable regions.
*
* node client/scripts/write-spell-projectile-template.mjs
*/
import { unlinkSync, existsSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";
import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";
const spells = [
{ id: "spell-light", rgb: [255, 248, 192] },
{ id: "spell-spark", rgb: [255, 144, 64] }
];
mkdirSync(new URL("../assets/fx/projectile/", import.meta.url), { recursive: true });
const SIZE = 8;
const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile");
for (const spell of spells)
{
for (let frame = 0; frame < 3; frame++)
{
const png = buildPng5(spell.rgb);
writeFileSync(
new URL(`../assets/fx/projectile/${spell.id}-${frame}.png`, import.meta.url),
png
);
}
}
/** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */
const MAGENTA = [220, 0, 220, 255];
const MAGENTA_HI = [255, 120, 255, 255];
function buildPng5 ([r, g, b])
const legacy = [
"spell-light-0.png",
"spell-light-1.png",
"spell-light-2.png",
"spell-spark-0.png",
"spell-spark-1.png",
"spell-spark-2.png"
];
for (const name of legacy)
{
const row = Buffer.alloc(1 + 5 * 4);
row[0] = 0;
for (let x = 0; x < 5; x++)
const path = join(OUT_DIR, name);
if (existsSync(path))
{
const i = 1 + x * 4;
row[i] = r;
row[i + 1] = g;
row[i + 2] = b;
row[i + 3] = x === 0 || x === 4 ? 0 : 255;
unlinkSync(path);
console.log(`Removed legacy ${name}`);
}
const raw = Buffer.concat(Array.from({ length: 5 }, () => row));
return encodePng(5, 5, deflateSync(raw));
}
function encodePng (w, h, idat)
let wrote = 0;
for (const def of Object.values(SPELL_DEFINITIONS))
{
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
const ihdr = chunk("IHDR", (() =>
{
const buf = Buffer.alloc(13);
buf.writeUInt32BE(w, 0);
buf.writeUInt32BE(h, 4);
buf[8] = 8; buf[9] = 6;
return buf;
})());
return Buffer.concat([signature, ihdr, chunk("IDAT", idat), chunk("IEND", Buffer.alloc(0))]);
const file = join(OUT_DIR, `spell-${def.spellId}.png`);
const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);
// Diamond body
fillRect(image, 3, 1, 2, 1, MAGENTA);
fillRect(image, 2, 2, 4, 1, MAGENTA);
fillRect(image, 1, 3, 6, 2, MAGENTA);
fillRect(image, 2, 5, 4, 1, MAGENTA);
fillRect(image, 3, 6, 2, 1, MAGENTA);
// Center highlight
fillRect(image, 3, 3, 2, 2, MAGENTA_HI);
writeRgbaPng(file, SIZE, SIZE, image.pixels);
wrote += 1;
}
function chunk (type, data)
{
const len = Buffer.alloc(4);
len.writeUInt32BE(data.length, 0);
const t = Buffer.from(type);
const crc = crc32(Buffer.concat([t, data]));
const c = Buffer.alloc(4);
c.writeUInt32BE(crc >>> 0, 0);
return Buffer.concat([len, t, data, c]);
}
function crc32 (buf)
{
let c = ~0;
for (let i = 0; i < buf.length; i++)
{
c ^= buf[i];
for (let k = 0; k < 8; k++)
{ c = (c >>> 1) ^ (c & 1 ? 0xedb88320 : 0); }
}
return ~c;
}
console.log(`Wrote ${wrote} magenta spell projectile placeholders in ${OUT_DIR}`);
@@ -1,74 +1,59 @@import { mkdirSync, writeFileSync } from "node:fs";#!/usr/bin/env nodeimport { deflateSync } from "node:zlib";/** * Magenta placeholder projectile art: one PNG per spell under * client/assets/fx/projectile/spell-<spellId>.png * * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element). * Replace any file with hand-drawn art; keep magenta for tintable regions. * * node client/scripts/write-spell-projectile-template.mjs */import { unlinkSync, existsSync } from "node:fs";import { join, dirname } from "node:path";import { fileURLToPath } from "node:url";import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";const spells = [const SIZE = 8; { id: "spell-light", rgb: [255, 248, 192] },const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile"); { id: "spell-spark", rgb: [255, 144, 64] }];mkdirSync(new URL("../assets/fx/projectile/", import.meta.url), { recursive: true });for (const spell of spells)/** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */{const MAGENTA = [220, 0, 220, 255]; for (let frame = 0; frame < 3; frame++)const MAGENTA_HI = [255, 120, 255, 255]; { const png = buildPng5(spell.rgb); writeFileSync( new URL(`../assets/fx/projectile/${spell.id}-${frame}.png`, import.meta.url), png ); }}function buildPng5 ([r, g, b])const legacy = [ "spell-light-0.png", "spell-light-1.png", "spell-light-2.png", "spell-spark-0.png", "spell-spark-1.png", "spell-spark-2.png"];for (const name of legacy){{ const row = Buffer.alloc(1 + 5 * 4); const path = join(OUT_DIR, name); row[0] = 0; if (existsSync(path)) for (let x = 0; x < 5; x++) { { const i = 1 + x * 4; unlinkSync(path); row[i] = r; console.log(`Removed legacy ${name}`); row[i + 1] = g; row[i + 2] = b; row[i + 3] = x === 0 || x === 4 ? 0 : 255; } } const raw = Buffer.concat(Array.from({ length: 5 }, () => row)); return encodePng(5, 5, deflateSync(raw));}}function encodePng (w, h, idat)let wrote = 0;for (const def of Object.values(SPELL_DEFINITIONS)){{ const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]); const file = join(OUT_DIR, `spell-${def.spellId}.png`); const ihdr = chunk("IHDR", (() => const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]); { // Diamond body const buf = Buffer.alloc(13); fillRect(image, 3, 1, 2, 1, MAGENTA); buf.writeUInt32BE(w, 0); fillRect(image, 2, 2, 4, 1, MAGENTA); buf.writeUInt32BE(h, 4); fillRect(image, 1, 3, 6, 2, MAGENTA); buf[8] = 8; buf[9] = 6; fillRect(image, 2, 5, 4, 1, MAGENTA); return buf; fillRect(image, 3, 6, 2, 1, MAGENTA); })()); // Center highlight return Buffer.concat([signature, ihdr, chunk("IDAT", idat), chunk("IEND", Buffer.alloc(0))]); fillRect(image, 3, 3, 2, 2, MAGENTA_HI); writeRgbaPng(file, SIZE, SIZE, image.pixels); wrote += 1;}}function chunk (type, data)console.log(`Wrote ${wrote} magenta spell projectile placeholders in ${OUT_DIR}`);{ const len = Buffer.alloc(4); len.writeUInt32BE(data.length, 0); const t = Buffer.from(type); const crc = crc32(Buffer.concat([t, data])); const c = Buffer.alloc(4); c.writeUInt32BE(crc >>> 0, 0); return Buffer.concat([len, t, data, c]);}function crc32 (buf){ let c = ~0; for (let i = 0; i < buf.length; i++) { c ^= buf[i]; for (let k = 0; k < 8; k++) { c = (c >>> 1) ^ (c & 1 ? 0xedb88320 : 0); } } return ~c;}@@ -34,7 +34,7 @@ import
resolveDimensionDarknessFactor,
resolveDimensionSeasonId
} from "/shared/world/dimensions.js";
import { SPELL_PROJECTILE_FRAME_MS } from "/shared/spells/constants.js";
import { spellDefinition, spellProjectileTint } from "/shared/definitions/spells.js";
import { skullTintColor } from "/shared/combat/skull.js";
const LAYER_GROUND = 0;
@@ -1646,13 +1646,18 @@ export class WorldView
});
}
/** Bloom-layer spell projectiles — unlit, animated travel. */
/** Bloom-layer spell projectiles — magenta-tinted, unique art per spell. */
spawnSpellProjectileFx (payload)
{
const baseSprite = payload.sprite ?? "fx:projectile:spell-light";
const image = this.#spellProjectileImage(baseSprite, 0);
const spellId = payload.spellId ?? null;
const def = spellId != null ? spellDefinition(spellId) : null;
const spriteName = payload.sprite
?? def?.projectileSprite
?? "fx:projectile:spell-mana-bullet";
const image = this.game.images[spriteName];
if (!image)
{ return; }
const tint = spellProjectileTint(def?.element);
const fromPivot = this.#projectileLaunchPoint(
payload.casterId ?? null,
payload.fromTileX,
@@ -1668,6 +1673,7 @@ export class WorldView
const object = new GameObject(0, 0, image, SORT_FX);
object.renderer.layer = RENDER_LAYER_BLOOM;
this.#markUnlit(object);
this.#syncUnlitTintSprite(object, tint);
if (object.transform)
{ object.transform.rotation = angle; }
this.scene.addObject(object);
@@ -1681,7 +1687,7 @@ export class WorldView
durationMs,
lerp: true,
spellProjectile: true,
baseSprite,
tint,
fromTileX: payload.fromTileX,
fromTileY: payload.fromTileY,
tileX: payload.tileX,
@@ -1752,24 +1758,6 @@ export class WorldView
);
}
#spellProjectileImage (baseSprite, frameIndex)
{
const frame = Math.max(0, Math.min(2, frameIndex | 0));
const stem = baseSprite.split(":").pop() ?? "spell-light";
const names = [
`${baseSprite}-${frame}`,
`fx:projectile:${stem}-${frame}`,
baseSprite,
`fx:projectile:${stem}`
];
for (const name of names)
{
if (this.game.images[name])
{ return this.game.images[name]; }
}
return null;
}
addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 })
{
this.dynamicLights.push({
@@ -4254,13 +4242,8 @@ export class WorldView
toPivot.x - fromPivot.x
) * (180 / Math.PI);
}
if (swipe.spellProjectile && swipe.baseSprite)
{
const frame = Math.floor((now - swipe.started) / SPELL_PROJECTILE_FRAME_MS) % 3;
const image = this.#spellProjectileImage(swipe.baseSprite, frame);
if (image && swipe.object?.renderer)
{ swipe.object.renderer.sprite = image; }
}
if (swipe.spellProjectile && swipe.tint)
{ this.#syncUnlitTintSprite(swipe.object, swipe.tint); }
this.#placePivoted(swipe.object, x, y, sortY, SORT_FX);
if (!swipe.spellProjectile)
{
@@ -34,7 +34,7 @@ import resolveDimensionDarknessFactor, resolveDimensionDarknessFactor, resolveDimensionSeasonId resolveDimensionSeasonId} from "/shared/world/dimensions.js";} from "/shared/world/dimensions.js";import { SPELL_PROJECTILE_FRAME_MS } from "/shared/spells/constants.js";import { spellDefinition, spellProjectileTint } from "/shared/definitions/spells.js";import { skullTintColor } from "/shared/combat/skull.js";import { skullTintColor } from "/shared/combat/skull.js";const LAYER_GROUND = 0;const LAYER_GROUND = 0;@@ -1646,13 +1646,18 @@ export class WorldView }); }); } } /** Bloom-layer spell projectiles — unlit, animated travel. */ /** Bloom-layer spell projectiles — magenta-tinted, unique art per spell. */ spawnSpellProjectileFx (payload) spawnSpellProjectileFx (payload) { { const baseSprite = payload.sprite ?? "fx:projectile:spell-light"; const spellId = payload.spellId ?? null; const image = this.#spellProjectileImage(baseSprite, 0); const def = spellId != null ? spellDefinition(spellId) : null; const spriteName = payload.sprite ?? def?.projectileSprite ?? "fx:projectile:spell-mana-bullet"; const image = this.game.images[spriteName]; if (!image) if (!image) { return; } { return; } const tint = spellProjectileTint(def?.element); const fromPivot = this.#projectileLaunchPoint( const fromPivot = this.#projectileLaunchPoint( payload.casterId ?? null, payload.casterId ?? null, payload.fromTileX, payload.fromTileX,@@ -1668,6 +1673,7 @@ export class WorldView const object = new GameObject(0, 0, image, SORT_FX); const object = new GameObject(0, 0, image, SORT_FX); object.renderer.layer = RENDER_LAYER_BLOOM; object.renderer.layer = RENDER_LAYER_BLOOM; this.#markUnlit(object); this.#markUnlit(object); this.#syncUnlitTintSprite(object, tint); if (object.transform) if (object.transform) { object.transform.rotation = angle; } { object.transform.rotation = angle; } this.scene.addObject(object); this.scene.addObject(object);@@ -1681,7 +1687,7 @@ export class WorldView durationMs, durationMs, lerp: true, lerp: true, spellProjectile: true, spellProjectile: true, baseSprite, tint, fromTileX: payload.fromTileX, fromTileX: payload.fromTileX, fromTileY: payload.fromTileY, fromTileY: payload.fromTileY, tileX: payload.tileX, tileX: payload.tileX,@@ -1752,24 +1758,6 @@ export class WorldView ); ); } } #spellProjectileImage (baseSprite, frameIndex) { const frame = Math.max(0, Math.min(2, frameIndex | 0)); const stem = baseSprite.split(":").pop() ?? "spell-light"; const names = [ `${baseSprite}-${frame}`, `fx:projectile:${stem}-${frame}`, baseSprite, `fx:projectile:${stem}` ]; for (const name of names) { if (this.game.images[name]) { return this.game.images[name]; } } return null; } addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 }) addDynamicLight ({ worldX, worldY, radiusTiles = 3, intensity = 1, durationMs = 250 }) { { this.dynamicLights.push({ this.dynamicLights.push({@@ -4254,13 +4242,8 @@ export class WorldView toPivot.x - fromPivot.x toPivot.x - fromPivot.x ) * (180 / Math.PI); ) * (180 / Math.PI); } } if (swipe.spellProjectile && swipe.baseSprite) if (swipe.spellProjectile && swipe.tint) { { this.#syncUnlitTintSprite(swipe.object, swipe.tint); } const frame = Math.floor((now - swipe.started) / SPELL_PROJECTILE_FRAME_MS) % 3; const image = this.#spellProjectileImage(swipe.baseSprite, frame); if (image && swipe.object?.renderer) { swipe.object.renderer.sprite = image; } } this.#placePivoted(swipe.object, x, y, sortY, SORT_FX); this.#placePivoted(swipe.object, x, y, sortY, SORT_FX); if (!swipe.spellProjectile) if (!swipe.spellProjectile) { {