+1 vote

I started working on a quest system and been constantly running into walls with it and cant seem to get a full working system with no holes. I'm starting over completely and am still planning to make one. But my question is, is it good to use a dictionary or array for a quest system or is there a better way to go about it. In my case I tried using both arrays and dicts to hold the names of the quest and the summary. But then I have no where to put the reward. I also used for loops, global scrips, and the list-item node along side them.

So is using arrays and dictionaries ideal for a quest system or is there a better way to store the quest? also any tips would be appreciated. Thanks!

asked Feb 20 in Engine by Asthmar (226 points)

1 Answer

+2 votes

Yes it's fine to use arrays and dictionaries. If you feel comfortable using them and know well about how to use them together, it can be a very useful way to control systems like quests.
You can use one array to save all the quests info, each quest as a dictionary saved inside the array.
For example:

var quests = []
func _ready():
    new_quest({"Name": "Killing 10 Slimes and save 5 Villiagers", "Type": "Main_Quest", "Accomplish_conditions": [{"Type": "Kill monsters", "monster_Type": "Slime", "amount_required": 10}, {"Save NPC", "NPC_Type": "Villager", "amount_required": 5}]})
    #Here is just an example of how to use arrays and dictionaries to control a big complex quests system. Using them in similar ways can do things that are not just for quests, but also for many other things in your game, like characters, spells, etc.

function new_quest(quest):
    quests.append(quest)

#.....Add more methods according to how you want to construct your program. For example: quest_accomplished(quest), are_quest_accomplish_conditions_satisfied(quest), etc. It goes on and on. It's very flexisble, and you can do lots of things.

If you prefer using scenes instead of tons of infos inside arrays and dictionaries, the idea is the same, instead of adding a dictionary into the array, using an instance of the quest scene, or a dictionary like: {"Info": quest.get("info"), "node": quest}

answered Feb 20 by Sween123 (726 points)
edited Feb 20 by Sween123
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.