Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 10-31-2013, 09:29 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default Custom 1 time NPC

This may be an odd request, but I was looking at creating an NPC that hands out a reward to the first 10 hails and then depops forever, however I have no idea how to write it.

The only way I know how to do it is to create 10 seperate npc id's all controlled by triggers, when #1 is hailed it depops and spawns #2 etc and once #10 is hailed he depops forever. The only issue is I have no way to keep one person from doing multiple hails unless I can have it check for the item in inventory first.

I guess I was just looking to see if someone had an easier way to do this.
Reply With Quote
  #2  
Old 10-31-2013, 09:33 PM
HnathBST
Sarnak
 
Join Date: Feb 2007
Location: Sunset Home
Posts: 71
Default

Quote:
Originally Posted by Maceblade View Post
This may be an odd request, but I was looking at creating an NPC that hands out a reward to the first 10 hails and then depops forever, however I have no idea how to write it.

The only way I know how to do it is to create 10 seperate npc id's all controlled by triggers, when #1 is hailed it depops and spawns #2 etc and once #10 is hailed he depops forever. The only issue is I have no way to keep one person from doing multiple hails unless I can have it check for the item in inventory first.

I guess I was just looking to see if someone had an easier way to do this.
I would say, create 1 npc. and use QGlobals to keep count of how many items he has handed out. right after he hands out his 10th item you depop him. I believe there is spawn tools in the quest perl. Though I don't know them or their syntax off the top of my head.

And, I would use an inventory check to make sure the person doesn't already have the item. I'm using QGlobals for a quest to hand out an armor package and it's a mess, I have a QGlobal for every PC that got an armor package on my server >.<
Reply With Quote
  #3  
Old 10-31-2013, 09:39 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default

Im weary on Qglobals bc I have yet to get it functioning with MaxCharLevel. I guess I could resort to a "flag" that would do it.

And thanks for the reply!
Reply With Quote
  #4  
Old 10-31-2013, 09:40 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

I have an idea, I'm going to put my server up really fast, write the code, and get back to you when I have it working or if I can't get it working.
Reply With Quote
  #5  
Old 10-31-2013, 09:43 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default

Thanks King!
Reply With Quote
  #6  
Old 10-31-2013, 09:58 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by Maceblade View Post
This may be an odd request, but I was looking at creating an NPC that hands out a reward to the first 10 hails and then depops forever, however I have no idea how to write it.

The only way I know how to do it is to create 10 seperate npc id's all controlled by triggers, when #1 is hailed it depops and spawns #2 etc and once #10 is hailed he depops forever. The only issue is I have no way to keep one person from doing multiple hails unless I can have it check for the item in inventory first.

I guess I was just looking to see if someone had an easier way to do this.
Something like this should work:

Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	my $CountToZero = (10 - $qglobals{"TenTimeEvent"});
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . $CountToZero . " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
You need to have qglobals enabled on the npc (Set to 1) and it is set at a global scope, meaning any NPC can grab this qglobal variable if you tried to fetch it.

He sets it once and when the value of the qglobal has been subtracted to 0, he no longer will make a sammich
Reply With Quote
  #7  
Old 10-31-2013, 10:02 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default

haha thanks Akk I will now test out this here sammich maker!
Reply With Quote
  #8  
Old 10-31-2013, 10:34 PM
HnathBST
Sarnak
 
Join Date: Feb 2007
Location: Sunset Home
Posts: 71
Default

Quote:
Originally Posted by Akkadius View Post
Something like this should work:

Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	my $CountToZero = (10 - $qglobals{"TenTimeEvent"});
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . $CountToZero . " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
You need to have qglobals enabled on the npc (Set to 1) and it is set at a global scope, meaning any NPC can grab this qglobal variable if you tried to fetch it.

He sets it once and when the value of the qglobal has been subtracted to 0, he no longer will make a sammich
I think you have $CountToZero incorrect. If the Qglobal is set to 10, $CountToZero = 10 - 10 = 0. So the NPC would say "I'm only doing it 0 more times". Unless my logic is wrong.

I would say:
Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . ( $qglobals{"TenTimeEvent"} - 1). " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
That eliminates the $CountToZero variable that was only used once for text anyway.
Reply With Quote
  #9  
Old 10-31-2013, 10:39 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default

H you were correct, only issue im having is that 1 person can bang out all 10 hails.
Reply With Quote
  #10  
Old 10-31-2013, 10:44 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Quote:
Originally Posted by Maceblade View Post
H you were correct, only issue im having is that 1 person can bang out all 10 hails.
Mace, I came up with a quick example for you - the count part was a simple mistake because I was thinking of something different before I got to the below section (quickly) but simply illustrating what you can do.

To limit 1 per person, you have to add additional checking. In this case I would create a character scoped (Type 5) qglobal to keep folks from being able to hail more than once from their character:

Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	my $CountToZero = ($qglobals{"TenTimeEvent"} - 1);
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEventChar"} == 1){
			quest::say("You already got your reward!");
		}
		elsif($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . $CountToZero . " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
			$client->SetGlobal("TenTimeEventChar", 1 , 5, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
I really suggest you read up on qglobals - they can be used often.
Reply With Quote
  #11  
Old 10-31-2013, 10:46 PM
Maceblade
Hill Giant
 
Join Date: Jun 2010
Posts: 231
Default

I wasnt complaining at all Akk I appreciate everyones help and this is working perfectly! Thank you everyone I have soo many uses for this now with the reroll
Reply With Quote
  #12  
Old 10-31-2013, 10:47 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Here, Entity Variables work just as well, make sure to set the NPC's qglobal to 1!

EDIT: Entity Variables reset upon #repop of the NPC.
Code:
sub EVENT_SAY
{
	if(!defined $qglobals{Won})
	{
		if($npc->GetEntityVariable("HailTest") >= 1 && $npc->GetEntityVariable("HailTest") <= 9)
		{
			if($text=~/Hail/i)
			{
				$npc->SetEntityVariable("HailTest", ($npc->GetEntityVariable("HailTest") + 1));
				quest::shout2("$name has hailed me, " . (10 - $npc->GetEntityVariable("HailTest")) . " more people can win!");
				quest::setglobal("Won", 1, 5, "F");
				#quest::givecash(Copper, Silver, Gold, Platinum);
				#quest::summonitem(1001, 1);
			}
		}
		elsif(!$npc->GetEntityVariable("HailTest"))
		{
			if($text=~/Hail/i)
			{
				$npc->SetEntityVariable("HailTest", 1);
				quest::shout2("$name has hailed me, " . (10 - $npc->GetEntityVariable("HailTest")) . " more people can win!");
				quest::setglobal("Won", 1, 5, "F");
				#quest::givecash(Copper, Silver, Gold, Platinum);
				#quest::summonitem(1001, 1);
			}
		}
		elsif($npc->GetEntityVariable("HailTest") > 9)
		{
			if($text=~/Hail/i)
			{
				$npc->Depop();
			}
		}
	}
	else
	{
		if($text=~/Hail/i)
		{
			plugin::Whisper("You may only win once!");
		}
	}
}
Reply With Quote
  #13  
Old 10-31-2013, 10:51 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Entity Variables don't persist beyond repop or zone, have to use something more persistent.
Reply With Quote
  #14  
Old 10-31-2013, 10:53 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Quote:
Originally Posted by Akkadius View Post
Entity Variables don't persist beyond repop or zone, have to use something more persistent.
The NPC cannot zone, but it can be repopped, I edited that in to my post.

EDIT: He could just set the NPC's respawn time to like 30 days or something so he could have time to delete it after the event ends.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 09:29 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3