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, 03:31 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

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

### IGNORE EVERYTHING BELOW HERE ###

package NPC;

sub new {
    my ( $class, %param ) = ( shift, @_ );
    $param{_class} = 14;
    return bless \%param, $class;
}

sub GetClass {
    shift->{_class};
}

package main;

my $npc = NPC->new();

sub quest::saylink {
    shift;
}

sub quest::say {
    say shift;
}

# this is what the client said (used to search available buffs)
my $text = "Clarity II";

### IGNORE EVERYTHING ABOVE HERE ###

# 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 {
    if ( $text =~ /hail/i ) {
        quest::say($greeting);
        return;
    }
    given ( [ grep { ${$_}[0] =~ /$text/i } @{$buffList} ] ) {

        # one exact match (probably clicked on saylink in list)
        when ( @{$_} == 1 && $text eq ${$_}[0][0] ) {
            say "That will be ${$_}[0][2]pp for ${$_}[0][0].";
        }

        # client typed targeted text that did not match hail and
        # more than one available spell name matched recieved text
        # TODO: create saylinks
        when ( @{$_} > 1 ) {
            foreach my $spell ( @{$_} ) {
                my ( $spellName, $spellID, $spellCost ) = @{$spell};
                say "I can cast $spellName on you for ${spellCost}pp.";
            }
        }
    }
}

### IGNORE EVERYTHING BELOW HERE ###

EVENT_SAY();
you can change the value of $text in this and run it outside of the emulator to see the results.
change $param{_class} to whatever class you want the npc to be.

nyquil is kicking in. you're on your own for a bit...
__________________
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
 

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