Dark Stone
Quest Editor Tutorial

Chapter 4: Creation of State Machines

The state machines are pre-programmed funcitons; They allow you to scenarize your quest. Lets see how to use some of these state machines in your quest.

1: Create a simple state machine

Right click in the edition window then select Add Machine.
Choose the state machine you need (when selected, read description on the top left to know its purpose).

Example 1

Select the state machine container1
Fill the properties window of the state machine with the following parameters. Eye

Enter new key: Give1
3D object: initial close. The 3D object before you used it. (ex: CHARRUE)
3D object: final open. The 3D object after you have used it. (ex: CHARRUE)
Received object: The object to give the player. (ex: Object1 (object devastator created previously. See the quest objects in chapter 3))
Sound to play when object is given: The sound to play when the object is given. (ex: ITEM_DROP)

Move the frame give1_0 inside the roomzone House1.
Pass in 3D edition of House1 place the plow and put the collisions around. Eye
In the game if you click on the plow, you obtain the object Devastator.

Example 2

Select the state machine: containerAttack2
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: NeedDevastator
Sound to play when object is given: CAISSEOPEN
Received item B: The object to be given to the player. (ex: ITEM_CRYSTAL3)
Object A to wear: The weapon that the player must equip himself with. (ex: Object1)
3D object: final open. The 3D object after we have used it. (ex: CAISSE_O)
3D object: initial close. The 3D object before we use it. (ex: CAISSE_C)

Move the frame NeedDevastator_0 inside the roomzone House1.
Pass into 3D edition of House1 and place the case. Eye
In the game, if you break the chest when you are holding the object Devastator you receive a crystal.

Example 3

Select the state machine: containerMonster1
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: Egg1
3D object: initial close. The 3D object before we use it. (ex: 2OEUFB)
3D object: final open. The 3D object after we have used it. (ex: 2OEUFD)
Monster to generate: Monster that will be generated when we click on this state machine. (ex: MYSVYVERN4)
Sound to play when monster appears: BARRELOPEN

To add some similar state machines, use the function instance (very useful for the doors for example)
- Right click on the frame of the egg and select Instances then Add.
- Make this operation two times and move the frames Egg1_0, Egg1_1 and Egg1_2 inside the roomzone Entrance1. Eye
- Pass into 3D view edition of Entrance1 and place the eggs in the appropriate areas. Eye
Now in the game if you click on one of the eggs, it breaks and a wyvern appears.

Example 4

Select the state machine: pnj1
Fill the properties window of the state machine with the following parameters. Eye

Enter the key: Rat1
Name of the character: Rat Sewers
Text displayed when we speak to him: sscchh... miammm... scchh... miammm.
Object to start transformation: Pizza
Transforms into this monster: RATMAN
Text displays when he transforms: Gloups
Name of the model: Rat

- Move the frame Rat1_0 inside the roomzone Custom1
- Pass into 3D view edition of Custom1 and place the rat in the center of the room. Eye
In the game if you give a piece of pizza to the rat, he transforms into a rat man.

The other state machines work almost the same, so lets take a look at some particular cases.

 

2: Create a state machine with messages

Select the state machine: LeverMessage1
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: MagicBox
3D object: Life up, close. (ex: CHEST_C)
3D object: Lower, open. (ex: CHEST_O)
Message number to be sent when we open it: (ex: 1)
Message number to be sent when we close it: (ex: 0)
Message number to deactivate the lever: (ex: 2)
Sound: CLIC3

- Move the frame of MagicBox_1 inside the roomzone Custom1.
- Pass into 3D view edition of Custom1 and place the trunk.
- Select the state machine: basicObject1
- Fill the properties window of the state machine with the following parameters. Eye

Enter new key: MagicMessage
Delay before this state machine is ready to regenerate: 10
Object to generate: Pizza
Message number that deactivates this state machine: 2
Message number that generates the object: 1
3D object:

- Move the frame MagicMessage_1 inside the roomzone Custom1.
- Pass into 3D view edition of Custom1 and place the state machine.
The messages are activated only when the state machines are linked.
This is how to proceed:
- Pass into 3D view edition of Custom1.
- Click on the Add Link icon , now, left click on the state machine that generates the message MagicBox_1 then click on the state machine that received the message MagicMessage_1. Eye

In the game each time you open the trunk you optain a peice of pizza.
Now we are going to add some state machines to complement this one.
Imagine that we want to deactivate the trunk MagicBox_0 with a lever.
Select the state machine: LeverMessage1
Fill the properties window of the state machine with the following parameters. Eye

