TTP Map Tutorial: Lowering Fence & Arranger

From Serious Sam Wiki
Jump to: navigation, search

In this part of the tutorial we will

  • add a fence that is lowering when the sigil is picked,
  • add an exit door with an arranger,
  • add a script to open the door when the arranger is solved.

Lowering Fence

Screenshot of lowering fence.
Adding the Fence

The lowering fence is supposed to be on the left side of the time switch where there is currently a normal fence. So let's do the following:

1. Select the center two fence models at positions (-4, 0, 7) and (-4, 0, 9) and delete them.
2. Add a 'Door' from the EntityList panel to the world and position it at (-4, 0, 8).
3. Switch to the Entity panel.
4. In the line 'Model' use resource control to browse for
Content/Talos/Models/TilePresets/Generic/LoweringFence.mdl.
5. Rotate the model into the right orientation.
6. Set 'Opening animation' to 'Lowering' because the animation of LoweringFence.mdl is called that and not 'Open'.
7. Uncheck the check box in the line 'Show message' to get rid of a repetitve console warning because LoweringFence.mdl does not support messages.

In our next step we should connect the fence properly to the lowering fence. Just use two more column models as connectors. You can copy them from existing columns and position them with the drag/align tool and potentially the guide for fine tuning. Position data at the end of the page.

Make the Fence lower when the Tetromino is picked

Now we only need to tell the engine when to open the fence. That is done with the help of a script:

1. Add a 'Script' from the EntityList panel to the world.
2. Position it close to the lowering fence to find it easily.
3. Switch to the Entity panel.
4. Set 'Script' with resource control to
Content/Talos/Levels/Scripts/LoweringFenceWhenTetrominoIsPickedUp.lua.
5. Double-click LMB.png on the script editor model to open the script editor.
6. Click LMB.png on the Tetromino in the viewport to select it.
7. Hold Ctrl+Alt+⇧ Shift and click/hold LMB.png in the viewport.
8. Move the mouse over one of the terms 'tetromino' in the script editor and let go of LMB.png. Both 'tetromino' terms should now appear with a green background.
9. Click LMB.png on the lowering fence in the viewport to select it.
10. Hold Ctrl+Alt+⇧ Shift and click/hold LMB.png in the viewport.
11. Move the mouse over one of the terms 'LoweringFence' in the script editor and let go of LMB.png. Both 'LoweringFence' terms should now appear with a green background.

Scripts are written in lua. By default, all scripts are executed at world spawn, i.e. at the beginning of the session. The code we just used from the standard campaign can be applied to our level because it works with so called handles. By dragging the Tetromino and the lowering fence on the corresponding terms in the editor the terms became handles for these entities. With that, the code is basically self-explanatory and this tutorial is not the place to describe scripting in more detail. But we will do the same thing again in a moment.

Exit Door

Screenshot of iron door and walls.

You can add an exit door whereever you want. I have added some walls around the Main chapter info that I moved a bit towards the puzzle entrance. The door is positioned in one of those walls. If you want you can try to recreate it with what you've learned so far. It is a bit finnicky to align the columns and the wall parts with the door because the width of the door is not an integer. But you'll figure it out ... if not, the position data is at the end of this page.

Do the following to add the door:

1. Add a 'Door' from the EntityList to the world.
2. In the screenshot the Door is positioned at (0.42, 0, 28).
3. Set the following in the Entity panel:
  • Model:
Content/Talos/Models/Iron_doors/ArrangerIronDoor_small.mdl
  • Show message:
Uncheck the checkbox.

Arranger

Now it's time to add a Puzzle arranger to the door:

Warning 16x16.png Warning: If you enter simulation with a Puzzle arranger that has no 'Puzzle data', the editor will crash!

Screenshot of Puzzle arranger.
Screenshot of Puzzle arranger.
1. Add a 'Puzzle arranger' from the EntityList to the world.
2. In the Entity panel set 'Puzzle arranging params' with resource control to
Content/Talos/Presets/PuzzleArranger/Stand01.rsc.
3. Rotate and Position the arranger so that it fits into the mounting of the Door. I used (0.15, 1.25, 27.96) with H = 180.
4. Set the Door as a 'Parent' of the arranger by
  • clicking LMB.png in the 'Parent' line,
  • holding Ctrl+Alt and clicking LMB.png on the Door.
