View Single Post
  #4  
Old 08-01-2010, 12:30 AM
cylynex2
Sarnak
 
Join Date: Jul 2010
Posts: 36
Default

In case anyone else was having trouble with it, here's a copy of working code that does progressive quests. Change your taskids for the flavor text and the taskset IDs.

Code is pretty messy, there's a lot of comments and debug text, but you get the idea.

Code:
# This example is based on a TaskSet (TaskSet 12), which consists of tasks 120, 121, 122, 123 and 124
#
# The tasks are designed to be performed sequentially. Once one task is completed it cannot be selected again
# and the next task in the sequence is made available.
#
sub EVENT_TASKACCEPTED {
        quest::say("You accepted task $task_id");
}

sub EVENT_SAY {
        # If the player hasn't completed the last task in the TaskSet
        $activecount = quest::activetasksinset(12);
        $donecount = quest::completedtasksinset(12);
		#$nexttaski = quest::nexttaskinset(12);
		$lasttask = quest::lasttaskinset(12);
		$activespeaktask = quest::activespeaktask();
		#$completed = quest::completedtasksinset(12);
        #quest::say("You have $activecount active tasks and $donecount completed tasks in task set 12");
		#quest::say("last task in set is $lasttask");
		#quest::say("Next task is $nexttaski"); 
		#quest::say("Completed: $completed");
		#quest::say("activespeak task is $activespeaktask");
        if(!quest::istaskcompleted(quest::lasttaskinset(12))) {
                # If the player has no tasks enabled for this task set, enable the first one
                if(quest::enabledtaskcount(12) == 0) {
                        quest::say("You have not done any of my tasks before!");
                        quest::enabletask(quest::firsttaskinset(12));
                }
                else {
                        # The player is enabled for a task in this TaskSet. Is he at the point
                        # in the task where he needs to speak to this NPC ?
                        $task = quest::activespeaktask();
						#quest::say("and the task nubmer thing is $task");
                        if($task != 0) {
                                # If task != 0, then the player needs to speak to me, find out which activity it is
                                $activity = quest::activespeakactivity($task);
                                # Mark the activity as complete
                                #quest::say("Updating task $task activity $activity");
                                quest::updatetaskactivity($task, $activity);
                                quest::say("Well done!");
                                # If the task is now complete, offer the next task, if there is one
                                if(!quest::istaskactive($task)) {
                                        quest::disabletask($task);
                                        if($task != quest::lasttaskinset(12)) {
                                                quest::say("Well done, I have another task if you are willing.");
                                                #quest::enabletask(quest::nexttaskinset(12, $task));
												quest::say("Ok past quest 1, need to find next quest in set.");
												#$firsttask = firsttaskinset(12);
												#quest::say("First Task in this set is $firsttask");
                                               
                                        }
                                        else {
                                                quest::say("Thank you for cleansing Qeynos Hills!");
                                        }
                                }
                        }
                        else {
                        }
                }
                # Bring up the task selector, only if the player has no active tasks in this set.
                if(quest::activetasksinset(12) == 0) {
					$first = quest::firsttaskinset(12);
					#quest::say("FIRST TASK IN SET WAS $first");
					$completed = quest::completedtasksinset(12);
					#quest::say("NUMBER COMPLETED IN SET IS $completed");
					$nexttask = $first + $completed;
					#quest::say("NEXT TASK ID WILL BE $nexttask");
					$lasttask = quest::lasttaskinset(12);
					#quest::say("Last task in this set has to be $lasttask");
					if ($nexttask <= $lasttask) {
						quest::say("pop task $nexttask");
						if ($nexttask == 218) {
							quest::say("These damn kobolds killed me!  What? NO I DO NOT DIE TO EVERY MOB THAT COMES ALONG.  Now as I was saying....Let's get some revenge.");
						} if ($nexttask == 219) {
							quest::say("Just don't bring me Kiri...I want one that heals....");
						} if ($nexttask == 220) {
							quest::say("Have I told you about my love for tennis?  Man I could talk about that all day....OK OK...Let's try this next...");
						} if ($nexttask == 221) {
							quest::say("The King! I bet my wife has a quest just like this one!");
						} if ($nexttask == 222) {
							quest::say("I'm not talking about Elvis or Mal here.");
						} if ($nexttask == 223) {
							quest::say("I really have to get back to the court, so I'm just gonna toss this out. This will take you a while.");
						}else {
							quest::say("Let's do another one!");
						}
						quest::enabletask($nexttask);
						quest::taskselector($nexttask);
					} else {
						quest::say("done!");
					}
                    #quest::tasksetselector(12);
                }
        }
        else {
                quest::say("Hail, Slayer of Gobbies!");
        }
}
Reply With Quote