hi guys over the last month iv developed a small 17th centuary map with 5 towns and a population now i would like to add quests like in nwm2 u walk up to someone and u talk to them and so the story line will progress can anyone direct me to resources to help me thanks
Well in order to do that, you must have some sort of dialogue system or something as well as some gui which would give hints to the player what to do on the quest.
I’ll give you some info on how we used to do it when programming Runescape private servers.
You make ints of progress, as well as some other stuff for e.g.:
public int Quest1progress = 0;
public int Quest2progress = 0;
public int Quest3progress = 0;
public int Quest4progress = 0;
public boolean Quest1started = false;
public boolean Quest2started = false;
public boolean Quest3started = false;
public boolean Quest4started = false;
public boolean Quest1done = false;
public boolean Quest2done = false;
public boolean Quest3done = false;
public boolean Quest4done = false;
etc. for different quests.
Then, if you want to start a first quest (Quest1), lets say you click talk on npc and quest starts, so then inside the code where you would talk to npc add something like:
if (!Quest1done !Quest1started) {
Quest1started = true;
Quest1progress = 1;
}
so it would tell that if the quest isn’t started and isn’t done, start the quest and go to progress 1.
Now with the progresses, basically you’d make something like this:
string Quest1Hint;
GUI.Label (Rect (10, 10, 100, 20), Quest1Hint);
switch(Quest1progress) {
case 1:
/*now add something like text on a gui window to give player hints on what to do at start of quest, for e.g.*/
Quest1Hint = "Go to town and bring me back an onion!";
break;
case 2:
Quest1Hint = "The blacksmith looks angry, maybe you should go talk to him and see what's going on?";
break;
Well I hope you get what i mean
Then again lets go back to the progress 1 hint, so the guy wants us to go to town and bring him back an onion?
Let’s go back to the code that we want to insert in the dialogue code with the guy:
if (!Quest1done !Quest1started) {
Quest1started = true;
Quest1progress = 1;
}
so what we add now is something like:
if (!Quest1done !Quest1started) {
Quest1started = true;
Quest1progress = 1;
}
else if (Quest1progress == 1) {
if (player.hasItem("onion")) {
//some dialogue chat here
Quest1progress = 2;
}
else
//some dialogue chat like "wheres my onion??" etc
else if (Quest1progress == 2) {
}
etc etc.
Then when you want the quest to end, just add something like:
//end quest
Quest1done = true;
//give player some reward or something
player.giveItem("dragon helmet");
etc.
This is to give you the basic idea of how to do it or how it is done in runescape private server programming ^^
It’s not that hard but you just have to have some brain to understand etc.
Hope you get it, Thanks
Without going into great detail, don’t forget the power of arrays. (And for C#, structs?) In Unity.js, you can make a custom class and then put that into an array - along the lines of:
myQuestArray : QuestDetails;
// The size of the array can be set in the inspector.
Class QuestDetails {
isStarted : boolean;
questProgress : int;
isEnded : boolean;
questName : String;
questDescription : String;
questImage : Texture2D;
questText01 : String;
questText02 : String;
questText03 : String;
questHint : String;
questReward : GameObject;
// etc.
}
(For more information on arrays, check out array in the docs in scripting and the manual. The information there is pretty straight forward.)
You can then access the information in the array by it’s location number, starting at [0] and ending in [myQuestArray.length] which is the array size number you set in the inspector MINUS one, as arrays count their length starting at 0.
var textToDisplay : String;
function SomeFunction (currentQuest : int) {
var questStarted : Boolean = myQuestArray[currentQuest].isStarted;
var questDone : Boolean = myQuestArray[currentQuest].isEnded;
var questProgress : int = myQuestArray[currentQuest].questProgress;
// etc...
// The first line is saying the local variable "QuestStarted" is set to isStarted of the current quest.
// The current quest is the number passed into the function as (currentQuest : int).
if (!questStarted !questDone) {
questStarted = true;
myQuestArray[currentQuest].isStarted = true;
questProgress = 1;
myQuestArray[currentQuest].questProgress = 1;
textToDisplay = "Hello, " + playerName + "! " + myQuestArray[currentQuest].questText01;
// etc.
... more code ...
}
Does this make sense? (Now this code was pulled from my back pocket, and I’ve not tested it, but it should point in the right direction!)