Author Topic: Quest System  (Read 1735 times)

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Quest System
« on: May 10, 2007, 01:56:09 AM »
For my new game, I wanted to include (for the first time, actually) a decent quest system.

I'm wondering how I would achieve the following things:

A map system with fixed points, but that can be easily expanded.
Example: You start out in Town A and have the following options: go to the fields, go to Town B, go in the woods. And so on.
How would that be the most efficiently implemented? Can it be done using a seperate table?

Secondly: How would I add quests? For example: Go to the woods, kill creature X go to Town B.
My guess is a field in the user table for acheived quests and current quests. Or a separate table even.
The quests should be easily exandable, meaning adding new content without having to change the sourcecode (not hardwired quests). Can this be don?

I really have no clue on this one -_-

Offline Shapulin

  • Level 9
  • *
  • Posts: 50
  • Reputation: +2/-4
    • View Profile
Re: Quest System
« Reply #1 on: May 10, 2007, 02:29:51 AM »
now you need a history script... and some NPC with a special behaviors... and...a history generator ;)

you could do some traveling characters and some map fixed cchars..

a witch in her house.... some goblin in a cave... some old man in a castle...etc

and some chars that travels from place to place...... 

you can make special items and forces in permanent regeneration....

an invencible dragon...a cave full of trolls...etc

then you can develope some "history generator" ...

go here to an example of hitory generator ;)

http://www.applegazette.com/macrumors.php

then....some times a traveling NPC search a player to give them a special quest..or some village leader or a wizard give them some information...




Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Quest System
« Reply #2 on: May 10, 2007, 03:14:54 AM »
I am actually more looking for help on how to actually do it in PHP.

Just making quests isn't the problem. I need help figuring out how to detect when a quest is finished and how to implement it so I don't have to hardcode everything into the code.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Quest System
« Reply #3 on: May 10, 2007, 03:44:06 AM »
For your quests, you could make them so that they require an item. Make it so it's only dropped by the quest target.
So, if you have to go defeat a werewolf or something, let the werewolf drop Werewolf Skull when it's dead. Then the players go back to the quest NPC and the NPC will check if they have that item in their inventory.

You could store the quest's info in a separate table, so it should look something like this:
id
username
quest_item
quest_id
time

Then have another table that stores all the basic quest info, which is what the quest_id refers to.

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
locations working!
« Reply #4 on: May 10, 2007, 04:41:03 AM »
hmm... that's a really nice idea :)

and it sounds quite reasonable to implement as well. Might give it a try.

[?∂??]

I also kinda figured out a way to do the locations.
I guess I'll simply store the current location in the users table and then make a bunch of .php files for each location with the options.
I'll still need a table for the location/map tho.
The table would look something like this:
ID
exits
name
quests

either that or make 3 tables:
table location
ID
name

table exits
ID
location
exit

table quests
ID
location
quest_id

the name will be the one that appears on the signposts saying "this way to $name". In the first example, the exits would be a string to store possible exits and then just get exploded into an array. Same with the quests field.
Now, what would make more sense?

[?∂?? 2]
Okay, I managed to implement the locations with the first method I mentioned above.
Now I just gotta figure out how to do the quests.

(especially mulitlevel quests =/ )
« Last Edit: May 10, 2007, 08:20:54 AM by Sinzygy »

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Quest System
« Reply #5 on: May 10, 2007, 10:55:16 AM »
The way I did my map on my RPG was to use a table with x and y co-ordinates. Like this, you already have a 2D map, and to find the exits you just look for a row with x co-ordinate + 1, or y co-ordinate + 1, etc. This way you can also process all locations from a single PHP file. If you want to see the rpg, it's at http://www.zegghq.com/
Although, that map system might not be what you had in mind.

I think you could store quests in a separate table, that way you can have more quest-related information, and just include a column that will refer to the location on the map of the quest.
On the quest table, include columns like:
text_before: text the NPC says before the user takes the quest - explains what to do, etc.
text_during: what to say if the user has taken the quest but hasn't completed it
text_after: what to say when the user has completed the quest
requirement: requirements before the user can take the quest (stats, level, item, gold, previous quest? possibly in separate columns each)
target: item needed by the user to complete quest (I am following up from my first suggestion about the items)
gold_reward: reward of gold, could be zero
item_reward: which item to reward, could be nothing

