Describe the bug
When using flatten proficiency to subtract level from attacks you get the correct value on the attacks themselves (-level) but incorrect on the experimental version of the strikes, which subtracts level a second time. This is caused by the loop which reduces the base attack value in addition to adding a custom "Proficiency without Level" penalty to the NPC, which only the experimental strikes use and which causes the level to be subtracted a second time.
To Reproduce
Steps to reproduce the behavior:
- Enable Flatten Proficiency in settings.
- Choose an NPC with a level other than 0 in the actor tab.
- Check strike values (i.e. a Grizzly Bear, a level 3 NPC, has +11 to strike with normal rules).
- Right click and select "Flatten NPC".
- Check strike values again...normal attack values will be +8 (11 base - 3 level) and experimental strike value will be +5 (11 base - 3 level from adjustment - 3 from Proficiency without Level modifier).
Expected behavior
Ideally both experimental strikes and normal strikes would work at the correct values when the creature is flattened. NOTE: I implemented a basic fix for my own use, code modification is below if you're interested (although it's not necessarily the best solution).
Screenshots
Normal View:
Flattened View (with bug):
Note that the experimental strikes are 3 lower than the normal strikes.
With my "fix":
Version Information:
- Electron browser (replicated on Chrome since it's a mechanics issue).
- FoundryVTT 0.7.9
- PF2E Toolbox 1.5.8
- Tested with all other modules deactivated as part of debugging.
Additional context
In my own version of the code I modified the buttons.unshift() functions for Flatten NPC in the following manner (the parts I removed are in comments here):
name: 'Flatten NPC',
icon: '<i class="fas fa-level-down-alt"></i>',
condition: (li) => {
const id = li.data('entity-id');
const actor = game.actors.get(id);
return actor.data.type === 'npc' && !hasModifier(actor);
},
callback: async (li) => {
const id = li.data('entity-id');
const actor = game.actors.get(id);
const level = parseInt(actor.data.data.details.level.value);
actor.addCustomModifier('all', modifierName, -level, 'untyped');
// let itemUpdates = [];
// for (let i = 0; i < actor.data['items'].length; i++) {
// const item = actor.data['items'][i];
// if (item.type === 'melee') {
// const oldAttack = parseInt(item.data.bonus.value);
// const newAttack = oldAttack - level;
// const attackUpdate = {
// _id: item._id,
// ['data.bonus.value']: newAttack,
// ['data.bonus.total']: newAttack,
// };
// itemUpdates.push(attackUpdate);
// }
// }
// await actor.updateEmbeddedEntity('OwnedItem', itemUpdates);
},
});
I did not include the second function because I removed the exact same block for both.
This fix works for me because I only use the experimental rolling method. I also tried changing the value of the modifier to 0 and only editing the strikes directly, but this removes all other level scaling (AC, saves, etc.). I'm not sure if this is a recent change in the Pathfinder 2e Foundry module that is causing this or if it's a long term bug and people just aren't messing with the option.
I do know that the core PF2e module does not support NPC scaling for proficiency without level, making that option of limited use. And ideal version for me would be a check box that would let me flatten or unflatten all NPCs automatically but I'll have to do some more research to find a solution for that.