|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
|
|
|
02-14-2013, 09:17 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
tested for syntax, not functionality.
Code:
# array of playable class long names
use constant CLASS_L => qw(
Unknown Warrior Cleric Paladin Ranger Shadowknight Druid Monk Bard Rogue
Shaman Necromancer Wizard Magician Enchanter Beastlord Berserker
);
# saylink
my $buffs = quest::saylink( "buffs", 1 );
# hashref containing buffs offered depening on the class of the npc
my $data = {
Enchanter => {
greet => "I have the $buffs for your mind.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Breeze", 697, 25 ],
[ "Clarity", 174, 50 ],
[ "Clarity II", 1693, 200 ],
[ "Alacrity", 170, 10 ],
[ "Augment", 1729, 30 ],
[ "Aanya's Quickening", 1708, 100 ],
[ "Rune I", 481, 5 ],
],
},
Necromancer => {
greet => "Souls and $buffs.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Dead Men Floating", 1391, 10 ],
],
},
};
# get class-specific stuff for this npc
my $npcClass = (CLASS_L)[ $npc->GetClass() ];
my $greeting = $data->{$npcClass}->{greet};
my $buffList = $data->{$npcClass}->{buffs};
sub EVENT_SAY {
# matches hail
if ( $text =~ /hail/i ) { quest::say($greeting); }
# doesn't match hail, but does match something in buff list
elsif ( my @match = grep { ${$_}[0] =~ /$text/i } @{$buffList} ) {
# single, exact match in buff list.
if ( @match == 1 && $text eq $match[0][0] ) {
my ( $spellName, $spellID, $spellCost ) = @{ $match[0] };
$client->Message( 315,
"That will be ${spellCost}pp for $spellName." );
quest::setglobal( "buff", $text, 0, "M5" );
}
# more than one match in buff list. list them.
else { CanCast( \@match ); }
}
# defaut to listing all buffs this npc can cast.
else { CanCast($buffList); }
}
sub EVENT_ITEM {
my $correctMoney = 0;
# if client has selected a buff
if ( defined $qglobals{buff} ) {
# find the buff selected
foreach my $spell ( @{$buffList} ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
# if client gave the correct amount of money, cast the spell
next if $qglobals{buff} != $spellName || $platinum != $spellCost;
$client->Message( 315,
"Thank you for the ${spellCost}pp. Prepare for $spellName!" );
$npc->CastSpell( $spellID, $client->GetID() );
$correctMoney = 1;
quest::delglobal("buff");
last;
}
}
# incorrect amount of money given or no qglobal for buff found for client
if ( !$correctMoney && ( $copper || $silver || $gold || $platinum ) ) {
$client->Message( 315,
"I don't need these coins. You may have them back." );
quest::givecash( $copper, $silver, $gold, $platinum );
}
}
sub CanCast {
foreach my $spell ( @{ +shift } ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
my $buffLink = quest::saylink( $spellName, 1 );
$client->Message( 315,
"I can cast $buffLink on you for ${spellCost}pp." );
}
}
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
|
|
|
02-14-2013, 09:42 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
I am trying, i cannot get it to work in game. I cannot see where sub EVENT_SAY calls the class specification to know which list to call. I am looking for another $npcClass to do the trick but obviously theres something i do not understand. Currently the NPC does not respond to a hail.
Edit: I dunno what I did, but I just got a response from a hail. It is blank, it is not pulling my $greeting = $data->{$npcClass}->{greet}; but its a start. Going to work on it some more, will update.
Edit2: I know what i did to fix, I took out the use 5.012 and use warnings ,I read you needed to use those for the given and when statements if thats the correct term. But noticed you took those out as well.
__________________
Last edited by Figback65; 02-14-2013 at 09:58 PM..
Reason: Working
|
02-14-2013, 09:53 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
everything that sets the class specific info for the current npc happens here (outside of any subroutine):
Code:
# get class-specific stuff for this npc
my $npcClass = (CLASS_L)[ $npc->GetClass() ];
my $greeting = $data->{$npcClass}->{greet};
my $buffList = $data->{$npcClass}->{buffs};
paste your full script (unless you're only using exactly what i posted).
nevermind. just saw your update.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
02-14-2013, 10:01 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
oops.
change this
Code:
# if client gave the correct amount of money, cast the spell
next if $qglobals{buff} != $spellName || $platinum != $spellCost;
to this
Code:
# if client gave the correct amount of money, cast the spell
next if $qglobals{buff} ne $spellName || $platinum != $spellCost;
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
02-14-2013, 10:18 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Ok change done. Still does not pull the greet. I am reading on arrays from the one of the books off the perl site you linked. lol light reading
Edit: But the npc is definately responding to the hail, he turns and does the Buffbot says. "
__________________
Last edited by Figback65; 02-14-2013 at 10:19 PM..
Reason: edit
|
02-14-2013, 10:30 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
probably something to do with that saylink quirkiness. looking at the source for that now.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
02-14-2013, 10:38 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Lol I changed
Code:
Necromancer => {
greet => [quest::say("Souls and $buffs.")],
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Dead Men Floating", 1391, 10 ],
Now the npc responds on hail and says Souls and Buffs(broke link) and on a 2nd line also still says the blank.
Edit: Getting closer!
__________________
Last edited by Figback65; 02-14-2013 at 10:38 PM..
Reason: woot
|
02-14-2013, 10:54 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Well when I had only changed the necro greet, it worked, then i changed the ench also and repopped the zone to spawn the buffbot as ench, zone.exe crashes. had to take the quest::say out.
__________________
|
|
|
|
02-14-2013, 10:58 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
that syntax is wrong, but it was good effort. this moves all of the calls to quest::saylink into EVENT_SAY per notes here:
http://www.eqemulator.net/wiki/wikka.php?wakka=SayLink
Code:
# array of playable class long names
use constant CLASS_L => qw(
Unknown Warrior Cleric Paladin Ranger Shadowknight Druid Monk Bard Rogue
Shaman Necromancer Wizard Magician Enchanter Beastlord Berserker
);
# hashref containing buffs offered depening on the class of the npc
my $data = {
Enchanter => {
greet => "I have the %s for your mind.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Breeze", 697, 25 ],
[ "Clarity", 174, 50 ],
[ "Clarity II", 1693, 200 ],
[ "Alacrity", 170, 10 ],
[ "Augment", 1729, 30 ],
[ "Aanya's Quickening", 1708, 100 ],
[ "Rune I", 481, 5 ],
],
},
Necromancer => {
greet => "Souls and %s.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Dead Men Floating", 1391, 10 ],
],
},
};
# get class-specific stuff for this npc
my $npcClass = (CLASS_L)[ $npc->GetClass() ];
my $greeting = $data->{$npcClass}->{greet};
my $buffList = $data->{$npcClass}->{buffs};
sub EVENT_SAY {
# saylink
my $buffs = quest::saylink( "buffs", 1 );
my $CanCast = sub {
foreach my $spell ( @{ +shift } ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
my $buffLink = quest::saylink( $spellName, 1 );
$client->Message( 315,
"I can cast $buffLink on you for ${spellCost}pp." );
}
};
# matches hail
if ( $text =~ /hail/i ) { quest::say( sprintf $greeting, $buffs); }
# doesn't match hail, but does match something in buff list
elsif ( my @match = grep { ${$_}[0] =~ /$text/i } @{$buffList} ) {
# single, exact match in buff list.
if ( @match == 1 && $text eq $match[0][0] ) {
my ( $spellName, $spellID, $spellCost ) = @{ $match[0] };
$client->Message( 315,
"That will be ${spellCost}pp for $spellName." );
quest::setglobal( "buff", $text, 0, "M5" );
}
# more than one match in buff list. list them.
else { $CanCast->( \@match ); }
}
# defaut to listing all buffs this npc can cast.
else { $CanCast->($buffList); }
}
sub EVENT_ITEM {
my $correctMoney = 0;
# if client has selected a buff
if ( defined $qglobals{buff} ) {
# find the buff selected
foreach my $spell ( @{$buffList} ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
# if client gave the correct amount of money, cast the spell
next if $qglobals{buff} ne $spellName || $platinum != $spellCost;
$client->Message( 315,
"Thank you for the ${spellCost}pp. Prepare for $spellName!" );
$npc->CastSpell( $spellID, $client->GetID() );
$correctMoney = 1;
quest::delglobal("buff");
last;
}
}
# incorrect amount of money given or no qglobal for buff found for client
if ( !$correctMoney && ( $copper || $silver || $gold || $platinum ) ) {
$client->Message( 315,
"I don't need these coins. You may have them back." );
quest::givecash( $copper||0, $silver||0, $gold||0, $platinum||0 );
}
}
the greetings have a %s where the saylink "buffs" will be inserted during the call to sprintf.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
|
|
|
02-14-2013, 11:07 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Use of uninitliazed value $greeting in sprintf line 51
__________________
|
02-14-2013, 11:18 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
that'll happen when the NPC is of a class that isn't covered in the hash ref.
to cover those issues, change this
Code:
my $greeting = $data->{$npcClass}->{greet};
to this
Code:
my $greeting = $data->{$npcClass}->{greet} || "Got %s?";
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
02-14-2013, 11:36 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
I only test the script on enchanter and necro bc that is the only 2 with a spelllist. I added what you suggested and i still get the error.
__________________
|
02-14-2013, 11:40 PM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
copy and paste the whole script you have now.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
|
|
|
02-14-2013, 11:56 PM
|
Discordant
|
|
Join Date: Aug 2009
Location: 2131231231
Posts: 255
|
|
Code:
# array of playable class long names
use constant CLASS_L => qw(
Unknown Warrior Cleric Paladin Ranger Shadowknight Druid Monk Bard Rogue
Shaman Necromancer Wizard Magician Enchanter Beastlord Berserker
);
# hashref containing buffs offered depening on the class of the npc
my $data = {
Enchanter => {
greet => "I have the %s for your mind.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Breeze", 697, 25 ],
[ "Clarity", 174, 50 ],
[ "Clarity II", 1693, 200 ],
[ "Alacrity", 170, 10 ],
[ "Augment", 1729, 30 ],
[ "Aanya's Quickening", 1708, 100 ],
[ "Rune I", 481, 5 ],
],
},
Necromancer => {
greet => "Souls and %s.",
buffs => [
[ "Bind Affinity", 35, 10 ],
[ "Dead Men Floating", 1391, 10 ],
],
},
};
# get class-specific stuff for this npc
my $npcClass = (CLASS_L)[ $npc->GetClass() ];
my $greeting = $data->{$npcClass}->{greet} || "Got %s?";
my $buffList = $data->{$npcClass}->{buffs};
sub EVENT_SAY {
# saylink
my $buffs = quest::saylink( "buffs", 1 );
my $CanCast = sub {
foreach my $spell ( @{ +shift } ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
my $buffLink = quest::saylink( $spellName, 1 );
$client->Message( 315,
"I can cast $buffLink on you for ${spellCost}pp." );
}
};
# matches hail
if ( $text =~ /hail/i ) { quest::say( sprintf $greeting, $buffs); }
# doesn't match hail, but does match something in buff list
elsif ( my @match = grep { ${$_}[0] =~ /$text/i } @{$buffList} ) {
# single, exact match in buff list.
if ( @match == 1 && $text eq $match[0][0] ) {
my ( $spellName, $spellID, $spellCost ) = @{ $match[0] };
$client->Message( 315,
"That will be ${spellCost}pp for $spellName." );
quest::setglobal( "buff", $text, 0, "M5" );
}
# more than one match in buff list. list them.
else { $CanCast->( \@match ); }
}
# defaut to listing all buffs this npc can cast.
else { $CanCast->($buffList); }
}
sub EVENT_ITEM {
my $correctMoney = 0;
# if client has selected a buff
if ( defined $qglobals{buff} ) {
# find the buff selected
foreach my $spell ( @{$buffList} ) {
my ( $spellName, $spellID, $spellCost ) = @{$spell};
# if client gave the correct amount of money, cast the spell
next if $qglobals{buff} ne $spellName || $platinum != $spellCost;
$client->Message( 315,
"Thank you for the ${spellCost}pp. Prepare for $spellName!" );
$npc->CastSpell( $spellID, $client->GetID() );
$correctMoney = 1;
quest::delglobal("buff");
last;
}
}
# incorrect amount of money given or no qglobal for buff found for client
if ( !$correctMoney && ( $copper || $silver || $gold || $platinum ) ) {
$client->Message( 315,
"I don't need these coins. You may have them back." );
quest::givecash( $copper||0, $silver||0, $gold||0, $platinum||0 );
}
}
__________________
|
|
|
|
02-15-2013, 12:07 AM
|
|
Dragon
|
|
Join Date: Dec 2009
Posts: 719
|
|
hrm... did you #repop after #reloadpl?
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
|
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 05:15 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|