DEADSOFTWARE

save/load fixes
[d2df-sdl.git] / src / mapdef / mapdef.txt
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,
102 // directions
103 enum DirType {
104 DIR_LEFT, // 0
105 DIR_RIGHT, // 1
106 DIR_SOMETHING2, // 2
109 // triggers
110 enum TriggerType {
111 TRIGGER_NONE, // 0
112 TRIGGER_EXIT, // 1
113 TRIGGER_TELEPORT, // 2
114 TRIGGER_OPENDOOR, // 3
115 TRIGGER_CLOSEDOOR, // 4
116 TRIGGER_DOOR, // 5
117 TRIGGER_DOOR5, // 6
118 TRIGGER_CLOSETRAP, // 7
119 TRIGGER_TRAP, // 8
120 TRIGGER_PRESS, // 9
121 TRIGGER_SECRET, // 10
122 TRIGGER_LIFTUP, // 11
123 TRIGGER_LIFTDOWN, // 12
124 TRIGGER_LIFT, // 13
125 TRIGGER_TEXTURE, // 14
126 TRIGGER_ON, // 15
127 TRIGGER_OFF, // 16
128 TRIGGER_ONOFF, // 17
129 TRIGGER_SOUND, // 18
130 TRIGGER_SPAWNMONSTER, // 19
131 TRIGGER_SPAWNITEM, // 20
132 TRIGGER_MUSIC, // 21
133 TRIGGER_PUSH, // 22
134 TRIGGER_SCORE, // 23
135 TRIGGER_MESSAGE, // 24
136 TRIGGER_DAMAGE, // 25
137 TRIGGER_HEALTH, // 26
138 TRIGGER_SHOT, // 27
139 TRIGGER_EFFECT, // 28
140 TRIGGER_SCRIPT, // 29
141 //
142 TRIGGER_MAX = MAX,
145 // "as XXX" means "generate this identifier for pascal sources
146 bitset PanelType {
147 PANEL_NONE = 0, // 0
148 PANEL_WALL, // 1
149 PANEL_BACK, // 2
150 PANEL_FORE, // 4
151 PANEL_WATER, // 8
152 PANEL_ACID1, // 16
153 PANEL_ACID2, // 32
154 PANEL_STEP, // 64
155 PANEL_LIFTUP, // 128
156 PANEL_LIFTDOWN, // 256
157 PANEL_OPENDOOR, // 512
158 PANEL_CLOSEDOOR, // 1024
159 PANEL_BLOCKMON, // 2048
160 PANEL_LIFTLEFT, // 4096
161 PANEL_LIFTRIGHT, // 8192
164 bitset PanelFlag {
165 PANEL_FLAG_NONE = 0, // 0
166 PANEL_FLAG_BLENDING, // 1
167 PANEL_FLAG_HIDE, // 2
168 PANEL_FLAG_WATERTEXTURES, // 4
171 enum EffectAction {
172 EFFECT_NONE, // 0
173 EFFECT_TELEPORT, // 1
174 EFFECT_RESPAWN, // 2
175 EFFECT_FIRE, // 3
178 enum Item {
179 ITEM_NONE, // 0
180 ITEM_MEDKIT_SMALL, // 1
181 ITEM_MEDKIT_LARGE, // 2
182 ITEM_MEDKIT_BLACK, // 3
183 ITEM_ARMOR_GREEN, // 4
184 ITEM_ARMOR_BLUE, // 5
185 ITEM_SPHERE_BLUE, // 6
186 ITEM_SPHERE_WHITE, // 7
187 ITEM_SUIT, // 8
188 ITEM_OXYGEN, // 9
189 ITEM_INVUL, // 10
190 ITEM_WEAPON_SAW, // 11
191 ITEM_WEAPON_SHOTGUN1, // 12
192 ITEM_WEAPON_SHOTGUN2, // 13
193 ITEM_WEAPON_CHAINGUN, // 14
194 ITEM_WEAPON_ROCKETLAUNCHER, // 15
195 ITEM_WEAPON_PLASMA, // 16
196 ITEM_WEAPON_BFG, // 17
197 ITEM_WEAPON_SUPERPULEMET, // 18
198 ITEM_AMMO_BULLETS, // 19
199 ITEM_AMMO_BULLETS_BOX, // 20
200 ITEM_AMMO_SHELLS, // 21
201 ITEM_AMMO_SHELLS_BOX, // 22
202 ITEM_AMMO_ROCKET, // 23
203 ITEM_AMMO_ROCKET_BOX, // 24
204 ITEM_AMMO_CELL, // 25
205 ITEM_AMMO_CELL_BIG, // 26
206 ITEM_AMMO_BACKPACK, // 27
207 ITEM_KEY_RED, // 28
208 ITEM_KEY_GREEN, // 29
209 ITEM_KEY_BLUE, // 30
210 ITEM_WEAPON_KASTET, // 31
211 ITEM_WEAPON_PISTOL, // 32
212 ITEM_BOTTLE, // 33
213 ITEM_HELMET, // 34
214 ITEM_JETPACK, // 35
215 ITEM_INVIS, // 36
216 ITEM_WEAPON_FLAMETHROWER, // 37
217 ITEM_AMMO_FUELCAN, // 38
218 //
219 ITEM_MAX = MAX, // store the last item's id in here use this in for loops
222 bitset ItemOption {
223 ITEM_OPTION_NONE = 0, // 0
224 ITEM_OPTION_ONLYDM, // 1
225 ITEM_OPTION_FALL, // 2
228 enum AreaType {
229 AREA_NONE, // 0
230 AREA_PLAYERPOINT1, // 1
231 AREA_PLAYERPOINT2, // 2
232 AREA_DMPOINT, // 3
233 AREA_REDFLAG, // 4
234 AREA_BLUEFLAG, // 5
235 AREA_DOMFLAG, // 6
236 AREA_REDTEAMPOINT, // 7
237 AREA_BLUETEAMPOINT, // 8
240 enum Monster {
241 MONSTER_NONE, // 0
242 MONSTER_DEMON, // 1
243 MONSTER_IMP, // 2
244 MONSTER_ZOMBY, // 3
245 MONSTER_SERG, // 4
246 MONSTER_CYBER, // 5
247 MONSTER_CGUN, // 6
248 MONSTER_BARON, // 7
249 MONSTER_KNIGHT, // 8
250 MONSTER_CACO, // 9
251 MONSTER_SOUL, // 10
252 MONSTER_PAIN, // 11
253 MONSTER_SPIDER, // 12
254 MONSTER_BSP, // 13
255 MONSTER_MANCUB, // 14
256 MONSTER_SKEL, // 15
257 MONSTER_VILE, // 16
258 MONSTER_FISH, // 17
259 MONSTER_BARREL, // 18
260 MONSTER_ROBO, // 19
261 MONSTER_MAN, // 20
262 // aliases (fixme: it should be `MONSTER_ZOMBIE = MONSTER_ZOMBY`!)
263 MONSTER_ZOMBIE = 3,
266 enum MonsterBehaviour {
267 BH_NORMAL, // 0
268 BH_KILLER, // 1
269 BH_MANIAC, // 2
270 BH_INSANE, // 3
271 BH_CANNIBAL, // 4
272 BH_GOOD, // 5
275 enum TriggerShot {
276 TRIGGER_SHOT_PISTOL, // 0
277 TRIGGER_SHOT_BULLET, // 1
278 TRIGGER_SHOT_SHOTGUN, // 2
279 TRIGGER_SHOT_SSG, // 3
280 TRIGGER_SHOT_IMP, // 4
281 TRIGGER_SHOT_PLASMA, // 5
282 TRIGGER_SHOT_SPIDER, // 6
283 TRIGGER_SHOT_CACO, // 7
284 TRIGGER_SHOT_BARON, // 8
285 TRIGGER_SHOT_MANCUB, // 9
286 TRIGGER_SHOT_REV, // 10
287 TRIGGER_SHOT_ROCKET, // 11
288 TRIGGER_SHOT_BFG, // 12
289 TRIGGER_SHOT_EXPL, // 13
290 TRIGGER_SHOT_BFGEXPL, // 14
291 //
292 TRIGGER_SHOT_MAX = MAX,
295 enum TriggerShotTarget {
296 TRIGGER_SHOT_TARGET_NONE, // 0
297 TRIGGER_SHOT_TARGET_MON, // 1
298 TRIGGER_SHOT_TARGET_PLR, // 2
299 TRIGGER_SHOT_TARGET_RED, // 3
300 TRIGGER_SHOT_TARGET_BLUE, // 4
301 TRIGGER_SHOT_TARGET_MONPLR, // 5
302 TRIGGER_SHOT_TARGET_PLRMON, // 6
305 enum TriggerShotAim {
306 TRIGGER_SHOT_AIM_DEFAULT, // 0
307 TRIGGER_SHOT_AIM_ALLMAP, // 1
308 TRIGGER_SHOT_AIM_TRACE, // 2
309 TRIGGER_SHOT_AIM_TRACEALL, // 3
312 enum TriggerEffect {
313 TRIGGER_EFFECT_PARTICLE, // 0
314 TRIGGER_EFFECT_ANIMATION, // 1
317 enum TriggerEffectType {
318 TRIGGER_EFFECT_SLIQUID, // 0
319 TRIGGER_EFFECT_LLIQUID, // 1
320 TRIGGER_EFFECT_DLIQUID, // 2
321 TRIGGER_EFFECT_BLOOD, // 3
322 TRIGGER_EFFECT_SPARK, // 4
323 TRIGGER_EFFECT_BUBBLE, // 5
324 TRIGGER_EFFECT_MAX = MAX,
327 enum TriggerEffectPos {
328 TRIGGER_EFFECT_POS_CENTER, // 0
329 TRIGGER_EFFECT_POS_AREA, // 1
332 enum TriggerMusicAction {
333 TRIGGER_MUSIC_ACTION_STOP, // 0
334 TRIGGER_MUSIC_ACTION_PLAY, // 1; unpause or restart
337 enum TriggerScoreAction {
338 TRIGGER_SCORE_ACTION_ADD, // 0
339 TRIGGER_SCORE_ACTION_SUB, // 1
340 TRIGGER_SCORE_ACTION_WIN, // 2
341 TRIGGER_SCORE_ACTION_LOOSE, // 3
344 enum TriggerMessageDest {
345 TRIGGER_MESSAGE_DEST_ME, // 0
346 TRIGGER_MESSAGE_DEST_MY_TEAM, // 1
347 TRIGGER_MESSAGE_DEST_ENEMY_TEAM, // 2
348 TRIGGER_MESSAGE_DEST_RED_TEAM, // 3
349 TRIGGER_MESSAGE_DEST_BLUE_TEAM, // 4
350 TRIGGER_MESSAGE_DEST_EVERYONE, // 5
353 enum TriggerMessageKind {
354 TRIGGER_MESSAGE_KIND_CHAT, // 0
355 TRIGGER_MESSAGE_KIND_GAME, // 1
358 bitset ActivateType {
359 ACTIVATE_NONE = 0, // 0
360 ACTIVATE_PLAYERCOLLIDE, // 1
361 ACTIVATE_MONSTERCOLLIDE, // 2
362 ACTIVATE_PLAYERPRESS, // 4
363 ACTIVATE_MONSTERPRESS, // 8
364 ACTIVATE_SHOT, // 16
365 ACTIVATE_NOMONSTER, // 32
366 ACTIVATE_CUSTOM = 255, // note that "direct assign" field doesn't affect bit counter
369 bitset Key {
370 KEY_NONE = 0, // 0
371 KEY_RED, // 1
372 KEY_GREEN, // 2
373 KEY_BLUE, // 4
374 KEY_REDTEAM, // 8
375 KEY_BLUETEAM, // 16
379 ////////////////////////////////////////////////////////////////////////////////
380 // various triggers
381 TriggerData for TRIGGER_EXIT {
382 "map" type char[16] offset 0 writedefault;
385 TriggerData for TRIGGER_TELEPORT {
386 "target" type point offset 0 writedefault;
387 "d2d" type bool offset 8 default false;
388 "silent" type bool offset 9 default false;
389 "direction" type ubyte offset 10 enum DirType default DIR_LEFT;
392 TriggerData for (TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR, TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP, TRIGGER_TRAP, TRIGGER_LIFTUP, TRIGGER_LIFTDOWN, TRIGGER_LIFT) {
393 "panelid" type int offset 0 panel writedefault;
394 "silent" type bool offset 4 default false;
395 "d2d" type bool offset 5 default false;
398 TriggerData for (TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF) {
399 "position" type point offset 0 as txy default (0 0) writedefault;
400 "size" type size offset 8 as twh default (0 0);
401 "wait" type ushort offset 12 default 0;
402 "count" alias pressCount type ushort offset 14 default 0;
403 "monsterid" type int offset 16 monster as monsterid default null;
404 "ext_random" type bool offset 20 default false;
405 // this one is for moving platforms
406 "panelid" panel default null;
407 "silent" type bool default true;
408 "sound" type string default "";
411 enum TriggerScoreTeam {
412 TRIGGER_SCORE_TEAM_MINE_RED, // 0
413 TRIGGER_SCORE_TEAM_MINE_BLUE, // 1
414 TRIGGER_SCORE_TEAM_FORCE_RED, // 2
415 TRIGGER_SCORE_TEAM_FORCE_BLUE, // 3
418 TriggerData for TRIGGER_SECRET {
421 TriggerData for TRIGGER_TEXTURE {
422 "activate_once" type bool offset 0 default false writedefault;
423 "animate_once" type bool offset 1 default false writedefault;
426 TriggerData for TRIGGER_SOUND {
427 "sound_name" type char[64] offset 0 writedefault;
428 "volume" type ubyte offset 64 default 0 writedefault; //??? default ???
429 "pan" type ubyte offset 65 default 0;
430 "local" type bool offset 66 default true; //??? default ???
431 "play_count" type ubyte offset 67 default 1;
432 "sound_switch" type bool offset 68 default false; //??? default ???
435 TriggerData for TRIGGER_SPAWNMONSTER {
436 "position" type point offset 0 as txy writedefault;
437 "type" alias spawnMonsType type ubyte offset 8 enum Monster default MONSTER_IMP writedefault;
438 "health" type int offset 12 writedefault;
439 "direction" type ubyte offset 16 enum DirType default DIR_LEFT writedefault;
440 "active" type bool offset 17 default true;
441 "count" alias monsCount type int offset 20 default 1 writedefault;
442 "effect" type ubyte offset 24 enum EffectAction default EFFECT_NONE writedefault;
443 "max" type ushort offset 26 default 1 writedefault;
444 "delay" type ushort offset 28 default 1000 writedefault;
445 "behaviour" type ubyte offset 30 enum MonsterBehaviour default BH_NORMAL;
448 TriggerData for TRIGGER_SPAWNITEM {
449 "position" type point offset 0 as txy writedefault;
450 "type" alias spawnItemType type ubyte offset 8 enum Item default ITEM_NONE writedefault;
451 "gravity" type bool offset 9 default true;
452 "dmonly" type bool offset 10 default false;
453 "count" alias itemCount type int offset 12 default 1;
454 "effect" type ubyte offset 16 enum EffectAction default EFFECT_NONE writedefault;
455 "max" type ushort offset 18 default 1;
456 "delay" type ushort offset 20 default 1000 writedefault;
459 TriggerData for TRIGGER_MUSIC {
460 "name" alias musicName type char[64] offset 0 writedefault;
461 "action" alias musicAction type ubyte offset 64 enum TriggerMusicAction writedefault;
464 TriggerData for TRIGGER_PUSH {
465 "angle" type ushort offset 0 writedefault;
466 "force" type ubyte offset 2 writedefault;
467 "reset_velocity" type bool offset 3 default false writedefault;
470 TriggerData for TRIGGER_SCORE {
471 "action" alias scoreAction type ubyte offset 0 enum TriggerScoreAction default TRIGGER_SCORE_ACTION_ADD writedefault;
472 "count" alias scoreCount type ubyte offset 1 default 1 writedefault;
473 "team" alias scoreTeam type ubyte offset 2 enum TriggerScoreTeam writedefault;
474 "console" alias scoreCon type bool offset 3 default false writedefault;
475 "message" alias scoreMsg type bool offset 4 default true writedefault;
478 TriggerData for TRIGGER_MESSAGE {
479 "kind" type ubyte offset 0 enum TriggerMessageKind default TRIGGER_MESSAGE_KIND_GAME writedefault;
480 "dest" alias msgDest type ubyte enum TriggerMessageDest offset 1;
481 "text" type char[100] offset 2 writedefault;
482 "time" alias msgTime type ushort offset 102 writedefault;
485 TriggerData for TRIGGER_DAMAGE {
486 "amount" type ushort offset 0 writedefault;
487 "interval" type ushort offset 2 writedefault;
490 TriggerData for TRIGGER_HEALTH {
491 "amount" type ushort offset 0 writedefault;
492 "interval" type ushort offset 2 writedefault;
493 "max" alias healMax type bool offset 4 writedefault;
494 "silent" type bool offset 5 writedefault;
497 TriggerData for TRIGGER_SHOT {
498 "position" type point offset 0 as txy writedefault;
499 "type" alias shotType type ubyte offset 8 enum TriggerShot writedefault;
500 "target" alias shotTarget type ubyte offset 9 enum TriggerShotTarget writedefault;
501 "quiet" type negbool offset 10; // negbool!
502 "aim" type byte offset 11 enum TriggerShotAim default TRIGGER_SHOT_AIM_DEFAULT;
503 "panelid" type int offset 12 panel default null writedefault;
504 "sight" type ushort offset 16;
505 "angle" type ushort offset 18;
506 "wait" type ushort offset 20;
507 "accuracy" type ushort offset 22;
508 "ammo" type ushort offset 24;
509 "reload" type ushort offset 26;
512 TriggerData for TRIGGER_EFFECT {
513 "count" alias FXCount type ubyte offset 0 writedefault;
514 "type" alias FXType type ubyte offset 1 enum TriggerEffect default TRIGGER_EFFECT_PARTICLE writedefault;
515 "subtype" alias FXSubType type ubyte offset 2 enum TriggerEffectType default TRIGGER_EFFECT_SPARK writedefault;
516 "red" alias FXRed type ubyte offset 3 writedefault;
517 "green" alias FXGreen type ubyte offset 4 writedefault;
518 "blue" alias FXBlue type ubyte offset 5 writedefault;
519 "pos" alias FXPos type ubyte offset 6 enum TriggerEffectPos default TRIGGER_EFFECT_POS_CENTER writedefault;
520 "wait" type ushort offset 8 writedefault;
521 "vel_x" type byte offset 10 writedefault;
522 "vel_y" type byte offset 11 writedefault;
523 "spread_l" type ubyte offset 12 writedefault;
524 "spread_r" type ubyte offset 13 writedefault;
525 "spread_u" type ubyte offset 14 writedefault;
526 "spread_d" type ubyte offset 15 writedefault;