PDA

View Full Version : Complex multistage quest npc


Figback65
03-16-2014, 02:12 PM
Hey all,

I know most of you guys know all the complex writing but for the ones teaching themselves like me, heres an example of a quest npc with multiple levels of response and actions. The hard part is to get them referenced in the right order, which is not top to bottom writing I have learned lol.

NOTE! There is globalflags which I save for chains later and for other reasons. You may or may not need flags or use so you can add a deleteglobal in there to rid of it.

Sorry if its sloppy, I try to clean my work up for u guys lol

questguy.pl
#Master Thaedus Task order
#Turn in stone
#Get portal invader task
#Return to complete and get firewood and kill task
#Turn in firewood for zone task update
#Return to complete and get summoner task
#Complete summoner task turn in head
#Move on to Thed
#
sub EVENT_SAY {
my $Rep1 = quest::saylink("I'll do what I can Master Thaedus.");
#my $Rep2 = quest::saylink("Im looking for a guy named Shady");

#After you turn stone in and get flagged
if ((defined $qglobals{"Moors_Open"}) && ($qglobals{"Moors_Open"} == 1)) {
if (quest::istaskactive(277)) {
plugin::Whisper("Do you have the summoners head?");
}

#If all 3 tasks are complete and on hail suggest moving on
elsif ((quest::istaskcompleted(273)) && (quest::istaskcompleted(275)) && (quest::istaskcompleted(277))) {
if($text=~/hail/i){
plugin::Whisper("Its time to move on and find Thed Creggle. Tell him Master Thaedus sent you. Unless you wanna do more tasks.");
quest::taskselector(273,275);
}
}

#if wood and kills have been completed then give summoner head task
elsif ((quest::istaskcompleted(273)) && (quest::istaskcompleted(275))) {
if($text=~/hail/i){
plugin::Whisper("So you say you seen a Circle of Mages? I have heard rumors of an Ancient Summoner in command of some powerful mages. Destroy the mages, kill the summoner, bring me her head!");
#quest::taskselector(277);
quest::assigntask(277);
}
}

#after you kill enough invaders and speak back with thaedus he gives you master quest and next 2 tasks wood and #kills
elsif (quest::istaskactivityactive(272,1)){
if($text=~/hail/i){
plugin::Whisper("Next I need you to gather some wood for our fires, we need to keep the way home lit. Go to the swamp and collect wood pieces off the inhabitants and return them to me. While your at it, make sure you take an ample amount of enemies while your there.");
quest::setglobal("Mast_Thae",1,5,'F'); #After completing invaders 1st time get flag to advance to repeat tasks
quest::assigntask(286);
quest::assigntask(273);
quest::assigntask(275);
}
}

#if portal invader quest is completed give wood task
elsif ((defined $qglobals{"Mast_Thae"}) && ($qglobals{"Mast_Thae"} == 1)) {

if ((quest::istaskcompleted(273)) && (quest::istaskcompleted(275))){
plugin:Whisper("I see you are back for more");
#quest::taskselector(273,275);

}

#after you collect enough wood and speak back with thaedus and give him wood
elsif (quest::istaskactivityactive(273,1)){
if($text=~/hail/i){
plugin::Whisper("Did you collect the wood? Hand it to me.");

}
}

#after you kill enough swamp mobs and return to thaedus
elsif (quest::istaskactivityactive(275,3)){
if($text=~/hail/i){
plugin::Whisper("Thank you for killing a ton of swamp mobs. So you say you seen a Circle of Mages, I have heard rumors of an Ancient Summoner. Destroy the mages, kill the summoner, bring me her head!");
}
}

#after you collect the head and return to thaedus and give him the head
elsif (quest::istaskactivityactive(277,1)){
if($text=~/hail/i){
plugin::Whisper("Thank you, solving the swamp problem.");
}
}





#Inform you need to finish
elsif ((quest::istaskactive(273)) && (quest::istaskactive(275))) {
plugin::Whisper("You need to finish the tasks at hand");
}
#Inform you need to finish
elsif (quest::istaskactive(273)) {
plugin::Whisper("You need to collect more fire wood");
}
#Inform you need to finish
elsif (quest::istaskactive(275)) {
plugin::Whisper("You need to kill more enemies of the swamp");
}

}






#first task killing portal invaders
elsif($text=~/hail/i){
plugin::Whisper("Were getting killed out here hero! We need your assistance in defending the portal so our forces may have unfettered access to Blightfire. $Rep1");
}
#Accepting the task portal invaders
elsif($text=~/i'll do what i can master thaedus/i){
quest::assigntask(272);
plugin::Whisper("Those portal invaders will never stop!");

}
#End Global check
}





#First arrive if you hail without having turned stone in.
elsif($text=~/hail/i){
plugin::Whisper("Hero! You made it! Hurry, hand me the stone so that we may open the portal.");
}

}




sub EVENT_ITEM {
my $Rep1 = quest::saylink("I'll do what I can Master Thaedus.");
#Handin Stone of Return to start task chain and flag
if (plugin::check_handin(\%itemcount, 2662 => 1)) {
quest::say("Thank the gods! We have our ride home men!");
plugin::Whisper("Were getting killed out here hero! We need your assistance in defending the portal so our forces may have unfettered access to Blightfire. $Rep1");
quest::setglobal("Moors_Open",1,5,'F');
#Class check for noob epics
if (($class eq "Bard") || ($class eq "Warrior") || ($class eq "Ranger")) {
quest::summonitem(2666);
}

elsif ($class eq "Cleric") {
quest::summonitem(2672);
}

elsif (($class eq "Berserker") || ($class eq "Paladin") || ($class eq "Shadowknight")) {
quest::summonitem(2670);
}

elsif (($class eq "Necromancer") || ($class eq "Wizard") || ($class eq "Enchanter") || ($class eq "Magician") || ($class eq "Shaman") || ($class eq "Beastlord") || ($class eq "Monk") || ($class eq "Druid")) {
quest::summonitem(2669);
}

elsif ($class eq "Rogue") {
quest::summonitem(2673);
}
}
#Handin wood for task and update zone task
if (plugin::check_handin(\%itemcount, 132571 => 4)) {
plugin::Whisper("Thank you, now our fires will burn brighter than ever");
quest::updatetaskactivity(286, 0);
}
#hand in summoners head and suggest move on
if (plugin::check_handin(\%itemcount, 132572 => 1)) {
plugin::Whisper("The Summoners Head. proof of her demise, now if the rest of her trash will just die....Its time for you to head east down the road to Thed Creggle, he is doing some important work, tell him Master Thaedus sent you.");

}

else {
plugin::return_items(\%itemcount);

}

}