Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Quests/Persistent data?  (Read 3259 times)
0 Members and 1 Guest are viewing this topic.
Offline evilfrenchguy

Junior Duke


Medals: 3



« Posted 2012-02-19 00:04:31 »

What do you guys do for quest systems? I was just thinking about what a good expandable way (i.e. adding new quests) would be. You'd have to account for the quest giver/returner, what type (fetch, kill, talk to), the target objective, and that's not event accounting for multi-step quests...

Hmm...the only thing I could think of is an XML file and build your class hierarchy off of that. Do you have any suggestions? Maybe scripting? I've never done scripting before though, so I could use a nudge in the right direction.
Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-02-19 04:26:00 »

XML is used to load/save the actual data, scripting is used to manipulate that data. Use them depending on what you need.

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #2 - Posted 2012-02-19 14:06:00 »

Just doing a little research on XML. So 1 simple quest in an XML file could like like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
<quest id="5">
           <name>
                   Hippo Hijynx II
           </name>
           <desc>
                   // Quest description
           </desc>
           <quest_flow>
                   <npc_start_id>54<npc_start_id />
                   <requirements>
                             <min_level>5</min_level>
                             <quest_completed_id>4</quest_completed_id>
                   </requirements>
                   <step id="1">
                              <fetch>
                                        <item_id>67</item_id>
                                        <quantity>3</quantity>
                              </fetch>
                              <npc_finish_id>54</npc_finish_id>
                   </step>
           </quest_flow>
</quest>


Do I have the general idea, and how can I keep track of all this in-game?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2012-02-19 15:07:27 »

Looks good. If it contains the data you need then it's fine. If you come to a point where you need a way to dynamically add code to manipulate data, then you need scripting Smiley

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #4 - Posted 2012-02-19 15:10:51 »

I see...

Do I need to write a custom parser since I'm using custom tags?
Offline UprightPath
« Reply #5 - Posted 2012-02-19 15:16:20 »

Yes, and no.

You can use an XML parser that's already available to read the XML and parse it into its node set. XML has very fewpredefined tags. It's meant to be customizable (Hence, eXtensible Markup Language). So most of the available parsers will be able to deal correctly with it, so long as it's well defined/well structured.

To actually use the set, you'll have custom code that knows the structure of your XML document, and how to traverse it/retrieve information. For the most part, you'll be able to just use the regular DOMDocument system available to process your nodes into your data-structures. However, if you need to do searches like "Find the quest which rewards 'this'", then you might want to look into one of the XML-Search languages like xQuery, and there are a few others that I can't remember off the top of my head.

Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2012-02-19 15:16:46 »

No, parsers don't do anything special with custom tags. I recommed you use XPP3 (this link downloads a zip, containing the JAR, JavaDoc, and sources).

EDIT:
@UprightPath
It is best not to search through an XML for certain data, but store it in memory in your data structures.

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #7 - Posted 2012-02-19 15:22:26 »

Thank you very much, gentlemen. This a good starting point.  Smiley
Offline Roquen
« Reply #8 - Posted 2012-02-19 15:28:14 »

XML: The solution in search of a problem.
Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #9 - Posted 2012-02-19 15:30:27 »

=p

it is pretty amazing...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline UprightPath
« Reply #10 - Posted 2012-02-19 15:34:11 »

@ra4king
I suppose so. I'll admit that I'm not used to actually storing data persistently in memory. The most XML fun I've had was loading it from a web site, converting it into a middle-format, then placing that data into a SQL database. Or, taking it from that database and putting it into a second XML format and sending it elsewhere.

But, for persistent quest data, it does make more sense to just cram it into your own data structures and keep it available. And it's a much better plan than attempting to save through the fun that is serialize functions.

Offline Roquen
« Reply #11 - Posted 2012-02-19 15:38:22 »

Personally I never ever use XML for anything EXCEPT as an importer/exporter to some interchange format.
Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #12 - Posted 2012-02-19 15:41:06 »

