Rename spell projectiles to spell-<element>-<tier>-<name>.
Sorts by element then tier in the asset folder and matches each spell more clearly.
@@ -1,7 +1,7 @@
1
1
#!/usr/bin/env node
2
2
/**
3
3
* Magenta placeholder projectile art: one PNG per spell under
4
* client/assets/fx/projectile/spell-<spellId>.png
4
* client/assets/fx/projectile/spell-<element>-<tier>-<spellId>.png
5
5
*
6
6
* Canvas is 16×16. Facing: the RIGHT side (+X) is the front/tip — the same
7
7
* convention as arrow.png. Runtime rotates with atan2(dy, dx) so 0° = flying east.
@@ -11,11 +11,11 @@
11
11
*
12
12
* node client/scripts/write-spell-projectile-template.mjs
13
13
*/
14
import { unlinkSync, existsSync } from "node:fs";
14
import { unlinkSync, readdirSync } from "node:fs";
15
15
import { join, dirname } from "node:path";
16
16
import { fileURLToPath } from "node:url";
17
17
import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";
18
import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";
18
import { SPELL_DEFINITIONS, spellProjectileStem } from "../../shared/definitions/spells.js";
19
19
20
20
const SIZE = 16;
21
21
/** Offset so the original 8×8 diamond sits centred on the 16×16 canvas. */
@@ -27,39 +27,34 @@ const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "f
27
27
const MAGENTA = [220, 0, 220, 255];
28
28
const MAGENTA_HI = [255, 120, 255, 255];
29
29
30
const legacy = [
31
"spell-light-0.png",
32
"spell-light-1.png",
33
"spell-light-2.png",
34
"spell-spark-0.png",
35
"spell-spark-1.png",
36
"spell-spark-2.png"
37
];
38
for (const name of legacy)
39
{
40
const path = join(OUT_DIR, name);
41
if (existsSync(path))
42
{
43
unlinkSync(path);
44
console.log(`Removed legacy ${name}`);
45
}
46
}
30
const keep = new Set(["arrow.png", "arrow-tipped.png"]);
31
const wanted = new Set();
47
32
48
33
let wrote = 0;
49
34
for (const def of Object.values(SPELL_DEFINITIONS))
50
35
{
51
const file = join(OUT_DIR, `spell-${def.spellId}.png`);
36
const stem = spellProjectileStem(def.element, def.tier, def.spellId);
37
wanted.add(`${stem}.png`);
38
const file = join(OUT_DIR, `${stem}.png`);
52
39
const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);
53
// Diamond body (same pixels as the old 8×8 art, centred)
54
40
fillRect(image, OX + 3, OY + 1, 2, 1, MAGENTA);
55
41
fillRect(image, OX + 2, OY + 2, 4, 1, MAGENTA);
56
42
fillRect(image, OX + 1, OY + 3, 6, 2, MAGENTA);
57
43
fillRect(image, OX + 2, OY + 5, 4, 1, MAGENTA);
58
44
fillRect(image, OX + 3, OY + 6, 2, 1, MAGENTA);
59
// Center highlight
60
45
fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI);
61
46
writeRgbaPng(file, SIZE, SIZE, image.pixels);
62
47
wrote += 1;
63
48
}
64
49
50
for (const name of readdirSync(OUT_DIR))
51
{
52
if (!name.startsWith("spell-") || !name.endsWith(".png"))
53
{ continue; }
54
if (wanted.has(name) || keep.has(name))
55
{ continue; }
56
unlinkSync(join(OUT_DIR, name));
57
console.log(`Removed obsolete ${name}`);
58
}
59
65
60
console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`);
@@ -1,7 +1,7 @@1
#!/usr/bin/env node1
#!/usr/bin/env node2
/**2
/**3
* Magenta placeholder projectile art: one PNG per spell under3
* Magenta placeholder projectile art: one PNG per spell under4
* client/assets/fx/projectile/spell-<spellId>.png4
* client/assets/fx/projectile/spell-<element>-<tier>-<spellId>.png5
*5
*6
* Canvas is 16×16. Facing: the RIGHT side (+X) is the front/tip — the same6
* Canvas is 16×16. Facing: the RIGHT side (+X) is the front/tip — the same7
* convention as arrow.png. Runtime rotates with atan2(dy, dx) so 0° = flying east.7
* convention as arrow.png. Runtime rotates with atan2(dy, dx) so 0° = flying east.@@ -11,11 +11,11 @@11
*11
*12
* node client/scripts/write-spell-projectile-template.mjs12
* node client/scripts/write-spell-projectile-template.mjs13
*/13
*/14
import { unlinkSync, existsSync } from "node:fs";14
import { unlinkSync, readdirSync } from "node:fs";15
import { join, dirname } from "node:path";15
import { join, dirname } from "node:path";16
import { fileURLToPath } from "node:url";16
import { fileURLToPath } from "node:url";17
import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";17
import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";18
import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js";18
import { SPELL_DEFINITIONS, spellProjectileStem } from "../../shared/definitions/spells.js";19
19
20
const SIZE = 16;20
const SIZE = 16;21
/** Offset so the original 8×8 diamond sits centred on the 16×16 canvas. */21
/** Offset so the original 8×8 diamond sits centred on the 16×16 canvas. */@@ -27,39 +27,34 @@ const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "f27
const MAGENTA = [220, 0, 220, 255];27
const MAGENTA = [220, 0, 220, 255];28
const MAGENTA_HI = [255, 120, 255, 255];28
const MAGENTA_HI = [255, 120, 255, 255];29
29
30
const legacy = [30
const keep = new Set(["arrow.png", "arrow-tipped.png"]);31
"spell-light-0.png",31
const wanted = new Set();32
"spell-light-1.png",33
"spell-light-2.png",34
"spell-spark-0.png",35
"spell-spark-1.png",36
"spell-spark-2.png"37
];38
for (const name of legacy)39
{40
const path = join(OUT_DIR, name);41
if (existsSync(path))42
{43
unlinkSync(path);44
console.log(`Removed legacy ${name}`);45
}46
}47
32
48
let wrote = 0;33
let wrote = 0;49
for (const def of Object.values(SPELL_DEFINITIONS))34
for (const def of Object.values(SPELL_DEFINITIONS))50
{35
{51
const file = join(OUT_DIR, `spell-${def.spellId}.png`);36
const stem = spellProjectileStem(def.element, def.tier, def.spellId);37
wanted.add(`${stem}.png`);38
const file = join(OUT_DIR, `${stem}.png`);52
const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);39
const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]);53
// Diamond body (same pixels as the old 8×8 art, centred)54
fillRect(image, OX + 3, OY + 1, 2, 1, MAGENTA);40
fillRect(image, OX + 3, OY + 1, 2, 1, MAGENTA);55
fillRect(image, OX + 2, OY + 2, 4, 1, MAGENTA);41
fillRect(image, OX + 2, OY + 2, 4, 1, MAGENTA);56
fillRect(image, OX + 1, OY + 3, 6, 2, MAGENTA);42
fillRect(image, OX + 1, OY + 3, 6, 2, MAGENTA);57
fillRect(image, OX + 2, OY + 5, 4, 1, MAGENTA);43
fillRect(image, OX + 2, OY + 5, 4, 1, MAGENTA);58
fillRect(image, OX + 3, OY + 6, 2, 1, MAGENTA);44
fillRect(image, OX + 3, OY + 6, 2, 1, MAGENTA);59
// Center highlight60
fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI);45
fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI);61
writeRgbaPng(file, SIZE, SIZE, image.pixels);46
writeRgbaPng(file, SIZE, SIZE, image.pixels);62
wrote += 1;47
wrote += 1;63
}48
}64
49
50
for (const name of readdirSync(OUT_DIR))51
{52
if (!name.startsWith("spell-") || !name.endsWith(".png"))53
{ continue; }54
if (wanted.has(name) || keep.has(name))55
{ continue; }56
unlinkSync(join(OUT_DIR, name));57
console.log(`Removed obsolete ${name}`);58
}59
65
console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`);60
console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`);@@ -1653,7 +1653,7 @@ export class WorldView
1653
1653
const def = spellId != null ? spellDefinition(spellId) : null;
1654
1654
const spriteName = payload.sprite
1655
1655
?? def?.projectileSprite
1656
?? "fx:projectile:spell-mana-bullet";
1656
?? "fx:projectile:spell-none-1-mana-bullet";
1657
1657
const image = this.game.images[spriteName];
1658
1658
if (!image)
1659
1659
{ return; }
@@ -1653,7 +1653,7 @@ export class WorldView1653
const def = spellId != null ? spellDefinition(spellId) : null;1653
const def = spellId != null ? spellDefinition(spellId) : null;1654
const spriteName = payload.sprite1654
const spriteName = payload.sprite1655
?? def?.projectileSprite1655
?? def?.projectileSprite1656
?? "fx:projectile:spell-mana-bullet";1656
?? "fx:projectile:spell-none-1-mana-bullet";1657
const image = this.game.images[spriteName];1657
const image = this.game.images[spriteName];1658
if (!image)1658
if (!image)1659
{ return; }1659
{ return; }