foundryvtt-lancer icon indicating copy to clipboard operation
foundryvtt-lancer copied to clipboard

[BUG] No Automation Setting for NPC Recharges

Open Eranziel opened this issue 1 year ago • 5 comments

Describe the bug There is no way to disable the automated NPC recharge roll when they start their turn.

Expected behavior There should be a setting in system automation for disabling the automatic recharge rolls.

Eranziel avatar Apr 28 '23 18:04 Eranziel

I think a stretch goal for this one would be to find a way to only roll once for recharge when multiple GMs are logged in; perhaps a debounce function?

msprijatelj avatar Apr 28 '23 19:04 msprijatelj

Yes, that's a good idea. Would be applicable to things like lock on consumption and (later) damage application.

Brainstorming, maybe a function which returns false if there are any other GMs logged in which are either 1) higher-ranked (GM > assistant GM), or 2) user ID is lower?

Eranziel avatar Apr 28 '23 22:04 Eranziel

There is actually a function for this in Foundry v11 core. game.users.activeGM() returns only one or zero users, so we can use that to see if the active GM is the client's user before running this kind of code.

Eranziel avatar Jan 08 '24 13:01 Eranziel

@Eranziel Would using that function negatively affect people who aren’t the active GM but control an NPC?

msprijatelj avatar Jan 08 '24 17:01 msprijatelj

No, everything should remain the same in that use case. The recharge automation only runs on GM clients currently, but it requires the turn to change. Players can't change the turn due to core Foundry permissions stuff, so there should always be a GM client to handle the automation. The NPC-controlling player would also still be able to click the Recharge button on the NPC sheet if/when needed.

Using game.users.activeGM() instead of user.isGM() just means the code runs only once if multiple GMs are logged in.

Eranziel avatar Jan 08 '24 18:01 Eranziel