I have been trying to figure out how to get the working, if possible, in MUSHclient. It works fine in a couple other clients but cannot figure it out here. I keep getting this:
Error number: -2147467259
Event: Execution of line 1 column 0
Description: (in cleanup) Undefined subroutine &main::delAlias called
Called by: Immediate execution
use strict;
use warnings;
no warnings 'redefine';
my %inflictedDamage;
my %takenDamage;
my $lastWeapon="unknown";
my %inflictedWeapons;
sub damageText {
my $txt='Damage Log:%r%cb%cuDamage inflicted:%cn%r%r';
my $shots=0;
my $damage=0;
foreach my $loc (keys %inflictedDamage) {
$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
$loc,
$inflictedDamage{$loc}->[1],
$inflictedDamage{$loc}->[0]);
$shots+=$inflictedDamage{$loc}->[0];
$damage+=$inflictedDamage{$loc}->[1];
}
$txt.=sprintf('%%ch%20s: %4d damage in %4d shots.%%cn%%r',
"Total",$damage,$shots);
$txt.='%r%cb%cuWeapons hit:%cn%r%r';
foreach my $loc (keys %inflictedWeapons) {
$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
$loc,
$inflictedWeapons{$loc}->[1],
$inflictedWeapons{$loc}->[0]);
}
$shots=0;
$damage=0;
$txt.='%r%cb%cuDamage taken:%cn%r%r';
foreach my $loc (keys %takenDamage) {
$txt .= sprintf('%20s: %4d damage in %4d shots.%%r',
$loc,
$takenDamage{$loc}->[1],
$takenDamage{$loc}->[0]);
$shots+=$takenDamage{$loc}->[0];
$damage+=$takenDamage{$loc}->[1];
}
$txt.=sprintf('%%ch%20s: %4d damage in %4d shots.%%r%%cn',
"Total",$damage,$shots);
$txt=~s/ (?= )/ \%/g;
return $txt;
}
delAlias(qr/^DAMAGE_/);
addAlias("DAMAGE_RESET",qr/^damagereset\s*$/,sub {
%inflictedDamage=();
%inflictedWeapons=();
%takenDamage=();
statusWindow->print(ansi('%cbDamage log reset%cn%r'));
return undef;
},1);
addAlias("DAMAGE_PRINT",qr/^dpr\s*$/,sub {
statusWindow->print(ansi(damageText));
return undef;
},1);
delTrigger(qr/^DAMAGE_/);
addTrigger("DAMAGE_DEAL",qr/You hit for (\d+) points of damage in the ([\w (]+[\w)])/, sub {
my $w=$2;
chomp $w;
$inflictedDamage{$w}->[0]++;
$inflictedDamage{$w}->[1]+=$1;
$inflictedWeapons{$lastWeapon}->[0]++;
$inflictedWeapons{$lastWeapon}->[1]+=$1;
return shift;
});
addTrigger("DAMAGE_TAKE",qr/You have been hit for (\d+) points of damage in the ([\w (]+[\w)])/, sub {
my $p=$1;
my $w=$2;
chomp $w;
unless ($w=~/transfer/) {
$takenDamage{$w}->[0]++;
$takenDamage{$w}->[1]+=$p;
}
return shift;
});
addTrigger("DAMAGE_WEAPON",qr/You fire ([\w\-\/]+) at/, sub {
$lastWeapon=$1;
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addTrigger("DAMAGE_WEAPON_KICK",qr/You try to kick/, sub {
$lastWeapon="Kick";
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addTrigger("DAMAGE_WEAPON_PUNCH",qr/You try to punch/, sub {
$lastWeapon="Punch";
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addTrigger("DAMAGE_WEAPON_CLUB",qr/You try to club/, sub {
$lastWeapon="Club";
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addTrigger("DAMAGE_WEAPON_AXE",qr/You try to axe/, sub {
$lastWeapon="Axe";
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addTrigger("DAMAGE_WEAPON_DFA",qr/You land on your target/, sub {
$lastWeapon="Death From Above";
delDelayed(qr/^DAMAGE_WEAPON_RESET$/);
addDelayed("DAMAGE_WEAPON_RESET",3,sub { $lastWeapon="unknown"; });
return shift;
});
addAlias("DAMAGE_INSERT",qr/\@DAMAGE\@/,sub {
my $t=damageText;
my $l=shift;
$l=~ s/\@DAMAGE\@/$t/;
return $l;
});
As I said, this works in a couple other clients, here is the link to a screenshot I took of what it is supposed to look like.
http://i221.photobucket.com/albums/dd134/mark_perryman/BTMux%20Stuff/test.jpg
Thank you, any help is greatly appreciated.
|