FANDOM


Events are scripted interactions that can be placed at any position on any map. They can take a variety of inputs, with access to input from the player in the form of getting them to enter a word or phrase, choose from a number of pre-set options, or selecting a character. Events can modify a wide variety of in-game variables: character stats, health, conditions, party gold, gems, awards, and so forth. They can also modify the map by adding monsters, changing tiles, adding objects, removing objects, and removing events, as well as providing output to the player in the form of NPC dialogs and output windows full of text, playing sound effects or CD audio, etc.

The events for a given map are stored in a file named MAZExxxx.EVT, where xxxx is a decimal representation of the map number. Like all other map files used by the Xeen engine, the first zero is replaced by an 'X' if the map number is greater than 99: MAZE0024.EVT for map number 24, and MAZEX128.EVT for map number 128.

Each individual event is stored as a set of lines, each of which contains an instruction for the engine to execute. The lines are numbered, so that it is possible to jump between lines using the equivalent of a GOTO command.

The event file itself consists of these lines all stored one after the other. Each line consists of:

  • Length byte - the next n bytes make up this line
  • X-Coordinate (byte) - the X-offset of this event
  • Y-Coordinate (byte) - the Y-offset of this event
  • Facing Direction (byte) - the directions this event can be triggered from
  • Line number (byte) - the relative number of this line in the current event
  • Opcode byte - the command to execute
  • Optional arguments - any number of bytes

The X, Y, and facing bytes combine to indicate the tile the party must be standing on, and the direction they must be facing to trigger the event. A direction value of 4 means that the event can be triggered if the party is facing any direction.

Event Example Edit

The raw data from the Vertigo event file has been broken down to show the line structure:

08  10 08 04  00     09  14 F5 02
08  10 08 04  01     08  09 00 05
06  10 08 04  02     01  1C 
08  10 08 04  03     09  2C 01 04
05  10 08 04  04     12 
07  10 08 04  05     20  00 28
0E  10 08 04  06     14  64 0A 00 00 00 00 00 00 00
09  10 08 04  07     0C  00 00 14 F5 

The first byte of each line shows the length of the line data (the number of following bytes.

The next three bytes are the X, Y, and facing bytes: this event is located at X=16, Y=8, and can be triggered from any direction.

The next byte is the line number. This is always incremented by one in every original Xeen game event examined.

There is always at least one more byte: the opcode for the command the engine should perform, which may have data bytes. In the above example, all the lines except line 4 (opcode 0x12) have at least one data byte.

00: If                 14 F5 02
01: If                 09 00 05
02: Display0x01        1C 
03: If                 2C 01 04
04: Exit 
05: WhoWill            00 28
06: GiveTreasureChest  64 0A 00 00 00 00 00 00 00
07: TakeOrGive         00 00 14 F5 

The game engine stores the results of certain commands in memory. The exact handling of the parameters for each of the above lines is available on each command's individual page, however a brief overview of this event is:

  • 0. If map flag F5 is set, go to line 2.
    • 1. Otherwise, go to line 5.
  • 2. Show the "Nothing here." message.
  • 3. Wait for the user to press a key.
  • 4. Stop execution of the script.
  • 5. Ask the user "Who will search?". If the user presses escape, the event will exit, otherwise execution will continue to the next line when they select a character.
  • 6. Use the GiveTreasureChest function to give the party a random amount of up to 10 gold.
  • 7. Set map flag F5, so that the user can't search this tree again. (See line 1)
  • There are no more lines, so the event is finished.

As you can see, many commands (such as If) are capable of serving multiple purposes, and can do many different things depending on the parameters passed.

All Opcodes Edit

Opcode Opcode Name Arguments
0x01Display0x01string text
0x02DoorTextSmlstring text
0x03DoorTextLrgstring text
0x04SignTextstring text
0x05NPCstring name, string conversationText, byte faceNumber, byte confirm, optional lineNumber nextLineNumber
0x06PlayFXbyte effectId
0x07TeleportAndExitbyte mapId, byte x, byte y
0x08Ifbyte comparisonType, itemdata value, lineNumber destination
0x09Ifbyte comparisonType, itemdata value, lineNumber destination
0x0AIfbyte comparisonType, itemdata value, lineNumber destination
0x0BMoveObjbyte objectNumber, byte x, byte y
0x0CTakeOrGivebyte takeType, itemdata object1, byte giveType, itemdata object2
0x0DNoAction-
0x0ERemove-
0x0FSetCharbyte characterIndex
0x10Spawnbyte monsterId, byte x, byte y, byte unknown
0x11DoTownEventbyte townEventId
0x12Exit-
0x13AlterMapbyte x, byte y, byte wall, byte value
0x14GiveExtendedunknown
0x15ConfirmWordstring acceptableWord1, lineNumber destination, string acceptableWord2, string promptText
0x16Damageuint16 amount, byte type
0x17JumpRndbyte max, byte comparison, lineNumber destination
0x18AlterEventlineNumber lineNumber, byte newOpcode
0x19CallEventbyte x, byte y, byte facingDirection
0x1AReturn-
0x1BSetVarbyte variableId, itemdata newValue
0x1CTakeOrGivebyte giveType, itemdata compareValue, byte giveType, itemdata object2
0x1DTakeOrGivebyte takeType, itemdata object1, byte giveType, itemdata object2
0x1ECutsceneEndClouds-
0x1FTeleportAndContinuebyte mapId, byte x, byte y
0x20WhoWillbyte whatIndex, string descriptionText
0x21RndDamagebyte damageType, byte max
0x22MoveWallObjbyte wallObjectNumber, byte x, byte y
0x23AlterCellFlagbyte x, byte y, byte newFlagValue
0x24AlterHeduint16 newValue
0x25DisplayStatstring text
0x26TakeOrGivebyte giveType, itemdata object1, byte giveType, itemdata object2
0x27SeatTextSmlstring text
0x28PlayEventVocbyte vocIndex
0x29DisplayBottomstring descriptionText
0x2AIfMapFlagbyte monsterId, lineNumber destination
0x2BSelRndChar-
0x2CGiveEnchantedbyte itemType, byte baseEnchantment, byte extraEnchantment, byte unknown
0x2DItemTypebyte itemType
0x2EMakeNothingHere-
0x2FNoAction-
0x30ChooseNumericbyte numberOfOptions, byte*n arrayOfLineNumbers
0x31DisplayBottomTwoLinesstring firstLine, string secondLine
0x32DisplayLargestring text
0x33ExchObjbyte objectNumber1, byte objectNumber2
0x34FallToMapmap mapId, byte x, byte y, byte fallDamage
0x35DisplayMainstring text
0x36Gotobyte c_surface, lineNumber destination
0x37ConfirmWordstring acceptableWord1, lineNumber destination1, string acceptableWord2, lineNumber destination2
0x38GotoRandombyte numberOfLineNumbers, byte*n arrayOfLineNumbers
0x39CutsceneEndDarkside-
0x3aCutsceneEndWorld-
0x3bFlipWorldbyte sideFlag
0x3cPlayCDbyte cdTrackNumber, uint16 startFrame, uint16 endFrame


Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.