|[ LiB ]|
Compiling this version of SimpleMUD is done the same way as the SimpleMUD from Chapter 8, and you can find compilation instructions in Appendix A, "Setting Up Your Compilers," on the CD.
Once you've got SimpleMUD up and running, you can Telnet into it on port 5100 and play around. I've included some sample datafiles, so you can play it the way it is.
Figure 9.2 shows a screenshot of the movement and store listing in action.
There's not much going on here; the player logs in, walks south, and takes a look at the listing in a weapon shop. Yes, the character has over 8,000 hitpoints, but hey, I'm doing that for testing purposes! Yeah!
Figure 9.3 shows the item and room interaction features.
Pay attention to the first four lines in this figure. When a player types buy kn , he buys a rusty knife . The same thing happens if a player types buy knif or buy k or buy kni . However, the command buy knife buys the player a plain Knife instead of a Rusty Knife . Why does this happen?
You might have noticed that the text of Bob speaking appears brighter than the rest of the room's description. That's because it uses a different color . I managed to get this effect by manually placing the VT100 color code for white into the room's description in the /maps/ default.map file. While this method is adequate for SimpleMUD, I wouldn't really recommend doing this for more advanced games . I explore a much better way of accomplishing this in Chapter 16 , "The Networking System."
Remember: All searching algorithms perform a dual-pass search, attempting to match the full name of an item first, and then performing a partial match. Therefore, when you type get knife , the algorithm detects the plain "Knife" because it fully matches. Any other partial match of "knife" is instead detected as a "Rusty Knife", since "Rusty Knife" is the first in the list. It's just a minor issue you should watch out for, and if you design your stores correctly, people may never notice it.
Figure 9.3 also shows the player dropping, getting, and selling knives and using money.
When using a dual-pass search, it's usually a good idea to put objects with the simplest names first in the list. For example, it may be more user friendly to list "Knife" before "Rusty Knife", even if it costs more. It's up to you, though.
|[ LiB ]|