# HG changeset patch # User Matti Hamalainen # Date 1470777664 -10800 # Node ID 55edb7d42ce457e2ad45541d76899d99c860fdf8 # Parent 9267d2b51e57042e28effefec16824c049cf4d87 Possibly improve spell crit detection/handling. diff -r 9267d2b51e57 -r 55edb7d42ce4 magestats.pl --- a/magestats.pl Tue Aug 09 23:06:01 2016 +0300 +++ b/magestats.pl Wed Aug 10 00:21:04 2016 +0300 @@ -224,6 +224,7 @@ my $essence_flag = 0; my $crit_flag = 0; my $crit_type; +my $crit_dist; my $last_spell = ""; my $staff_worn = 0; my $spell_active = 0; @@ -270,8 +271,21 @@ } +sub crit_update() +{ + if ($crit_flag) { + my $type = get_spell_type($last_spell); +# print STDERR "crit: $type : $last_spell : $crit_type [$crit_dist]\n"; + $$spells{$type}{"crits"}{$crit_type}++; + $crit_flag = 0; + } +} + + sub spell_update($) { + crit_update(); + $last_spell = $_[0]; $spell_active = $nline; @@ -306,13 +320,6 @@ } } } - - # Crit hits - if ($crit_flag) { - $crit_flag = 0; -# print STDERR "crit: $type : $last_spell : $crit_type\n"; - $$spells{$type}{"crits"}{$crit_type}++; - } } @@ -396,10 +403,15 @@ $s =~ /^You feel like you managed to channel additional (POWER) to your spell\./ || $s =~ /^You feel like your spell gained additional (power)\./ || $s =~ /^(Unseen) BURSTS of magic are absorbed into the spell/) { - $crit_type = $1; - $crit_flag = 1; + $crit_dist = $nline - $spell_active; + if ($spell_active > 0 && $crit_dist <= 5) { + $crit_type = $1; + $crit_flag = 1; + } } } + + crit_update(); }