Overview
How to build a M.U.D in ADLENGINE.What this guide will reveal:How to create rooms / exits.How to setup and manage player statistics, health, gold etcHow to setup basic Combat using dice rolls factoring player / creature statsHow to setup and manage creature statistics, health, gold etcHow to setup basic quests and dialogues
Download Example Files
You can find the files (as I work on them) at the link below.
[link]The rpg.adlengine file is ready to play.
The room images are all set to pattern (pattern.jpg). If you would like to customise the room images do the following.
1. Find the adlengine folder in steamapps (under program files steam steamapps )
2. rename package.nw to package.zip (ignore the warning – you will need to be able to edit file extensions which is in folder options)
3. open the zip
4. add the .jpg image plus any other images / sounds you want to use, to the zip (supports subfolders)
5. close the zip file
6. rename the zip file back to package.nw
7. relaunch adlengine
To use different images for the rooms (not supplied)
In each room:
If the image is in a subfolder:
Ignore the .jpg extension, you dont need to add this.
——————-
3 Rooms:
- Tavern
- Rented Room
- Village Square
3 Objects:
- Bar
- Bed
- Fountain
- – gold coins (inside fountain)
1 Character:
- Barkeep
The Tavern
objects: Bar.
exits: north and south
To build exits:
Now lock the north door: (the room for rent)
In the tavern you will be able to a) talk to barkeep b) buy beer c) rent room
To rent a room:
This is a custom command that calls script_rentroom. This script checks if the player can afford to rent the room, IF they have enough gold it calls script_unlockdoor ELSE it tells them they cant afford to rent the room.
To setup a custom command you simply type if custom command then do something
custom commands can also have an optional and
e.g. if rent room then do script_rentroom
IF they are able to rent the room script_unlockroom unlocks and opens the door to the north and deducts 2 gold from the players gold.
I added the optional ability to also buy a beer:
If the player can afford it they will buy and drink a beer automatically which calls the script_drinkbeer script.
NB: All the script files (.verbose) and .adlengine files can be opened / edited in notepad or similar text editors. Do this to see how each script works.
The Rented Room
objects: Bed.
The door will remain locked until the player rents the room. Once they have paid they can then travel north into the room.
Then, in the room they have the option to:
Again the sleep command is a custom command.
This calls script_rest which adds a day to the date, heals the player to 100 health and then forces the player to move south, locking the door behind them.
The Village Square
objects: Fountain.
Inside the fountain I have placed coins. To make this possible
To reveal the coins which will then allow the player to take them:
This makes them known to the player so they can take them simply by using the command:
However to be able to take them we need to set make them take-able. There are two ways to do this.
1) When you build objects if you want the player to be able to take them add .obj on the end which will build an empty {takeable} object.
.obj is a class of object, of which there are currently a few available. Adding this automatically grants special pre-defined properties. I am working on adding custom classes..
Current Classes:
- .obj
- .chest
- .food
- .drink
- .ai
- .exit
2) use the following scripting command
– Affecting The Village Square Lighting
Let’s have the hour of day affect the lighting level in the village square.
real-time-light.verbose
This script will be saved locally in the Village Square. The code gets the current hour and if its past 5pm its the night time ELSE its the daytime.
nighttime.verbose
This script again needs to be stored globally. It looks to see if the time is past 6am in the morning IF so its the daytime so it makes the room light ELSE its the nighttime so it makes the room dark.
The Player
Lets grant our player some health.
And some gold to spend.
Building Another Room
To add more rooms:
i.e.
This will build a room (if one doesn’t already exist) to the north and will create exits to the north into the room and south out of the room.
Inside the room you can set:
The room name:
i.e.
The room description:
i.e.
The room image:
i.e.
The room visibility:
i.e.
values you can set for room visibility:
- pitch black
- barely lit
- dark
- light
- well lit
- bright
Adding Survival Stats
First lets set up some survival based stats.
Next we shall create three script files that provide the player with feedback when their stats change significantly. Dont forget to store them using the editor (.editor) – storing them globally will mean it will work anywhere. Locally would render them only in that particular room. Great for things like water, where it depletes our players air, for example.
hunger.verbose:
thirst.verbose:
energy.verbose:
Notice how in the energy script we’ve not minused from the player energy? this is because we’re going to deplete the energy based on actions / commands you perform such as taking something thats heavy, or moving around alot.
We can now set up 2 timed events to handle, hunger and thirst.
Adding a Real-Time Clock
To setup a real-time clock we’re going to attach it to our player so it always follows us.
The quicker way to setup the clock would be to create script file called setupclock.verbose and add the above commands terminated with ; to allow for quicker import into your game/s.
Now we need to create the first of 3 scripts which need to be stored globally to allow the time to run everywhere:
runtime.verbose
This script will be run every second. It gets the current seconds, adds 1 to it, stores it again and then checks if 60 seconds has passed (a minute) if so then run the minute-passed script.
To run this script every second:
minute-passed
This script gets the current minutes, adds 1 to it, stores it again and then checks if 60 minutes has passed (a minute) if so then run the hour-passed script. PLUS it resets seconds to 0.
hour-passed
This script gets the current hours, adds 1 to it, stores it again and then checks if 24 hours has passed (a day) if so then run the day-passed script. PLUS it resets minutes to 0.
To retrieve the current time we shall build another script:
whattimeisit.verbose
This script when called prints the time in the special debug message in the bottom middle of the screen. It takes the current hours, minutes and seconds.
Clears the message text.
Writes The time is:
Writes a space (info space)
Writes the hours followed by :
Writes the minutes followed by :
and finally writes the seconds. (you could omit the final two lines if you didnt want to show the seconds. i.e. ala a digital clock)
Now we’ll process the days…
day-passed.verbose
This script takes the current days, adds 1, stores it back in, and if the number of days reaches 365 it adds 1 to the year. It also resets the hours to 0. If you wanted to add a custom year length, you could add player.yearlength and instead of ?days=365 you would first store the yearlength in a variable and then ?days=yrlength for example.
And finally now onto the years.
year-passed.verbose
This final script takes the current year, adds 1, stores the new year and resets the days to 0.