AR Studios
May 17, 2007, 11:17:31 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new AR Studios Forum!
Pages: [1] 2 3 ... 10

 on: April 15, 2007, 10:38:22 pm 
Started by admin - Last post by admin
Which monster makes your blood curdle everytime you run into them? What monsters do you think are the easiest to defeat? Which do you think are the hardest?

What monsters that are not in the game that you would like to see added?

 on: April 15, 2007, 10:37:15 pm 
Started by admin - Last post by admin
To get some discussion going here, what sort of spells and abilities would you like to see in the game. Though with the campaign editor you can create virtually any spell or ability you can think of. This is mainly for the initial campaigns. Post what you would like to see.

 on: February 22, 2007, 05:17:54 pm 
Started by admin - Last post by Izekeal
This seems straightforward enough, I have a bit of a background with programming so I should be right at home in the editor.

 on: February 22, 2007, 02:54:13 pm 
Started by admin - Last post by admin
Scripting Tutorial

Scripting in Dungeons of Darkness is completely event based. What this means is that certain events need to take place in order for a script to be called. For example, if you define a search event on a certain tile, the script you create for this event will be called when a player searches that tile. Or if you define an enemy death event, the script you create for that event will be called when the enemy is defeated in combat (his or her HP is reduced to 0). These are just a couple examples of possible script events in Dungeons of Darkness, there are many more available to you as a scripter.

Dungeons of Darkness uses VBScript as it's scripting language. There is a nice VBScript tutorial at W3Schools, just ignore the references to using VBScript in HTML documents, this is not the case for Dungeons of Darkness. If you are new to VBScript or programming in general, this would be a nice introductory read before jumping into this tutorial. Examples in this tutorial might make a little more sense.

Basic scripts can be created by anyone, even those who are not familiar with programming, by clicking on the functions in the editor you wish to add. More advanced scripts will require a basic understanding of VBScript and programming. After reading this tutorial you should be able to create some of your own more advanced scripts.

First of all, some things you should know about the script editor. There is a check syntax function in main menu that will allow you to check the syntax of the entire script you are working on or the function you are working on. This is ALWAYS a good idea to do before you save your script and assume your changes will work. If you don't do this and assume your scripts work when actually there are some errors in your script, your campaign will do some very weird things. If the check syntax function finds any errors it will try and report them to you as well as where they occur.

Secondly, there are two boxes on the right hand side, the top one contains variables that can be used within the script, and the bottom one contains custom functions that can be called from scripts to get the results you want. Double clicking a selection in either box will auto-insert the variable or function into your code. For variables, it will just insert the name in the box into your code. This was added for ease of use, you could just as well type the name of the variable into the code editor and it will work the same. Functions work a little differently. When a function is double clicked in the lower box to the right, the function will be added to the code editor with parantheses behind the name. Also, either the word "Call" or "var =" will be inserted before the function call. Let me explain what these parantheses and preceding texts mean to you.


A function is piece of code that you call to perform certain tasks. Every event that you code in Dungeons of Darkness is its own function. The name of the function you are editing appears in the upper right drop down box. If you click this box you may see multiple functions in the list, depending on how events you have defined on your map.

Functions can be called from your scripts in one of two ways. Suppose we have a function named Add, the purpose of this function is to add two numbers together. The function looks like this:

function Add()
  theNumber = 1 + 2
end function

This function really doesn't do much for us, it will always assign 3 (1 + 2) to the variable theNumber. But for the sake of this tutorial lets use it in a script. If we wanted to call this function from our script we could write either:



Call Add()

When our script hits one of the above lines, it will move into the Add function defined above and assign 1 + 2 to our theNumber variable. This is where the "Call" part comes in. When you double click a function to add it, the code editor will add either a "Call" or "var = " before your function. If a "Call" is added before, this means that nothing is returned from the function. In essence, your telling the function to "do something, but don't give me back any data". You can just as well get rid of the Call before the function name and everything will still work peachy, the code editor just adds it to tell you that nothing is returned from the function.

"What do you mean nothing is returned from the function? I can return data from a function?" you ask? Yes you can. Using the same function example from above, let's modify it a bit so that it returns something instead:

function Add()
  Add = 1 + 2
end function

Basically all we did was replace the variable theNumber with the function name Add. What we are telling our to do now is add 1 + 2, but return it to whoever called this function. Easy, just remember if you assign something to the function name, whatever you assign will be returned to whoever called that function. So now, if you double clicked on this Add function in the script editor, it would print:

var = Add()

in our code window. Why is that? Because the script editor knows that the Add() function returns something now so it is telling you to assign that value to a variable. You will want to replace the "var" with your own variable name though with something named intelligently so you know what the data in the variable represents. This example will change a little once we get into control structures further along in the tutorial.

The next question is, what is with the parantheses at the end of the function. These are required in case you want to specify function parameters. A function parameter is a value passed to a function that can be used within the funciton itself. Lets consider the Add() function again, and this time make it more useful:

function Add(num1, num2)
  Add = num1 + num2
end function

The num1 and num2 variables define parameters needed for this function to work properly. Right now, they mean absolutely nothing because they are not assigned a value at all. But if we call add like this:

myNumber = Add(1, 2)

we will assign 3 to the myNumber variable. See we passed the numbers 1 and 2 as paramters to the Add function. These values were assigned to the num1 and num2 parameters, and then added together, then returned by the Add function. If we tried calling Add like:

myNumber = Add()


myNumber = Add(1)

