this should take care of spell casting specialization skills correctly.
i haven't tested it yet, but the syntax is correct and the logic looks sound.
Code:
use List::Util qw(first);
# shorthand aliases for the client methods we'll be using
$CanSkill = sub { $client->CanHaveSkill(shift) };
$MaxSkill = sub { $client->MaxSkill( shift, $class, $ulevel ) };
$RawSkill = sub { $client->GetRawSkill(shift) };
$SetSkill = sub { $client->SetSkill( shift, shift ) };
# set all available skills to max value for client's current level
# NOTE: spell-casting specialization skills are handled later
foreach my $skillNum ( 0 .. 42, 48 .. 74 ) {
next unless $CanSkill->($skillNum);
$SetSkill->( $skillNum, $MaxSkill->($skillNum) );
}
# if client is a caster and can specialize
if ( $CanSkill->(43) ) {
# get current raw value for all spell-casting spec skills
my %spec = map { $_ => $RawSkill->($_) } ( 43 .. 47 );
# if one spell-casting spec skill is above 50 (main spec for caster),
# set it to the max value for the client's current level
# (this skill is deleted from hash and doesn't get calculated again)
if ( my $mainSpec = first { $spec{$_} > 50 } keys %spec ) {
$SetSkill->( $mainSpec, $MaxSkill->($mainSpec) );
delete $spec{$mainSpec};
}
# set spell-casting spec skills to max value for client's current level
# all skill levels but the first one that goes over 50 are capped at 50
foreach my $skillNum ( keys %spec ) {
next if $spec{$skillNum} == 50;
my $maxVal = $MaxSkill->($skillNum);
$SetSkill->( $skillNum, $maxVal > 50 ? 50 : $maxVal );
}
}
NOTE: oops... i forgot to include the List::Util module in my copy/paste. corrected.