#!/usr/bin/perl # (c) 2008 by Scott David Gray # Set initial HTML values $mylocation = "http://www.unseelie.org/cgi-bin/powerattack.cgi" ; $rtitle = "D&D 3rd edition Power Attack damage estimator" ; $rfirstline = "D&D 3rd edition Power Attack damage estimator:" ; $rbgcolor = "99AABB" ; $rfontcolor = "222288" ; $rlinkcolor = "0000FF" ; $rpastlinkcolor = "4422CC" ; $rclicklinkcolor = "000000" ; # Gather raw data use CGI qw(:standard); $basetohit = param("basetohit"); $basedamage = param("basedamage"); $powermultiplier = param("powermultiplier"); $critthreat = param("critthreat"); $basetoconfirm = param("basetoconfirm"); $critmult = param("critmult"); $minac = param("minac"); $maxac = param("maxac"); # Output print "Content-type: text/html\nPragma: no-cache\n\n"; # HTML print < $rtitle

$rfirstline


© 2008 by Scott David Gray.


This program is designed to calculate likely damage dealt, depending on average damage from the weapon, the base to hit, and whether or not power attack is being used (and to what level) against various armor classes.

END_HTML if (param()) { print < A fighter who adds +$basetohit to hit with her/his primary attack who does average base damage of $basedamage using a $powermultiplier-handed weapon, with a crit range of $critthreat-20\/$critmult and who adds +$basetoconfirm to confirm a crit, will do average damage according to the tables presented below, depending on the Armor Class of her/his opponent (from $minac AC to $maxac AC), and the number of points taken off of her/his to-hit roll for the power attack feat:



END_HTML2

print < $maxac) {

  print("AC\t$AC\t");

  $powerdeduct = 0;

  until ($powerdeduct > 5) {

   $probhit = 20-($AC-$basetohit+$powerdeduct);

   if ($probhit < 1) {

     $probhit = 1

   }

   if ($probhit > 19) {

     $probhit = 19

   }

   $probhit = ($probhit/20) ;

   $damage = ($probhit*(($powerdeduct * $powermultiplier)+$basedamage));

   $roundedfull = sprintf("%.2f", $damage);

   print ("$roundedfull\t");

   $powerdeduct++;

  }

 print("\n");

 $AC++;

}

print < $maxac) {

  print("AC\t$AC\t");

  $powerdeduct = 0;

  until ($powerdeduct > 5) {

   $probhit = 20-($AC-$basetohit+$powerdeduct);

   if ($probhit < 1) {

     $probhit = 1

   }

   if ($probhit > 19) {

     $probhit = 19

   }

   $critlikely = (21-$critthreat);

   if ($critlikely < 1) {

     $critlikely = 1

   }

   if ($critlikely > $probhit) {

     $critlikely = $probhit

   }

   $probhit = ($probhit/20) ;

   $damage = ($probhit*(($powerdeduct * $powermultiplier)+$basedamage));

   $probconfirm = 20-($AC-$basetoconfirm+$powerdeduct);

   if ($probconfirm < 1) {

     $probconfirm = 1

   }

   if ($probconfirm > 19) {

     $probconfirm = 19

   }

   $critconfirmed = ($probconfirm*$critlikely/400) ;

   $critdamage = ($damage * ($critconfirmed) * ($critmult - 1));

   $fulldamage = ($damage + $critdamage);

   $roundedfull = sprintf("%.2f", $fulldamage);

   print ("$roundedfull\t");

   $powerdeduct++;

  }

 print("\n");

 $AC++;

}

print < $maxac) {

  print("AC\t$AC\t");

  $powerdeduct = 0;

  until ($powerdeduct > 5) {

   $probhit = 20-($AC-$basetohit+$powerdeduct);

   if ($probhit < 1) {

     $probhit = 1

   }

   if ($probhit > 19) {

     $probhit = 19

   }

   $probhit = ($probhit/20) ;

   $probsecondhit = 25-($AC-$basetohit+$powerdeduct);

   if ($probsecondhit < 1) {

     $probsecondhit = 1

   }

   if ($probsecondhit > 19) {

     $probsecondhit = 19

   }

   $probsecondhit = ($probsecondhit/20) ;

   $probbothhits = ($probhit + $probsecondhit) ;

   $damage = ($probbothhits*(($powerdeduct * $powermultiplier)+$basedamage));

   $roundedfull = sprintf("%.2f", $damage);

   print ("$roundedfull\t");

   $powerdeduct++;

  }

 print("\n");

 $AC++;

}

print < $maxac) {

  print("AC\t$AC\t");

  $powerdeduct = 0;

  until ($powerdeduct > 5) {

   $probhit = 20-($AC-$basetohit+$powerdeduct);

   if ($probhit < 1) {

     $probhit = 1

   }

   if ($probhit > 19) {

     $probhit = 19

   }

   $probsecondhit = 25-($AC-$basetohit+$powerdeduct);

   if ($probsecondhit < 1) {

     $probsecondhit = 1

   }

   if ($probsecondhit > 19) {

     $probsecondhit = 19

   }

   $critlikely = (21-$critthreat);

   if ($critlikely < 1) {

     $critlikely = 1

   }

   if ($critlikely > $probhit) {

     $critlikely = $probhit

   }

   $secondcritlikely = (21-$critthreat);

   if ($secondcritlikely < 1) {

     $secondcritlikely = 1

   }

   if ($secondcritlikely > $probsecondhit) {

     $secondcritlikely = $probsecondhit

   }

   $probhit = ($probhit/20) ;

   $damage = ($probhit*(($powerdeduct * $powermultiplier)+$basedamage));

   $probconfirm = 20-($AC-$basetoconfirm+$powerdeduct);

   if ($probconfirm < 1) {

     $probconfirm = 1

   }

   if ($probconfirm > 19) {

     $probconfirm = 19

   }

   $probsecondconfirm = 25-($AC-$basetoconfirm+$powerdeduct);

   if ($probsecondconfirm < 1) {

     $probsecondconfirm = 1

   }

   if ($probsecondconfirm > 19) {

     $probsecondconfirm = 19

   }

   $critconfirmed = ($probconfirm*$critlikely/400) ;

   $critdamage = ($damage * ($critconfirmed) * ($critmult - 1));

   $secondcritconfirmed = ($probsecondconfirm*$secondcritlikely/400) ;

   $secondcritdamage = ($damage * ($secondcritconfirmed) * ($critmult - 1));

   $fulldamage = (($damage*2) + $critdamage + $secondcritdamage);

   $roundedfull = sprintf("%.2f", $fulldamage);

   print ("$roundedfull\t");

   $powerdeduct++;

  }

 print("\n");

 $AC++;

}

}

print <

END_HTML25

print <

  

The form below allows you to submit numbers to the power attack program. The numbers will be crunched on another machine.


Data:

What is the character's total plus to hit with all modifiers included?
What is the average damage the character does with each swing?
What is the power multiplier on an attack (1 for 1-handed weapons, 2 for 2-handed weapons)?
What is the lowest natural roll for a crit threat?
What is the character's plus to confirm a crit, with all modifiers included?
What is the damage multiplier for a critical?
What is the minimum AC we should calculate?
What is the maximum AC we should calculate?


If you find this program to be useful, you will want to check out my PERL Card Calculator program, PERL General Dice Pool Calculator program, and PERL Shadowrun Dice Pool Calculator program.

The source code for this program can be found here. END_HTML3