EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Custom (https://www.eqemulator.org/forums/forumdisplay.php?f=671)
-   -   shared script example (https://www.eqemulator.org/forums/showthread.php?t=36311)

c0ncrete 01-22-2013 09:39 AM

shared script example
 
this way, when you change one, the the other is changed.

additional customizations included and commented.

guildlobby\A_Priest_of_Luclin.pl
Code:

# get current working directory from full path to script
# note: linux users may be able to use relative path
( my $cwd = $0 ) =~ s/(?:(?!\\)\S)+$//;

# execute other script
do "${cwd}A_Priestess_of_Luclin.pl";

guildlobby\A_Priestess_of_Luclin.pl
Code:

sub EVENT_SAY {

    # only respond to hail (not technically accurate)
    return unless $text =~ /hail/i;

    # response
    quest::emote( "continues to chant towards the altar as you approach. 'If y"
          . "ou are in need of our aid, speak to the disciple and bring me one"
          . " of the soulstones that he sells. I must continue to delve into t"
          . "he twilight of our world in search of lost souls.'" );

}

sub EVENT_ITEM {

    # aww...
    my $no_help =
        "A focus powerful enough to assist someone of your stature has not yet"
      . " been discovered.";

    # yeah, right!
    my $under_powered =
        "This focus is not powerful enough to summon the remnants of your form"
      . "er self. The Disciples of Luclin can help you select an appropriate f"
      . "ocus.";

    # wtf, srsly?!
    my $wasted_time =
        "thrusts the soulstone back at you with a cold stare. 'Do not waste my"
      . " time, $race! Leave me to my work!'";

    # valid soulstone item ids and the maximum level they are effective
    my $soulstone = {
        76013 => 20,    # Minor Soulstone
        76014 => 30,    # Lesser Soulstone
        76015 => 40,    # Soulstone
        76016 => 50,    # Greater Soulstone
        76017 => 55,    # Faceted Soulstone
        76018 => 70,    # Pristine Soulstone
        76019 => 75,    # Glowing Soulstone
        76048 => 80,    # Primstic Soulstone
        76065 => 85,    # Iridescent Soulstone
        76274 => 90,    # Phantasmal Soulstone
        76275 => 95    # Luminous Soulstone
    };

    # don't check items if client is over level 95
    if ( $ulevel > 95 ) {
        quest::say($no_help);
    }

    # check items
    else {

        # iterate over items that were handed in
        foreach $itemID ( keys %itemcount ) {

            # skip items that do not have entries in soulstone hashref
            next unless $itemID and defined $soulstone->{$itemID};

            # verify current soulstone will work for client's level
            # note: over-powered soulstones WILL work
            my $max_level = $soulstone->{$itemID};
            unless ( $ulevel <= $max_level ) {
                quest::say($under_powered);
                next;
            }

            # don't use soulstone if client has no corpses
            if ( $client->GetCorpseCount() < 1 ) {
                quest::emote($wasted_time);
                last;
            }

            # consume first appropriate soulstone found and summon corpses
            if ( plugin::check_handin( \%itemcount, $itemID => 1 ) ) {
                SummonCorpses();
                last;
            }
        }

    }

    # vary item return text, based on the number of items to be returned
    # note: do not count soulstones as we've already sent text for those
    if ( my $quantity = grep { $_ && !$soulstone->{$_} } keys %itemcount ) {
        quest::say( sprintf "I do not need th%s.",
            $quantity > 1 ? "ese" : "is" );
    }

    # return unused items
    plugin::return_items( \%itemcount );

}

# does what it says on the tin
sub SummonCorpses {

    my $x = $client->GetX();
    my $y = $client->GetY();
    my $z = $client->GetZ();

    # spooky flavor
    quest::emote( "takes your stone and places it on the altar.  Shadows begin"
          . " to drift across the floor and over the altar and finally onto th"
          . "e soulstone.  The priest's voice chants with intensity and is soo"
          . "n joined with several others as the shadows slowly coalesce into "
          . "a wispy mass that feels familiar.  The two candles near the altar"
          . " explode with light and there, before you, appears all that remai"
          . "ns of your former life." );

    quest::summonallplayercorpses( $client->CharacterID(), $x, $y, $z, 0 );

}


c0ncrete 01-22-2013 11:01 AM

small tweak

change this
Code:

    # don't check items if client is over level 95
    if ( $ulevel > 95 ) {
        quest::say($no_help);
    }

to this
Code:

  # don't check items if client is over level 95 and has turned in a soulstone
    if ( $ulevel > 95 && grep { $soulstone->{$_} } keys %itemcount ) {
        quest::say($no_help);
    }

that way, the client will only get the $no_help message if he/she is over level 95 and has turned in a soulstone.

Tabasco 01-22-2013 11:07 AM

In linux you can just make symbolic link.

Code:

ln -s A_Priest_of_Luclin.pl A_Priestess_of_Luclin.pl
I gather this can be done in newer versions of windows also, but I've never had to mess with it.
http://en.wikipedia.org/wiki/NTFS_symbolic_link

c0ncrete 01-22-2013 11:11 AM

good point. that makes things even more efficient.

thanks for the feedback.

c0ncrete 01-22-2013 11:32 AM

this should be a platform-independent match so things should work without worrying about symlinks, junctions, etc (i'm working with xp here...)

Code:

( my $cwd = $0 ) =~ s/(?:(?!\\|/)\S)+$//;

Akkadius 01-22-2013 01:49 PM

Or you can put the script in the default.pl and make some checks that look for either NPC name to load the appropriate script.

c0ncrete 01-22-2013 05:05 PM

i'm having issues today... :|

forgot to escape something in the updated regex

Code:

( my $cwd = $0 ) =~ s/(?:(?!\\|\/)\S)+$//;


All times are GMT -4. The time now is 05:28 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.