A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [Disc] Quest/Mission Management

  1. #1
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261

    [Disc] Quest/Mission Management

    I've been trying to figure out a way to implement a quest/mission manager in to my RPG, but can't quite figure everything out (or at least the best way to do things).

    Data Storage
    I'm thinking of holding quest data in XML like so:

    PHP Code:
    <Holder>
        <
    QuestChain>
            <
    quest name="End of the World" id="q1001">The end of the world is hereYou're screwed.</quest>
            <quest></quest>
            <quest></quest>
        </QuestChain>
        <QuestChain>
            <quest></quest>
            <quest></quest>
            <quest></quest>
            <quest></quest>
            <quest></quest>
        </QuestChain>
        <QuestChain>
            <quest></quest>
            <quest></quest>
            <quest></quest>
        </QuestChain>
        <QuestChain>
            <quest></quest>
        </QuestChain>
    </Holder> 
    This would easily allow me to give the player quests based on what's next in the quest line.

    Saving/Loading quest data
    How do you save which quests where completed? Data will sit in a database, so keeping the parameters to a minimum is a must.
    Potentially, you could have hundreds of quests. How do you manage all that data?

    The only/best way I can think of, is to give each quest a unique id, then if quest if finished, add that id to a string:
    finishedQuests += "uniqueId123";

    When all is said and done, the end string is going to be a long series of ids. On load i could parse that string and see what quests are done/not done.

    Is there a better way to do this? Any potential problems with this method?

    Quest Types
    1. Kill X amount of Z
    2. Kill Z, bring X amount of items from Z

    Going to keep quest types simple for now, because of next part;

    Quest Objectives
    How do you set and track quest objectives?
    Need to track location of quest (map id, x, y, enemy type)
    How many enemies were killed/objects collected.
    Need to save this data as well. How do I do THAT?

    These are just the things off the top of my head. Any feedback/suggestions welcome.

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Suppose you got 10 quests. All you need for keeping track of which is started or which is finished is simple string:

    finishedQuests = "0120120121";

    0 represents for example state of "finished", 1 is "started" and 2 is "not started yet". Now if your quests have id numbers from 0 to 10 you only need to check corresponding letter from the string.

  3. #3
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Quote Originally Posted by tonypa View Post
    Suppose you got 10 quests. All you need for keeping track of which is started or which is finished is simple string:

    finishedQuests = "0120120121";

    0 represents for example state of "finished", 1 is "started" and 2 is "not started yet". Now if your quests have id numbers from 0 to 10 you only need to check corresponding letter from the string.
    What if a new quest is added in between? That would mess up the order of finished quests in that string. I think using a quest id and quest state is a bit more reliable.

    That aside, how do you track how many enemies you killed for a specific quest?

    Thinking about WoW's quest system, they only allow you to hold ~20 quests at a time. So I guess there is a separate string that holds all the current quest data?

    Again, just thinking out loud...

  4. #4
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Well, through PHP, you can make a PHP class that corresponds to a Quest class. You load info inside a Quest class in Flash, and then store it with PHP. The Quest class would then hold everything.

    Or, like you mentioned, a String for each quest would work, plus it would probably be faster to load / save.

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  5. #5
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    I would be very interested in hearing how you guys handle quests/mission in your games. My mind is stuck where it is... i need someone to "think out of the box"

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Quote Originally Posted by PRadvan View Post
    What if a new quest is added in between? That would mess up the order of finished quests in that string. I think using a quest id and quest state is a bit more reliable.
    No, each quest has id. Its id does not change because it got started or was finished. You access the string by id of the quest in interest. The string will always hold state of all quests, meaning if you got 1000 quests your string is always 1000 chars. When you start quest with id 900, you simply change the char at position 900 in the string. When quest with id 555 is finished, you change the char at position 555.

    Tracking specific quests. I would set up runningQuests object/array where each quest you have started is put. It will have stored its id and its progress. You can access the original quest by id and compare the progress with requirements in quest.

    For example: quest id = 100, requirement is to kill 10 monsters with id = 34 (surely you have monsters set up by id too). Now when the quest is started you add new piece into runningQuests with id = 100 and monster id = 34 and monstersKilled = 0. Whenever you kill monster with id = 34 you add monstersKilled += 1 in the corresponding quest in runningQuests and also compare the monstersKilled with monstersRequired from original quest. Saving the runningQuests only needs 2 pieces: id and kills, so its short and can be easily transfered, you can get the id of monster when game is running.
    Last edited by tonypa; 06-25-2009 at 02:49 PM.

  7. #7
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Quote Originally Posted by tonypa View Post
    No, each quest has id. Its id does not change because it got started or was finished. You access the string by id of the quest in interest. The string will always hold state of all quests, meaning if you got 1000 quests your string is always 1000 chars. When you start quest with id 900, you simply change the char at position 900 in the string. When quest with id 555 is finished, you change the char at position 555.
    Ok that makes sense. But what happens when someone plays, saves the game, comes back later but the quest line changed. A couple of quests were removed, and a 20+ quests added.

    When that string is loaded/parsed, its going to have holes (deleted quests) and new undefined quests (you haven't saved yet after new quests were added). I can't fully see it working in my head but i think this might present a problem?

  8. #8
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Quote Originally Posted by tonypa View Post
    Tracking specific quests. I would set up runningQuests object/array where each quest you have started is put. It will have stored its id and its progress. You can access the original quest by id and compare the progress with requirements in quest.

    For example: quest id = 100, requirement is to kill 10 monsters with id = 34 (surely you have monsters set up by id too). Now when the quest is started you add new piece into runningQuests with id = 100 and monster id = 34 and monstersKilled = 0. Whenever you kill monster with id = 34 you add monstersKilled += 1 in the corresponding quest in runningQuests and also compare the monstersKilled with monstersRequired from original quest. Saving the runningQuests only needs 2 pieces: id and kills, so its short and can be easily transfered, you can get the id of monster when game is running.
    This is excellent.

    I suppose "get X amount of thing from Z" would work the same way. Check activeQuests, if activeQuest 1001 requires X things from Z, when Z killed, drop thing based on chance.

    Based on this quest system (give or take), what other types of quests are possible?

  9. #9
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967
    Quote Originally Posted by PRadvan View Post
    Ok that makes sense. But what happens when someone plays, saves the game, comes back later but the quest line changed. A couple of quests were removed, and a 20+ quests added.

    When that string is loaded/parsed, its going to have holes (deleted quests) and new undefined quests (you haven't saved yet after new quests were added). I can't fully see it working in my head but i think this might present a problem?
    Think of the quest id numbers as an autoincrementing key in a database. If you add new quests, you add them always at the end. Even if they are level 1 quests, their IDs would still be the next number at the end.

    If you remove quests, then you have to have some code that knows what to do when you see an in progress quest that returns null values when you try and look it up. Basically if you look it up and don't find it, make sure your lookup did not fail, and then set that quest as either completed or not started to clear it out.

    edit::
    better yet, if you delete a quest, just change the quest title to something easily identified like "DELETED". Then when you look up a quest and the title is "DELETED" you set that quest as not started (or complete, whichever you prefer)
    Last edited by Alluvian; 06-25-2009 at 04:04 PM.

  10. #10
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Sorry, I didnt think about adding or removing the quests from the whole game.

    Quote Originally Posted by PRadvan View Post
    I suppose "get X amount of thing from Z" would work the same way. Check activeQuests, if activeQuest 1001 requires X things from Z, when Z killed, drop thing based on chance.

    Based on this quest system (give or take), what other types of quests are possible?
    Talk to X, then talk to Y. Wear item Z (doesnt matter how you get it). Visit location XX-YY. Gain at least number X in stat Y. Stuff like that.

  11. #11
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Quote Originally Posted by Alluvian View Post
    Think of the quest id numbers as an autoincrementing key in a database. If you add new quests, you add them always at the end. Even if they are level 1 quests, their IDs would still be the next number at the end.

    If you remove quests, then you have to have some code that knows what to do when you see an in progress quest that returns null values when you try and look it up. Basically if you look it up and don't find it, make sure your lookup did not fail, and then set that quest as either completed or not started to clear it out.

    edit::
    better yet, if you delete a quest, just change the quest title to something easily identified like "DELETED". Then when you look up a quest and the title is "DELETED" you set that quest as not started (or complete, whichever you prefer)
    I guess that works. Its just hard to visualize at first since the finishedQuests string values positions are dynamic.

    So if I save quest status like so:
    var finishedQuests:String = "2100000000000000000000000000000000000000"

    quest0 status = finishedQuests.substring(0, 1)
    quest555 status = finishedQuests.substring(555, 1)

    Quote Originally Posted by tonypa View Post
    Talk to X, then talk to Y. Wear item Z (doesnt matter how you get it). Visit location XX-YY. Gain at least number X in stat Y. Stuff like that.
    Good stuff. That would definitely work in a system like this.

    ---

    Another thought I just had; instead of going with the linear "wow quest system", i can also just have random repeatable quests (sort of like eve online). Would save the headache of saving/tracking completed quests and such, but makes it that much more ... meh.

  12. #12
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967
    Yeah, one odd thing is that the length of the string will get longer as you add new quests, but you know that the value of any extra characters at the end will start at '0' for all players.

  13. #13
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    I think I'm going to go for mission objective classes. Something like this;

    Mission objective classes: Kill, Collect, Rescue, GoTo, TalkTo
    PHP Code:
    //Kill(map id, enemy id, amount
    killMission = new Kill("map33""enemy111"10)
    //Collect(map id, enemy id, item id, amount
    collectMission = new Collect("map33""enemy111""item2020"10); 
    Quest Data will be saved in XML
    PHP Code:
    <questChain>
     <
    quest type="kill" map="map33" enemy="enemy111" amount="10" />
     <
    quest type"collect" map="map33" enemy="enemy111" item="item2020" amount="10" />
    </
    questChain>
    <
    questChain>
     <
    quest type="kill" map="map33" enemy="enemy111" amount="10" />
     <
    quest type="kill" map="map33" enemy="enemy111" amount="10" />
     <
    quest type"collect" map="map33" enemy="enemy111" item="item2020" amount="10" />
    </
    questChain
    Save/Load quest progress
    Active quest log with 10-20 max quest slots. Will save all data as a string:
    PHP Code:
    //this one saves 3 quests and their progress
    //final version will have shorter parameter names

    var questData:String "questId=q0001,status=1,kills=10,itemId=i2020, amount=6|questId=q0002,status=1,kills=10,itemId=i2020, amount=6|questId=q0003,status=1,kills=10,itemId=i2020, amount=6|" 

    Linear quest lines will require a way to track completed quests. I'm planning on doing that by adding a complete quest's id to a completedQuest string. Then when parsing the quest xml, quests can be available/not available based on what's completed.
    PHP Code:
    var completedQuests:String "q0001,q0002,q0003"
    I opted to go with quest id's in the completedQuests string because the quest status will already by tracked by the quest log. This way is also more stable/easier than relying on character position in a string to track the status.

    Thoughts?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center