-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_scripts.js
89 lines (73 loc) · 1.96 KB
/
update_scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const fs = require('fs');
const z = fs.readFileSync("MODELDEF.txt").toString();
const lines = z.split(/\r?\n/);
const NUM_FRAMES = 960; // Total number of frames. MUST NOT EXCEED 1000 or else precaching does NOT work and you get graphical glitches!
const FRAME_TICKS = 8; // Selaco runs 35 tics per second
const CHAR = "B";
const CHAR2 = "X";
function getSprite(num) {
return `${CHAR}${num.toString(32).padStart(3, CHAR2)}`.toUpperCase();
}
let out = [];
for (let l of lines) {
out.push(l);
if (l.indexOf("// GENERATED DATA BELOW") > -1) {
break;
}
}
for (let i = 1; i <= NUM_FRAMES; i++) {
let v = String(i).padStart(4, '0');
out.push(`Model VACBOT_ES_BadApple
{
noperpixellighting
Path "MD/VACBOT"
Model 0 "VAC_SCREEN.obj"
Skin 0 "BAD_${v}.png"
Scale 1.0 1.0 1.0
angleoffset 90
FrameIndex ${getSprite(i)} A 0 0
}`)
}
fs.writeFileSync("MODELDEF.txt", out.join('\n'));
/// --------------
const v = fs.readFileSync("VACBOT_OVERRIDE.zsc").toString();
const vlines = v.split(/\r?\n/);
out = [];
for (let l of vlines) {
out.push(l);
if (l.indexOf("// GENERATED DATA BEGIN") > -1) {
break;
}
}
out.push(`Precache:`);
for (let i = 1; i <= NUM_FRAMES; i++) {
out.push(` ${getSprite(i)} A 0;`);
}
out.push(` stop;`);
for (let i = 1; i <= NUM_FRAMES; i++) {
let v = String(i).padStart(4, '0');
let vplus = String(i+1).padStart(4, '0');
if (i === NUM_FRAMES) {
vplus = "0000";
}
out.push(`Frame_${v}:
${getSprite(i)} A ${FRAME_TICKS} BRIGHT;
goto Frame_${vplus};`);
}
let output = false;
for (let l of vlines) {
if (l.indexOf("// GENERATED DATA END") > -1) {
output = true;
}
if (output) {
out.push(l);
}
}
fs.writeFileSync("VACBOT_OVERRIDE.zsc", out.join('\n'));
//////////////////////
out = [];
for (let i = 1; i <= NUM_FRAMES; i++) {
out.push(`sprite ${getSprite(i)}, 172, 172
{}`);
}
fs.writeFileSync("TEXTURES.txt", out.join('\n'));