HEXEN Specs v0.9 Page 1 The Official Hexen Technical Specs Author: Ben Morris (bmorris@islandnet.com) Information from Raven provided by Ben Gokey [Disclaimer] The text contained in this document is for informational purposes only. If you decide to use this information in any way, neither id Software, Raven Software, nor Ben Morris can be held responsible for any damages or losses (including, but not limited to: dismembered bodily parts, telefrags and lack of sleep) incurred by this information's use. Although this is an "Official" specification, some of the information contained within might be old, or just plain typed in wrong. You have been warned. !!! NB: This version of the specs, 0.9, is a preliminary release. Most of the information here is tried and true, but there's a good chance there are errors in the file. If something doesn't look right, or really IS wrong, please contact me (Ben Morris) at the address above. Please do NOT contact me about new versions of the specs; I will release the new versions when they are ready. Thanks. ** Set your tab width to 4. Page 1 HEXEN Specs v0.9 Page 2 +--------------------------------------------------------------------------- ¦ ¦ ¦ Table of Contents +---+ No, this isn't finished. +--------------------------------------------------------------------------- ¦ ¦ ¦ Definitions used in this File +---+ Angle [0..255] Used in "angle" parameters to Special types: 0 East 32 Northeast 64 North 96 Northwest 128 West 160 Southwest 192 South 224 Southeast * NOTE that this differs from DOOM/Heretic in that 45/90 degree increments are not used. However, this difference does _not_ apply for the angles used for the THINGS in map editing - they are the same as DOOM's (eg: 0 = East, 90 = North, etc.) Tics Time unit of length 1/35 second. So, 35 tics = 1 second. Octics Time unit of length 8 tics. So, 8 octics = 1 second. Page 2 HEXEN Specs v0.9 Page 3 +--------------------------------------------------------------------------- ¦ i ¦ About This File +---+ This file was written for those who are interested in the inner workings of Hexen. It doesn't contain playing tips or information on how to get Hexen working on your system. This file is intended to be supplementary to Matt Fell's "Unofficial DOOM Specs", which probably came with your copy of DOOM or DOOM ][. Wherever it's relevant, this file refers to a specific section in the DOOM specs (be sure you have version 1.666!), so it's a good idea to have a copy at hand. +--------------------------------------------------------------------------- ¦ i ¦ Introduction to Hexen +---+ Hexen is the sequel to Heretic, Raven Software's first collaboration with id Software. [..] Hexen's major difference from Heretic and DOOM is its programmability. Hexen features a powerful script language that can be used to create a wide variety of in-game effects such as traps, puzzles and even earthquakes! [...] Page 3 HEXEN Specs v0.9 Page 4 +--------------------------------------------------------------------------- ¦ 3-0 ¦ Hexen Data Structures +-----+ This section outlines the format of the new data blocks in a Hexen map - the LINEDEF and THING structures. These structures have changed from the versions used in DOOM and Heretic. [DOOM Specs ref] [3-1] The Hexen LINEDEF structure --------------------------------- Offset Size Meaning --------------------------------------------------- 0 word the line's start-vertex 2 word the line's end-vertex 4 word line flags (see below) 6 byte special type (see [Specials]) 7 5 bytes special arguments 12 word the line's right sidedef number 14 word the line's left sidedef number [3-1-1] Line Flags ------------------ The following flags are starred with an asterisk if they're new for Hexen: Bits Meaning when Set --------------------------------------------------- 0 impassable - the line cannot be crossed. 1 impassable to monsters only. 2 two-sided 3 upper texture is unpegged (drawn from top-down) 4 lower/middle texture is unpegged (drawn from bottom-up) 5 secret - the line appears as impassable on the automap. 6 sound can't travel through the line, but only for monsters' ears. 7 never draw the line on the auto-map, even with the map cheat enabled. 8 the line is always drawn on the auto-map, even if it hasn't been seen by the player. * 9 the line's special ([3-1]) is repeatable, ie: it can be activated more than once. * 10..12 the line's special activation, ie: how the special is Page 4 HEXEN Specs v0.9 Page 5 activated. Value Activated when... --------------------------------------------- 0 Player crosses the line 1 Player uses the line with the use key 2 Monster crosses the line 3 Projectile impacts the wall 4 Player pushes the wall 5 Projectile crosses the line To get the special activation, use the following formula: activation := (line.flags BITAND 0x1C00) BITSHIFTRIGHT 10 [3-2] The Hexen THING structure ------------------------------- Offset Size Meaning --------------------------------------------------- * 0 word thing ID - used in scripts and specials to identify a THING or a set of THINGs. 2 word x-position on the map 4 word y-position on the map * 6 word starting altitude on the map - the THING is created at this altitude above the floor of the sector it's in when the map is entered, and is immediately subjected to gravity. 8 word the angle the thing is facing when the map is entered. 10 word the thing type (see [3-2-2].) * 12 word thing flags (see [3-2-1].) 14 byte special type (see [Specials]). a thing's special is activated when the thing is killed (Monster), destroyed (Tree, Urn, etc.), or picked up (Artifact, Puzzle Piece.) 15 5 bytes special arguments [3-2-1] Thing Flags ------------------- The following flags are starred with an asterisk if they're new for Hexen: Bits Meaning when Set --------------------------------------------------- 0 the thing appears on the Easy skill settings (1-2) 1 the thing appears on the Normal skill setting (3) Page 5 HEXEN Specs v0.9 Page 6 2 the thing appears on the Hard skill settings (4-5) 3 the thing is deaf - it sits around until it's hurt, or until it sees a player. * 4 the thing is dormant - it never wakes up until it's activated using the Thing_Activate() special. * 5 the thing appears for the Fighter class. * 6 the thing appears for the Cleric class. * 7 the thing appears for the Mage class. * 8 the thing appears in single-player games. * 9 the thing appears in cooperative games. * 10 the thing appears in deathmatch games. Each "thing appears" flag must be set for each condition under which the thing is to appear. For multi-player games involving more than one class, a thing that is set for one of the classes involved will also appear for the other two classes in the game. For example, if you set the three pieces of the Fighter's sword to appear for only the Fighter (bit 5 is set) and in Deathmatch (bit 10 is set), if a Mage or a Cleric is also playing, the pieces of the sword will be visible to them, too. [3-2-2] Thing Types ------------------- Creatures as well as some objects can be activated and/or deactivated with the ThingActivate and ThingDeactivate line specials. Creatures will freeze when deactivated and resume when activated. Activation can also be used to bring a "dormant" creature to life. If a creature has a special, that special will be activated upon its death. Also, if the creature is teleported away using the banishment device (teleport other), the special will be activated and then removed from the creature. Type Name ----------------------------------------------------------- 1 Player_1_start 2 Player_2_start 3 Player_3_start 4 Player_4_start 11 Player_Deathmatch 14 Player_TeleportSpot 10 2C_SerpentStaff 8010 2F_Axe 53 2M_ConeOfShards Page 6 HEXEN Specs v0.9 Page 7 8009 3C_Firestorm 123 3F_Hammer 8040 3M_Lightning 20 4C_1Shaft 19 4C_2Cross 18 4C_3Arc 16 4F_1Hilt 13 4F_2Crosspiece 12 4F_3Blade 23 4M_1Stick 22 4M_2Stub 21 4M_3Skull 10110 A_Flechette 8003 A_BoostMana 8002 A_BootsOfSpeed 8041 A_Bracers 84 A_IconOfDefender 30 A_Porkelator 83 A_WingsOfWrath 32 A_HealingComplete (Urn) 82 A_HealingHefty (Flask) 81 A_HealingWimpy (Vial) 10120 A_HealRadius 8000 A_Repulsion 86 A_DarkServant 36 A_ChaosDevice 33 A_Torch 10040 A_Banishment 8008 Ar_Amulet 8005 Ar_Armor 8007 Ar_Helmet 8006 Ar_Shield 114 C_Bishop 107 C_Centaur 115 C_CentaurLeader 10101 C_ClericBoss 31 C_Demon 8080 C_Demon2 254 C_Dragon 10030 C_Ettin 10100 C_FighterBoss 10060 C_FireImp 112 C_Fly 10080 C_Heresiarch 8020 C_IceGuy 10200 C_Korax 10102 C_MageBoss Page 7 HEXEN Specs v0.9 Page 8 121 C_Serpent 120 C_SerpentLeader 34 C_Wraith 10011 C_Wraith2 8032 K_AxeKey 8034 K_CastleKey 8031 K_CaveKey 8035 K_DungeonKey 8033 K_FireKey 8200 K_GoldKey 8037 K_RustyKey 8036 K_SilverKey 8030 K_SteelKey 8039 K_SwampKey 8038 K_WasteKey 122 Mana_1 124 Mana_2 8004 ManaCombined 3000 PO_Anchor 3001 PO_StartSpot 3002 PO_StartSpot_Crush 1410 SE_Wind 10225 Spawn_Bat 10000 Spawn_Fog 10001 Spawn_Fog_a 10002 Spawn_Fog_b 10003 Spawn_Fog_c 113 Spawn_Leaf 10090 Spike_Down 10091 Spike_Up 1403 SS_Creak 1408 SS_EarthCrack 1401 SS_Heavy 1407 SS_Ice 1405 SS_Lava 1402 SS_Metal 1409 SS_Metal2 1404 SS_Silent 1400 SS_Stone 1406 SS_Water 9001 X_MapSpot 9013 X_MapSpotGravity Page 8 HEXEN Specs v0.9 Page 9 8064 Z_ArmorSuit 77 Z_Banner 8100 Z_Barrel 8065 Z_Bell 8066 Z_BlueCandle 8061 Z_BrassBrazier 8103 Z_Bucket 119 Z_Candle 8069 Z_Cauldron 8070 Z_Cauldron_Unlit 8071 Z_Chain32 8072 Z_Chain64 8073 Z_ChainHeart 8074 Z_ChainLHook 8075 Z_ChainSHook 8077 Z_ChainSkull 8076 Z_ChainSpikeBall 17 Z_Chandelier 8063 Z_Chandelier_Unlit 8042 Z_FireBull 8043 Z_FireBull_Unlit 8060 Z_FireSkull 118 Z_GlitterBridge 10503 Z_LargeFlame_Permanent 10502 Z_LargeFlame_Timed 10501 Z_SmallFlame_Permanent 10500 Z_SmallFlame_Timed 140 Z_TeleportSmoke 116 Z_TwinedTorch 117 Z_TwinedTorch_Unlit 103 Z_VasePillar 54 Z_Wall_Torch_Lit 55 Z_Wall_Torch_Unlit 5 Z_WingedStatue 6 ZC_Rock1 7 ZC_Rock2 9 ZC_Rock3 15 ZC_Rock4 41 ZC_ShroomLarge 42 ZC_ShroomSmall1 44 ZC_ShroomSmall2 45 ZC_ShroomSmall3 52 ZC_StalactiteLarge 56 ZC_StalactiteMedium 57 ZC_StalactiteSmall 48 ZC_Stalagmite_Pillar 49 ZC_StalagmiteLarge 50 ZC_StalagmiteMedium 51 ZC_StalagmiteSmall Page 9 HEXEN Specs v0.9 Page 10 8062 ZF_DestructibleTree 8068 ZF_Hedge 8104 ZF_ShroomBoom 39 ZF_ShroomLarge1 40 ZF_ShroomLarge2 46 ZF_ShroomSmall1 47 ZF_ShroomSmall2 8101 ZF_Shrub1 8102 ZF_Shrub2 29 ZF_StumpBare 28 ZF_StumpBurned 24 ZF_TreeDead 25 ZF_TreeDestructible 80 ZF_TreeGnarled1 87 ZF_TreeGnarled2 78 ZF_TreeLarge1 79 ZF_TreeLarge2 111 ZG_BloodPool 71 ZG_CorpseHanging 61 ZG_CorpseKabob 108 ZG_CorpseLynched 109 ZG_CorpseNoHeart 110 ZG_CorpseSitting 62 ZG_CorpseSleeping 8067 ZG_IronMaiden 65 ZG_TombstoneBigCross 69 ZG_TombstoneBrianP 66 ZG_TombstoneBrianR 67 ZG_TombstoneCrossCircle 63 ZG_TombstoneRIP 64 ZG_TombstoneShane 68 ZG_TombstoneSmallCross 93 ZI_IceSpikeLarge 94 ZI_IceSpikeMedium 95 ZI_IceSpikeSmall 89 ZI_IcicleLarge 90 ZI_IcicleMedium 91 ZI_IcicleSmall 8502 ZM_CandleWeb 8509 ZM_CleaverMeat 8508 ZM_GobletSilver 8507 ZM_GobletSmall 8505 ZM_GobletSpill 8506 ZM_GobletTall 8504 ZM_LgCandle 8500 ZM_LgStein 104 ZM_Pot1 105 ZM_Pot2 106 ZM_Pot3 100 ZM_Rubble1 Page 10 HEXEN Specs v0.9 Page 11 101 ZM_Rubble2 102 ZM_Rubble3 8503 ZM_SmCandle 8501 ZM_SmStein 8051 ZP_GargBrnzShort 8047 ZP_GargBrnzTall 8044 ZP_GargCorrode 76 ZP_GargIceShort 73 ZP_GargIceTall 8050 ZP_GargLavaBrtShort 8046 ZP_GargLavaBrtTall 8049 ZP_GargLavaDrkShort 8045 ZP_GargLavaDrkTall 74 ZP_GargPortalShort 72 ZP_GargPortalTall 8052 ZP_GargStlShort 8048 ZP_GargStlTall 88 ZS_Log 58 ZS_Moss1 59 ZS_Moss2 37 ZS_Stump1 38 ZS_Stump2 27 ZS_Tree1 26 ZS_Tree2 60 ZS_Vine 99 ZW_RockBlack 97 ZW_RockBrownLarge 98 ZW_RockBrownSmall 9003 ZZ_BigGem 9007 ZZ_Book1 9008 ZZ_Book2 9016 ZZ_CWeapon 9015 ZZ_FWeapon 9018 ZZ_Gear 9019 ZZ_Gear2 9020 ZZ_Gear3 9021 ZZ_Gear4 9006 ZZ_GemBlue1 9010 ZZ_GemBlue2 9005 ZZ_GemGreen1 9009 ZZ_GemGreen2 9012 ZZ_GemPedestal 9004 ZZ_GemRed 9017 ZZ_MWeapon 9002 ZZ_Skull 9014 ZZ_Skull2 9011 ZZ_WingedStatueNoSkull Page 11 HEXEN Specs v0.9 Page 12 +--------------------------------------------------------------------------- ¦ 4-0 ¦ Hexen Script Language +-----+ The Hexen Script Language is called the "Action Code Script", or ACS. Each map has an ACS file that contains the scripts specific to that map. The scripts within it are identified using numbers that the general special ACS_Execute() uses. A script itself can call the ACS_Execute() special (actually quite common), which will spawn another script that will run concurrently with the rest of the scripts. A script can also be declared as OPEN, which will make it run automatically upon entering the map. This is used for perpetual type effects, level initialization, etc. The compiler takes the ACS file and produces and object file that is the last lump in the map WAD (BEHAVIOR). To create a compiled ACS file from a text script, use the DOS command: c:\hexen> acs filename [enter] This command will produce 'filename.o' from 'filename.acs'. The contents of the output file (filename.o) can be directly used as the BEHAVIOR lump of the map it's used with. Map scripts should start with #include "common.acs", which is just... #include "specials.acs" #include "defs.acs" #include "wvars.acs" The file "specials.acs" defines all the general specials. These are used within scripts just like function calls. The file "defs.acs" defines a bunch of constants that are used by the scripts. The file "wvars.acs" defines all the world variables. It needs to be included by all maps so they use consistent indexing. [4-1] Variables and their Scope -------------------------------- There is only one data type ACS, a 4 byte integer. Use the keyword int to declare an integer variable. You may also use the keyword str, it is synonymous with int. It's used to indicate that you'll be using the variable as a string. The compiler doesn't use string pointers, it uses string handles, which are just integers. Declaring a variable is simple. There are two "types" of variable - "str" and "int": Page 12 HEXEN Specs v0.9 Page 13 str mystring; int myint; or: str texture, sound; int i, tid; * Note: You can't assign a variable in its declaration; you must give it a value in a different expression. The SCOPE of a variable is one of World-scope, Map-scope, or Script-scope. - World-scope variables are global, and can be accessed in any map. Hexen maintains [n] permanent globals, numbered 0-[n-1]. You must assign one of the globals a name in order to access it, like this: world int 5:Grunt; This tells Hexen to reference world global number 5 whenever it encounters the name "Grunt". - Map-scope variables are local to the current map. They must be declared outside of any script code, but without the world keyword. These variables can't be accessed in any other map. - Script-scope variables are local to the current script - they can't be accessed by any other script or map. Here's some code that shows the declaration of all three scopes: world int 3:DungeonAccess; // World-scope int mapTimer; // Map-scope script 4 (void) { int x, y; // Script-scope ... } [4-2] Language Structure ------------------------ Here is a quick reference manual type definition of the language. It ends with a description of all the internal functions. Page 13 HEXEN Specs v0.9 Page 14 [4-2-1] Keywords ---------------- The following identifiers are reserved for use as keywords, and may not be used otherwise: break case const continue default define do else goto if include int open print printbold restart script special str suspend switch terminate until void while world [4-2-2] Comments ---------------- Comments are ignored by the script compiler. /* This is a comment. */ int a; // And this is a comment [4-2-3] World-variable definitions ---------------------------------- world int : ; Page 14 HEXEN Specs v0.9 Page 15 world int : , ... ; [4-2-4] Map-variable definitions -------------------------------- Declares a variable local to the current map. int ; str ; int , ... ; [4-2-5] Include Directive ------------------------- Includes the source of the specified file and compiles it. #include [4-2-5] Define Directive ------------------------ Replaces an identifier with a constant expression. #define [4-2-6] Constant Expressions ---------------------------- : decimal 200 hexadecimal 0x00a0, 0x00A0 fixed point 32.0, 0.5, 103.329 any radix _digits binary 2_01001010 octal 8_072310 decimal 10_50025 hexadecimal 16_00a03f2 [4-2-7] String Literals ----------------------- : "string" Page 15 HEXEN Specs v0.9 Page 16 [4-2-6] Script Definitions -------------------------- To define a script: : script ( ) { } script OPEN { } eg: script 10 (void) { ... } script 5 OPEN { ... } * Note that OPEN scripts do not take arguments. [4-2-6] Statements ------------------ : [4-2-6-1] Declaration Statements -------------------------------- Delcaration statements create script variables. : int ; int , , ... ; [4-2-6-1] Assignment Statements ------------------------------- Assigns an expression to a variable. Page 16 HEXEN Specs v0.9 Page 17 : ; : = += -= *= /= %= * Note: An assignment of the form V = E is equivalent to V = V E. For example: A += 5; is the same as A = A + 5; [4-2-6-2] Compound Statements ----------------------------- : { } : <...> [4-2-6-3] Switch Statements --------------------------- A switch statement evaluates an integral expression and passes control to the code following the matched case. : switch ( ) { } : case : default : Example: switch (a) { case 1: // when a == 1 b = 1; // .. this is executed, break; // and this breaks out of the switch(). case 2: // when a == 2 Page 17 HEXEN Specs v0.9 Page 18 b = 8; // .. this is executed, // but there is no break, so it continues to the next // case, even though a != 3. case 3: // when a == 3 b = 666; // .. this is executed, break; // and this breaks out of the switch(). default: // when none of the other cases match, b = 777; // .. this is executed. } * Note for C users: While C only allows integral expressions in a switch statement, ACS allows full expressions such as "a + 10". [4-2-6-4] Jump Statements ------------------------- A jump statement passes control to another portion of the script. : continue ; break ; restart ; [4-2-6-5] Iteration Statements ------------------------------ : while ( ) until ( ) do while ( ) ; do until ( ) ; for ( ; ; ) The continue, break and restart keywords can be used in an iteration statement: - the continue keyword jumps to the end of the last in the iteration-statement. The loop continues. - the break keyword jumps right out of the iteration-statement. [4-2-6-6] Function Statements ----------------------------- Page 18 HEXEN Specs v0.9 Page 19 A function statement calls a Hexen internal-function, or a Hexen linespecial-function. : | : ( , ... ) ; ( const : , ... ) ; : ( , ... ) ; ( const : , ... ) ; [4-2-6-7] Print Statements -------------------------- : print ( : , ... ) ; printbold ( : , ... ) ; : s string d decimal c constant [4-2-6-8] Selection Statements ------------------------------ : if ( ) if ( ) else [4-2-6-9] Control Statements ---------------------------- : suspend ; // suspends the script terminate ; // terminates the script [4-2-7] Internal Functions -------------------------- void tagwait(int tag); ---------------------- Page 19 HEXEN Specs v0.9 Page 20 The current script is suspended until all sectors marked with are inactive. void polywait(int po); ---------------------- The current script is suspended until the polyobj marked with is incactive. void scriptwait(int script); ---------------------------- The current script is suspended until the script specified by