The first version of the formula has a syntax error somewhere in it, crashing the game when called. The second, simplified version of the formula works perfectly. It seems like this is a somewhat different way of using scripts and the damage formula box; it's very useful to know.
I've run into a problem, however. When the enemies would all die to bombs on the first turn, the variable goes up by one; when I attack a lone Skeleton, it does 242 damage, but displays 116. I then tested this with two throwaway debug enemies, which have 10 DEF and 110 HP, and the game showed them taking 76 damage, but dying. If I use the bombs on an enemy with more health, enough to survive the attack, it works fine; the solution to this, I assume, would be to only increase the variable after damage has been shown on screen, somehow.
Also, no, I'm not sure how to have the skill cost a common event, but I do know how to make the skill cost set the variable I'm using to 0. I'm using Yanfly's Skill Cost Manager, and these notetags:
<custom cost requirement>
$game_party.item_number($data_items) >= 1
</custom cost requirement>
<custom cost perform>
$game_variables == 0
</custom cost perform>
For clarity, I have the player equip a Bomb weapon, and change the default attack to this one when that weapon is equipped.
Also, about the animation - I'd like for it to be centered on the enemies, and only display as many explosions as there are enemies. Setting it to the "screen" setting makes the animation just play a single explosion, in the center of the screen, then do damage, which is nice, since the damage step happens quicker - but perhaps I should make multiple animations, and multiple skills, depending on how many enemies are being targeted, then change which skill is used depending on how many enemies there are?