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 02-05-2010, 05:53 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Most likely you are using the old way to access qglobals. You should be checking them by doing something like $qglobals{myglobalname} instead of just $myglobalname. Using the new way should work 100% of the time.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 02-05-2010, 06:25 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Here is the Quest

Code:
#!/usr/bin/perl
 
# Level => (Cost, Buff set)
# Hash is iterated over, and as soon as player level is >= to hash level,
# cost is applied
my %pbuffs =
(
	65 => { cost => 1000, set => 'high' },
	55 => { cost => 500,  set => 'general' },
	45 => { cost => 450,  set => 'general' },
	30 => { cost => 300,  set => 'general' },
	20 => { cost => 150,  set => 'general' },
	0  => { cost => 0,    set => 'general' }
);

# Buff sets. Referenced by pbuffs
my %buffset =
(
	general => [2112, 2517, 8199, 1939, 2517],
	high    => [2112, 2517, 278,  13,   5257, 5396, 1939]
);

# Returns pbuff value for level
# Args: level
sub getpb
{
	my $level = shift;

	foreach $key (reverse sort keys %pbuffs)
	{
		if ($level >= $key)
		{
			return $pbuffs{$key};
		}
	}
}

# Returns buff cost for level
# Args: level
sub getbuffcost
{
	return getpb(shift)->{'cost'};
}

# Casts buffs given a name
# Args: array of spells
sub castspells
{
	foreach $spell (@_)
	{
		quest::selfcast($spell);
	}
}

# Returns buff set for level
sub getbuffset
{
	return @{$buffset{getpb(shift)->{'set'}}};
}

sub EVENT_SPAWN
{
quest::settimer(1,1);
}

sub EVENT_SAY 
{
	my $saylink1 = quest::saylink("buffs");
	my $saylink2 = quest::saylink("pay");
	my $cost = getbuffcost($ulevel);
	my @buffs = getbuffset($ulevel);
	my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if (defined $qglobals{hkchinese})
{
	if ($text =~ /hail/i)
	{
		quest::say("Ru guo nin xu yao yi xie buff [$saylink1], gao shu wo, dang ran, nin ke
neng xu yao fu dian dai jia [$saylink2].");
		$npc->SetAppearance(0);
		quest::settimer(1,10);
	}
	elsif ($text =~ /buffs/i)
	{
		if ($credit < $cost)
		{
			quest::say("Xiao gui, ni xiang pian guo wo ma? mei na me rong yi! ni xu yao zhi shao"
				. ($cost - $credit) . " PP.");
		}
		else
		{
			castspells(@buffs);
 
			# Only record and say this stuff if there was a cost
			if ($cost > 0)
			{
				$credit -= $cost;
				quest::setglobal('buffcredit', "$credit", 5, 'F');
				quest::say("Xie xie nin, $name! zai wo zhe li, nin hai sheng xia $credit PP ke yi 
buff.");
			}
		}
	}
	elsif ($text =~ /pay/i)
	{
		if ($cost > 0)
		{
			quest::say("Rang wo kan kan, $race.. nin zui shao xu yao $cost PP, bu neng zai 
jiang jia le.");
			quest::say("Nin hai you $credit PP zai wo zhe li, ru guo nin da suan zai cun yi
xie,"
				. " zhi jie ba PP gei wo jiu ke yi le");
		}
		else
		{
			quest::say("Nin kan shang qu xiang ge nian qing ren, $name. mian fei!");
		}
	}
}
else
{
 
	if ($text =~ /hail/i)
	{
		quest::say("If you want some [$saylink1] just let me know.  Of course you may have to [$saylink2].");
		$npc->SetAppearance(0);
		quest::settimer(1,10);
	}
	elsif ($text =~ /buffs/i)
	{
		if ($credit < $cost)
		{
			quest::say("Phuh!  Are you trying to cheat me?  You need "
				. ($cost - $credit) . " more plat!");
		}
		else
		{
			castspells(@buffs);
 
			# Only record and say this stuff if there was a cost
			if ($cost > 0)
			{
				$credit -= $cost;
				quest::setglobal('buffcredit', "$credit", 5, 'F');
				quest::say("Thanks $name!  You have $credit left in credit.");
			}
		}
	}
	elsif ($text =~ /pay/i)
	{
		if ($cost > 0)
		{
			quest::say("Let's see, $race.. For you? A lowly $cost plat!");
			quest::say("You have $credit plat in credit.  If you want more credit,"
				. " just hand me some plat!");
		}
		else
		{
			quest::say("You look like a nice young $race, $name.  No charge for you!");
		}
	}
}
}
sub EVENT_ITEM
{
	my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
 if (defined $qglobals{hkchinese})
{
	if ($platinum > 0)
	{
		$credit += $platinum;
		quest::setglobal('buffcredit', "$credit", 5, 'F');
		quest::say("Xie xie $name! nin xian zai you $credit PP zai wo zhe li!");
	}
	else 
		{
		plugin::return_items(\%itemcount);
    		}
 }
else
{
	if ($platinum > 0)
	{
		$credit += $platinum;
		quest::setglobal('buffcredit', "$credit", 5, 'F');
		quest::say("Thank You $name! You now have $credit PP credit");
	}
	else 
		{
		plugin::return_items(\%itemcount);
    		}
}
}
Reply With Quote
  #3  
Old 02-05-2010, 06:52 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Hmm, from what I can tell, that looks ok to me. The only thing that stands out is that you use single quotes instead of double quotes for setting the name of your qglobals. I dunno what affect that might have, but I always use double quotes around the name of the qglobal.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply

Thread Tools
Display Modes

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:07 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3