// yes, this file serves both as format description and as template for code generation // the engine will use this description to parse legacy binary map format // notes: // * field without offset is not in binary format // * fields with `writedefault` will be written even if they contain default values // * fields with `internal` won't be written to any file ever (and won't be read) // * `ubyte` is unsigned byte, and `byte` is signed byte // * all strings are in utf-8 // * struct with `header` flag will contain all other structs and it's own fields as top-level entities // * in binary, `size` is two ushorts // * `as xy` will use `X` and `Y` for points // * `as txy` will use `tX` and `tY` for points // * `as wh` will use `Width` and `Height` for size // * `as twh` will use `tWidth` and `tHeight` for size // * `as monsterid`: special hack for triggers: monster record number+1 in binary (so 0 means "none") // * `binblock` and `offset` (and `[]` arrays) are used to parse legacy binary format //////////////////////////////////////////////////////////////////////////////// // main blocks "map" size 452 bytes header binblock 7 { "name" type char[32] offset 0 writedefault tip "map name"; "author" type char[32] offset 32 default "" writedefault tip "map author"; "description" type char[256] offset 64 default "" writedefault tip "map description"; "music" type char[64] offset 320 default 'Standart.wad:D2DMUS\ПРОСТОТА' writedefault tip "music resource"; "sky" type char[64] offset 384 default 'Standart.wad:D2DSKY\RSKY1' writedefault tip "sky resource"; "size" type size offset 448 as wh writedefault; // not in binary // temporary, for lighting experiments "light_ambient" type color default (0 0 0 255) tip "ambient light for the whole level"; } "texture" size 65 bytes binblock 1 { "path" type char[64] offset 0 writedefault; "animated" type bool offset 64 default false; } "panel" size 18 bytes binblock 2 { "position" type point offset 0 as xy writedefault; "size" type size offset 8 as wh as wh writedefault; "texture" type ushort offset 12 texture writedefault; "type" type ushort offset 14 bitset unique PanelType writedefault; "alpha" type ubyte offset 16 default 0; "flags" type ubyte offset 17 bitset PanelFlag default PANEL_FLAG_NONE; // moving platform options, not in binary "move_speed" type point default (0 0); "size_speed" type point default (0 0); // alas, `size` cannot be negative "move_start" type point default (0 0); "move_end" type point default (0 0); "size_end" type size default (0 0); "move_active" type bool default false; "move_once" type bool default false; "end_pos_trigger" trigger default null; "end_size_trigger" trigger default null; } "item" size 10 bytes binblock 3 { "position" type point offset 0 as xy writedefault; "type" type ubyte offset 8 enum Item writedefault; "options" type ubyte offset 9 bitset ItemOption default ITEM_OPTION_NONE; } "monster" size 10 bytes binblock 5 { "position" type point offset 0 as xy writedefault; "type" type ubyte offset 8 enum Monster writedefault; "direction" type ubyte offset 9 enum DirType default DIR_LEFT; } "area" size 10 bytes binblock 4 { "position" type point offset 0 as xy writedefault; "type" type ubyte offset 8 enum AreaType writedefault; "direction" type ubyte offset 9 enum DirType default DIR_LEFT; } "trigger" size 148 bytes binblock 6 { "position" type point offset 0 as xy writedefault; "size" type size offset 8 as wh writedefault; "enabled" type bool offset 12 default true; "texture_panel" type int offset 13 panel default null; "type" type ubyte offset 17 enum TriggerType writedefault; "activate_type" type ubyte offset 18 bitset ActivateType; "keys" type ubyte offset 19 bitset Key default KEY_NONE; //WARNING: "trigdata" MUST be defined before "type", and "type" MUST be named "type" (for now, can be changed later) "triggerdata" type trigdata[128] offset 20; // the only special nested structure //DO NOT USE! experimental feature! will be removed! "exoma_init" type string default "" tip "will be called on trigger creation"; "exoma_think" type string default "" tip "will be called on each think step"; "exoma_check" type string default "" tip "will be called before activation"; "exoma_action" type string default "" tip "will be called on activation"; } //////////////////////////////////////////////////////////////////////////////// // special texture identifiers, used to generate pascal sources enum TextureSpecial { TEXTURE_SPECIAL_WATER = -1, TEXTURE_SPECIAL_ACID1 = -2, TEXTURE_SPECIAL_ACID2 = -3, TEXTURE_NONE = -4, } // directions enum DirType { DIR_LEFT, // 0 DIR_RIGHT, // 1 DIR_SOMETHING2, // 2 } // triggers enum TriggerType { TRIGGER_NONE, // 0 TRIGGER_EXIT, // 1 TRIGGER_TELEPORT, // 2 TRIGGER_OPENDOOR, // 3 TRIGGER_CLOSEDOOR, // 4 TRIGGER_DOOR, // 5 TRIGGER_DOOR5, // 6 TRIGGER_CLOSETRAP, // 7 TRIGGER_TRAP, // 8 TRIGGER_PRESS, // 9 TRIGGER_SECRET, // 10 TRIGGER_LIFTUP, // 11 TRIGGER_LIFTDOWN, // 12 TRIGGER_LIFT, // 13 TRIGGER_TEXTURE, // 14 TRIGGER_ON, // 15 TRIGGER_OFF, // 16 TRIGGER_ONOFF, // 17 TRIGGER_SOUND, // 18 TRIGGER_SPAWNMONSTER, // 19 TRIGGER_SPAWNITEM, // 20 TRIGGER_MUSIC, // 21 TRIGGER_PUSH, // 22 TRIGGER_SCORE, // 23 TRIGGER_MESSAGE, // 24 TRIGGER_DAMAGE, // 25 TRIGGER_HEALTH, // 26 TRIGGER_SHOT, // 27 TRIGGER_EFFECT, // 28 TRIGGER_SCRIPT, // 29 // TRIGGER_MAX = MAX, } // "as XXX" means "generate this identifier for pascal sources bitset PanelType { PANEL_NONE = 0, // 0 PANEL_WALL, // 1 PANEL_BACK, // 2 PANEL_FORE, // 4 PANEL_WATER, // 8 PANEL_ACID1, // 16 PANEL_ACID2, // 32 PANEL_STEP, // 64 PANEL_LIFTUP, // 128 PANEL_LIFTDOWN, // 256 PANEL_OPENDOOR, // 512 PANEL_CLOSEDOOR, // 1024 PANEL_BLOCKMON, // 2048 PANEL_LIFTLEFT, // 4096 PANEL_LIFTRIGHT, // 8192 } bitset PanelFlag { PANEL_FLAG_NONE = 0, // 0 PANEL_FLAG_BLENDING, // 1 PANEL_FLAG_HIDE, // 2 PANEL_FLAG_WATERTEXTURES, // 4 } enum EffectAction { EFFECT_NONE, // 0 EFFECT_TELEPORT, // 1 EFFECT_RESPAWN, // 2 EFFECT_FIRE, // 3 } //WARNING! max allowed items types is 127 enum Item { ITEM_NONE, // 0 ITEM_MEDKIT_SMALL, // 1 ITEM_MEDKIT_LARGE, // 2 ITEM_MEDKIT_BLACK, // 3 ITEM_ARMOR_GREEN, // 4 ITEM_ARMOR_BLUE, // 5 ITEM_SPHERE_BLUE, // 6 ITEM_SPHERE_WHITE, // 7 ITEM_SUIT, // 8 ITEM_OXYGEN, // 9 ITEM_INVUL, // 10 ITEM_WEAPON_SAW, // 11 ITEM_WEAPON_SHOTGUN1, // 12 ITEM_WEAPON_SHOTGUN2, // 13 ITEM_WEAPON_CHAINGUN, // 14 ITEM_WEAPON_ROCKETLAUNCHER, // 15 ITEM_WEAPON_PLASMA, // 16 ITEM_WEAPON_BFG, // 17 ITEM_WEAPON_SUPERPULEMET, // 18 ITEM_AMMO_BULLETS, // 19 ITEM_AMMO_BULLETS_BOX, // 20 ITEM_AMMO_SHELLS, // 21 ITEM_AMMO_SHELLS_BOX, // 22 ITEM_AMMO_ROCKET, // 23 ITEM_AMMO_ROCKET_BOX, // 24 ITEM_AMMO_CELL, // 25 ITEM_AMMO_CELL_BIG, // 26 ITEM_AMMO_BACKPACK, // 27 ITEM_KEY_RED, // 28 ITEM_KEY_GREEN, // 29 ITEM_KEY_BLUE, // 30 ITEM_WEAPON_KASTET, // 31 ITEM_WEAPON_PISTOL, // 32 ITEM_BOTTLE, // 33 ITEM_HELMET, // 34 ITEM_JETPACK, // 35 ITEM_INVIS, // 36 ITEM_WEAPON_FLAMETHROWER, // 37 ITEM_AMMO_FUELCAN, // 38 // ITEM_MAX = MAX, // store the last item's id in here use this in for loops } bitset ItemOption { ITEM_OPTION_NONE = 0, // 0 ITEM_OPTION_ONLYDM, // 1 ITEM_OPTION_FALL, // 2 } enum AreaType { AREA_NONE, // 0 AREA_PLAYERPOINT1, // 1 AREA_PLAYERPOINT2, // 2 AREA_DMPOINT, // 3 AREA_REDFLAG, // 4 AREA_BLUEFLAG, // 5 AREA_DOMFLAG, // 6 AREA_REDTEAMPOINT, // 7 AREA_BLUETEAMPOINT, // 8 } enum Monster { MONSTER_NONE, // 0 MONSTER_DEMON, // 1 MONSTER_IMP, // 2 MONSTER_ZOMBY, // 3 MONSTER_SERG, // 4 MONSTER_CYBER, // 5 MONSTER_CGUN, // 6 MONSTER_BARON, // 7 MONSTER_KNIGHT, // 8 MONSTER_CACO, // 9 MONSTER_SOUL, // 10 MONSTER_PAIN, // 11 MONSTER_SPIDER, // 12 MONSTER_BSP, // 13 MONSTER_MANCUB, // 14 MONSTER_SKEL, // 15 MONSTER_VILE, // 16 MONSTER_FISH, // 17 MONSTER_BARREL, // 18 MONSTER_ROBO, // 19 MONSTER_MAN, // 20 // aliases (fixme: it should be `MONSTER_ZOMBIE = MONSTER_ZOMBY`!) MONSTER_ZOMBIE = 3, } enum MonsterBehaviour { BH_NORMAL, // 0 BH_KILLER, // 1 BH_MANIAC, // 2 BH_INSANE, // 3 BH_CANNIBAL, // 4 BH_GOOD, // 5 } enum TriggerShot { TRIGGER_SHOT_PISTOL, // 0 TRIGGER_SHOT_BULLET, // 1 TRIGGER_SHOT_SHOTGUN, // 2 TRIGGER_SHOT_SSG, // 3 TRIGGER_SHOT_IMP, // 4 TRIGGER_SHOT_PLASMA, // 5 TRIGGER_SHOT_SPIDER, // 6 TRIGGER_SHOT_CACO, // 7 TRIGGER_SHOT_BARON, // 8 TRIGGER_SHOT_MANCUB, // 9 TRIGGER_SHOT_REV, // 10 TRIGGER_SHOT_ROCKET, // 11 TRIGGER_SHOT_BFG, // 12 TRIGGER_SHOT_EXPL, // 13 TRIGGER_SHOT_BFGEXPL, // 14 TRIGGER_SHOT_FLAME, // 15 // TRIGGER_SHOT_MAX = MAX, } enum TriggerShotTarget { TRIGGER_SHOT_TARGET_NONE, // 0 TRIGGER_SHOT_TARGET_MON, // 1 TRIGGER_SHOT_TARGET_PLR, // 2 TRIGGER_SHOT_TARGET_RED, // 3 TRIGGER_SHOT_TARGET_BLUE, // 4 TRIGGER_SHOT_TARGET_MONPLR, // 5 TRIGGER_SHOT_TARGET_PLRMON, // 6 } enum TriggerShotAim { TRIGGER_SHOT_AIM_DEFAULT, // 0 TRIGGER_SHOT_AIM_ALLMAP, // 1 TRIGGER_SHOT_AIM_TRACE, // 2 TRIGGER_SHOT_AIM_TRACEALL, // 3 } enum TriggerEffect { TRIGGER_EFFECT_PARTICLE, // 0 TRIGGER_EFFECT_ANIMATION, // 1 } enum TriggerEffectType { TRIGGER_EFFECT_SLIQUID, // 0 TRIGGER_EFFECT_LLIQUID, // 1 TRIGGER_EFFECT_DLIQUID, // 2 TRIGGER_EFFECT_BLOOD, // 3 TRIGGER_EFFECT_SPARK, // 4 TRIGGER_EFFECT_BUBBLE, // 5 TRIGGER_EFFECT_MAX = MAX, } enum TriggerEffectPos { TRIGGER_EFFECT_POS_CENTER, // 0 TRIGGER_EFFECT_POS_AREA, // 1 } enum TriggerMusicAction { TRIGGER_MUSIC_ACTION_STOP, // 0 TRIGGER_MUSIC_ACTION_PLAY, // 1; unpause or restart } enum TriggerScoreAction { TRIGGER_SCORE_ACTION_ADD, // 0 TRIGGER_SCORE_ACTION_SUB, // 1 TRIGGER_SCORE_ACTION_WIN, // 2 TRIGGER_SCORE_ACTION_LOOSE, // 3 } enum TriggerMessageDest { TRIGGER_MESSAGE_DEST_ME, // 0 TRIGGER_MESSAGE_DEST_MY_TEAM, // 1 TRIGGER_MESSAGE_DEST_ENEMY_TEAM, // 2 TRIGGER_MESSAGE_DEST_RED_TEAM, // 3 TRIGGER_MESSAGE_DEST_BLUE_TEAM, // 4 TRIGGER_MESSAGE_DEST_EVERYONE, // 5 } enum TriggerMessageKind { TRIGGER_MESSAGE_KIND_CHAT, // 0 TRIGGER_MESSAGE_KIND_GAME, // 1 } bitset ActivateType { ACTIVATE_NONE = 0, // 0 ACTIVATE_PLAYERCOLLIDE, // 1 ACTIVATE_MONSTERCOLLIDE, // 2 ACTIVATE_PLAYERPRESS, // 4 ACTIVATE_MONSTERPRESS, // 8 ACTIVATE_SHOT, // 16 ACTIVATE_NOMONSTER, // 32 ACTIVATE_CUSTOM = 255, // note that "direct assign" field doesn't affect bit counter } bitset Key { KEY_NONE = 0, // 0 KEY_RED, // 1 KEY_GREEN, // 2 KEY_BLUE, // 4 KEY_REDTEAM, // 8 KEY_BLUETEAM, // 16 } enum HitType { HIT_SOME, // 0 HIT_ROCKET, // 1 HIT_BFG, // 2 HIT_TRAP, // 3 HIT_FALL, // 4 HIT_WATER, // 5 HIT_ACID, // 6 HIT_ELECTRO, // 7 HIT_FLAME, // 8 HIT_SELF, // 9 HIT_DISCON, // 10 } //////////////////////////////////////////////////////////////////////////////// // various triggers TriggerData for TRIGGER_EXIT { "map" type char[16] offset 0 writedefault; } TriggerData for TRIGGER_TELEPORT { "target" type point offset 0 writedefault; "d2d" type bool offset 8 default false; "silent" type bool offset 9 default false; "direction" type ubyte offset 10 enum DirType default DIR_LEFT; } TriggerData for (TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR, TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP, TRIGGER_TRAP, TRIGGER_LIFTUP, TRIGGER_LIFTDOWN, TRIGGER_LIFT) { "panelid" type int offset 0 panel writedefault; "silent" type bool offset 4 default false; "d2d" type bool offset 5 default false; } TriggerData for (TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF) { "position" type point offset 0 as txy default (0 0) writedefault; "size" type size offset 8 as twh default (0 0); "wait" type ushort offset 12 default 0; "count" alias pressCount type ushort offset 14 default 0; "monsterid" type int offset 16 monster as monsterid default null; "ext_random" type bool offset 20 default false; // this one is for moving platforms "panelid" panel default null; "silent" type bool default true; "sound" type string default ""; } enum TriggerScoreTeam { TRIGGER_SCORE_TEAM_MINE_RED, // 0 TRIGGER_SCORE_TEAM_MINE_BLUE, // 1 TRIGGER_SCORE_TEAM_FORCE_RED, // 2 TRIGGER_SCORE_TEAM_FORCE_BLUE, // 3 } TriggerData for TRIGGER_SECRET { } TriggerData for TRIGGER_TEXTURE { "activate_once" type bool offset 0 default false writedefault; "animate_once" type bool offset 1 default false writedefault; } TriggerData for TRIGGER_SOUND { "sound_name" type char[64] offset 0 writedefault; "volume" type ubyte offset 64 default 0 writedefault; //??? default ??? "pan" type ubyte offset 65 default 0; "local" type bool offset 66 default true; //??? default ??? "play_count" type ubyte offset 67 default 1; "sound_switch" type bool offset 68 default false; //??? default ??? } TriggerData for TRIGGER_SPAWNMONSTER { "position" type point offset 0 as txy writedefault; "type" alias spawnMonsType type ubyte offset 8 enum Monster default MONSTER_IMP writedefault; "health" type int offset 12 writedefault; "direction" type ubyte offset 16 enum DirType default DIR_LEFT writedefault; "active" type bool offset 17 default true; "count" alias monsCount type int offset 20 default 1 writedefault; "effect" type ubyte offset 24 enum EffectAction default EFFECT_NONE writedefault; "max" type ushort offset 26 default 1 writedefault; "delay" type ushort offset 28 default 1000 writedefault; "behaviour" type ubyte offset 30 enum MonsterBehaviour default BH_NORMAL; } TriggerData for TRIGGER_SPAWNITEM { "position" type point offset 0 as txy writedefault; "type" alias spawnItemType type ubyte offset 8 enum Item default ITEM_NONE writedefault; "gravity" type bool offset 9 default true; "dmonly" type bool offset 10 default false; "count" alias itemCount type int offset 12 default 1; "effect" type ubyte offset 16 enum EffectAction default EFFECT_NONE writedefault; "max" type ushort offset 18 default 1; "delay" type ushort offset 20 default 1000 writedefault; } TriggerData for TRIGGER_MUSIC { "name" alias musicName type char[64] offset 0 writedefault; "action" alias musicAction type ubyte offset 64 enum TriggerMusicAction writedefault; } TriggerData for TRIGGER_PUSH { "angle" type ushort offset 0 writedefault; "force" type ubyte offset 2 writedefault; "reset_velocity" type bool offset 3 default false writedefault; } TriggerData for TRIGGER_SCORE { "action" alias scoreAction type ubyte offset 0 enum TriggerScoreAction default TRIGGER_SCORE_ACTION_ADD writedefault; "count" alias scoreCount type ubyte offset 1 default 1 writedefault; "team" alias scoreTeam type ubyte offset 2 enum TriggerScoreTeam writedefault; "console" alias scoreCon type bool offset 3 default false writedefault; "message" alias scoreMsg type bool offset 4 default true writedefault; } TriggerData for TRIGGER_MESSAGE { "kind" type ubyte offset 0 enum TriggerMessageKind default TRIGGER_MESSAGE_KIND_GAME writedefault; "dest" alias msgDest type ubyte enum TriggerMessageDest offset 1; "text" type char[100] offset 2 writedefault; "time" alias msgTime type ushort offset 102 writedefault; } TriggerData for TRIGGER_DAMAGE { "amount" type ushort offset 0 writedefault; "interval" type ushort offset 2 writedefault; "kind" type ubyte offset 4 enum HitType default HIT_SOME writedefault; } TriggerData for TRIGGER_HEALTH { "amount" type ushort offset 0 writedefault; "interval" type ushort offset 2 writedefault; "max" alias healMax type bool offset 4 writedefault; "silent" type bool offset 5 writedefault; } TriggerData for TRIGGER_SHOT { "position" type point offset 0 as txy writedefault; "type" alias shotType type ubyte offset 8 enum TriggerShot writedefault; "target" alias shotTarget type ubyte offset 9 enum TriggerShotTarget writedefault; "sound" alias shotSound type negbool offset 10; // negbool! "aim" type byte offset 11 enum TriggerShotAim default TRIGGER_SHOT_AIM_DEFAULT; "panelid" type int offset 12 panel default null writedefault; "sight" type ushort offset 16; "angle" type ushort offset 18; "wait" type ushort offset 20; "accuracy" type ushort offset 22; "ammo" type ushort offset 24; "reload" type ushort offset 26; } TriggerData for TRIGGER_EFFECT { "count" alias FXCount type ubyte offset 0 writedefault; "type" alias FXType type ubyte offset 1 enum TriggerEffect default TRIGGER_EFFECT_PARTICLE writedefault; "subtype" alias FXSubType type ubyte offset 2 enum TriggerEffectType default TRIGGER_EFFECT_SPARK writedefault; "red" alias FXRed type ubyte offset 3 writedefault; "green" alias FXGreen type ubyte offset 4 writedefault; "blue" alias FXBlue type ubyte offset 5 writedefault; "pos" alias FXPos type ubyte offset 6 enum TriggerEffectPos default TRIGGER_EFFECT_POS_CENTER writedefault; "wait" type ushort offset 8 writedefault; "vel_x" type byte offset 10 writedefault; "vel_y" type byte offset 11 writedefault; "spread_l" type ubyte offset 12 writedefault; "spread_r" type ubyte offset 13 writedefault; "spread_u" type ubyte offset 14 writedefault; "spread_d" type ubyte offset 15 writedefault; }