Jump to content

Role-Playing Adventure Books


cags

Recommended Posts

There are a few different types of books available but the type I'm referring to are the ones where you will read a piece of text and at the end of that description you will receive a list of options 'walk left (turn to 100)', 'walk right (turn to 342)', 'take a nap (turn to 563)'. As an educational process I was thinking about how such a book could be implemented through a programming language. I suppose the obvious choice is to store each location in a database with at least id and description. You could then have a separate table for links which would include parent_id, link_text, link_id. From there it is fairly simple to have a system up and running that would allow you to be able to navigate around the world. The mental road block I hit was how exactly to expand upon this. For example, upon arriving at certain locations you may find an item or gain a password. Alternatively you may get automatically sent elsewhere if you have a specific item or password.

 

I'm assuming it will require creation of some kind of scripting language. For example each location item in the database could have an action field, which would contain something like add_item:12, I could then parse this out and simply add item 12 to the characters inventory or check_item:12,goto:14 and then parse that out as if user has item 12 then goto location 14. In theory I suppose the action field could contain multiple actions that get parsed out in order. Another thing that may occur during the course of a game is a fight encounter. When you reach a square you fight an opponent if you win you move to location x if you loose you either move to location y or game over. I suppose this could be written into a similar sort of scripting language structure.

 

One thing that is used in the books I have read (Fabled Lands) is perform a certain action if a location has been visited more than x amount of times, I have no idea how I could track this. From a purely programmatic standpoint I could perhaps envision a location class that could be inherited from to create sub-classes that could have extra functions for performing such actions, the problem I have is, I have no idea how to wrap that around a storage medium such as a database.

 

Overall I'm not really sure if I'm thinking along the right sort of lines or completely off at a tangent. I'm just wondering if anyone else has any thoughts or opinions on the best approach.

Link to comment
Share on other sites

To track how many times a player has visited a location, you could use a table like this:

player_id | location_id | count

Everytime a player visits a certain location, you update count.

 

I agree on the scripting part, however, I would also add "scripting support" for each individual link. Perhaps you have actions that you want to occur every time you access a certain location, but then again, you may want to have actions that only get executed when you click on a certain link.

You might also want to consider to have an ability to group your commands if you need the same sequence of commands perfomed often.

Link to comment
Share on other sites

You might want to look into interactive fiction - that may be a little different than what you are thinking of, but I think it's very similar.  There are scripting languages and standards that allow you to write these interactive books, and then there are interpreters that will play them.  You can do all the things you are talking about, from picking up items to using passwords to talking to other characters and exploring.

 

http://www.andybrain.com/archive/interactive_fiction.htm

 

http://www.web-adventures.org/

 

http://en.wikipedia.org/wiki/Interactive_fiction

 

I don't know of any PHP tools, but there are some web-based ones, like the web-adventures.org

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.