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 09-10-2009, 04:23 PM
Pandaman
Fire Beetle
 
Join Date: Sep 2009
Posts: 28
Default (another) quest global question

Is it possible to set a quest global upon turning in an item?

Looked through forum post after forum post, as well as the wiki. And if there is, I am just not finding it. ;S
Reply With Quote
  #2  
Old 09-10-2009, 04:31 PM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

Not sure if you meant this, but setting a qglobal in sub EVENT_ITEM is working the same way as in sub EVENT_SAY.

like:
Code:
sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount,itemID => 1)) {

		quest::summonitem(itemID);
		quest::setglobal("$globalname",3,5,"F");
		}
	else {
		$client->Message(6, "$npcname looks confused." );
		plugin::return_items(\%itemcount);
		}
}
__________________
Reply With Quote
  #3  
Old 09-10-2009, 04:37 PM
Pandaman
Fire Beetle
 
Join Date: Sep 2009
Posts: 28
Default

That's exactly what I was looking for. For some reason, I can't seem to get my NPC to use the global when I hand him an item, and since it's a two-part quest.. it's bothersome.
Reply With Quote
  #4  
Old 09-10-2009, 04:45 PM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

Check if the NPC's qglobal flag is set to 1. I tend to forget about that.
__________________
Reply With Quote
  #5  
Old 09-10-2009, 07:09 PM
Pandaman
Fire Beetle
 
Join Date: Sep 2009
Posts: 28
Default

Hmm, seems to be something wrong.

If you still could assist me, i would greatly appreciate it. I just need to figure out globals, and then maybe it wont be such a pain in the ass.

Thanks

