crnormand / gurps

Implementing a GURPS 4e game aid for Foundry VTT
MIT License
104 stars 49 forks source link

Feature Request: OtF to allow adding an item to the Effects Modifier #1951

Open Farmeroz opened 1 month ago

Farmeroz commented 1 month ago

Example provided from the GURPS Discord by SavageGM was "character casts Blur for a-5 to be hit and then on success of the spell the macro would automatically put a "-5 Blur" into the Effects Modifier.

If there's a way to do this via JS in the meantime, that would also be great.

Farmeroz commented 1 month ago

Nick provided a link to https://discord.com/channels/228546929494065152/788878698349723669/1273075849943584851 but SavageGM unable to get it to work with their Blur spell.

This is what they have done so far:

// get selected tokens
let tokens = canvas.tokens.controlled

if (tokens && tokens.length > 0) {
 // create a new effect
 let effect = {
  id: 'Blur-5',
  label: 'Blur -5',
  changes: [{
    key: 'data.conditions.target.modifiers',
    value: '-5 for Blur',
    mode: 2 // ADD
   }]
 }

 // toggle the effect for all selected tokens
 for (let token of tokens) {
  token.toggleEffect(effect)
 }
}

Discord message thread: https://discord.com/channels/228546929494065152/788878698349723669/1273076295399510137

mjeffw commented 5 days ago

I just updated the "Cool Macros" page to make this work correctly. I want to add this as a popup GUI feature at some point.