Saturday, May 29, 2010

The Broken Hourglass: A Small Sample of Code

I don't really have anything exciting to say today--mostly just popping in to say "Yup, coding continues." (I almost wrote ~"Coding continues"~ which should tell you something about how dialog is formatted).  I'm still working on learning; it's a pretty steep curve.  Hmmm... since I'm feeling uninspired and uninspiring today, how bout I give you an almost completely unexplained snippet of code? One that isn't in the game at all.

First, a basic creature looks something like this:

<xml>
<Template value="crecolor_19.CREATURETEMPLATE"/>
<Template value="basic-innocent.CREATURETEMPLATE"/>
<Name value= ~Nemo~/>
<race value="human"/>
<appearance value="mhhero1"/>
<Dialogue value="nemo"/>
<Party value="nemo_alone"/>

<Starting_Itemcount value="simple$(gold,900)"/>
<Starting_Item value="dagger"/>

<Area value="area_govinn"/>
<x value="1539"/>
<y value="2476"/>
<initial_direction value="west"/>
</xml>

Then he has a party, which generally says where he hangs out and who else gets mad if he's attacked, and which can, sometimes, be used to make groups of creatures do things together. His is called nemo_alone:

<xml>
<Area value="area_govinn"/>
</xml>

And then he has a script:

begin nemo

begin talk
    goto nemo_greet
end

begin nemo_greet
say ~"Hello. I am Nemo."~
++ ~"Hello, Nemo. I want you to give me some sanguil."~ goto nemo_give
++ ~"Nemo, it is time for you to leave."~ goto nemo_bye
end

begin nemo_give
say ~"I don't normally do things like this, but ok."~ do ( (_atomic_item_give ("nemo"::"CREATURE") ("gold"::"ITEM") ) 25 _player1) goto nemo_enough
end

begin nemo_enough
say ~"Was that enough?"~
++ ~"Yes. Now I want you to leave."~ goto nemo_bye
++ ~"No."~ goto nemo_toobad
end

begin nemo_bye
say ~"Such is the way of the world."~  goto nemo_depart
end

begin nemo_toobad
say ~"Too bad. I'm leaving anyway."~ goto nemo_depart
end

begin nemo_depart
do (_escape_area_remove_from_game _me)
exit
end

end

And here he is, real as life and twice as natural:


There are bits and pieces of tutorial over at the Planewalker Games Website, by the way, if you happen to feel like delving into this in more detail.

Incidentally, this also demonstrates the difficulty I, personally, have in keeping it simple or short, but that is another story.

3 comments:

  1. I'm impressed! And thoroughly confused :-) though it looks like coding could become quite addictive, once you get the hang of it. I can't wait to see the pixelated goats & books!

    ReplyDelete
  2. Hello !

    I am following TBH for a few years now, sadly the official website isn't updated much and only recently I've found out about your blog.

    Most of your early posts about TBH laked content and weren't so interesting.
    But this post explains a lot...

    About a 1-2 years ago I've tried to start a "learning cRPG", as I am not a programmer I couldn't be bothered with complicated scripts.

    From your example I already can see that it can turn to a mess with 2-3 more dialog options and a few responses to each option which can lead to more options and responses.
    From a writers point of view it's too much scripting and bad format (after you create a heavy dialog with "your" method it's hard to follow all options and add new ones/correct old ones.

    For my heavy dialog game (that is currently on hold), I've used Dlgedit which is a part of the Adonthell Game Engine (which also includes character editor, quest editor, map editor and items editor which I haven't used for my game).
    The engine is released under GPL making it free source, so you can use it for free.
    The downs of the engine (from writers point of view) are :
    1. No integrated spell-checker (I badly need one).
    2. You have to compile/install the whole engine and not just the dialog creating tool you need.

    But the pros are awesome :
    1. Free source, and you can speak to the developers and ask for more features.
    2. Very visual , you can see the whole dialog tree even if it's 10 levels of dialogs (options and responses).
    3. Very easy to use - no programing needed.
    4. You can add scripts to each dialog option/response.

    I've installed it on GNU/Linux so it works great, but I don't know how easy/hard it is to install it on Windows.

    Links :

    LGN Article about Adonthell :
    http://lgn.linux-hardcore.com/adonthell-0-4-not-just-a-game/

    Dlgedit :
    http://adonthell.berlios.de/doc/index.php/Tools:Dlgedit:Contents

    Adonthell project page :
    http://adonthell.linuxgames.com/

    Thanks
    MaximB
    Linux Gaming New Editor.

    ReplyDelete
  3. Yup. The posts tend to be lighter on content and deliberately so; I'd rather mention "a quest" than give away spoilers!

    The blog posts here are more my musings on writing and learning to code than on the game itself--Character Bios & plot information belong on the Site Proper which, I hope, will be getting more updates soonish, now that Jason's shaken out the bugs.

    The Broken Hourglass has its own engine, designed by Wes Weimer, and it's already very much in use, but thanks for the rec.

    ReplyDelete