I'm okay with 2-dimensional arrays, but when I get to 3 or more, I can't seem to wrap my head around how to assign and/or pull values from specific parts.
To give an example, let's take the following example:
We know that a player can take up to 5 total quests, and each quest can have a max of 5 tasks.
Let's assume I have the following multi-dimensional array holding all of a players quest data:
Quest ID Quest task #needed #done #flag
int quests [5] [5] [1] [1] [1]
|
Pretend that a player accepts a quest that wants them to kill 2 bears, 5 ducks, and 13 wolves.
That quest has an ID of 78, which we store in "Quest ID", as shown above.
Each creature has an ID, stored in the "Quest Task" as shown above.
The number of each creature needed in the "#needed" as indicated above.
For the progress of each kill, that value is stored in "#done".
The "#flag", in this case, will remain 0.
What I'd like to do is the following:
1 2 3 4 5 6 7
|
quests[0] = 78; // Store the questID
quests[0][0] = 3945; // Store the 1st creature ID
quests[0][1] = 2230; // Store the 2nd creature ID
quests[0][2] = 3045; // Store the 3rd creature ID
quests[0][0][0] = 2; // Store how many needed of the 1st creature
quests[0][1][0] = 5; // Store how many needed of the 2nd creature
quests[0][2][0] = 13; // Store how many needed of the 3rd creature
|
As we know, the above code can't be done. How do I assign certain values to each specific dimension?
Thanks.