Skip to main content
gamedev.net
🔒 Locked

RPG help

Started by AdamGL 7 replies 1.1k views
Original Post
AdamGL
AdamGL
I'm making a 2-d rpg and I need some advice. Should I hardcode quests and stuff, or load them from a file. I don't know how I could load quests info from a file because I would need "if" statements that say, ex: "if player brings 200 gold to npc...", just a rough example. Anyone have any Ideas?
bi-FreeSoftware
-silencer-
-silencer-
If you don't want to hard code it for flexability reasons, and you don't want to take the time to learn about scripting languages, try this..

In a quest log file, create a header for each of your quests followed by the quest file.. like this..

NPC# GoldCost Level RequiredFlags QuestFileName
4% 200% 5% 1,2,4,6% quest1.dat
6% 100% 7% 3,5,7% quest2.dat
.
.
.

It's easiest to use a delimiter - such as %.
Now you check your quest log file whenever an item/action could trigger a quest, and do your if's based on the NPC, GoldCost, Level, Requirements, etc. If all are satisfied, load up the specific quest file.
Ravuya
Ravuya
Hell no, don't hardcode it. NEVER hardcode anything in an RPG if you can help it.

Either learn to embed scripting languages (which is somewhat complex) or create "stereotypes" for your quests (i.e. Need X Gold, Bring Me Item, Bring That Person Item, Kill The Foozle) and reference those from a text file, then use a hardcoded decision system to determine if it satisfies the requirement of the mission's stereotype.
AdamGL
AdamGL
I like -silencer-'s idea. I'm going to try that one out. Thanks for your input guys!
bi-FreeSoftware
TechnoGoth
TechnoGoth
You might want think about using an xml file rather then a text file. It is more flexible, easier to build and maintain, and eaiser to work with then a text file.

An example of quest node in the xml could look like this:

<quest>  <Initator>Old man</Initator>  <Text>Help, I'm sick I need 200 gold for healing</Text>  <Objectives>      <Objective type="give" target="initator" object="gold" amount="200"></Objective>  </Objectives>  <Rewards>     <Reward type="give" target="player" object="magic beans amount="3">   </Rewards></quest>


As you can see it is alot easier to work with and maintain then a simple text file.
AdamGL
AdamGL
Ok, how would I load xml files and how do i program in them. Any tutorials...
bi-FreeSoftware

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.