@UprightPath
For single player RPGs anyway. Once you add a server then it might be best to store the data in a database.

I just need to figure out how I should put together the actual data structure. If I'm doing quests in XML, it would make sense to use it for items and npcs as well.
Offline UprightPath
« Reply #13 - Posted 2012-02-19 16:09:51 »

Well, XML can be edited by hand, where as most other formats you tend to require a program to add stuff. And if you're serializing anything, you need to have some form of converter, if you make any change to the storage class.

And, even if you're storing stuff in a DB, you wouldn't need to get stuff out of it in an XML format, so the searching through XML is doubly bleh in those cases.

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #14 - Posted 2012-02-19 16:15:03 »

Yeah, that puts a lot of overhead on the server.
Offline Roquen
« Reply #15 - Posted 2012-02-19 16:30:22 »

I'm not attempting to convince anyone not to use XML, but can you think of a more verbose and less readable text format?  I can't.  Plenty of games used text prior to XML and you could (usually) read the data in the file.  Compare the above to, say JSON if non-custom formats are they way you want to go.
Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #16 - Posted 2012-02-19 16:33:18 »

I think that XML is one the most readable ways to store and read data if the tags are descriptive. Why, do you have another suggestion?
Offline Roquen
« Reply #17 - Posted 2012-02-19 16:46:28 »

Use whatever works for you.  Personally I don't like any begin/end tag system when the data is generally short when compared the tags.  Too much noise compare to signal.  The example above has very little data, but quite a bit of text.  Even properly colorified I find it hard to see the data.
Offline UprightPath
« Reply #18 - Posted 2012-02-19 16:49:30 »

Well, it depends on the complexity of the text file you're going to use. As for XML's readability? I can read it fine, and if you know what the intent of the tags are, a lot of it becomes clear. It's a very context based thing.

If you're at all planning on allowing anyone else to edit the files without the use of a program (Like a quest/content creator), then using another format probably isn't going to work so well. Since you will have to define your own rules about how the file will be read into your system (What the use of \n, \r, \t, and other characters mean), you'll have to make these rules available to others. And, if you decide that you need to add in another piece of data, your whole format is probably going to change. XML is fairly easy to change (Add tags to), and reading it doesn't change too much when you do so.

So, a lot ends up depending on how set your data format will be. If you think you have everything you need to store your quest/other data and that you don't want other people poking around inside of the text files, then using some sort of plain text parser could be easier than attempting to define a whole XML document. If you think that you might need to add/remove/change things later in the development process or that you want to allow people to add/remove quests by editing the text document directly, then XML is probably better for you.

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #19 - Posted 2012-02-19 17:14:30 »

@Roquen
I guess I get that. There probably should be more data than tags, but I just threw that example out to see if I was understanding right.

Would it make more sense to come up with the XML, then a data structure, or the other way around? I'm just trying to think how I can read in all this quest data and be able to organize the Java classes/code to be able to have it function in the game.
Offline UprightPath
« Reply #20 - Posted 2012-02-19 17:20:35 »

Figure out what you need first.

And initially, don't worry about your storage structure. Use something else to input static data in your initial stages, rather than loading during all of the testing. Once you're fairly sure what you need, then look at the sort of storage structure you're going to use.

As for the structure, how you're reading/filling in your data should not be causing that large of an effect. Except that you'll need to have some form of loading order to ensure that you can get all of your references straight before you start filling in stuff.

Offline evilfrenchguy

Junior Duke


Medals: 3



« Reply #21 - Posted 2012-02-19 17:46:05 »

That makes sense.

Should it be wise to have a QuestManager clasd to do all the checking once the data is in? I need something in Java to actually check things globally like if I meet the requirements to start the quest. Basically a system that looks around and says, "Hey, Player is talking with the npc that starts quest x. Has he started it already or should it be started now? Does he even meet the requirements? Is he just finishing now? How do I even know?"

Basically a system that takes this quest data and is able to link it with the game world and player's status.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (33 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!