And anything else you might want to include in your quests. All you have to do is check this table for a quest that is in the same location as the player, then process the row's information.

You should also have another place to store the quests that the user has completed (could be in the players table, or in a separate table, I'd prefer a separate table). This way, you can also have multilevel quests:

Say you have Quest 1, which is to defeat the minions, and will require 10 minion skulls.
There are no previous quest requirements for this.
Quest 2: Defeat the boss and bring back the Treasure.
Then for this quest, the requirement would be Quest 1. You could store this by referring to the quest's ID.

Or you could also have a separate stat which can only be increased by completing quests (let's say, Fame). Then to start some quests you might need a certain amount of Fame before you can join.
« Last Edit: May 10, 2007, 10:56:58 AM by Zeggy »

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Quest System
« Reply #6 on: May 10, 2007, 03:33:27 PM »
okay, here's how I've done it. (it seems to be working for now)

I made 3 tables

1st: locations (ID, name, exits, time)
ID: name of the locatinfile
name: name of the location
exits: to where you can exit
time: how long it takes to get there

2nd: quests (ID, prequisites,name,start,middle,end,shorttext,starttext,middletext,endtext,reward)
ID: the ID of the quest
prequisites: if any other quests need to be done before this one can be done
name: name of the quest
start: the location where this quest can be found
middle: a list of locations that need to be visitied.
end: where the quest is succesfully finished.
shorttext: the linkk that will appear if this quest is available
starttext: the text that will appear if the player klicks on the link
middletext: a list of text-passages that are displayed for each location from the middle field
endtext: the text that is diplayed at the end of the quest
reward: the amount of silver the player gets for completing the quest

3rd: quest_log (ID,user,quest,phase)
ID: the id of the quest log
user: for which user this entry is
quest: for which quest it is
phase: in which phase of the quest the player is at the moment.

Now, everytime a new location is visited I check a) is there a new quest available or b)is an already begun quest running that has a middle point here and if b)is the player in the correct phase of the quest or does he have to do anything before.

maybe some more about the phase:

I make an array which contains all the locations that are relevant for the quest in the order of which they have to be visited.
So phase 1 = start (if they get the quest, they are at phase 1)
now they have to visit location.middle.1 to get to phase 2. If they go to location.middle.2 before they went to location.middle.1 they won't see anything until they visit the first location and advance one step in the quest-phase.
With this, I can keep users from discovering stuff they shouldn't know about yet and I can direct closely the route they take. Of course, this compromises the freedom of the player, but they won't really recognise it since there usually is only one way to a certain location.
if the phase is = 0 and there is an entry in the quest_log, this means the player has successfully completed this quest.

any comments/improvements/questions?

Offline Broda

  • Level 13
  • *
  • Posts: 97
  • Reputation: +2/-0
    • View Profile
    • Nightfall Games
Re: Quest System
« Reply #7 on: May 10, 2007, 04:06:35 PM »
Sounds like it'll work to me.

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Quest System
« Reply #8 on: May 10, 2007, 04:59:57 PM »
it's working for 1 location and 1 quest.

I didn't have time to test it further and with quests in different phases, but I'll figure it out eventually  --)

Offline beam

  • Level 15
  • *
  • Posts: 132
  • Reputation: +2/-0
  • Dance Commander
    • View Profile
Re: Quest System
« Reply #9 on: May 14, 2007, 03:23:01 AM »
Haha Zeggy I can't do anything in your game besides login and look at my stats. Is there anything I'm missing?

And to stay on topic:

I think Kingdom of Loathing did quests very well, because they integrated them into the game, rather than just exploring a coordinate grid going to certain locations.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Quest System
« Reply #10 on: May 14, 2007, 03:47:14 AM »
Beam: You can use the map, use the arrow keys to move around. :)
If you move off the home map and explore other maps, you can fight monsters.

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Quest System
« Reply #11 on: May 14, 2007, 06:02:13 AM »
I think Kingdom of Loathing did quests very well, because they integrated them into the game, rather than just exploring a coordinate grid going to certain locations.

Yeah, I took at the map/quest-system of KoL and as far as I could figure out, they're just hardcoded. I'm doing something like this right now, but I'm trying to keep it a bit more flexible.

Do you know how they implemented he quests in KoL and how they check which ones are active and which ones can't be done right now?

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal