Wow, thank you very much! I could have never found the solution by myself.
I've updated the OP just in case someone comes across this corner case behaviour.
Out of curiosity, how did you find out?
I... opened the source code. I would not have found it otherwise.
bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*HP_PER_HEART && checkmagiccost(perilid) // Must actually be able to shoot sword beams && ((itemsbuf[wpnid].flags & ITEM_FLAG1) || itemsbuf[wpnid].misc1 <= game->get_maxlife()/HP_PER_HEART));
That `ITEM_FLAG1` thing is the `B. H. is Percent` flag. Fun, isn't it?