Difference between revisions of "CSBwin/DSA/Lesson 3"
m (CSBwin/DSA Lesson 3 moved to CSBwin/DSA/Lesson 3) |
|
(No difference)
|
Latest revision as of 16:31, 6 January 2009
Messages: To and Fro/Set and Clear/Now and Later
Almost everything that happens in Dungeon Master happens as a result of a message. When you press a button on the wall, a message is sent. Perhaps to a Door. Perhaps to a Pit. Perhaps to a DSA. If a Door opens, it is because it has received a message. If a creature moves, it is because it has received a message (Creatures send messages to themselves as reminders to move again at a later time!). Most Actuators can either receive messages or send messages and many can do both. DSAs are no exception as they can receive, respond to, and send messages.
Message properties
- Message Type. This is complicated. There are messages to cause monsters to move about. There are messages to cause light spells to wear off. There are messages to re-enable monster generators. But for our purposes there is only one message type (a small fabrication). We will be talking about messages sent from Actuators like pushbuttons, pressure pads, DSAs, Counters, etc. to other Actuators, Doors, Teleporters, Pits, etc.
- Time of delivery. This is the time the message should be delivered to the target. In the editor, this is always specified as a 'Delay', the amount of time between the creation of the message and the delivery of the message.
- Action. This can be 0, 1, or 2. This number is interpreted by the object that receives the message. A door interprets it as 0 = Open, 1 = Close, and 2 = Change. An AND/OR actuator interprest this as Set, Clear, or Toggle.
- Target location. The location consists of
- The level
- The x and y coordinate of the cell on the level
- The position. A number from 0 to 3. This number is interpreted by the 'postman' who delivers the message or by the object that receives the message.
Let us talk about these properties a bit more.
Time of Delivery
Time is kept in units of about 1/6th second. The message has a 24-bit number saying at what time the message is to be delivered. The time can be any time up to 16,777,215. This is about 776 hours. If the player plays longer than this, then things will most certainly go to Hell in a handbasket. When you edit an Actuator that sends a message, you will find a field called 'Delay'. When the Actuator creates and sends a message, the 'Delay' is added to the current time to produce a time-of-delivery. Unfortunately, this field can usually contain only small numbers. In fact, this delay is generally limited to values of zero to fifteen. When DSAs create messages, this delay can be a very large number. So one reason to use a DSA might be as a 'relay' to provide very long delays.
Target Location
Most Actuators cannot send messages to levels other than the level on which they themselves are located. A DSA can send a message to any level. So another reason to use a DSA might be as a relay to get messages across level boundaries. When you edit an Actuator like a pushbutton there is generally a 'Target' box with 'column', 'row', 'position', and a 'Browse' button. The column is the x-coordinate, the row is the y-coordinate, and the position is selectable from 'North', South', 'East' and 'West'. In some cases, these direction names make sense because the message will be sent only to actuators located in the corresponding side of the cell at the given column and row. In other cases, this position parameter is interpreted as a number from zero to three, respectively. A DSA interprets this 'position', along with the 'action' as a message name. There are three different actions and four different 'positions' and so there are altogether twelve different message names :
Set | Clear | Toggle | |
---|---|---|---|
0=North | S0 | C0 | T0 |
1=East | S1 | C1 | T1 |
2=South | S2 | C2 | T2 |
3=West | S3 | C3 | T3 |
Along the top of the table are the possible 'actions' and along the side are the four possible 'positions' and the interior cells of the table give the name of the message as interpreted by a DSA. These names are the names of the messages that you see along the top of the DSA State Table described in Lesson 2.
Here is an example of a 'Target Editor' taken from the 'Edit Pressurepad' dialog :
When the party steps on this Pressurepad, a message it will go to the same level as the Pressurepad, to the cell at x=4 and y=12, with position 'south', and with Action = Set. If there is a DSA located in that cell, it will interpret this as a message named 'S2', as you can see by looking into the table above ("DSA Message Names") in the column 'Set' and the row '2=South'. The DSA will then execute whatever code has been placed in its 'S2' row for its current state.
So now you know how to send a message to a DSA and how the DSA interprets the message. In our next lesson] we will tell you how you can tell a DSA to SEND a message. To anywhere and after an arbitrary delay.