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

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 02-14-2013, 09:17 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

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;
Reply With Quote
 


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: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