Skip to content

Instantly share code, notes, and snippets.

@7H3LaughingMan
Last active December 24, 2024 00:57
Show Gist options
  • Save 7H3LaughingMan/dfac0caafeb18cf5d37152c58dd358f1 to your computer and use it in GitHub Desktop.
Save 7H3LaughingMan/dfac0caafeb18cf5d37152c58dd358f1 to your computer and use it in GitHub Desktop.
Alchemist Exploration
let cumulativeDelta = 0;
Hooks.on("updateWorldTime", (worldTime, delta) => {
if (game.combat || !game.user.character) {
cumulativeDelta = 0;
return;
}
if (delta < 0) {
cumulativeDelta = 0;
delta = 0;
} else if (delta > 3600) {
delta = 3600;
}
cumulativeDelta += delta;
if (cumulativeDelta >= 600) {
const rounds = Math.floor(cumulativeDelta / 600);
const versatileVials = game.user.character.getResource("versatileVials");
if (versatileVials) {
const vials = game.user.character.level >= 9 ? 3 : 2;
await game.user.character.updateResource("versatileVials", versatileVials.value + vials * rounds);
}
cumulativeDelta %= 600;
}
});
ui.notifications.info("Created Alchemist Exploration Hook");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment