|  |  | 
 
  |  |  |  |  
  |  |  |  |  
  |  |  |  |  
  |  |  |  |  
  |  | 
	
		
   
   
      | Quests::Q&A This is the quest support section |  
	
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				03-04-2014, 09:58 AM
			
			
			
		 |  
	| 
		
			
			| Fire Beetle |  | 
					Join Date: Dec 2007 Location: home 
						Posts: 13
					      |  |  
	| 
				 Newby Needs a Hand 
 I have recently been trying my hand at writing encounter scripts and while I have had some success I have found a few hangups I can't overcome. 
My issue with the encounter I have set up is I cannot seem to get the second $hpevent variables to work.  Here is a copy of my encounter.  I would be much obliged if someone can help me out.  Also any simple pointers would be awesome.  I just started delving into this a week ago.
 
	Code: sub EVENT_SPAWN
{
	quest::shout("You will regret trespassing in my kingdom!");
	quest::setnexthpevent(75);
}
sub EVENT_HP
{
	quest::emote("quaffs a magical elixir.");
	quest::shout("Now you will die!");
	quest::npcsize(9);
	quest::modifynpcstat("min_hit",70);
	quest::modifynpcstat("max_hit",120);
	quest::setnexthpevent(50);
}
if($hpevent==50)
{
	quest::shout("Guards!");
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();
	quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
	quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
}
sub EVENT_AGGRO
{
	quest::emote("lunges at you.");
	quest::shout("Me thinks you will make an excellent $race stew!");
}
sub EVENT_DEATH
{
	quest::emote("whimpers in pain.");
	quest::shout("My spleen!");
}
sub EVENT_SLAY
{
	quest::emote("laughts at $targetname.");
}
			
			
			
			
				  |  
 
  |  |  |  |  
	
		
	
	
 
  |  |  |  |  
	| 
			
			 
			
				03-04-2014, 10:01 AM
			
			
			
		 |  
	| 
		
			
			| Hill Giant |  | 
					Join Date: Oct 2002 Location: Rockville, MD 
						Posts: 124
					      |  |  
	| 
				  
 Currently you are closing your sub EVENT_HP out before the next hpevent. 
	Code: sub EVENT_HP
{ 
	quest::emote("quaffs a magical elixir.");
	quest::shout("Now you will die!");
	quest::npcsize(9);
	quest::modifynpcstat("min_hit",70);
	quest::modifynpcstat("max_hit",120);
	quest::setnexthpevent(50);
} #Closing the event early
if($hpevent==50)
{
	quest::shout("Guards!");
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();
	quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
	quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
} Should be:
 
	Code: sub EVENT_HP {
if ($hpevent == 75) {
	quest::emote("quaffs a magical elixir.");
	quest::shout("Now you will die!");
	quest::npcsize(9);
	quest::modifynpcstat("min_hit",70);
	quest::modifynpcstat("max_hit",120);
	quest::setnexthpevent(50);
}
if ($hpevent == 50) {
	quest::shout("Guards!");
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();
	quest::spawn2(11174,0,0,$x+5,$y+5,$z,$h);
	quest::spawn2(11175,0,0,$x+5,$y-5,$z,$h);
}
} That should work for ya
				__________________ 
				Bront -Server Admin/Owner and Lead Quest Dev for Kildrukaun's Prophecy 
http://kpemu.com/ |  
 
  |  |  |  |  
	
		
	
	
	| 
			
			 
			
				03-04-2014, 11:40 AM
			
			
			
		 |  
	| 
		
			
			| Dragon |  | 
					Join Date: May 2010 
						Posts: 965
					      |  |  
	| 
 Additionally, there is no reason to create local variables for xyzh. They are already set to the values you are setting them to. Just remove those lines. |  
	
		
	
	
	| 
			
			 
			
				03-05-2014, 11:06 AM
			
			
			
		 |  
	| 
		
			
			| Fire Beetle |  | 
					Join Date: Dec 2007 Location: home 
						Posts: 13
					      |  |  
	| 
 Thanks a lot!  That fixed the event.  And thanks for the additional pointers, sorvani.  I'll try and clean my script up a little. |  
	
		
	
	
	| 
			
			 
			
				03-05-2014, 06:02 PM
			
			
			
		 |  
	| 
		
			
			| Dragon |  | 
					Join Date: May 2010 
						Posts: 965
					      |  |  
	| 
 What you did is littered all over the the quest code, so it is understandable where you got it from. |  
	
		
	
	
	
	
	| 
	|  Posting Rules |  
	| 
		
		You may not post new threads You may not post replies You may not post attachments You may not edit your posts 
 HTML code is Off 
 |  |  |  All times are GMT -4. The time now is 08:21 AM.
 
 |  |  
    |  |  |  |  
    |  |  |  |  
     |  |  |  |  
 |  |