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 04-25-2011, 10:46 PM
Packet's Avatar
Packet
Hill Giant
 
Join Date: Jun 2010
Location: Omicron Percei-8
Posts: 106
Default Variable Catastrophy

So I know there is a much easier way to do this however I haven't discovered a method of using an array for $hasitem to check for a list of items in a players inventory. Anyways, with that being said I have an issue which I just don't seem to see where the problem is...

Code:
sub EVENT_SPAWN {
        $x = $npc->GetX();
        $y = $npc->GetY();
	$range = 70;
        quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range);
}

sub EVENT_ENTER
{
if($ulevel == 1) {
$n = $client->GetName();
quest::movepc(152, -200, 36, -55, -125);
$client->Message(15, "You have not become attuned yet. Speak with Gharj at the top of the platform.");
}
elsif($hasitem{1079} && $ulevel <= 10) {
$npc->SendAppearanceEffect(180);
quest::doanim(66);
quest::say("Hey, you! $name! Come over here... You cannot use the portal without a [shard]! Come over here!");
}
}


sub EVENT_SAY
{
	my $fitem = 9991;
	my $qsitem = 9992;
	my $hitem = 9993;
	my $eitem = 9994;
	my $gitem = 1079;
	my $feitem = 9996;
	my $nitem = 9997;
	my $kitem = 9998;
	my $gritem = 9999;
	my $oitem = 10000;
	my $ritem = 10001;
	my $aitem = 10002;
	my $fvar = quest::saylink(Freeport);
	my $qvar = quest::saylink(Qeynos);
	my $hvar = quest::saylink(Halas);
	my $evar = quest::saylink(Erudin);
	my $gvar = quest::saylink(GreaterFaydark);
	my $fevar = quest::saylink(Felwithe);
	my $nvar = quest::saylink(Neriak);
	my $kvar = quest::saylink(Kaladim);
	my $grvar = quest::saylink(Grobb);
	my $ovar = quest::saylink(Oggok);
	my $rvar = quest::saylink(Rivervale);
	my $akvar = quest::saylink(Akanon);

if($text=~/hail/i && $hasitem{$fitem} || $hasitem{$qsitem} || $hasitem{$hitem} || $hasitem{$eitem} || $hasitem{$gitem} || $hasitem{$feitem} || $hasitem{$nitem} || $hasitem{$kitem} || $hasitem{$gritem} || $hasitem{$oitem} || $hasitem{$ritem} || $hasitem{$aitem})
{
quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
}
else
{
if($text=~/hail/i && $ulevel == 2) 
{
quest::say("Greetings, $name! I am Thiddian and I have the [shards] necessary for you to travel back home. There are rifts throughout Norrath that only those whom have been attuned can see. Simply walk into one and you can return here.");
}
if($text=~/shard/i) {
quest::doanim(55);
quest::say("Ehhh.. ehm... The shards are what allow us to travel through these soul portals. The thing is, you can only have one. No one has ever stepped into the rift with two shards and I dont think we should try. Anyways, thats enough babbling from me... Please choose your land.");
$client->Message(15, "Select only ONE of the following:");
$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
if($text=~/Freeport/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($fitem);
{
if($text=~/Qeynos/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($qsitem);
}
if($text=~/Halas/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($hitem);
}
if($text=~/Erudin/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($eitem);
}
if($text=~/Greater/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($gitem);
}
if($text=~/Felwithe/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($feitem);
}
if($text=~/Neriak/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($nitem);
}
if($text=~/Kaladim/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($kitem);
}
if($text=~/Grobb/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($gritem);
}
if($text=~/Oggok/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($oitem);
}
if($text=~/Rivervale/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($ritem);
}
if($text=~/anon/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($aitem);
}
}
}
This quest is "still a work in progress" however it worked until I added the following sniplet:

Code:
if($text=~/hail/i && $hasitem{$fitem} || $hasitem{$qsitem} || $hasitem{$hitem} || $hasitem{$eitem} || $hasitem{$gitem} || $hasitem{$feitem} || $hasitem{$nitem} || $hasitem{$kitem} || $hasitem{$gritem} || $hasitem{$oitem} || $hasitem{$ritem} || $hasitem{$aitem})
{
quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
}
else
{
I am going to assume that the problem probably does lye in my ridiculous $hasitem if statement... I am not necessarily looking for the answer but a nudge in the right direction. What I want to happen here is when a player hails the npc, I want it to check for an array of items. If it detects any of the items, it will spit out "quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");" otherwise it will continue on with the rest of the script. I get absolutely 0 errors and the npc simply doesn't respond. The proximity works fine on enter so the problem isn't before my SAY event.
__________________
Packet Loss
Current project:
Dark Horizons

Formerly "Richardo"
Reply With Quote
  #2  
Old 04-25-2011, 11:43 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,490
Default

Did you try enclosing all your $hasitems inside parenteses?

if ($text=~/hail/i && (the rest here)) {
Reply With Quote
  #3  
Old 04-26-2011, 06:38 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Code:
my $akvar = quest::saylink(Akanon);
You can't use unquoted strings for quest::saylink(). Put quotes around them like this:

Code:
my $akvar = quest::saylink("Akanon");
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 04-26-2011, 11:53 AM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 541
Default

There were many problems, instead of pointing them all out, I rewrote the script. BTW, I'm not sure if the indents were lost on copy/paste or you just dont use them but until you can write a script without needing to debug it, you should keep things as orderly as possible(and if not for yourself, especially when asking others to look through your code).

Code:
sub EVENT_SPAWN {
	my $x = $npc->GetX();
	my $y = $npc->GetY();
	my $range = 70;
	quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range);
}

sub EVENT_ENTER
{
	if($ulevel == 1) {
		quest::movepc(152, -200, 36, -55, -125);
		$client->Message(15, "You have not become attuned yet. Speak with Gharj at the top of the platform.");
	}
	elsif($hasitem{1079} && $ulevel <= 10) {
		$npc->SendAppearanceEffect(180);
		quest::doanim(66);
		$client->Message(0, "Hey, you! $name! Come over here... You cannot use the portal without a [shard]! Come over here!");
	}
}

sub EVENT_SAY
{
	my @items = qw(9991 9992 9993 9994 1079 9996 9997 9998 9999 10000 10001 10002);
	my @links = qw(Freeport Qeynos Halas Erudin GreaterFaydark Felwithe Neriak Kaladim Grobb Oggok Rivervale Akanon);

	if($text=~/hail/i) {
		if($ulevel == 2) {
			quest::say("Greetings, $name! I am Thiddian and I have the [shards] necessary for you to travel back home. There are rifts throughout Norrath that only those whom have been attuned can see. Simply walk into one and you can return here.");
		}
		foreach $item(@items) {
			if($hasitem{$item}) {
				quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
			}
		}
	}
	elsif($text=~/shard/i) {
		quest::doanim(55);
		quest::say("Ehhh.. ehm... The shards are what allow us to travel through these soul portals. The thing is, you can only have one. No one has ever stepped into the rift with two shards and I dont think we should try. Anyways, thats enough babbling from me... Please choose your land.");
		$client->Message(15, "Select only ONE of the following:");
		my $link_string = "";
		my $temp_link = "";
		foreach $link(@links) {
			$temp_link = quest::saylink("$link");
			$link_string = $link_string . $temp_link;
		}
		$client->Message(15, "$link_string");
	}
	else {
		my $counter = 0;
		foreach $link(@links) {
			if($text=~/$link/i) {
				quest::doanim(67);
				$npc->SendAppearanceEffect(180);
				quest::summonitem($items[$counter]);
			}
			$counter++;
		}
	}
}
Possibly the link loop won't work like that, havent tested it in a while and cant remember, however its pretty easy to modify it if it doesnt work as intended.
Reply With Quote
  #5  
Old 04-26-2011, 11:59 AM
Packet's Avatar
Packet
Hill Giant
 
Join Date: Jun 2010
Location: Omicron Percei-8
Posts: 106
Default

SOLVED!


Used an old perl syntax checker ( http://ult-tex.net/tools/ultra/line_count.pl ) and found a few broken statements and typos. I do apologize for wasting you guys time but thanks again for the tips. If you have ANY criticism, that is exactly what I am looking for to broaden my undertanding of perl (which is why I am doing this in the first place). Also, if anyone is interested - $hasitem{} only checks masterslots such as cursor, equipped items and main item slots but it will not check bank or bag slots. Check out the link below if you want to do that... I am going to try it out, hopefully it works out.

http://www.eqemulator.org/forums/showthread.php?t=33018

Couple of things to point out. in the prior script, I used elsif instead of if on everything following } else { if($blah blah.. Didn't like that too much.

Here is the revised version:

Code:
sub EVENT_SPAWN {
        $x = $npc->GetX();
        $y = $npc->GetY();
	$range = 70;
        quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range);
}

sub EVENT_ENTER {
if($ulevel == 1) {
$n = $client->GetName();
quest::movepc(152, -200, 36, -55, -125);
$client->Message(15, "You have not become attuned yet. Speak with Gharj at the top of the platform.");
}
elsif($hasitem{1079} && $ulevel <= 10) {
$npc->SendAppearanceEffect(180);
quest::doanim(66);
quest::say("Hey, you! $name! Come over here... You cannot use the portal without a [shard]! Come over here!");
}
}


sub EVENT_SAY {
	my $fitem = 9991;
	my $qsitem = 9992;
	my $hitem = 9993;
	my $eitem = 9994;
	my $gitem = 1079;
	my $feitem = 9996;
	my $nitem = 9997;
	my $kitem = 9998;
	my $gritem = 9999;
	my $oitem = 10000;
	my $ritem = 10001;
	my $aitem = 10002;
	my $fvar = quest::saylink("Freeport");
	my $qvar = quest::saylink("Qeynos");
	my $hvar = quest::saylink("Halas");
	my $evar = quest::saylink("Erudin");
	my $gvar = quest::saylink("GreaterFaydark");
	my $fevar = quest::saylink("Felwithe");
	my $nvar = quest::saylink("Neriak");
	my $kvar = quest::saylink("Kaladim");
	my $grvar = quest::saylink("Grobb");
	my $ovar = quest::saylink("Oggok");
	my $rvar = quest::saylink("Rivervale");
	my $akvar = quest::saylink("Akanon");

#removed $text=~/hail/i && ()
if($hasitem{$fitem} || $hasitem{$qsitem} || $hasitem{$hitem} || $hasitem{$eitem} || $hasitem{$gitem} || $hasitem{$feitem} || $hasitem{$nitem} || $hasitem{$kitem} || $hasitem{$gritem} || $hasitem{$oitem} || $hasitem{$ritem} || $hasitem{$aitem})
{
quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
}
else
{
if($text=~/hail/i) 
{
quest::say("Greetings, $name! I am Thiddian and I have the [shards] necessary for you to travel back home. There are rifts throughout Norrath that only those whom have been attuned can see. Simply walk into one and you can return here.");
}
if($text=~/shard/i) {
quest::doanim(55);
quest::say("Ehhh.. ehm... The shards are what allow us to travel through these soul portals. The thing is, you can only have one. No one has ever stepped into the rift with two shards and I dont think we should try. Anyways, thats enough babbling from me... Please choose your land.");
$client->Message(15, "Select only ONE of the following:");
$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
if($text=~/Freeport/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($fitem);
}
if($text=~/Qeynos/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($qsitem);
}
if($text=~/Halas/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($hitem);
}
if($text=~/Erudin/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($eitem);
}
if($text=~/Greater/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($gitem);
}
if($text=~/Felwithe/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($feitem);
}
if($text=~/Neriak/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($nitem);
}
if($text=~/Kaladim/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($kitem);
}
if($text=~/Grobb/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($gritem);
}
if($text=~/Oggok/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($oitem);
}
if($text=~/Rivervale/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($ritem);
}
if($text=~/anon/i) {
##quest::say($hresp);
quest::doanim(67);
$npc->SendAppearanceEffect(180);
quest::summonitem($aitem);
}
}
}
__________________
Packet Loss
Current project:
Dark Horizons

Formerly "Richardo"
Reply With Quote
  #6  
Old 04-26-2011, 02:28 PM
Packet's Avatar
Packet
Hill Giant
 
Join Date: Jun 2010
Location: Omicron Percei-8
Posts: 106
Default

Cleaned it up a 'little bit'. This is all experimentation for me and I am posting the final script for reference if anyone ever needs help searching for an array of items in a players inventory. If I knew anything about creating a hash and literal array, this script probably would have been a lot smaller and less cluttered. Anyways, here it is.

If anyone has critisism and cares to elaborate, I would be deeply grateful.

Code:
#Packet Loss
#This is my experimentation with inventory checks via proximity and say event.
		#each of these items id's are just place holders - they run through the hasitem checks in all player inventory slots (incl. bank)
		my $fitem = 9991; 
		my $qsitem = 9992;
		my $hitem = 9993;
		my $eitem = 9994;
		my $gitem = 1079;
		my $feitem = 9996;
		my $nitem = 9997;
		my $kitem = 9998;
		my $gritem = 9999;
		my $oitem = 10000;
		my $ritem = 10001;
		my $aitem = 10002;


sub EVENT_SPAWN {
        $x = $npc->GetX();
        $y = $npc->GetY();
		$range = 70;
		#ty akkadius - the $range makes setting proximity easily.
        quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range);
	}

sub EVENT_ENTER {

		if($ulevel == 1) {
	quest::movepc(152, -200, 36, -55, -125);
	$client->Message(15, "You have not become attuned yet. Speak with Gharj at the top of the platform.");
}
if((plugin::check_hasitem($client, $fitem) || plugin::check_hasitem($client, $qsitem) || plugin::check_hasitem($client, $hitem) || plugin::check_hasitem($client, $eitem) || plugin::check_hasitem($client, $gitem) || plugin::check_hasitem($client, $feitem) || plugin::check_hasitem($client, $nitem) || plugin::check_hasitem($client, $kitem) || plugin::check_hasitem($client, $gritem) || plugin::check_hasitem($client, $oitem) || plugin::check_hasitem($client, $ritem) || plugin::check_hasitem($client, $aitem)))
{
	quest::me("Thiddian waves at you.");
	quest::doanim(29);
}
	else
{
		if($ulevel == 2) {
	$npc->SendAppearanceEffect(180);
	quest::doanim(66);
	quest::say("Hey, you! $name! Come over here... You cannot use the portal without a [shard]!!");
}
		if($ulevel >= 3) {
	quest::say("Hey ther $name! Could I interest you in a [shard]? I see that you do not have one!");
	quest::doanim(29);
		}
	}
}

sub EVENT_SAY {
		my $fvar = quest::saylink("Freeport");
		my $qvar = quest::saylink("Qeynos");
		my $hvar = quest::saylink("Halas");
		my $evar = quest::saylink("Erudin");
		my $gvar = quest::saylink("GreaterFaydark");
		my $fevar = quest::saylink("Felwithe");
		my $nvar = quest::saylink("Neriak");
		my $kvar = quest::saylink("Kaladim");
		my $grvar = quest::saylink("Grobb");
		my $ovar = quest::saylink("Oggok");
		my $rvar = quest::saylink("Rivervale");
		my $akvar = quest::saylink("Akanon");
		#my $hresp = ("Here you go!");
		#my $hresp = quest::ChooseRandom("Here you go!", "There!", "Here, take this.");
		#second option for random responses. Both vars disabled by default

if((plugin::check_hasitem($client, $fitem) || plugin::check_hasitem($client, $qsitem) || plugin::check_hasitem($client, $hitem) || plugin::check_hasitem($client, $eitem) || plugin::check_hasitem($client, $gitem) || plugin::check_hasitem($client, $feitem) || plugin::check_hasitem($client, $nitem) || plugin::check_hasitem($client, $kitem) || plugin::check_hasitem($client, $gritem) || plugin::check_hasitem($client, $oitem) || plugin::check_hasitem($client, $ritem) || plugin::check_hasitem($client, $aitem)))
{
	quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
}
	else
{
		#first time getting a shard.
		if($text=~/hail/i && $ulevel == 2) 
{
	quest::say("Greetings, $name! I am Thiddian and I have the [shards] necessary for you to travel back home. There are rifts throughout Norrath that only those whom have been attuned can see. Simply walk into one and you can return here.");
}
		if($text=~/hail/i && $ulevel >= 3) {
	quest::say("Welcome back $name! Could I interest you in a [shard]?");
}
		#newb shard response
		if($text=~/shard/i && $ulevel == 2) {
	quest::doanim(70);
	quest::say("Ehhh.. ehm... The shards are what allow us to travel through these soul portals. The thing is, you can only have one. No one has ever stepped into the rift with two shards and I dont think we should try. Anyways, thats enough babbling from me... Please choose your land.");
	$client->Message(15, "Select only ONE of the following:");
	$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
		#no more explanations needed - greet!
		if($text=~/shard/i && $ulevel >= 3) {
	quest::doanim(67);
	$client->Message(15, "Select only ONE of the following:");
	$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
		if($text=~/Freeport/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($fitem);
}
		if($text=~/Qeynos/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($qsitem);
}
		if($text=~/Halas/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($hitem);
}
		if($text=~/Erudin/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($eitem);
}
		if($text=~/Greater/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($gitem);
}
		if($text=~/Felwithe/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($feitem);
}
		if($text=~/Neriak/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($nitem);
}
		if($text=~/Kaladim/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($kitem);
}
		if($text=~/Grobb/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($gritem);
}
		if($text=~/Oggok/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($oitem);
}
		if($text=~/Rivervale/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($ritem);
}
		if($text=~/anon/i) {
	#quest::say($hresp);
	quest::doanim(43);
	$npc->SendAppearanceEffect(180);
	quest::summonitem($aitem);
		}
	}
}
The point of this script is to keep players from having multiple items in the list without using global variables (may have been wise to use gbvar but I don't know anything about that yet. Still a little confused on that concept.
__________________
Packet Loss
Current project:
Dark Horizons

Formerly "Richardo"
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:19 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