I got annoyed at constantly having to use Psypoke's damage calculator, so I came up with this Perl thing to do it. Maybe someone else will find it useful!
edit: times %f, not %i.
Code:
#!/usr/bin/perl
use POSIX qw(floor);
# Does damage calculations for Pokemon
# Invoke as follows:
# damcalc A B C D...n
# A = Your attack
# B = Their defense
# C = The power of the attack
# D to n = Multiplers (STAB, NVE, SE, etc.).
# Example: damcalc 405 375 80 2 1.5 1.3
# Translated: Life Orb Tyranitar's 405 attack against somebody's 75 defense, using Crunch, Super Effective, STABed.
$mult = 1;
if($#ARGV > 2) {
foreach $i (3 .. $#ARGV) {
$mult *= $ARGV[$i];
}
}
$min = floor(floor(floor(floor(42 * $ARGV[0] * $ARGV[2] / $ARGV[1]) / 50) + 2) * .85 * $mult);
$max = floor(floor(floor(floor(42 * $ARGV[0] * $ARGV[2] / $ARGV[1]) / 50) + 2) * $mult);
printf("%i attack vs. %i defense, %i power, times %f: %i - %i\n", $ARGV[0], $ARGV[1], $ARGV[2], $mult, $min, $max);
exit 0;
edit: times %f, not %i.