we would get an error because the Add function expects 2 and only 2 parameters to be passed to this function. It does what it is supposed to do, Adds two numbers together and returns the result. You should now have an understanding of what everything means when you double click either the variables or functions provided to you in the editor. If you are still confused, read through it again and study the link at the top of this tutorial also. If you are still confused, ask questions in the forum, the community there is friendly and would be more than glad to help you out.

You can also create your own functions in the script editor by going to the menu File->Add Function. A box will come up asking you to name your function and parameters. Functions created in this manner will not be available in the functions box to the lower right, but you can call them in your scripts by using the correct syntax that was described above.

Now moving on.

Example One - Opening Doors

Probably the most common script event you will create while making your maps is opening doors. In this example we will go over how to do so. Create a new campaign and name it whatever you like, let's leave the the size of the map to the default. Enter in any other information you like for the Campaign and Quest descriptions.

Once you have created a new campaign and are at the map editor screen, create a small square room right in the middle of the map. Put a door somewhere on the right side of the room. Now, right click the door tile on the map and then select "Tile Enter Event", this will bring up the script editor for us. If you notice in the upper right corner, the function we want to edit is already selected. Excellent, all we need to do now is code the event. Okay all we want to do for now is open the door when a player steps on to this tile. To do this, double click the function in the lower right box named "OpenDoor". This will add the following code to editor:

Call OpenDoor()

You will notice in the Function Box that this function expects two parameters, and XTile and a YTile. These parameters determine on which tile you'd like to open a door. Well we obviously want to open the door on the tile we are editing, why do we need to send parameters telling which door to open? Well, suppose for instance in your map you want to code an event so that when a player steps on a switch it opens a door on the other side of the map, you would need to specify which door it should open. It isn't obvious to the game script which door we want to open even though we are editing a certain door tiles event, but it is obvious to us. So look in the upper right corner in the box that tells which function we are currently in. You should see two numbers in that function that tell us which tile we are currently editing a script form. Use those numbers as parameters for this OpenDoor function call. For example if the two numbers in my editor were 12 for X and 14 for Y my new function call would look like:

Call OpenDoor(12, 14)

Now give your players starting positions on the map by right clicking and selecting the start positions for a tile. Save the map and then start a new game and select this new campaign you have created. When you move on to your door you'll notice that it disappears! Perfect, this is just what we want, unfortunatley our door doesn't lead anywhere though. Well that's easy enough to change just be adding a hallway in the map editor.

Load the campaign you just created in the editor again. Now lets go over script flags and the If conditional statement. We'll create a door that is locked until the player steps on a certain tile. Once you have your campaign loaded in the editor, right click on the door tile and click on the "Tile Enter Event" again to open the script editor for that event. Now what we want to do is only open the door if a player has satisfied a certain condition, in this case, the condition is stepping on a certain tile that triggers the door to unlock. To do this, we will use flags and an if statement.

First, let me explain what the flags are for. Each campaign you create is designated 9999 flags you can use. Think of these flags as variables that can be set to any value between 0 and 255. The important thing to remember about these flags is that they are saved when a player saves his or her game, and they are maintained throughout the campaign. Variables within scripts are not saved with a save game and only exist within the script/function they are defined in. Remember, always use flags to define events that have happened. You will see what I mean.

Now that we know what flags are, we can write our new script. Enter the following code into the script and replace what was already there:

If GetFlag(1) = 0 Then
  Call Message("This door is locked. There must be a switch around here somewhere.")
  Call OpenDoor(12, 14)
End If

We have now used the invaluable if statement. The GetFlag function returns the value of the flag that we want. In this case we are asking for the value of flag 1. All flags default values are 0, so if you have explicitly set a flags value, it will always be 0. In this case, if flag 1's value is 0, then we display a message stating that the door is locked and the player needs to find the switch. If the flag is anything but 0, the player has found the switch and we open the door. As you might have guessed, we need to create another event that sets that flag to a non-zero number when the player finds the switch. Easy enough to do. Let's place a pile of bones in the upper left corner of the room. Right click on the bone pile and select the "On Tile Enter" event to open the script editor. Now in the script editor type:

If GetFlag(1) = 0 Then
  Call Message("As you step onto the pile of bones, the floor beneath you moves and you here a clicking sound come from near the door.")
  Call SetFlag(1, 1)
End If

What this will do is tell our scripts to set flag 1, the flag that holds whether or not the door is locked, to change its value to 1 if it isn't already. This essentially unlocks the door so that when a player moves onto the door after stepping on this file, the door will open! It will also display the message typed out between double quotes. Give it a try creating a new game using your campaign you have created.

In this example you have learned how to open doors and how to create locked doors that open given a certain event. You are not limited to unlocking doors only when a player steps on a tile, you can unlock a door whenever any scriptable event occurs. Play around with this some more and see if you can get the door to unlock by having a certain item in inventory (a key maybe?) or by killing a certain monster.

 on: December 19, 2006, 10:51:26 am 
Started by candyman - Last post by admin
Yes, it is. I will be releasing a new build in the next few days that includes the first 2 quests in a full length campaign. I will be sending out an email to everyone to let them know when the build will be available. Sorry for the delay, the content takes a little more time to develop and on top of that I was implementing the save/load system as well as the shop screen which appears after each quest.

 on: December 18, 2006, 09:54:41 am 
Started by candyman - Last post by candyman
Been awhile since the last update...just trying to see if the game is still being made.

Pages: [1] 2 3 ... 10