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[]
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[]
Opcode | Opcode Name | Arguments |
---|---|---|
0x01 | Display0x01 | string text |
0x02 | DoorTextSml | string text |
0x03 | DoorTextLrg | string text |
0x04 | SignText | string text |
0x05 | NPC | string name, string conversationText, byte faceNumber, byte confirm, optional lineNumber nextLineNumber |
0x06 | PlayFX | byte effectId |
0x07 | TeleportAndExit | byte mapId, byte x, byte y |
0x08 | If | byte comparisonType, itemdata value, lineNumber destination |
0x09 | If | byte comparisonType, itemdata value, lineNumber destination |
0x0A | If | byte comparisonType, itemdata value, lineNumber destination |
0x0B | MoveObj | byte objectNumber, byte x, byte y |
0x0C | TakeOrGive | byte takeType, itemdata object1, byte giveType, itemdata object2 |
0x0D | NoAction | - |
0x0E | Remove | - |
0x0F | SetChar | byte characterIndex |
0x10 | Spawn | byte monsterId, byte x, byte y, byte unknown |
0x11 | DoTownEvent | byte townEventId |
0x12 | Exit | - |
0x13 | AlterMap | byte x, byte y, byte wall, byte value |
0x14 | GiveExtended | unknown |
0x15 | ConfirmWord | string acceptableWord1, lineNumber destination, string acceptableWord2, string promptText |
0x16 | Damage | uint16 amount, byte type |
0x17 | JumpRnd | byte max, byte comparison, lineNumber destination |
0x18 | AlterEvent | lineNumber lineNumber, byte newOpcode |
0x19 | CallEvent | byte x, byte y, byte facingDirection |
0x1A | Return | - |
0x1B | SetVar | byte variableId, itemdata newValue |
0x1C | TakeOrGive | byte giveType, itemdata compareValue, byte giveType, itemdata object2 |
0x1D | TakeOrGive | byte takeType, itemdata object1, byte giveType, itemdata object2 |
0x1E | CutsceneEndClouds | - |
0x1F | TeleportAndContinue | byte mapId, byte x, byte y |
0x20 | WhoWill | byte whatIndex, string descriptionText |
0x21 | RndDamage | byte damageType, byte max |
0x22 | MoveWallObj | byte wallObjectNumber, byte x, byte y |
0x23 | AlterCellFlag | byte x, byte y, byte newFlagValue |
0x24 | AlterHed | uint16 newValue |
0x25 | DisplayStat | string text |
0x26 | TakeOrGive | byte giveType, itemdata object1, byte giveType, itemdata object2 |
0x27 | SeatTextSml | string text |
0x28 | PlayEventVoc | byte vocIndex |
0x29 | DisplayBottom | string descriptionText |
0x2A | IfMapFlag | byte monsterId, lineNumber destination |
0x2B | SelRndChar | - |
0x2C | GiveEnchanted | byte itemType, byte baseEnchantment, byte extraEnchantment, byte unknown |
0x2D | ItemType | byte itemType |
0x2E | MakeNothingHere | - |
0x2F | NoAction | - |
0x30 | ChooseNumeric | byte numberOfOptions, byte*n arrayOfLineNumbers |
0x31 | DisplayBottomTwoLines | string firstLine, string secondLine |
0x32 | DisplayLarge | string text |
0x33 | ExchObj | byte objectNumber1, byte objectNumber2 |
0x34 | FallToMap | map mapId, byte x, byte y, byte fallDamage |
0x35 | DisplayMain | string text |
0x36 | Goto | byte c_surface, lineNumber destination |
0x37 | ConfirmWord | string acceptableWord1, lineNumber destination1, string acceptableWord2, lineNumber destination2 |
0x38 | GotoRandom | byte numberOfLineNumbers, byte*n arrayOfLineNumbers |
0x39 | CutsceneEndDarkside | - |
0x3a | CutsceneEndWorld | - |
0x3b | FlipWorld | byte sideFlag |
0x3c | PlayCD | byte cdTrackNumber, uint16 startFrame, uint16 endFrame |
Event Opcodes
| ||||||||||
|
All Event Opcodes
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|