PDA

View Full Version : Simple ammo counter for 4E ruleset



valeros
April 14th, 2020, 03:48
Simple ammo counter for the 4E ruleset by using code from the 5E ruleset.

The ammo only displays with the weapon on the combat tab of the full character sheet or the main tab if the mini character sheet. (That was existing functionality.) It does not display with the power on the Powers tab (though using a power will still decrement the ammo.)

Since the actual weapon databasenode used in an attack is not passed in the call to perform an attack (and I was not willing to find all the places attacks can be called from and fixing it there), the ammo is decremented based on the weapon name. So if you have two weapons named the same, it will decrement from the first one it finds. It does try to distinguish between the melee and thrown version of the same weapon (e.g., a dagger), but otherwise the first match is used.

kevininrussia
April 14th, 2020, 05:07
Thank you! Works great! But of course I am going to ask for another feature :-) Currently if there are two targets attacked, only one ammo is used. Is it possible to decrease the ammo based on how many targets are attacked? For example: Ranger power - Split the Tree

Thanks again!

valeros
April 14th, 2020, 07:00
Ok, try this one. It decrements one per target. And not based on the targets in the power but by how many targets Fantasy Grounds shows. That is, if you target 10 creatures with Split the Tree, Fantasy Grounds rolls against 10 targets, so this decrements 10, not just two like the power says. Also, be warned that there is a chain of function calls made between when the weapon info is available and when the targets are available. So there is the possibility something can happen between them and somehow this extension will miss something or count wrong. I hope not (it worked for me), but be on the lookout when you use it at first.

kevininrussia
April 14th, 2020, 07:23
Works perfectly in my tests. Thanks!

valeros
April 15th, 2020, 04:07
Updated to not crash with rolling with NPCs