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

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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-14-2013, 03:25 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Cool, thanks very much guys, ill work on it for a few days and then update!
__________________
Reply With Quote
  #2  
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
  #3  
Old 02-14-2013, 04:32 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Quote:
Originally Posted by c0ncrete View Post

change $param{_class} to whatever class you want the npc to be.

The NPC is in a spawngroup of multiple classes. So when it dies or respawns, the script will determine which class it spawned as and set the spell list for that class....
$param{_class} = $npc->GetClass(); ?

Now by your comment, are you suggesting that I need to change it manually in the script to force a spell list, by the way you have coded it.

This is the 1st time I have seen packages and some syntax you are using, I am googling and researching all I can to understand what you have given. Going to need some time to learn all of this lol.

Edit: And hash tables
__________________

Last edited by Figback65; 02-14-2013 at 04:34 PM.. Reason: Hash
Reply With Quote
  #4  
Old 02-14-2013, 04:54 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

there is a reason i put the comments about ignoring what was above and below a certain point....

the code within those areas was just put there to emulate the behavior of the script being run via the server. if you were to run this script as it is written from a command prompt, you will see a near identical example of how it would work from inside the game. i was letting you know the things you would need to change if you were running it outside of the game so you could see the different results, depending upon a given scenario (client said / npc class is).

to get it to work in the game, you'd remove the lines that are inside the areas designated for you to ignore and change the remaining say lines to quest::say(), $client->Message(), or whatever other message delivery function you would want to use.
__________________
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
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 10:09 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 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3