View Single Post
  #3  
Old 11-12-2012, 03:32 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

it's got to be an issue with the definition of the arrays or iterating over the elements, but i don't completely follow why it would be problematic. the following script gets to the end of the file and prints PASSED (even with the original regexp patterns):

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

# matches named and generic gloomingdeep kobolds
my $kobolds = '(?=^(#([bopt]|s(e|l[ai]|p))|(a_)?gloomi))';
# matches named and generic gloom/fang spiders (not queen)
my $spiders = '(?=^(#v|a_gloom[_f]))';
# matches named and generic rats
my $rats    = '(?=^(#r[au]|a_(cave|diseased)_r))';

sub EVENT_SAY
{
    if ( !$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner() ) {
        return;
    }
    if ( $text =~ /hail/i ) {
        quest::say("Shh! I think I hear the kobolds...");
    }
}

sub EVENT_ITEM
{
   if ( !$npc || $npc->GetOwnerID() || $npc->GetSwarmOwner() ) {
      plugin::GivePetItems();
      return;
   }
   plugin::return_items(\%itemcount);
}

sub EVENT_COMBAT
{
    if ( $combat_state ) {
        if ( $mname =~ /$kobolds/i ) {
            quest::emote("brandishes razor sharp claws and circles inward.");
        }
        elsif ( $mname =~ /$spiders/i ) {
            quest::emote("scuttles forward to attack.");
        }
        elsif ( $mname =~ /#queen/i ) {
            quest::emote("brandishes razor sharp fangs and attacks!");
        }
        elsif ( $mname =~ /$rats/i ) {
            quest::emote("races forward to attack.");
        }
    }
}

sub EVENT_DEATH
{
    if ( $mname =~ /$kobolds/i ) {
        quest::emote("unleashes a lupine yelp as it collapses on the floor.");
    }
    elsif ( $mname =~ /$spiders/i ) {
        quest::emote("collapses in a heap of broken legs.");
    }
    elsif ( $mname =~ /#queen/i ) {
        quest::emote("'s corpse unleashes a chittering keen as it falls backward.");
    }
    elsif ( $mname =~ /$rats/i ) {
        quest::emote("'s corpse stops moving.");
    }
}

print "PASSED\n";
i'll be testing in-game to make sure it works as expected.
Reply With Quote