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

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

Reply
 
Thread Tools Display Modes
  #31  
Old 02-15-2013, 12:11 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

yes, #reloadpl and #repop and #repop force
__________________
Reply With Quote
  #32  
Old 02-15-2013, 01:19 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

this works.

i think it might have had something to do with scope and assigning a value to $npcClass by way of the constant. it was an empty string until i moved the declarations of that and $buffList inside of the scopes they were used. the same does not apply to $data, however.

Code:
use 5.012;
no strict 'vars';
use warnings;

# 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 ],
       ],
   },
};

sub EVENT_SAY {

    my $npcClass = (CLASS_L)[ $npc->GetClass() ];
    my $greeting = $data->{$npcClass}->{greet} || "Got %s?";
    my $buffList = $data->{$npcClass}->{buffs};

    # 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 $npcClass = (CLASS_L)[ $npc->GetClass() ];
    my $buffList = $data->{$npcClass}->{buffs};

    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 );
    }
}
__________________
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;
Reply With Quote
  #33  
Old 02-15-2013, 01:41 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

:( 1st attempt isnt working, looking into it now though.
__________________
Reply With Quote
  #34  
Old 02-15-2013, 01:48 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i had it running on an enchanter npc. if it's not casting the buff, make sure the npc has qglobals enabled.
__________________
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;
Reply With Quote
  #35  
Old 02-15-2013, 01:49 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

qglobals is 1, i am checking everything tho. I will update in a few. If it works for u, i obviously missing something.
__________________
Reply With Quote
  #36  
Old 02-15-2013, 02:02 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

I dunno.... My npc is enchanter class 14, it has a enchanter spell list assigned(even though i dont think that matters since it pulls the clientside buffs from script), qglobal is 1, i copied ur script verbatim, I deleted everything inside of mine to make sure it was empty before i pasted. I #reloadpl and #repop force and #repop.


Edit: I wish I knew more to help better, lol. Although you have shined a lot of light on this for me, I am definately going to keep learning this. much fun
__________________

Last edited by Figback65; 02-15-2013 at 02:08 AM.. Reason: edit
Reply With Quote
  #37  
Old 02-15-2013, 02:12 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

haven't the faintest on that one. have 160135.pl in tutoriala and popped the npc with #dbspawn 160135 and everything is working for me here.
__________________
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;
Reply With Quote
  #38  
Old 02-15-2013, 02:21 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

Ill get some fresh eyes on it tomorrow. Thanks for helpen me today c0ncrete.
__________________
Reply With Quote
  #39  
Old 02-15-2013, 03:26 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

Hmmm what about maybe a version of perl issue? Commands missing maybe? My server is ran off an old winxp 32bit machine currently. Active Perl 5.10.1 and Mysql server 5.1. I dunno lol Tryen to troubleshoot every angle.
__________________
Reply With Quote
  #40  
Old 02-15-2013, 03:42 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

try removing the first three lines then.
__________________
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;
Reply With Quote
  #41  
Old 02-15-2013, 07:00 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

Awsome, it works for Enchy, so happah!!! lol. Necro is not working tho and i added cleric and its not working either. Looking into that now, just got freed up.
__________________
Reply With Quote
  #42  
Old 02-15-2013, 07:03 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

Ok, i was wrong, it works for all classes. The problem is, it doesnt work on a repop alone. What I mean is, if you #reloadpl while on the necro class then hail him, the necro responds and works properly. If you repop to a enchy or now added cleric, and hail him, he will not respond. If you then #reloadpl he will begin responding. But as soon as you repop to another enchy or cleric or necro, he stops responding again until you #reloadpl.

Edit: Maybe a sub EVENT_SPAWN around the hash table?

Edit: Nope didnt work., Only response was Got "Buffs?" But it did allow the npc to respond every repop without the #reloadpl
__________________

Last edited by Figback65; 02-15-2013 at 07:10 PM.. Reason: hash
Reply With Quote
  #43  
Old 02-15-2013, 07:25 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Get the PM?
Reply With Quote
  #44  
Old 02-15-2013, 10:40 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

Replied again. Use NPC ID(s) for the script names, vice clean name.
Reply With Quote
  #45  
Old 02-15-2013, 11:15 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 253
Default

Ok I did that, and it works. But by doing it this way, its linked directly to a class and i have 16 scripts with 16 spell lists in each one, when the default buffbot was 16 scripts with 1 spell list in each. Its the same, except we did way more work for an autocheck we could have manually done.

Edit : Eitherway I am VERY happy and currently finishing up the scripts.

Thank you very much guys!!!
__________________

Last edited by Figback65; 02-15-2013 at 11:16 PM.. Reason: edit
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 07:21 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