Advertisement

RPG tasks

Started by February 13, 2000 11:38 AM
3 comments, last by PsYcHoPrOg 24 years, 7 months ago
In an RPG(role playing game), how would you do a task system? What I mean is ,as the hard-core gamer would know, is that, in RPGs, there are many tasks to be performed. Whether it''s saving a goddess, or getting an item, you always need to do one thing before another. Tasks that continue the story can not be performed out of sequence. How would I do this in code? It''s been driving me nuts! I''d have to write millions of if() statements, but is there another way? HELP!!
D:
You could put the tasks in a listsystem similar to a messageboard.

ie.

struct tasktype {
int taskid
int parenttaskid
...
}

If parenttaskid ain''t a positive number then it can be done without any other tasks been completed. If it is a positive number you check if the item where the taskid quals the parenttaskid you want to show/complete is completed.

Some sort of linked list/binary tree can make this done in a fast way.

Death is lifes way saying your fired.
Advertisement
errand is right on. Personally, I like the tree idea, though not necessarily a binary tree. Every task would be represented by a node in the tree like follows:

struct TaskNode
{
int taskId;
TaskNode *enabledTasks[];
}

Every task that a character could complete would maintain a collection of child tasks that this task then enables. (To begin with, for example, a "beginGame" task enables "talkingToKingToGetQuest", which then enables both "leavingCastle" and "enteringBasementToSeeSage". This enables plenty of branching. In addition, this needn''t necessarily be a tree, allowing multiple ways of getting to a specific task. This would simply require that each node also store whether or not it had been done. At a larger scale, you just have to store a list of the next set of tasks which can be done, and check against that list whenever the player tries to do something. This list can then be updated whenever a task on that list is completed.

Obviously, there are many potential improvements/optimizations, but this ought to get you started.

-Brian
Thank you, After I posted this up, it came to me, but I was''nt sure if the idea would work or not. Getting it as a suggestion from two people deifinately tells me so, thanks for the help. But, how would I store the actual, individual tasks.
D:
Thank you, After I posted this up, it came to me, but I was''nt sure if the idea would work or not. Getting it as a suggestion from two people deifinately tells me so, thanks for the help. But, how would I store the actual, individual tasks. How and where would I define how the individual tasks need to be completed? thanks.

This topic is closed to new replies.

Advertisement