From 9d4704897fae5da7f012e7de700035e3bc8e0ed4 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 3 Apr 2025 22:19:03 -0600 Subject: [PATCH] Update the macros to include a reminder and throw some extra stats into the WorldAPI --- Axolotl-with-a-Gun/guns/AK-47.mjs | 9 +- Axolotl-with-a-Gun/guns/glock.mjs | 11 +- Axolotl-with-a-Gun/guns/gunsword/base.mjs | 112 ++++++++++++++ Axolotl-with-a-Gun/guns/hand-cannon/base.mjs | 102 +++++++++++++ Axolotl-with-a-Gun/guns/mini-gun/base.mjs | 153 +++++++++++++++++++ Axolotl-with-a-Gun/guns/rocket-launcher.mjs | 9 +- Axolotl-with-a-Gun/hobby.mjs | 8 +- 7 files changed, 386 insertions(+), 18 deletions(-) create mode 100644 Axolotl-with-a-Gun/guns/gunsword/base.mjs create mode 100644 Axolotl-with-a-Gun/guns/hand-cannon/base.mjs create mode 100644 Axolotl-with-a-Gun/guns/mini-gun/base.mjs diff --git a/Axolotl-with-a-Gun/guns/AK-47.mjs b/Axolotl-with-a-Gun/guns/AK-47.mjs index 8accf6e..badada8 100644 --- a/Axolotl-with-a-Gun/guns/AK-47.mjs +++ b/Axolotl-with-a-Gun/guns/AK-47.mjs @@ -1,6 +1,6 @@ const notifStyle = ` font-size: 1.5rem; - margin-bottom: 0.5rem; + margin: 0.5rem 0; padding: 6px 8px; box-shadow: 0 0 10px var(--color-shadow-dark); color: var(--color-text-light-1); @@ -78,15 +78,16 @@ async function rollDice() { results.push(`
  • ${total}
  • `); } + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; if (successes >= 8) { - content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; } else if (successes === 0) { - content += `

    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; } diff --git a/Axolotl-with-a-Gun/guns/glock.mjs b/Axolotl-with-a-Gun/guns/glock.mjs index 2c1f167..2aa1f97 100644 --- a/Axolotl-with-a-Gun/guns/glock.mjs +++ b/Axolotl-with-a-Gun/guns/glock.mjs @@ -1,6 +1,6 @@ const notifStyle = ` font-size: 1.5rem; - margin-bottom: 0.5rem; + margin: 0.5rem 0; padding: 6px 8px; box-shadow: 0 0 10px var(--color-shadow-dark); color: var(--color-text-light-1); @@ -15,8 +15,6 @@ const redNotif = ` background: var(--color-level-error-bg); border: 1px solid var(--color-level-error);`; -const blueText = `color: ; filter: sepia(0.5) hue-rotate()`; - async function rollDice() { const sidesOnDice = 6; @@ -74,15 +72,16 @@ async function rollDice() { successes = Math.max(successes, 1); + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; if (successes >= 8) { - content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; } else if (successes === 0) { - content += `

    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; } diff --git a/Axolotl-with-a-Gun/guns/gunsword/base.mjs b/Axolotl-with-a-Gun/guns/gunsword/base.mjs new file mode 100644 index 0000000..9282040 --- /dev/null +++ b/Axolotl-with-a-Gun/guns/gunsword/base.mjs @@ -0,0 +1,112 @@ +const notifStyle = ` + font-size: 1.5rem; + margin: 0.5rem 0; + padding: 6px 8px; + box-shadow: 0 0 10px var(--color-shadow-dark); + color: var(--color-text-light-1); + border-radius: 5px; + text-align: center;`; + +const greenNotif = ` + background: var(--color-level-success-bg); + border: 1px solid var(--color-level-success-border);`; + +const redNotif = ` + background: var(--color-level-error-bg); + border: 1px solid var(--color-level-error);`; + +async function rollDice() { + const sidesOnDice = 6; + + let comboCount = game.user.getFlag(`world`, `comboCount`) ?? 0; + + const answers = await DialogManager.ask({ + id: `gunsword-dice-pool`, + question: `Set up your dice pool:`, + inputs: [ + { + key: `statBase`, + inputType: `number`, + label: `Stat Base`, + autofocus: true, + }, + { + key: `extraDice`, + inputType: `number`, + label: `Extra Dice`, + defaultValue: 0, + }, + { + key: `comboCount`, + inputType: `hidden`, + label: `Combo`, + details: `Your current C-C-C-Combo Meter is at: ${comboCount}`, + }, + ], + }); + const { statBase, extraDice } = answers; + let rollMode = game.settings.get(`core`, `rollMode`); + + let diceCount = statBase; + diceCount += extraDice; + + let successes = 0; + let critsOnly = 0; + const results = []; + for (let i = diceCount; i > 0; i--) { + let r = new Roll(`1d${sidesOnDice}`); + await r.evaluate(); + let classes = `roll die d${sidesOnDice}`; + + const total = r.total; + + if (total === statBase && critsOnly === 0) { + successes += comboCount; + critsOnly += 1; + classes += ` success`; + comboCount = 0; + } + else if (total <= statBase) { + successes += 1; + comboCount += 1; + } + else { + classes += ` discarded` + } + + // Save dice stats if present + WorldAPI?.saveRollValue?.(sidesOnDice, total); + + results.push(`
  • ${total}
  • `); + } + + game.user.setFlag(`world`, `comboCount`, comboCount); + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}
    Combo Count After Roll: ${comboCount}`; + + if (successes >= 8) { + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + } + else if (successes === 0) { + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + } + + if (rollMode === CONST.DICE_ROLL_MODES.BLIND) { + ui.notifications.info(`Cannot make a blind roll from the macro, rolling with mode "Private GM Roll" instead`); + rollMode = CONST.DICE_ROLL_MODES.PRIVATE; + }; + + const chatData = ChatMessage.applyRollMode( + { + flavor: `(Gun: Gunsword)`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +rollDice(); \ No newline at end of file diff --git a/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs b/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs new file mode 100644 index 0000000..268d6cd --- /dev/null +++ b/Axolotl-with-a-Gun/guns/hand-cannon/base.mjs @@ -0,0 +1,102 @@ +const notifStyle = ` + font-size: 1.5rem; + margin: 0.5rem 0; + padding: 6px 8px; + box-shadow: 0 0 10px var(--color-shadow-dark); + color: var(--color-text-light-1); + border-radius: 5px; + text-align: center;`; + +const greenNotif = ` + background: var(--color-level-success-bg); + border: 1px solid var(--color-level-success-border);`; + +const redNotif = ` + background: var(--color-level-error-bg); + border: 1px solid var(--color-level-error);`; + +async function rollDice() { + const sidesOnDice = 6; + + const answers = await DialogManager.ask({ + id: `gunsword-dice-pool`, + question: `Set up your dice pool:`, + inputs: [ + { + key: `statBase`, + inputType: `number`, + label: `Stat Base`, + autofocus: true, + }, + { + key: `extraDice`, + inputType: `number`, + label: `Extra Dice`, + defaultValue: 0, + }, + ], + }); + const { statBase, extraDice } = answers; + let rollMode = game.settings.get(`core`, `rollMode`); + + let diceCount = statBase; + diceCount += extraDice; + + let successes = 0; + let critsOnly = 0; + const results = []; + for (let i = diceCount; i > 0; i--) { + let r = new Roll(`1d${sidesOnDice}x=${statBase}`); + await r.evaluate(); + + for (const die of r.terms[0].results) { + let classes = `roll die d${sidesOnDice}`; + const total = die.result; + + if (total <= statBase) { + successes += 1; + } + else { + classes += ` discarded` + } + if (total === statBase) { + successes += 1; + critsOnly += 1; + classes += ` success exploded`; + } + // Save dice stats if present + WorldAPI?.saveRollValue?.(sidesOnDice, total); + + results.push(`
  • ${total}
  • `); + } + } + + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; + + if (successes >= 8) { + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + } + else if (successes === 0) { + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + } + + if (rollMode === CONST.DICE_ROLL_MODES.BLIND) { + ui.notifications.info(`Cannot make a blind roll from the macro, rolling with mode "Private GM Roll" instead`); + rollMode = CONST.DICE_ROLL_MODES.PRIVATE; + }; + + const chatData = ChatMessage.applyRollMode( + { + flavor: `(Gun: Hand Cannon)`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +rollDice(); \ No newline at end of file diff --git a/Axolotl-with-a-Gun/guns/mini-gun/base.mjs b/Axolotl-with-a-Gun/guns/mini-gun/base.mjs new file mode 100644 index 0000000..d0e2962 --- /dev/null +++ b/Axolotl-with-a-Gun/guns/mini-gun/base.mjs @@ -0,0 +1,153 @@ +const notifStyle = ` + font-size: 1.5rem; + margin: 0.5rem 0; + padding: 6px 8px; + box-shadow: 0 0 10px var(--color-shadow-dark); + color: var(--color-text-light-1); + border-radius: 5px; + text-align: center;`; + +const greenNotif = ` + background: var(--color-level-success-bg); + border: 1px solid var(--color-level-success-border);`; + +const redNotif = ` + background: var(--color-level-error-bg); + border: 1px solid var(--color-level-error);`; + +async function main() { + let heatMeter = game.user.getFlag(`world`, `heatMeter`) ?? 0; + + const answers = await DialogManager.ask({ + id: `mini-gun-dice-pool`, + question: `Set up your dice pool:`, + inputs: [ + { + key: `statBase`, + inputType: `number`, + label: `Stat Base`, + autofocus: true, + }, + { + key: `extraDice`, + inputType: `number`, + label: `Extra Dice`, + defaultValue: 0, + }, + ], + }); + const { statBase, extraDice } = answers; + let rollMode = game.settings.get(`core`, `rollMode`); + + let diceCount = statBase; + diceCount += extraDice; + + let gunLoss = 0; + let successes = 0; + let critsOnly = 0; + let results = []; + for (let i = 0; i < diceCount; i++) { + let succeeded = false; + + let r = new Roll(`1d6`); + await r.evaluate(); + let classes = `roll die d6`; + + const total = r.total; + + if (total <= statBase) { + successes += 1; + succeeded = true; + } + else { + classes += ` discarded` + } + if (total === statBase) { + successes += 1; + critsOnly += 1; + classes += ` success`; + } + + if (succeeded) { + try { + const { holdTheTrigger } = await DialogManager.ask({ + id: `mini-gun-hold-the-trigger`, + question: `Hold The Trigger?`, + inputs: [ + { + key: `_1`, + inputType: `hidden`, + label: `Success Count: ${successes}`, + }, + { + key: `_2`, + inputType: `hidden`, + label: `Total Dice Rolled: ${i + 1}/${diceCount}`, + }, + { + key: `_3`, + inputType: `hidden`, + label: `Current Heat: ${heatMeter}/6`, + }, + { + key: `holdTheTrigger`, + inputType: `checkbox`, + label: `Hold The Trigger?`, + details: `If you hold the trigger, you roll an additional dice, and gain 1 heat. If you don't hold the trigger, you lose one heat. When you reach 6 heat, you lost all heat and lose 2 GUN.`, + defaultValue: false, + autofocus: true, + } + ], + }); + heatMeter += (holdTheTrigger ? 1 : -1); + if (holdTheTrigger) { + diceCount += 1; + } + if (heatMeter >= 6) { + heatMeter = 0; + gunLoss += 2; + } + } catch {}; + } + + // Save dice stats if present + WorldAPI?.saveRollValue?.(sidesOnDice, total); + + results.push(`
  • ${total}
  • `); + }; + + game.user.setFlag(`world`, `heatMeter`, heatMeter); + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); + WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); + + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}
    Final Heat: ${heatMeter}`; + + if (gunLoss > 0) { + content += `
    Lose ${gunLoss} GUN
    `; + } + + if (successes >= 8) { + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; + } + else if (successes === 0) { + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + } + + + if (rollMode === CONST.DICE_ROLL_MODES.BLIND) { + ui.notifications.info(`Cannot make a blind roll from the macro, rolling with mode "Private GM Roll" instead`); + rollMode = CONST.DICE_ROLL_MODES.PRIVATE; + }; + + const chatData = ChatMessage.applyRollMode( + { + flavor: `(Gun: Mini-Gun)`, + content, + }, + rollMode, + ); + + await ChatMessage.implementation.create(chatData); +} + +main(); \ No newline at end of file diff --git a/Axolotl-with-a-Gun/guns/rocket-launcher.mjs b/Axolotl-with-a-Gun/guns/rocket-launcher.mjs index 958e81f..5fc1740 100644 --- a/Axolotl-with-a-Gun/guns/rocket-launcher.mjs +++ b/Axolotl-with-a-Gun/guns/rocket-launcher.mjs @@ -1,6 +1,6 @@ const notifStyle = ` font-size: 1.5rem; - margin-bottom: 0.5rem; + margin: 0.5rem 0; padding: 6px 8px; box-shadow: 0 0 10px var(--color-shadow-dark); color: var(--color-text-light-1); @@ -65,15 +65,16 @@ async function rollDice() { results.push(`
  • ${total}
  • `); } + WorldAPI?.saveRollValue?.(20, Math.min(diceCount, 20)); WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; if (successes >= 8) { - content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + content += `
    POP OFF
    Add one to your hobby stat and gain 1 additional Momentum!`; } else if (successes === 0) { - content += `

    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; } diff --git a/Axolotl-with-a-Gun/hobby.mjs b/Axolotl-with-a-Gun/hobby.mjs index cdae639..b00f841 100644 --- a/Axolotl-with-a-Gun/hobby.mjs +++ b/Axolotl-with-a-Gun/hobby.mjs @@ -1,6 +1,6 @@ const notifStyle = ` font-size: 1.5rem; - margin-bottom: 0.5rem; + margin: 0.5rem 0; padding: 6px 8px; box-shadow: 0 0 10px var(--color-shadow-dark); color: var(--color-text-light-1); @@ -71,13 +71,13 @@ async function rollDice() { WorldAPI?.saveRollValue?.(100, successes === 0 ? 100 : successes); - let content = `Rolls:
      ${results.join(`\n`)}

    Successes: ${successes}
    Crits: ${critsOnly}`; + let content = `Rolls:
      ${results.join(`\n`)}

    Gain 1 Momentum
    Successes: ${successes}
    Crits: ${critsOnly}`; if (successes >= 8) { - content += `

    POP OFF
    Add one to the stat you didn't use and gain 1 Momentum!`; + content += `
    POP OFF
    Add one to your gun stat and gain 1 additional Momentum!`; } else if (successes === 0) { - content += `

    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; + content += `
    Pinned Down
    Roll a d6, rescuing you becomes a new objective`; }