Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FunkyTune

How to do scripting for an RPG?

This topic is 5763 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Me and a couple of friends are aiming to create a SMALL Zelda-style RPG. (C++, DirectX 7) The scripting we'll need will mostly concern dialogs with other people. For example, if you talked to the old lady in the house outside town, and then give the shopkeeper a certain stone, then he will say something... you get the point. I've STFW'd, but I couldn't really find what I was looking for. Most articles are about making your own scripting language, but I was thinking about using Lua. Is Lua good for this kind of task? Does anyone know any good tutorial, or have any good tips on how to manage things? EDIT: Spelling... /John [edited by - FunkyTune on September 14, 2002 7:18:24 AM]

Share this post


Link to post
Share on other sites
Advertisement
For a simple RPG, I''d do something like this:

Two boolean arrays, QuestItems and QuestFlags.

Each time a conversation occurs, you open up the file for that conversation (I''d preload these...but you get the picture.)

File would be in a format like this:

I+1,F+1
{
say:It''s nice that you got another item, but I already have one.
}
F+1
{
say:You already gave me the item.
}
I+1
{
set:I-1
set:F+1
say:Than you for the item.
}
I-1
{
say:I need this item.
}
*
{
say:I don''t know how I got here.
}

You read in a line, and check the conditions for that line. F+# means that QuestFlags(#) is Set, F-# means that QuestFlags(#) is not set, etc. Conditions would be comma delimited, and in reverse order of execution (initial conditions at end). * is a catch-all.

If all conditions on a row are set, execute the statements inside the { } block. set: would change the flags/items. say: would trigger dialog.

This is easily expandable, and not too difficult to write. If you wanted to add in comments support, prior to parsing the line, search the string for a unique character or character combo that you won''t be using (// or # for example), and blank the string after that.

Other options: instead of hard-coding the strings in this file, replace the strings with string identifiers, and put the strings in a different file. That would make localization easier. You could also encrypt that other file to reduce "cheating."

RomSteady - Test Locally, Test Globally, Test Early, Test Often

Share this post


Link to post
Share on other sites
For dialogs, you could also keep switches as bitflags, and write a little script that does specific tasks when certain combinations of switches are on. You could make a small editor, so you could give them names, or just try like hell to remember them all. An easy way that first comes to mind is creating simple variables that contain the combination of switches you want before making something happen. Like..

BYTE OldManWillYell = (1<<5) | (1<<6);
if(Robbed the old mans shoes) Switches |= 1<<5;
if(Kidnapped his daughter) Switches |= 1<<6;

if(OldManWillYell == Switches)
Yell damnit, yell.

Of course this is all hard coded, which I''m not implying to do. However I believe it''s much easier to make your own script design. There''s no need to learn something that''s going to apply to way more than you need.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!