View Single Post
  #1  
Old 01-22-2013, 09:39 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default 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 );

}
__________________
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