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

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

Reply
 
Thread Tools Display Modes
  #46  
Old 02-16-2013, 03:46 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

i don't know why you're having issues at this point. i made some minor changes to the script (shown in red below) and tossed it on an npc in tutorialb and it worked exactly as i expected it would. half of them spawned as erudites (necros) and the other half as high elves (enchanters), and both showed the correct responses when hailed.

quests\tutorialb\a_cave_rat.pl
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_SPAWN {

    if ( 49 > (int rand 99) + 1 ) {
        $npc->SetEntityVariable( "Class", 14 );
        $npc->SetRace(5);
    }
    else {
        $npc->SetEntityVariable( "Class", 11 );
        $npc->SetRace(3);
    }
}

sub EVENT_SAY {

    my $npcClass = (CLASS_L)[ $npc->GetEntityVariable("Class") ];
    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->GetEntityVariable("Class") ];
    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
  #47  
Old 02-16-2013, 04:59 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

ok checkin it out now.
Thanks c0ncrete.
__________________
Reply With Quote
  #48  
Old 02-16-2013, 05:17 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Nope, still same issue. It will work indefinately after each #reloadpl, but any normal respawn from death or #repop, does not respond to the hail until you #reloadpl again.

I did rename scripts to NPCid#.pl and those work every time with respawns without #reloadpl, so the script definately works on pulling the correct class.

Only thing I still think of is my version of perl maybe? The guide I followed...

http://new.eqemulator.net/forums/showthread.php?t=32980


Edit: After the initial "bang your head against wall" stage, I have had the server up and running pretty good since june of 2012. Fixed a lot of missing database stuff and cleaned it up pretty well. So I am scared to try and use another perl lol bc of how hard it was getting started. Specially with all the errors you helped me with from just changing to the new build lol
__________________

Last edited by Figback65; 02-16-2013 at 05:21 PM.. Reason: Edit
Reply With Quote
  #49  
Old 02-16-2013, 05:46 PM
ghanja's Avatar
ghanja
Dragon
 
Join Date: Aug 2012
Location: Hershey, PA
Posts: 499
Default

What build is your server running?
Reply With Quote
  #50  
Old 02-16-2013, 06:47 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

My server is running everything posted in that guide, mysql 5.1 and perl 5.10.1 build 1007, source2294, built with cmake 2.8, compiled with visual c++ 2008.
__________________
Reply With Quote
  #51  
Old 02-16-2013, 10:13 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

just verified it works after rats begin to respawn as well. i built my executables on the 15th. i've got some custom stuff in there as well, but nothing that should change how the script works.

you can always back up your database and executables, update, and test it out and then revert if it doesn't work.
__________________
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
  #52  
Old 02-18-2013, 09:17 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Ok, ill work on that this weekend when i get some more time.
Ty
Fig
__________________
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 10:59 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