Mercurial > hg > batmud > misc
comparison magestats.pl @ 344:55edb7d42ce4 misc
Possibly improve spell crit detection/handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Aug 2016 00:21:04 +0300 |
parents | 9267d2b51e57 |
children | 4dce0dd371a5 |
comparison
equal
deleted
inserted
replaced
343:9267d2b51e57 | 344:55edb7d42ce4 |
---|---|
222 } | 222 } |
223 my $match = join("|", @all_spells); | 223 my $match = join("|", @all_spells); |
224 my $essence_flag = 0; | 224 my $essence_flag = 0; |
225 my $crit_flag = 0; | 225 my $crit_flag = 0; |
226 my $crit_type; | 226 my $crit_type; |
227 my $crit_dist; | |
227 my $last_spell = ""; | 228 my $last_spell = ""; |
228 my $staff_worn = 0; | 229 my $staff_worn = 0; |
229 my $spell_active = 0; | 230 my $spell_active = 0; |
230 my $nline = 0; | 231 my $nline = 0; |
231 | 232 |
268 $$spells{"staff"}{"desc"} = $desc; | 269 $$spells{"staff"}{"desc"} = $desc; |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 | 273 |
274 sub crit_update() | |
275 { | |
276 if ($crit_flag) { | |
277 my $type = get_spell_type($last_spell); | |
278 # print STDERR "crit: $type : $last_spell : $crit_type [$crit_dist]\n"; | |
279 $$spells{$type}{"crits"}{$crit_type}++; | |
280 $crit_flag = 0; | |
281 } | |
282 } | |
283 | |
284 | |
273 sub spell_update($) | 285 sub spell_update($) |
274 { | 286 { |
287 crit_update(); | |
288 | |
275 $last_spell = $_[0]; | 289 $last_spell = $_[0]; |
276 | 290 |
277 $spell_active = $nline; | 291 $spell_active = $nline; |
278 my $type = get_spell_type($last_spell); | 292 my $type = get_spell_type($last_spell); |
279 | 293 |
303 foreach my $class ("single", "area") { | 317 foreach my $class ("single", "area") { |
304 my $name = $$spells{$type}{$class}; | 318 my $name = $$spells{$type}{$class}; |
305 push(@{$$spells{$type}{"essence"}{"blasts"}{$class}}, $$spells{$name}{"blasts"}); | 319 push(@{$$spells{$type}{"essence"}{"blasts"}{$class}}, $$spells{$name}{"blasts"}); |
306 } | 320 } |
307 } | 321 } |
308 } | |
309 | |
310 # Crit hits | |
311 if ($crit_flag) { | |
312 $crit_flag = 0; | |
313 # print STDERR "crit: $type : $last_spell : $crit_type\n"; | |
314 $$spells{$type}{"crits"}{$crit_type}++; | |
315 } | 322 } |
316 } | 323 } |
317 | 324 |
318 | 325 |
319 sub staff_match($$$) | 326 sub staff_match($$$) |
394 $essence_flag = 1; | 401 $essence_flag = 1; |
395 } elsif ($s =~ /^Your fingertips are surrounded with swirling (ENERGY) as you cast the spell\./ || | 402 } elsif ($s =~ /^Your fingertips are surrounded with swirling (ENERGY) as you cast the spell\./ || |
396 $s =~ /^You feel like you managed to channel additional (POWER) to your spell\./ || | 403 $s =~ /^You feel like you managed to channel additional (POWER) to your spell\./ || |
397 $s =~ /^You feel like your spell gained additional (power)\./ || | 404 $s =~ /^You feel like your spell gained additional (power)\./ || |
398 $s =~ /^(Unseen) BURSTS of magic are absorbed into the spell/) { | 405 $s =~ /^(Unseen) BURSTS of magic are absorbed into the spell/) { |
399 $crit_type = $1; | 406 $crit_dist = $nline - $spell_active; |
400 $crit_flag = 1; | 407 if ($spell_active > 0 && $crit_dist <= 5) { |
408 $crit_type = $1; | |
409 $crit_flag = 1; | |
410 } | |
401 } | 411 } |
402 } | 412 } |
413 | |
414 crit_update(); | |
403 } | 415 } |
404 | 416 |
405 | 417 |
406 ### | 418 ### |
407 ### Dump cache to stdout | 419 ### Dump cache to stdout |