Is there any builtin or commonly used function to determine the actual amount of damage that your last action caused to an enemy? I know it is hidden somewhere deep within the bowels of fightoptimizer, but I wasn't sure if there was a more recent or more stable method...
You could just flag monster_hp() in one round, then compare it to monster_hp() in the following round. This would ensure that you are using mafia's latest methods of damage detection. It would also be prone to whatever errors might materialize in mafia's latest methods.
But that would find out the damage your attack did, plus retailation damage, plus passive damage, plus any other sources of damage during that turn.
Maybe fishing from fight.php with a visit_url, searching for weapon/skill specific message?
Looked at fight.php -- you may be able to strip integers from the contents of the fourth <table>. I'm sure there are exceptions, but it would be far easier to code those than to enter in every string that causes damage (accounting for both singular/plural opponents and Sword Behind).
And don't forget -- you'd want to look for an integer bounded by spaces, as otherwise you might run into problems if a number is part of an item name. You'd also have to make exceptions so it doesn't catch stuff like "334 scroll".