Enter new key: Lever1
3D object: Life up, close. lever_c
3D object: Lower, open. lever_o
Message number to be sent when we open it: 2
Message number to be sent when we close it: 1
Message number to deactivate the lever: 3
Sound: CLIC3

Make a link from lever1_0 to MagicMessage_0.

We can add an explosion on the trunk to make it more dramatic.
Select the state machine: effect1.
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: fx
3D object: Not visible.
Message number that displays effect: 2
Message number that deactivates this state machine: 1
Effect to play: explode
Options: No collision
Delay before this state machine is ready to display a new effect: 500

Place fx_0 behind the coffer MagicBox_0 in the 3D view.
Make the link from lever1_0 to fx_0. Eye

Well, lets explain what we have done.
Each time the trunk MagicBox is open, it sends message 1 to MagicMessage that generates a peice of pizza, the message 0 (when trunk is closed) does nothing at all.
If we activate the lever, the message 2 is sent to MagicMessage (it deactivates the trunk, so don't have pizza anymore) and to fx_0 too (which makes the trunk explode).
Now if we activate the lever again, message 1 is send to fx_0 which is deactivated (so it won't explode any more).

NOTE: Each state machine can send and receive a maximum of 8 links.

 

3: Create a state machine with variables

This type of state machine works like an event counter.
In this example, the player must put 3 crystals on a specific flagstone. When the 3 crystals are on the good place. a trunk will open by itself and give a forth crystal.

Select the state machine: ContactObj
Fill the properties of this state machine with the following parameters. Eye

Enter new key: Contact1
3D object: switch released. PLATE3_0
3D object: switch pushed. PLATE3_0
Message number to be sent when pressed: 1
Message number to be sent when released 0
Object to detect: ITEM_CRISTAL1

Create 2 other similar state machines with each ITEM_CRISTAL2 and ITEM_CRISTAL3 for the parameter Object to detect:.
Move the 3 frames of these state machines to the roomzone Room1.
Select the state machines with the following parameters. Eye

Enter new key: TestContact1
Message number used to disconnect this state machine: 7
Value to add: 1
Virtual object to use for variable: virtual1
Message number used for the variable: 1
3D object: Not visible.

Create 2 other similar state machines.
Move the 3 frames of these state machines and the frame of virtual1 inside the roomzone Room1
Select the state machine: testVar
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: Testv
3D object: Not visible.
Message number that begins the test: 1
Virtual objects to use for variable: virtual1
Value to compare: the value we want to obtain (ex: 3)
Operator: Equal
Message number to be sent if the test is OK: 6
Message number to be sent if the test fails: 0
Message number used to disconnect this state machine: 7

Move this state machine inside the roomzone Room1
Select the state machine: containerMsg1
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: GenCrystal
3D objects: initial close. CHEST_C
3D objects: final open. CHEST_O
Received object: ITEM_CRISTAL4
Sound to play when object is given: BOSXHIT
Message number that gives object: 6

Move the trunk to the roomzone Room1.
Select the state machine: effect1.
Fill the properties window of this state machine with the following parameters. Eye

Enter new key: fxcase
Delay before this state machine is ready to display a new effect: 500
Options: No collision
Effect to play: (ex: detection)
Message number that deactivates this state machine: 2
Message number that displays effect: 0
3D object: Not visible.

Move the frame of fxcase_0 to the roomzone Room1
Organize the frames of the new state machines in hierarchy ivew. Eye
Pass into 3D view edition of Room1 and move the state machines then make the following links .
contactx to testcontactx
testcontactx to testv
testv to GenCrystal
testv to fxcase

You must obtain something like this: Eye
Explanation:
When you put the right crystal on the right contactx, it sends message 1 to testcontactx, so the value +1 will be added to testv.
testv tests the value of the variable until we obtain the 3, then it sends message 6 to the trunk GenCrystal_0 to open it and give the crystal ITEM_CRISTAL4.
If the total of testv is not 3, it sends message 0 to fxcase that plays the effect detection.

Most types of state machines have been studied. The others won't cause you any problems, they are a declination of the state machines we have just seen.
This tutorial comes to its end, lets see the final part: The generation of the quest.

Chapter 5: Generation of the quest
Story | Quests | Skills | Spells | Armoury | Enchantments
Character Info | Downloads | Shortcut Keys
DarkStone
Green Web Hosting! This site hosted by DreamHost. Valid XHTML 1.0 Strict