Basically, I want the texts that do not require the quest global to go out as normal, but if you hail him after you turn in the item, he would respond with the same thing he does after you turn in the item, and keep on going from there. the only problem is, it all works great, he won't do the second part once I turn it in, but as soon as I turn it in, everyone is able to do the second conversation.
Code:
sub EVENT_SAY
{
if($text=~/Hail/i)
 	{
 	quest::emote("jumps at your voice, and begins breathing heavily...");
 	$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
 	}

 elsif($text=~/Hail/i && rin_quest == 0)
	{
	$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
	}

 if($text=~/you're not crazy/i)
 	{
 	quest::emote("nods while looking at you...");
 	$client->Message(5, "Rin Distlmore whispers - Before I hit rock bottom I was a successful merchant right here in Freeport. I made my living crafting marvelous gems. One night, while I was closing up shop, I was approached by a strange [man].");
 	}

 if($text=~/what man?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - He never gave me a name. He handed me a list of [instructions], written in a strange language. They described in extraordinary detail how to gather materials for and craft the most remarkable of gems.");
 	}
 
 if($text=~/What instructions?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - I told him it would take countless platinum to make what he asked, and he walked away in a scuff. He told me where he got them, though. If you can [bring me the instructions], I can tell you where to get the required materials, and will craft this gem for you, free of charge.");
 	}

 if($text=~/i will bring you the instructions/i)
 	{
 	quest::emote("cackles, almost.. crazily...");
 	$client->Message(5, "Rin Distlmore whispers - Very good sir! There.. there is a slight [problem] though...");
 	}
 
 if($text=~/what problem?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - I overheard people talking. The man was eaten by none other than [Untel'Dak]. You must slay this beast and bring me the instructions he will surely have in... most unpleasant places.");
 	}
 
 if($text=~/untel'dak?/i)
 	{
 	quest::emote("shrugs");
 	$client->Message(5, "Rin Distlmore whispers - I wish I could tell you more, but I have never laid eyes on him. He is not of this world; he resides in a place where only nightmares dwell.");
	}

 if($text=~/i forgive you/i && $rin_quest == 0)
 	{
 	$client->Message(5, "Rin Distlmore whispers - You must be exceptionally strong. As promised, I will craft you the gem. You just have to bring me the [items] on the list.");
 	}
 
 if($text=~/what items?/i && $rin_quest == 0)
 	{
 	$client->Message(5, "Rin Distlmore whispers - To craft this item for you, I will need [three items] of extremely rare quality.");
 	}

 if($text=~/three items?/i && $rin_quest == 0)
 	{
 	$client->Message(5, "Rin Distlmore whispers - Yes. The [first] and [second] should come with only slight difficulty. The [third] you may have some trouble with.");
 	}
 
 if($text=~/the first/i && $rin_quest == 0)
 	{
 	$client->Message(5, "Rin Distlmore whispers - The first gem is held by Overking Bathezid. He will not part with it willingly. It is his most prized possesion. If power is what you seek, you will have to take it from him.");
 	}

 if($text=~/the second/i && $rin_quest == 0)
 	{
	$client->Message(5, "Rin Distlmore whispers - The second gem is held by The Junk Beast in the Plane of Innovation. The [clockwork] some how got a hold of it, and now are refusing to give it up.");
	}
 
 if($text=~/what clockwork?/i && $rin_quest == 0)
	{
	$client->Message(5, "Rin Distlmore whispers - The clockwork are mechanical beings that reside in the Plane of Innovation. They are ruthless, as they have no souls. Be careful in there.");
	}

 if($text=~/the third/i && $rin_quest == 0)
	{
	$client->Message(5, "Rin Distlmore whispers - The third gem is held by none other than Aerin'Dar. His lair lies in the Plane of Valor. Thousands have died before his claws. Be careful.");
	}

}

sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount, 1037 => 1)) {
		quest::setglobal("rin_quest",0,1,"F");
		$client->Message(5, "Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
	else {
		$client->Message(6, "Rin Distlemore looks confused" );
		plugin::return_items(\%itemcount);
		}
}
Reply With Quote
  #6  
Old 09-11-2009, 03:49 AM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

I can look into this tonight. just a quick guess till then, there were a missing $, and also setting qglobal to zero means making it undefined. I also set your qglobal to be visible zonewide (you can change it back to quest::setglobal("rin_quest",1,1,"F"); if you like).

Can't test it atm, but try this:
Code:
sub EVENT_SAY
{
if($text=~/Hail/i)
 	{
 	quest::emote("jumps at your voice, and begins breathing heavily...");
 	$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
 	}

 elsif($text=~/Hail/i && $rin_quest == 1)
	{
	$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
	}

 if($text=~/you're not crazy/i)
 	{
 	quest::emote("nods while looking at you...");
 	$client->Message(5, "Rin Distlmore whispers - Before I hit rock bottom I was a successful merchant right here in Freeport. I made my living crafting marvelous gems. One night, while I was closing up shop, I was approached by a strange [man].");
 	}

 if($text=~/what man?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - He never gave me a name. He handed me a list of [instructions], written in a strange language. They described in extraordinary detail how to gather materials for and craft the most remarkable of gems.");
 	}
 
 if($text=~/What instructions?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - I told him it would take countless platinum to make what he asked, and he walked away in a scuff. He told me where he got them, though. If you can [bring me the instructions], I can tell you where to get the required materials, and will craft this gem for you, free of charge.");
 	}

 if($text=~/i will bring you the instructions/i)
 	{
 	quest::emote("cackles, almost.. crazily...");
 	$client->Message(5, "Rin Distlmore whispers - Very good sir! There.. there is a slight [problem] though...");
 	}
 
 if($text=~/what problem?/i)
 	{
 	$client->Message(5, "Rin Distlmore whispers - I overheard people talking. The man was eaten by none other than [Untel'Dak]. You must slay this beast and bring me the instructions he will surely have in... most unpleasant places.");
 	}
 
 if($text=~/untel'dak?/i)
 	{
 	quest::emote("shrugs");
 	$client->Message(5, "Rin Distlmore whispers - I wish I could tell you more, but I have never laid eyes on him. He is not of this world; he resides in a place where only nightmares dwell.");
	}

 if($text=~/i forgive you/i && $rin_quest == 1)
 	{
 	$client->Message(5, "Rin Distlmore whispers - You must be exceptionally strong. As promised, I will craft you the gem. You just have to bring me the [items] on the list.");
 	}
 
 if($text=~/what items?/i && $rin_quest == 1)
 	{
 	$client->Message(5, "Rin Distlmore whispers - To craft this item for you, I will need [three items] of extremely rare quality.");
 	}

 if($text=~/three items?/i && $rin_quest == 1)
 	{
 	$client->Message(5, "Rin Distlmore whispers - Yes. The [first] and [second] should come with only slight difficulty. The [third] you may have some trouble with.");
 	}
 
 if($text=~/the first/i && $rin_quest == 1)
 	{
 	$client->Message(5, "Rin Distlmore whispers - The first gem is held by Overking Bathezid. He will not part with it willingly. It is his most prized possesion. If power is what you seek, you will have to take it from him.");
 	}

 if($text=~/the second/i && $rin_quest == 1)
 	{
	$client->Message(5, "Rin Distlmore whispers - The second gem is held by The Junk Beast in the Plane of Innovation. The [clockwork] some how got a hold of it, and now are refusing to give it up.");
	}
 
 if($text=~/what clockwork?/i && $rin_quest == 1)
	{
	$client->Message(5, "Rin Distlmore whispers - The clockwork are mechanical beings that reside in the Plane of Innovation. They are ruthless, as they have no souls. Be careful in there.");
	}

 if($text=~/the third/i && $rin_quest == 1)
	{
	$client->Message(5, "Rin Distlmore whispers - The third gem is held by none other than Aerin'Dar. His lair lies in the Plane of Valor. Thousands have died before his claws. Be careful.");
	}

}

sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount, 1037 => 1)) {
		quest::setglobal("rin_quest",1,5,"F");
		$client->Message(5, "Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
	else {
		$client->Message(6, "Rin Distlemore looks confused" );
		plugin::return_items(\%itemcount);
		}
}
__________________
Reply With Quote
  #7  
Old 09-11-2009, 04:08 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Just an FYI, but, you should never use quest globals like this:

Code:
 elsif($text=~/Hail/i && $rin_quest == 1)
By doing that, it will pull the qglobal information, but it will also save the value of $rin_quest as a variable in that particular script. This means that once one person that has that qglobal hails this NPC, the next person to hail it will also get the same response. This is because the NPC will then see $rin_quest as being equal to 1 since that is what the last player set the variable to on that particular script when they spoke to it.

To use qglobals the right way and ensure that you never run into issues that could cause you major headaches (believe me, I have been through this myself lol), then use them in this way instead:

Code:
 elsif($text=~/Hail/i && $qglobals{rin_quest} == 1)
Doing this will ensure 100% that the variable value does not get saved on the NPC. So, each player that interacts with it will get the actual results of the qglobals they have set instead of possibly gaining access to things that others have earned before them.

Also, I didn't review the full script you have there completely, but your elsif here would definitely be a problem:

Code:
if($text=~/Hail/i)
 	{
 	quest::emote("jumps at your voice, and begins breathing heavily...");
 	$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
 	}

 elsif($text=~/Hail/i && $rin_quest == 1)
	{
	$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
	}
An elsif will only trigger if the first "if" was false. In this case, if a player hails an NPC, the first one will always be true, so it will never get to the second elseif.

A better way to write this might be the following:

Code:
	if($text=~/Hail/i)
 	{
 	 	if($qglobals{rin_quest} == 1)
		{
			$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
		else
		{
 			quest::emote("jumps at your voice, and begins breathing heavily...");
 			$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
		}
	}
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-11-2009 at 04:14 AM..
Reply With Quote
  #8  
Old 09-11-2009, 04:14 AM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

Rather try this, I was sleepy :p
Code:
my $globalname = rin_quest;

sub EVENT_SAY {
if($text=~/Hail/i) {
 	quest::emote("jumps at your voice, and begins breathing heavily...");
 	$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
 	}
 if($text=~/Hail/i && $qglobals{$globalname} == 1) {
	$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
	}
 if($text=~/you're not crazy/i) {
 	quest::emote("nods while looking at you...");
 	$client->Message(5, "Rin Distlmore whispers - Before I hit rock bottom I was a successful merchant right here in Freeport. I made my living crafting marvelous gems. One night, while I was closing up shop, I was approached by a strange [man].");
 	}
 if($text=~/what man?/i) {
 	$client->Message(5, "Rin Distlmore whispers - He never gave me a name. He handed me a list of [instructions], written in a strange language. They described in extraordinary detail how to gather materials for and craft the most remarkable of gems.");
 	}
 
 if($text=~/What instructions?/i) {
 	$client->Message(5, "Rin Distlmore whispers - I told him it would take countless platinum to make what he asked, and he walked away in a scuff. He told me where he got them, though. If you can [bring me the instructions], I can tell you where to get the required materials, and will craft this gem for you, free of charge.");
 	}

 if($text=~/i will bring you the instructions/i) {
 	quest::emote("cackles, almost.. crazily...");
 	$client->Message(5, "Rin Distlmore whispers - Very good sir! There.. there is a slight [problem] though...");
 	}
 
 if($text=~/what problem?/i) {
 	$client->Message(5, "Rin Distlmore whispers - I overheard people talking. The man was eaten by none other than [Untel'Dak]. You must slay this beast and bring me the instructions he will surely have in... most unpleasant places.");
 	}
 
 if($text=~/untel'dak?/i) {
 	quest::emote("shrugs");
 	$client->Message(5, "Rin Distlmore whispers - I wish I could tell you more, but I have never laid eyes on him. He is not of this world; he resides in a place where only nightmares dwell.");
	}
 if($text=~/i forgive you/i && $qglobals{$globalname} == 1) {
 	$client->Message(5, "Rin Distlmore whispers - You must be exceptionally strong. As promised, I will craft you the gem. You just have to bring me the [items] on the list.");
 	}
 if($text=~/what items?/i && $qglobals{$globalname} == 1) {
 	$client->Message(5, "Rin Distlmore whispers - To craft this item for you, I will need [three items] of extremely rare quality.");
 	}
 if($text=~/three items?/i && $qglobals{$globalname} == 1) {
 	$client->Message(5, "Rin Distlmore whispers - Yes. The [first] and [second] should come with only slight difficulty. The [third] you may have some trouble with.");
	} 
 if($text=~/the first/i && $qglobals{$globalname} == 1) {
 	$client->Message(5, "Rin Distlmore whispers - The first gem is held by Overking Bathezid. He will not part with it willingly. It is his most prized possesion. If power is what you seek, you will have to take it from him.");
 	}
 if($text=~/the second/i && $qglobals{$globalname} == 1) {
	$client->Message(5, "Rin Distlmore whispers - The second gem is held by The Junk Beast in the Plane of Innovation. The [clockwork] some how got a hold of it, and now are refusing to give it up.");
	} 
 if($text=~/what clockwork?/i && $qglobals{$globalname} == 1) {
	$client->Message(5, "Rin Distlmore whispers - The clockwork are mechanical beings that reside in the Plane of Innovation. They are ruthless, as they have no souls. Be careful in there.");
	}
 if($text=~/the third/i && $qglobals{$globalname} == 1) {
	$client->Message(5, "Rin Distlmore whispers - The third gem is held by none other than Aerin'Dar. His lair lies in the Plane of Valor. Thousands have died before his claws. Be careful.");
	}
}

sub EVENT_ITEM {
	if (plugin::check_handin(\%itemcount, 1037 => 1)) {
		quest::setglobal("$globalname",1,5,"F");
		$client->Message(5, "Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
	else {
		$client->Message(6, "Rin Distlemore looks confused" );
		plugin::return_items(\%itemcount);
		}
}
__________________
Reply With Quote
  #9  
Old 09-11-2009, 04:14 AM
Lillu
Hill Giant
 
Join Date: Sep 2008
Posts: 204
Default

Trev beats me as always hehe
__________________
Reply With Quote
  #10  
Old 09-11-2009, 07:25 AM
Pandaman
Fire Beetle
 
Join Date: Sep 2009
Posts: 28
Default

Thanks a ton folks! I really appreciate it. Quest globals are a pain in the ass to me, but this was a big help.
Reply With Quote
  #11  
Old 09-11-2009, 08:02 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

Quote:
Originally Posted by trevius View Post
A better way to write this might be the following:

Code:
	if($text=~/Hail/i)
 	{
 	 	if($qglobals{rin_quest} == 1)
		{
			$client->Message(5, ("Rin Distlmore whispers - I am so sorry! I should never have sent you to that place! Can you ever [forgive me]?");
		}
		else
		{
 			quest::emote("jumps at your voice, and begins breathing heavily...");
 			$client->Message(5, "Oh, it's just you. I bet [you think I'm crazy] too, huh? Everyone thinks I'm crazy!");
		}
	}
Just to caveat, you should also check if the global is defined before making a == check.
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
Reply With Quote
  #12  
Old 09-11-2009, 11:06 AM
Congdar
Developer
 
Join Date: Jul 2007
Location: my own little world
Posts: 751
Default

Quote:
Originally Posted by joligario View Post
Just to caveat, you should also check if the global is defined before making a == check.
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
Checking if the global is defined first is good practice. Not doing that will get your log files filled up with perl messages about undefined variable use. The script will still work if you don't check, but when an actual error happens and you need to study the log files, it's nice to not have to wade through Perl error messages that aren't related to the error you are looking for.

In this case where all you are doing is setting a flag once, the second part is not needed.
Code:
if(defined($qglobals{rin_quest}))
is the same as
Code:
if(defined($qglobals{rin_quest}) && $qglobals{rin_quest} == 1)
The second part would only be needed if you were to use the global for further questing and updating the qglobal value to 2, 3, etc.


Additionally, organization of the code helps readability for others should the script need to be updated to extend the quest or change it.
Code:
EVENT_SAY {

if(defined($qglobals{rin_quest}) {

    if($text=~/Hail/i) {
        quest::say("This is the flagged conversation section");
    }

}
else {

    if($text=~/Hail/i) {
        quest::say("This is the NON-flagged conversation section");
    }

}
}
then if later you want to extend the quest using the same qglobal
Code:
EVENT_SAY {

if(defined($qglobals{rin_quest}) {

    if($qglobals{rin_quest} == 1) {

        if($text=~/Hail/i) {
            quest::say("This is the flagged==1 conversation section");
        }
    }

    if($qglobals{rin_quest} == 2) {

        if($text=~/Hail/i) {
            quest::say("This is the flagged==2 conversation section");
        }
    }

}
else {

    if($text=~/Hail/i) {
        quest::say("This is the NON-flagged conversation section");
    }

}
}

Last edited by Congdar; 09-11-2009 at 11:20 AM..
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 02:06 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