-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_tileset.js
336 lines (327 loc) · 6.74 KB
/
make_tileset.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/* eslint max-len:off */
const assert = require('assert');
const fs = require('fs');
function output(filename, content) {
content = content.trim();
assert(content);
content += '\n';
// assert(!fs.existsSync(filename));
console.log(filename);
fs.writeFileSync(filename, content);
}
const DOOR = 1;
const SECRETDOOR = 2;
const SOLID = 3;
// const CEILING = 4;
const FLOOR = 5;
const DETAIL = 6;
const MEDKIT = 7;
const NOTE = 8;
const TERMINAL = 9;
const STAIRS = 10;
const WALLDETAIL = 11;
let sheet = 'ruins';
let files = {
door1: [DOOR],
door2: [DOOR],
door3: [DOOR],
wall1: [SOLID],
door_locked: [SOLID],
door_unlocked: [SOLID],
floor1a: [FLOOR, 'ceiling1'],
floor1b: [FLOOR, 'ceiling1'],
floor3: [FLOOR, 'ceiling3'],
floor2: [FLOOR, 'ceiling2'],
secret1: [SECRETDOOR],
wall1b: [SOLID],
wall2: [SOLID],
wall3: [SOLID],
};
let vstyle = `
---
fog_color: '#191c0e'
background_color: '#191c0e'
background_img: space1
fog_params:
- 0.003
- 0.0005
- 800.0
cell_swaps:
open: ${sheet}_open
wall_swaps:
open: demo_open
door: ${sheet}_door
door_oneway: ${sheet}_door
door_locked: demo_door_locked
door_locked_unlocked: demo_door_locked_unlocked
secret_door: ${sheet}_secret_door
secret_door_unvisited: ${sheet}_secret_door
solid: ${sheet}_solid
stairs_in: ${files.stairs_in ? sheet : 'ship2'}_stairs_in
stairs_out: ${files.stairs_in ? sheet : 'ship2'}_stairs_out
`.trim();
let did = {};
for (let filename in files) {
let [type, extra1, extra2] = files[filename];
let cat;
let content;
if (type === DOOR) {
if (!did[type]) {
vstyle = vstyle.replace(` door: ${sheet}_door`, ` door: ${sheet}_${filename}`);
vstyle = vstyle.replace(` door_oneway: ${sheet}_door`, ` door_oneway: ${sheet}_${filename}`);
}
cat = 'wall';
content = `
---
open_move: true
open_vis: false
advertise_other_side: true
map_view_wall_frames_from: door
visuals:
type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${filename}
`;
} else if (type === WALLDETAIL) {
assert(extra1);
cat = 'wall';
content = `
---
open_move: false
open_vis: false
advertise_other_side: false
map_view_wall_frames_from: solid
visuals:
- type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${extra1}
- pass: default
detail_layer: 1
type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${filename}
`;
} else if (type === SECRETDOOR) {
if (!did[type]) {
vstyle = vstyle.replace(`secret_door: ${sheet}_secret_door`, `secret_door: ${sheet}_${filename}`);
vstyle = vstyle.replace(`secret_door_unvisited: ${sheet}_secret_door`, `secret_door_unvisited: ${sheet}_${filename}`);
}
cat = 'wall';
content = `
---
open_move: true
open_vis: false
is_secret: true
visuals:
- type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${filename}
replace:
- func: UNVISITED
name: secret_door_unvisited
`;
} else if (type === SOLID) {
if (!did[type]) {
vstyle = vstyle.replace(`solid: ${sheet}_solid`, `solid: ${sheet}_${filename}`);
}
cat = 'wall';
content = `
---
open_move: false
open_vis: false
map_view_wall_frames_from: solid
visuals:
- type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${filename}
`;
} else if (type === STAIRS) {
cat = 'wall';
content = `
---
open_move: true
open_vis: false
map_view_wall_frames_from: 'door'
visuals:
type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${filename}
`;
} else if (type === FLOOR) {
if (!did[type]) {
vstyle = vstyle.replace(`open: ${sheet}_open`, `open: ${sheet}_${filename}`);
}
cat = 'cell';
content = `
---
open_vis: true
default_wall: solid
visuals:
- pass: bg
type: simple_floor
opts:
spritesheet: ${sheet}
tile: ${filename}
`.trim();
if (extra1) {
content = `${content}
- pass: bg
type: simple_ceiling
opts:
spritesheet: ${sheet}
tile: ${extra1}
`;
}
} else if (type === DETAIL || type === MEDKIT || type === NOTE || type === TERMINAL) {
assert(extra1);
cat = 'cell';
content = `
---
open_move: true
open_vis: true
default_wall: solid
${type === MEDKIT ? 'default_events:\n- dialog medkit' :
type === NOTE ? 'default_events:\n- dialog note MSG' :
type === TERMINAL ? 'default_events:\n- dialog terminal MSG' : ''}
visuals:
`.trim();
if (extra2) {
content = `${content}
- pass: bg
type: simple_ceiling
opts:
spritesheet: ${sheet}
tile: ${extra2}
`.trim();
}
content = `${content}
- pass: bg
type: simple_floor
opts:
spritesheet: ${sheet}
tile: ${extra1}
- type: simple_billboard
opts:
spritesheet: ${sheet}
tile: ${filename}
offs: [0, 0, 0]
face_camera: false # Otherwise faces frustum
`;
}
if (!did[type]) {
did[type] = filename;
}
output(`src/client/${cat}s/${sheet}_${filename}.${cat}def`, content);
}
if (!did[NOTE]) {
output(`src/client/cells/${sheet}_note.celldef`, `
---
open_move: true
open_vis: true
default_wall: solid
default_events:
- dialog note MSG
visuals:
# - pass: bg
# type: simple_ceiling
# opts:
# spritesheet: ${sheet}
# tile: ceiling
- pass: bg
type: simple_floor
opts:
spritesheet: ${sheet}
tile: ${did[FLOOR]}
- pass: default
detail_layer: 1
type: simple_floor
opts:
spritesheet: ship2
tile: note
`.trim());
}
if (!did[TERMINAL]) {
output(`src/client/cells/${sheet}_terminal.celldef`, `
---
open_move: true
open_vis: true
default_wall: solid
default_events:
- dialog terminal MSG
visuals:
# - pass: bg
# type: simple_ceiling
# opts:
# spritesheet: ${sheet}
# tile: ceiling
- pass: bg
type: simple_floor
opts:
spritesheet: ${sheet}
tile: ${did[FLOOR]}
- type: simple_billboard
opts:
spritesheet: ship2
tile:
- terminal1
- terminal2
- terminal3
- terminal4
- terminal5
times: 500
do_blend: 500
offs: [0, 0, -0.158]
face_camera: false # Otherwise faces frustum
`.trim());
}
if (!did[MEDKIT]) {
output(`src/client/cells/${sheet}_medkit.celldef`, `
---
open_move: true
open_vis: true
# map_view_detail_frame: 27
default_wall: solid
default_events:
- dialog medkit
visuals:
# - pass: bg
# type: simple_ceiling
# opts:
# spritesheet: ${sheet}
# tile: ceiling
- pass: bg
type: simple_floor
opts:
spritesheet: ${sheet}
tile: ${did[FLOOR]}
- type: simple_billboard
opts:
spritesheet: ship2
tile: medkit
offs: [0, 0, 0]
face_camera: false # Otherwise faces frustum
`);
}
output(`src/client/walls/${sheet}_solitude_door.walldef`, `
---
open_move: true
open_vis: false
advertise_other_side: true
map_view_wall_frames_from: door
visuals:
- type: simple_wall
opts:
spritesheet: ${sheet}
tile: ${did[SOLID]}
- type: simple_wall
opts:
spritesheet: solitude
tile: gateway
`);
output(`src/client/vstyles/${sheet}.vstyle`, vstyle);