5. Set 'ParentPart' to 'RightDoor'. This tells the arranager what part of the Door it is attached to because the door has three parent parts.
6. In the top line 'Puzzle data' create a new Puzzle data resource with resource control.
7. Set the Puzzle data parameters as follows:
  • Unlock type
'Door' because we have a door Tetromino.
  • Needed tetrominos
'O' because we have an O Tetromino. In case of more than one tetromino list all letters without space.
  • HUD icon
Content/Talos/Textures/HUD/DoorTutorial_Atlased.tex
  • Arranger outline material
Create a new Material component with resource control and set 'Material' to
Content/Talos/Presets/PuzzleArranger/OutlineDoor.mtr.
  • Shell area stretch
'0.033'. Fits the part of the arranger that holds available tetrominos into the right side of the arranger.
  • Arrange area stretch
'0.05'. Adjusts the tetromino sizes to the arranger area.
  • Arrange area
  • left: 4
  • right: 6
  • up: 4
  • down: 6
This adjusts the size of the arrange area to the size we need: 2 x 2 squares for our O Tetromino.
  • Shell area
  • left: 0
  • right: 10
  • up: 0
  • down: 15
This adjusts the size of the right arranger area so that it covers the whole front.
8. Save the puzzle data resource in the folder
Content/Talos/Databases/Arrangers.
Puzzle data resources must be saved in this folder or they will not work. Note that the Puzzle arranger name is automatically exchanged with the name of the Puzzle data resource.

This concludes the creation of the Puzzle arranger. If you are building a map with more than one world you also have to add the Puzzle data resource to the global list of tetromino instances:

1. Select World info.
2. Expand 'World params', 'Episode params', 'Tetromino instances'.
3. In the line 'Arrangers [0]' click LMB.png on the yellow plus sign to add a new arranger instance and expand it.
4. In the line '[0]' browse with resource control to the folder
Content/Talos/Databases/Arrangers
and select the Puzzle data resource file of the arranger.

Like this the arranger can be operated with Tetrominos from every world.

Script

Like above with the lowering fence we need to tell the Door when to open with a script:

1. Add a 'Script' from the EntityList panel to the world.
2. Position it close to the Door to find it easily.
3. Switch to the Entity panel.
4. Set 'Script' with resource control to
Content/Talos/Scripts/ArrangerOpensDoor.lua.
5. Double-click LMB.png on the Script editor model to open the script editor.
6. Click LMB.png on the Puzzle arranger in the viewport to select it.
7. Hold Ctrl+Alt+⇧ Shift and click/hold LMB.png in the viewport.
8. Move the mouse over one of the terms 'Stand' in the script editor and let go of LMB.png. Both 'Stand' terms should now appear with a green background.
9. Click LMB.png on the Door in the viewport to select it.
10. Hold Ctrl+Alt+⇧ Shift and click/hold LMB.png in the viewport.
11. Move the mouse over one of the terms 'Door' in the script editor and let go of LMB.png. Both 'Door' terms should now appear with a green background.

The code of this Script is a bit different from the Script for the lowering fence but it does exactly the same.

Position, Orientation and Resource File Data

Here are position, orientation and resource file data of all entities added in this article:

Added Entities
Entity X Y Z B P H Resource file
Door -4 0 8 0 0 0 LoweringFence.mdl
Simple model -4 0 5.625 0 0 0 Wall_05x4_25.mdl
Simple model -4 0 10.375 0 0 0 Wall_05x4_25.mdl
Script -4 2 8 0 0 0 LoweringFenceWhenTetrominoIsPickedUp.lua
Simple model 4 0 24 90 0 0 Wall_8x4.mdl
Simple model -4 0 24 90 0 0 Wall_8x4.mdl
Simple model 4 0 28 0 0 0 Wall_05x4_25.mdl
Simple model 1.59 0 28 0 0 0 Wall_05x4_25.mdl
Simple model -1.59 0 28 0 0 0 Wall_05x4_25.mdl
Simple model -4 0 28 0 0 0 Wall_05x4_25.mdl
Simple model 2.8 0 28 0 0 0 Wall_2x4.mdl
Simple model -2.8 0 28 0 0 0 Wall_2x4.mdl
Door 0.42 0 28 180 0 0 ArrangerIronDoor_small.mdl
Puzzle arranger 0.15 1.25 27.96 180 0 0 Stand01.rsc
Script 0 3.5 28 0 0 0 ArrangerOpensDoor.lua


Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Green.png Nav Blue.png