Code:

dam {
var %basedam = $calc(($int($calc($int($calc(42 * $int($calc($1)) * $int($calc($3)) / $int($calc($2)))) / 50)) + 2) $iif($4 isnum,$5-,$4-))
if ($4 isnum) {
var %mn = $int($calc(%basedam *.85)) | var %mx = $int(%basedam)
var %min = $round($calc(%mn * 100 / $4),2) | var %max = $round($calc(%mx * 100 / $4),2)
if (%mn < $4 && %mx >= $4) {
var %i 0 | while ($int($calc(%basedam * ((%i + 85) / 100))) < $4) { inc %i }
var %x $int($calc($1))
while ($int($calc(($int($calc($int($calc(42 * %x * $int($calc($3)) / $int($calc($2)))) / 50)) + 2) $5- *.85)) <= $4) { inc %x }
var %OHKO ( $+ $calc(100 - %i / .16) $+ % OHKO, $calc(%x - $int($calc($1))) more $+(point,$iif($calc(%x - $int($calc($1))) != 1,s)) required for OHKO)
}
if (%mn < $int($calc($4 / 2)) && %mx >= $int($calc($4 / 2))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while ($calc($int($calc(%basedam * ((%i + 85) / 100))) + $int($calc(%basedam * ((%j + 85) / 100)))) < $4 && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO $calc((256 - %a)/2.56) $+ % 2HKO
}
if (%mn <= $int($calc($4 $iif($calc($4 / 16) < 1,/2-1,*15/32))) && %mx >= $int($calc($4 $iif($calc($4 / 16) < 1,/2-1,*15/32)))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while ($calc($int($calc(%basedam * ((%i + 85)/100))) + $int($calc(%basedam * ((%j + 85)/100)))) < $int($calc($4 $iif($calc($4 / 16) < 1,-1,*15/16))) && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO $iif(%THKO,$+(%THKO,$chr(44))) $calc((256 - %a)/2.56) $+ % $iif(!%THKO,2HKO) with Sandstorm
}
if (%mn <= $int($calc($4 $iif($calc($4 / 16) < 1,/2+1,*17/32))) && %mx >= $int($calc($4 $iif($calc($4 / 16) < 1,/2+1,*17/32)))) {
var %j 0 | var %a 0 | while (%j <= 16) {
var %i 0 | while ($calc($int($calc(%basedam * ((%i + 85)/100))) + $int($calc(%basedam * ((%j + 85)/100)))) < $int($calc($4 $iif($calc($4 / 16) < 1,+1,*17/16))) && %i < 15) { inc %i }
inc %a %i | inc %j
}
var %THKO $iif(%THKO,$+(%THKO,$chr(44))) $calc((256 - %a)/2.56) $+ % $iif(!%THKO,2HKO) with Leftovers
}
echo 4 -a $1 attack vs $2 defense, $3 $+(power,$iif($5,$+($chr(40),$5-,$chr(41))),$chr(44)) $4 max HP: %min $+ % - %max $+ % $iif(%OHKO,%OHKO) $iif(%THKO,$+($chr(40),%THKO,$chr(41)))
}
else { echo 4 -a $1 attack vs $2 defense, $3 $+(power,$iif($4,$+($chr(40),$4-,$chr(41))),:) $int($calc(%basedam *.85)) - $int(%basedam) }
}