1 // yes, this file serves both as format description and as template for code generation
2 // the engine will use this description to parse legacy binary map format
4 // notes:
5 // * field without offset is not in binary format
6 // * fields with `writedefault` will be written even if they contain default values
7 // * fields with `internal` won't be written to any file ever (and won't be read)
8 // * `ubyte` is unsigned byte, and `byte` is signed byte
9 // * all strings are in utf-8
10 // * struct with `header` flag will contain all other structs and it's own fields as top-level entities
11 // * in binary, `size` is two ushorts
12 // * `as xy` will use `X` and `Y` for points
13 // * `as txy` will use `tX` and `tY` for points
14 // * `as wh` will use `Width` and `Height` for size
15 // * `as twh` will use `tWidth` and `tHeight` for size
16 // * `as monsterid`: special hack for triggers: monster record number+1 in binary (so 0 means "none")
17 // * `binblock` and `offset` (and `[]` arrays) are used to parse legacy binary format
19 ////////////////////////////////////////////////////////////////////////////////
20 // main blocks
21 "map" size 452 bytes header binblock 7 {
22 "name" type char[32] offset 0 writedefault tip "map name";
23 "author" type char[32] offset 32 default "" writedefault tip "map author";
24 "description" type char[256] offset 64 default "" writedefault tip "map description";
25 "music" type char[64] offset 320 default 'Standart.wad:D2DMUS\ПРОСТОТА' writedefault tip "music resource";
26 "sky" type char[64] offset 384 default 'Standart.wad:D2DSKY\RSKY1' writedefault tip "sky resource";
27 "size" type size offset 448 as wh writedefault;
28 // not in binary
29 // temporary, for lighting experiments
30 "light_ambient" type color default (0 0 0 255) tip "ambient light for the whole level";
31 }
33 "texture" size 65 bytes binblock 1 {
34 "path" type char[64] offset 0 writedefault;
35 "animated" type bool offset 64 default false;
36 }
38 "panel" size 18 bytes binblock 2 {
39 "position" type point offset 0 as xy writedefault;
40 "size" type size offset 8 as wh as wh writedefault;
41 "texture" type ushort offset 12 texture writedefault;
42 "type" type ushort offset 14 bitset unique PanelType writedefault;
43 "alpha" type ubyte offset 16 default 0;
44 "flags" type ubyte offset 17 bitset PanelFlag default PANEL_FLAG_NONE;
45 // moving platform options, not in binary
46 "move_speed" type point default (0 0);
47 "size_speed" type point default (0 0); // alas, `size` cannot be negative
48 "move_start" type point default (0 0);
49 "move_end" type point default (0 0);
50 "size_end" type size default (0 0);
51 "move_active" type bool default false;
52 "move_once" type bool default false;
53 "end_pos_trigger" trigger default null;
54 "end_size_trigger" trigger default null;
55 }
57 "item" size 10 bytes binblock 3 {
58 "position" type point offset 0 as xy writedefault;
59 "type" type ubyte offset 8 enum Item writedefault;
60 "options" type ubyte offset 9 bitset ItemOption default ITEM_OPTION_NONE;
61 }
63 "monster" size 10 bytes binblock 5 {
64 "position" type point offset 0 as xy writedefault;
65 "type" type ubyte offset 8 enum Monster writedefault;
66 "direction" type ubyte offset 9 enum DirType default DIR_LEFT;
67 }
69 "area" size 10 bytes binblock 4 {
70 "position" type point offset 0 as xy writedefault;
71 "type" type ubyte offset 8 enum AreaType writedefault;
72 "direction" type ubyte offset 9 enum DirType default DIR_LEFT;
73 }
75 "trigger" size 148 bytes binblock 6 {
76 "position" type point offset 0 as xy writedefault;
77 "size" type size offset 8 as wh writedefault;
78 "enabled" type bool offset 12 default true;
79 "texture_panel" type int offset 13 panel default null;
80 "type" type ubyte offset 17 enum TriggerType writedefault;
81 "activate_type" type ubyte offset 18 bitset ActivateType;
82 "keys" type ubyte offset 19 bitset Key default KEY_NONE;
83 //WARNING: "trigdata" MUST be defined before "type", and "type" MUST be named "type" (for now, can be changed later)
84 "triggerdata" type trigdata[128] offset 20; // the only special nested structure
85 //DO NOT USE! experimental feature! will be removed!
86 "exoma_init" type string default "" tip "will be called on trigger creation";
87 "exoma_think" type string default "" tip "will be called on each think step";
88 "exoma_check" type string default "" tip "will be called before activation";
89 "exoma_action" type string default "" tip "will be called on activation";
90 }
93 ////////////////////////////////////////////////////////////////////////////////
94 // special texture identifiers, used to generate pascal sources
95 enum TextureSpecial {
96 TEXTURE_SPECIAL_WATER = -1,
97 TEXTURE_SPECIAL_ACID1 = -2,
98 TEXTURE_SPECIAL_ACID2 = -3,
99 TEXTURE_NONE = -4,
100 }
102 // directions
103 enum DirType {
104 DIR_LEFT, // 0
105 DIR_RIGHT, // 1
106 DIR_PRESERVE, // 2
107 DIR_REVERSE, // 3
108 }
110 // triggers
111 enum TriggerType {
112 TRIGGER_NONE, // 0
113 TRIGGER_EXIT, // 1
114 TRIGGER_TELEPORT, // 2
115 TRIGGER_OPENDOOR, // 3
116 TRIGGER_CLOSEDOOR, // 4
117 TRIGGER_DOOR, // 5
118 TRIGGER_DOOR5, // 6
119 TRIGGER_CLOSETRAP, // 7
120 TRIGGER_TRAP, // 8
121 TRIGGER_PRESS, // 9
122 TRIGGER_SECRET, // 10
123 TRIGGER_LIFTUP, // 11
124 TRIGGER_LIFTDOWN, // 12
125 TRIGGER_LIFT, // 13
126 TRIGGER_TEXTURE, // 14
127 TRIGGER_ON, // 15
128 TRIGGER_OFF, // 16
129 TRIGGER_ONOFF, // 17
130 TRIGGER_SOUND, // 18
131 TRIGGER_SPAWNMONSTER, // 19
132 TRIGGER_SPAWNITEM, // 20
133 TRIGGER_MUSIC, // 21
134 TRIGGER_PUSH, // 22
135 TRIGGER_SCORE, // 23
136 TRIGGER_MESSAGE, // 24
137 TRIGGER_DAMAGE, // 25
138 TRIGGER_HEALTH, // 26
139 TRIGGER_SHOT, // 27
140 TRIGGER_EFFECT, // 28
141 TRIGGER_SCRIPT, // 29
142 //
143 TRIGGER_MAX = MAX,
144 }
146 // "as XXX" means "generate this identifier for pascal sources
147 bitset PanelType {
148 PANEL_NONE = 0, // 0
149 PANEL_WALL, // 1
150 PANEL_BACK, // 2
151 PANEL_FORE, // 4
152 PANEL_WATER, // 8
153 PANEL_ACID1, // 16
154 PANEL_ACID2, // 32
155 PANEL_STEP, // 64
156 PANEL_LIFTUP, // 128
157 PANEL_LIFTDOWN, // 256
158 PANEL_OPENDOOR, // 512
159 PANEL_CLOSEDOOR, // 1024
160 PANEL_BLOCKMON, // 2048
161 PANEL_LIFTLEFT, // 4096
162 PANEL_LIFTRIGHT, // 8192
163 }
165 bitset PanelFlag {
166 PANEL_FLAG_NONE = 0, // 0
167 PANEL_FLAG_BLENDING, // 1
168 PANEL_FLAG_HIDE, // 2
169 PANEL_FLAG_WATERTEXTURES, // 4
170 }
172 enum EffectAction {
173 EFFECT_NONE, // 0
174 EFFECT_TELEPORT, // 1
175 EFFECT_RESPAWN, // 2
176 EFFECT_FIRE, // 3
177 }
179 //WARNING! max allowed items types is 127
180 enum Item {
181 ITEM_NONE, // 0
182 ITEM_MEDKIT_SMALL, // 1
183 ITEM_MEDKIT_LARGE, // 2
184 ITEM_MEDKIT_BLACK, // 3
185 ITEM_ARMOR_GREEN, // 4
186 ITEM_ARMOR_BLUE, // 5
187 ITEM_SPHERE_BLUE, // 6
188 ITEM_SPHERE_WHITE, // 7
189 ITEM_SUIT, // 8
190 ITEM_OXYGEN, // 9
191 ITEM_INVUL, // 10
192 ITEM_WEAPON_SAW, // 11
193 ITEM_WEAPON_SHOTGUN1, // 12
194 ITEM_WEAPON_SHOTGUN2, // 13
195 ITEM_WEAPON_CHAINGUN, // 14
196 ITEM_WEAPON_ROCKETLAUNCHER, // 15
197 ITEM_WEAPON_PLASMA, // 16
198 ITEM_WEAPON_BFG, // 17
199 ITEM_WEAPON_SUPERPULEMET, // 18
200 ITEM_AMMO_BULLETS, // 19
201 ITEM_AMMO_BULLETS_BOX, // 20
202 ITEM_AMMO_SHELLS, // 21
203 ITEM_AMMO_SHELLS_BOX, // 22
204 ITEM_AMMO_ROCKET, // 23
205 ITEM_AMMO_ROCKET_BOX, // 24
206 ITEM_AMMO_CELL, // 25
207 ITEM_AMMO_CELL_BIG, // 26
208 ITEM_AMMO_BACKPACK, // 27
209 ITEM_KEY_RED, // 28
210 ITEM_KEY_GREEN, // 29
211 ITEM_KEY_BLUE, // 30
212 ITEM_WEAPON_KASTET, // 31
213 ITEM_WEAPON_PISTOL, // 32
214 ITEM_BOTTLE, // 33
215 ITEM_HELMET, // 34
216 ITEM_JETPACK, // 35
217 ITEM_INVIS, // 36
218 ITEM_WEAPON_FLAMETHROWER, // 37
219 ITEM_AMMO_FUELCAN, // 38
220 //
221 ITEM_MAX = MAX, // store the last item's id in here use this in for loops
222 }
224 bitset ItemOption {
225 ITEM_OPTION_NONE = 0, // 0
226 ITEM_OPTION_ONLYDM, // 1
227 ITEM_OPTION_FALL, // 2
228 }
230 enum AreaType {
231 AREA_NONE, // 0
232 AREA_PLAYERPOINT1, // 1
233 AREA_PLAYERPOINT2, // 2
234 AREA_DMPOINT, // 3
235 AREA_REDFLAG, // 4
236 AREA_BLUEFLAG, // 5
237 AREA_DOMFLAG, // 6
238 AREA_REDTEAMPOINT, // 7
239 AREA_BLUETEAMPOINT, // 8
240 }
242 enum Monster {
243 MONSTER_NONE, // 0
244 MONSTER_DEMON, // 1
245 MONSTER_IMP, // 2
246 MONSTER_ZOMBY, // 3
247 MONSTER_SERG, // 4
248 MONSTER_CYBER, // 5
249 MONSTER_CGUN, // 6
250 MONSTER_BARON, // 7
251 MONSTER_KNIGHT, // 8
252 MONSTER_CACO, // 9
253 MONSTER_SOUL, // 10
254 MONSTER_PAIN, // 11
255 MONSTER_SPIDER, // 12
256 MONSTER_BSP, // 13
257 MONSTER_MANCUB, // 14
258 MONSTER_SKEL, // 15
259 MONSTER_VILE, // 16
260 MONSTER_FISH, // 17
261 MONSTER_BARREL, // 18
262 MONSTER_ROBO, // 19
263 MONSTER_MAN, // 20
264 // aliases (fixme: it should be `MONSTER_ZOMBIE = MONSTER_ZOMBY`!)
265 MONSTER_ZOMBIE = 3,
266 }
268 enum MonsterBehaviour {
269 BH_NORMAL, // 0
270 BH_KILLER, // 1
271 BH_MANIAC, // 2
272 BH_INSANE, // 3
273 BH_CANNIBAL, // 4
274 BH_GOOD, // 5
275 }
277 enum TriggerShot {
278 TRIGGER_SHOT_PISTOL, // 0
279 TRIGGER_SHOT_BULLET, // 1
280 TRIGGER_SHOT_SHOTGUN, // 2
281 TRIGGER_SHOT_SSG, // 3
282 TRIGGER_SHOT_IMP, // 4
283 TRIGGER_SHOT_PLASMA, // 5
284 TRIGGER_SHOT_SPIDER, // 6
285 TRIGGER_SHOT_CACO, // 7
286 TRIGGER_SHOT_BARON, // 8
287 TRIGGER_SHOT_MANCUB, // 9
288 TRIGGER_SHOT_REV, // 10
289 TRIGGER_SHOT_ROCKET, // 11
290 TRIGGER_SHOT_BFG, // 12
291 TRIGGER_SHOT_EXPL, // 13
292 TRIGGER_SHOT_BFGEXPL, // 14
293 TRIGGER_SHOT_FLAME, // 15
294 //
295 TRIGGER_SHOT_MAX = MAX,
296 }
298 enum TriggerShotTarget {
299 TRIGGER_SHOT_TARGET_NONE, // 0
300 TRIGGER_SHOT_TARGET_MON, // 1
301 TRIGGER_SHOT_TARGET_PLR, // 2
302 TRIGGER_SHOT_TARGET_RED, // 3
303 TRIGGER_SHOT_TARGET_BLUE, // 4
304 TRIGGER_SHOT_TARGET_MONPLR, // 5
305 TRIGGER_SHOT_TARGET_PLRMON, // 6
306 }
308 enum TriggerShotAim {
309 TRIGGER_SHOT_AIM_DEFAULT, // 0
310 TRIGGER_SHOT_AIM_ALLMAP, // 1
311 TRIGGER_SHOT_AIM_TRACE, // 2
312 TRIGGER_SHOT_AIM_TRACEALL, // 3
313 }
315 enum TriggerEffect {
316 TRIGGER_EFFECT_PARTICLE, // 0
317 TRIGGER_EFFECT_ANIMATION, // 1
318 }
320 enum TriggerEffectType {
321 TRIGGER_EFFECT_SLIQUID, // 0
322 TRIGGER_EFFECT_LLIQUID, // 1
323 TRIGGER_EFFECT_DLIQUID, // 2
324 TRIGGER_EFFECT_BLOOD, // 3
325 TRIGGER_EFFECT_SPARK, // 4
326 TRIGGER_EFFECT_BUBBLE, // 5
327 TRIGGER_EFFECT_MAX = MAX,
328 }
330 enum TriggerEffectPos {
331 TRIGGER_EFFECT_POS_CENTER, // 0
332 TRIGGER_EFFECT_POS_AREA, // 1
333 }
335 enum TriggerMusicAction {
336 TRIGGER_MUSIC_ACTION_STOP, // 0
337 TRIGGER_MUSIC_ACTION_PLAY, // 1; unpause or restart
338 }
340 enum TriggerScoreAction {
341 TRIGGER_SCORE_ACTION_ADD, // 0
342 TRIGGER_SCORE_ACTION_SUB, // 1
343 TRIGGER_SCORE_ACTION_WIN, // 2
344 TRIGGER_SCORE_ACTION_LOOSE, // 3
345 }
347 enum TriggerMessageDest {
348 TRIGGER_MESSAGE_DEST_ME, // 0
349 TRIGGER_MESSAGE_DEST_MY_TEAM, // 1
350 TRIGGER_MESSAGE_DEST_ENEMY_TEAM, // 2
351 TRIGGER_MESSAGE_DEST_RED_TEAM, // 3
352 TRIGGER_MESSAGE_DEST_BLUE_TEAM, // 4
353 TRIGGER_MESSAGE_DEST_EVERYONE, // 5
354 }
356 enum TriggerMessageKind {
357 TRIGGER_MESSAGE_KIND_CHAT, // 0
358 TRIGGER_MESSAGE_KIND_GAME, // 1
359 }
361 bitset ActivateType {
362 ACTIVATE_NONE = 0, // 0
363 ACTIVATE_PLAYERCOLLIDE, // 1
364 ACTIVATE_MONSTERCOLLIDE, // 2
365 ACTIVATE_PLAYERPRESS, // 4
366 ACTIVATE_MONSTERPRESS, // 8
367 ACTIVATE_SHOT, // 16
368 ACTIVATE_NOMONSTER, // 32
369 ACTIVATE_CUSTOM = 255, // note that "direct assign" field doesn't affect bit counter
370 }
372 bitset Key {
373 KEY_NONE = 0, // 0
374 KEY_RED, // 1
375 KEY_GREEN, // 2
376 KEY_BLUE, // 4
377 KEY_REDTEAM, // 8
378 KEY_BLUETEAM, // 16
379 }
381 enum HitType {
382 HIT_SOME, // 0
383 HIT_ROCKET, // 1
384 HIT_BFG, // 2
385 HIT_TRAP, // 3
386 HIT_FALL, // 4
387 HIT_WATER, // 5
388 HIT_ACID, // 6
389 HIT_ELECTRO, // 7
390 HIT_FLAME, // 8
391 HIT_SELF, // 9
392 HIT_DISCON, // 10
393 }
396 ////////////////////////////////////////////////////////////////////////////////
397 // various triggers
398 TriggerData for TRIGGER_EXIT {
399 "map" type char[16] offset 0 writedefault;
400 }
402 TriggerData for TRIGGER_TELEPORT {
403 "target" type point offset 0 writedefault;
404 "d2d" type bool offset 8 default false;
405 "silent" type bool offset 9 default false;
406 "direction" type ubyte offset 10 enum DirType default DIR_LEFT;
407 }
409 TriggerData for (TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR, TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP, TRIGGER_TRAP, TRIGGER_LIFTUP, TRIGGER_LIFTDOWN, TRIGGER_LIFT) {
410 "panelid" type int offset 0 panel writedefault;
411 "silent" type bool offset 4 default false;
412 "d2d" type bool offset 5 default false;
413 }
415 TriggerData for (TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF) {
416 "position" type point offset 0 as txy default (0 0) writedefault;
417 "size" type size offset 8 as twh default (0 0);
418 "wait" type ushort offset 12 default 0;
419 "count" alias pressCount type ushort offset 14 default 0;
420 "monsterid" type int offset 16 monster as monsterid default null;
421 "ext_random" type bool offset 20 default false;
422 // this one is for moving platforms
423 "panelid" panel default null;
424 "silent" type bool default true;
425 "sound" type string default "";
426 }
428 enum TriggerScoreTeam {
429 TRIGGER_SCORE_TEAM_MINE_RED, // 0
430 TRIGGER_SCORE_TEAM_MINE_BLUE, // 1
431 TRIGGER_SCORE_TEAM_FORCE_RED, // 2
432 TRIGGER_SCORE_TEAM_FORCE_BLUE, // 3
433 }
435 TriggerData for TRIGGER_SECRET {
436 }
438 TriggerData for TRIGGER_TEXTURE {
439 "activate_once" type bool offset 0 default false writedefault;
440 "animate_once" type bool offset 1 default false writedefault;
441 }
443 TriggerData for TRIGGER_SOUND {
444 "sound_name" type char[64] offset 0 writedefault;
445 "volume" type ubyte offset 64 default 0 writedefault; //??? default ???
446 "pan" type ubyte offset 65 default 0;
447 "local" type bool offset 66 default true; //??? default ???
448 "play_count" type ubyte offset 67 default 1;
449 "sound_switch" type bool offset 68 default false; //??? default ???
450 }
452 TriggerData for TRIGGER_SPAWNMONSTER {
453 "position" type point offset 0 as txy writedefault;
454 "type" alias spawnMonsType type ubyte offset 8 enum Monster default MONSTER_IMP writedefault;
455 "health" type int offset 12 writedefault;
456 "direction" type ubyte offset 16 enum DirType default DIR_LEFT writedefault;
457 "active" type bool offset 17 default true;
458 "count" alias monsCount type int offset 20 default 1 writedefault;
459 "effect" type ubyte offset 24 enum EffectAction default EFFECT_NONE writedefault;
460 "max" type ushort offset 26 default 1 writedefault;
461 "delay" type ushort offset 28 default 1000 writedefault;
462 "behaviour" type ubyte offset 30 enum MonsterBehaviour default BH_NORMAL;
463 }
465 TriggerData for TRIGGER_SPAWNITEM {
466 "position" type point offset 0 as txy writedefault;
467 "type" alias spawnItemType type ubyte offset 8 enum Item default ITEM_NONE writedefault;
468 "gravity" type bool offset 9 default true;
469 "dmonly" type bool offset 10 default false;
470 "count" alias itemCount type int offset 12 default 1;
471 "effect" type ubyte offset 16 enum EffectAction default EFFECT_NONE writedefault;
472 "max" type ushort offset 18 default 1;
473 "delay" type ushort offset 20 default 1000 writedefault;
474 }
476 TriggerData for TRIGGER_MUSIC {
477 "name" alias musicName type char[64] offset 0 writedefault;
478 "action" alias musicAction type ubyte offset 64 enum TriggerMusicAction writedefault;
479 }
481 TriggerData for TRIGGER_PUSH {
482 "angle" type ushort offset 0 writedefault;
483 "force" type ubyte offset 2 writedefault;
484 "reset_velocity" type bool offset 3 default false writedefault;
485 }
487 TriggerData for TRIGGER_SCORE {
488 "action" alias scoreAction type ubyte offset 0 enum TriggerScoreAction default TRIGGER_SCORE_ACTION_ADD writedefault;
489 "count" alias scoreCount type ubyte offset 1 default 1 writedefault;
490 "team" alias scoreTeam type ubyte offset 2 enum TriggerScoreTeam writedefault;
491 "console" alias scoreCon type bool offset 3 default false writedefault;
492 "message" alias scoreMsg type bool offset 4 default true writedefault;
493 }
495 TriggerData for TRIGGER_MESSAGE {
496 "kind" type ubyte offset 0 enum TriggerMessageKind default TRIGGER_MESSAGE_KIND_GAME writedefault;
497 "dest" alias msgDest type ubyte enum TriggerMessageDest offset 1;
498 "text" type char[100] offset 2 writedefault;
499 "time" alias msgTime type ushort offset 102 writedefault;
500 }
502 TriggerData for TRIGGER_DAMAGE {
503 "amount" type ushort offset 0 writedefault;
504 "interval" type ushort offset 2 writedefault;
505 "kind" type ubyte offset 4 enum HitType default HIT_SOME writedefault;
506 }
508 TriggerData for TRIGGER_HEALTH {
509 "amount" type ushort offset 0 writedefault;
510 "interval" type ushort offset 2 writedefault;
511 "max" alias healMax type bool offset 4 writedefault;
512 "silent" type bool offset 5 writedefault;
513 }
515 TriggerData for TRIGGER_SHOT {
516 "position" type point offset 0 as txy writedefault;
517 "type" alias shotType type ubyte offset 8 enum TriggerShot writedefault;
518 "target" alias shotTarget type ubyte offset 9 enum TriggerShotTarget writedefault;
519 "sound" alias shotSound type negbool offset 10; // negbool!
520 "aim" type byte offset 11 enum TriggerShotAim default TRIGGER_SHOT_AIM_DEFAULT;
521 "panelid" type int offset 12 panel default null writedefault;
522 "sight" type ushort offset 16;
523 "angle" type ushort offset 18;
524 "wait" type ushort offset 20;
525 "accuracy" type ushort offset 22;
526 "ammo" type ushort offset 24;
527 "reload" type ushort offset 26;
528 }
530 TriggerData for TRIGGER_EFFECT {
531 "count" alias FXCount type ubyte offset 0 writedefault;
532 "type" alias FXType type ubyte offset 1 enum TriggerEffect default TRIGGER_EFFECT_PARTICLE writedefault;
533 "subtype" alias FXSubType type ubyte offset 2 enum TriggerEffectType default TRIGGER_EFFECT_SPARK writedefault;
534 "red" alias FXRed type ubyte offset 3 writedefault;
535 "green" alias FXGreen type ubyte offset 4 writedefault;
536 "blue" alias FXBlue type ubyte offset 5 writedefault;
537 "pos" alias FXPos type ubyte offset 6 enum TriggerEffectPos default TRIGGER_EFFECT_POS_CENTER writedefault;
538 "wait" type ushort offset 8 writedefault;
539 "vel_x" type byte offset 10 writedefault;
540 "vel_y" type byte offset 11 writedefault;
541 "spread_l" type ubyte offset 12 writedefault;
542 "spread_r" type ubyte offset 13 writedefault;
543 "spread_u" type ubyte offset 14 writedefault;
544 "spread_d" type ubyte offset 15 writedefault;
545 }