[DSB Tutorial 2] Wallitems, Triggers, and Multiple Levels

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

[DSB Tutorial 2] Wallitems, Triggers, and Multiple Levels

Post by Sophia »

Wallitems!
The gray walls of this dungeon are looking pretty featureless. Let's add some wallitems to dress them up. We can start with some simple decorations. Under "Wallitems" in the "DECO" class, select a "hook" item.
Image

Add a few of them. It will appear as a small purple triangle.
Image

Just like other objects, wallitems use subtile positioning. The place in the tile that the wallitem is added depends upon where exactly in the tile you click. For example, to add the wallitem to the north side of the tile, click in the upper portion of the tile. The tile position where the object you're adding will be added, as well as the current coordinates, is always shown in the upper right corner of the editor.
Image

Now let's add a button. Any wallitem can be used as a trigger in DSB, but it's usually a good idea (at least when you don't want to confuse players -too- much) to have your buttons and triggers look like buttons and triggers, and not just decorations. So, go into the "BUTTON" class and select a "button_blue" and add it to the dungeon.
Image

It will appear as a more prominent blue/green square. By default, buttons are displayed in this more prominent way to make them stand out, but all of this can be customized later on, of course.
Image

Right-click your newly created button and you will be shown this interface, where you can edit most aspects of the button. This is called the instance editor.
Image

In the upper left, you can change the button's position on the tile. Simply click in one of the quadrants, and the button will be relocated there. Items on the floor will be aligned differently, to show the four positions that items can rest on the floor, and monsters, which can also be centered, will have five possible positions instead of four. Below that are the object's flags. Not every object can use every flag, e.g., only a door can be "Bashed." Anything can be "Inactive," which means that it is no longer visible and cannot be interacted with. You'll learn about activating and deactivating objects very shortly, when you use this button to open a door.

To the right are the ExVars, which are variables stored via Lua that control aspects of the button (or whatever else) not managed by the core engine. You can edit these variables directly, but it is usually better to use the built-in editors that ESB provides. However, some objects have advanced features that do not (yet) have easy interfaces in ESB, and custom objects you or other dungeon authors create also many not have nice editors in ESB. In these cases, editing the exvars directly is the only option.

Click "Edit OpBys" to see one such editor.
Image

You don't need to do very much, as the defaults are fine for this simple button. The only thing to change is to only allow the button to be pushed once, by checking the "Disable Self" box. This means that the button can be pushed only once, and will not work after that.
Image

Click Ok to get out of the OpBy editor. Note that because you enabled the "disable_self" option, ESB stored your choice here.
Image

Next, choose to "Edit Targets" and you will be presented with the target picker.
Image

Choose "Deactivate" from the list on the right. In DSB, any time you Deactivate something, you make it disappear. That means it is the way to open doors, remove movable walls, close pits, and so on.

Click the door next to the button. ESB will highlight the tile you selected. Because there is more than one thing on the tile, ESB will then ask you which thing you mean, so choose the wooden door.
Image

You can see it has now been added to the list of targets with the proper message being sent. Click Ok to get out of here, and then close the instance editor window to get back to the main ESB screen.
Image

If you hover your mouse over the button, you will see a line drawn from the button to its target(s). The message being sent determines the color: Activate is red, Deactivate is green, Toggle is orange, Next Tick is olive, Clean Up is bright cyan, and so on. You'll learn more about all of these messages in a later tutorial.
Image

Eek, Monsters!
What's a dungeon without monsters? Let's add one. We'll add a mummy, which is under "Monsters" in class "HUMANOID", called, appropriately enough, "mummy". You could really place the mummy anywhere, but let's seal the mummy in behind the door to give the player an interesting surprise when he/she presses the button to open it.
Image

Right-click the mummy to edit it. You'll get the same familiar instance editor. Note that the controls in the upper left are now suited for a monster, however. You can change the monster's tile position to any of the four corners, or center the monster. If the monster isn't centered on the tile, do that now, by clicking in the middle, so it looks like the image shown here.
Image

In DSB, you can place objects inside of other objects. This is useful for chests and bags and so on. It's also the way that you create monsters that are carrying items they drop when they die. Let's give this mummy a key. In the lower left, in the "Contents" section, click "Add" to add something inside of this mummy.

This window will appear. Find the gold key, which is "key_gold" under the "KEY" class. Then click "Add" to add a the gold key to the mummy's inventory.
Image

Close the container builder. You'll see that the gold key is now inside of the mummy.
Image

While we're here, let's make sure that the mummy is looking at us when we open the door.
Image

Keyholes!
Close the window for the mummy. Now that we've added a gold key to our dungeon, let's provide a place to use that gold key. Find "keyhole_gold" in the list of objects, under "Wallitems" in the "KEYHOLE" class. Add a gold keyhole just northwest of the other door.
Image

Right-click it to edit it, and take a look at its OpBy editor. Note that ESB has tried to set up the keyhole with sensible default options. It will take a gold key (only), destroy that gold key, and only work once. This makes it work very much like a standard gold lock in DM or CSB.
Image

All you have to do is go into the target editor and tell the keyhole to send a "Deactivate" message to the door. It's the exact same thing that you've already done for the button that opened a door; the fact that this trigger is operated by a key and not just being pushed makes no difference when it comes to target selection.

If you did it right, this is what you should see when you hover over the keyhole:
Image

Floor triggers!
Now we have a locked door we can open. This is good, but there's no incentive to actually use the key, because players can just walk around the other side. Let's block that off next. Under "FloorFlats" in the class "WALL", choose a "movablewall" object.
Image

Add it here.
Image

Also in "FloorFlats", just above, go into the "TRIGGER" class and add a "pad" object. Put it a short distance away from the movable wall, like here.
Image

A "pad" is a floor trigger, which works slightly differently from a wall button, but it is similar enough that the interface should seem very familiar to you if you've gotten good at adding wall buttons. Right click it, and go into its "OpBy" editor. You'll have slightly different options, but also many of the same ones.

In this case, let's make the pad triggerable by the party, any thing, or any monster. Also check the box for "Constant Weight", which means that the trigger must have something continually on it, or it will reverse whatever triggering action you assign to it.
Image

Use the target editor to make the floor pad send a Deactivate message to the movable wall. If you need a reminder on how to do this, see the previous examples.

Delving Deeper!
This dungeon level is shaping up nicely (at least for a first test) but it's still only one level. The next step will be to increase the dungeon to multiple levels. In the Edit Menu, choose Global Info. Here, you can see and set the number of levels in the dungeon. Currently, there is only one level. Change the number of levels to 2, by editing the text box below, and press "Change Levels" to add a second level to the dungeon.
Image

Now let's provide a way to get there. Enter Dungeon Drawing mode, either from the menu, or by pressing D on the keyboard, and carve out a little bit of space. Then, in "FloorUprights", under the "STAIRS" class, add a "stairsdown" object. Make sure that you've placed the stairs on an empty floor, not on a wall, or you won't be able to see or use them!
Image

Go down a level, either by choosing Next Level in the View menu, or by pressing E on your keyboard. When you hover over squares, the level will now be indicated as 1, instead of 0, because we are one level deeper in the dungeon.
Image

Carve out a little bit of space, and place some "stairsup" directly below the "stairsdown" on the level above. As before, make sure you've placed the stairs on an empty floor tile, not a wall.
Image

Finally, let's add a more direct way to get down to the lower level. Add a "pit", which is a "FloorFlat" of class "PIT".
Image

There is another class, "PIT_CEIL", to show pits on the ceiling, but you don't need to manually add ceiling pits associated with your floor pits. DSB default to taking care of adding a ceiling pit associated with every floor pit.

Let's also provide a way to open and close the pit. Right click the pad trigger we added before, and go into its target editor. Choose "Deactivate", and, just like you made it deactivate the wall, make it deactivate the pit as well. If you've done it right, the pad should now have two targets.
Image

Enjoy playing with the wide varieties of object options in DSB! Next time, we'll do even more interesting things with objects, including using other messages, as well as creating custom objects with Lua script.
User avatar
Kesa
Journeyman
Posts: 67
Joined: Fri Sep 10, 2010 11:44 pm

Re: [DSB Tutorial 2] Wallitems, Triggers, and Multiple Level

Post by Kesa »

Very nice ^.^ these tuts will definitely help get DSB going ^.^
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: [DSB Tutorial 2] Wallitems, Triggers, and Multiple Level

Post by zoom »

all very nice and this is just the beginning!! ;)
How big is the initial dungeon? Can it be made smaller again?

what happens if I give my 100x10 mana champion a moonstone on the neck? how do bonusses apply?
does it take effect immediately,as said:
like result is 103x10 Mana in ESB if I donned the necklace?
or is the result still 100 in ESB and 97 in DSB if I remove the necklace? How can I calculate stat vs item boni
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: [DSB Tutorial 2] Wallitems, Triggers, and Multiple Level

Post by Sophia »

The initial dungeon is 32x32 but it can be resized however you want.

All stats in ESB are -base stats-, meaning without any bonus items. For the time being you'll have to figure out the result after bonus items yourself. (or just run DSB and see what it is... :P )
Post Reply