View Single Post
  #5  
Old 07-27-2009, 02:24 AM
Justsomeguy
Fire Beetle
 
Join Date: Apr 2005
Posts: 7
Default

This script doesn't spawn an npc. Spawning is mentioned above though. And do remember you need to take into account players hailing quest npc when the npc is moving back and forth, so adding a $busy variable or something could be helpful too. Here is a basic script with a captain and a guard. Player hails captain and asks for help back to the camp. Captain calls guard. Guard walks into room and then takes player back.

Captain.pl

Code:
my $npcvariable = 0;

sub EVENT_SAY {
	if ($text=~/hail/i) {
		quest::say("Hello, $name.  Do I need to call a guard to help you?");
	}
	elsif ($text=~/yes/i) {
		#signals guard
		quest::say("Very well.  Guard!!!");
		quest::signal(1001);
	}
}


 
sub EVENT_SIGNAL {
	
	#Captain signals guard to move up
	
	if($npcvariable < 1) {
	quest::say("Please show our new recruit to the main post.");
	quest::signal(1001);
	$npcvariable = 0;
	}
}
Guard.pl

Code:
my $npcwaypoint = 0;
 
sub EVENT_SIGNAL {
	
	if($npcwaypoint < 1) {	#Captain signals guard to move up
	quest::moveto(600, 200, 12);
	$npcwaypoint = 1;
	}
	elsif($npcwaypoint == 3) {	#Guard is told to take player back.  See timer
	quest::say("Yes, sir, right away!");
	quest::settimer("movement",3);
	}
}

sub EVENT_WAYPOINT {


  $npc->SaveGuardSpot(0);	#this is so npcs don't not walk to waypoint and return immediately

	if($npcwaypoint == 1) {	#npc turns corner
	$npcwaypoint = 2;
	quest::moveto(600, 100, 12);
	}
	elsif($npcwaypoint == 2) {	#npc turns corner
	quest::moveto(340, 100, 12);
	$npcwaypoint = 3;
	}
	#npc arrives at captain
	elsif($npcwaypoint == 3) {
	quest::say("Yes, sir?!");
	quest::signal(1000);
	}
	elsif($npcwaypoint == 4) {	#npc turns corner
	quest::moveto(340, 100, 12);
	$npcwaypoint = 5;
	}
	#guard has taken player back with him.  Resets script for next user
	elsif($npcwaypoint == 5) {	#npc turns corner
	$npcwaypoint = 6;
	quest::moveto(600, 100, 12);
	$npcwaypoint = 0;
	}
}

sub EVENT_TIMER {
	quest::stoptimer("$timer");

	if($npcwaypoint == 3) {		#just used a timer here since players may need some time to react.
	quest::moveto(340, 100, 12);
	$npcwaypoint = 4;
	}
}
Reply With Quote