crnormand / gurps

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

Chat command for visual/sound effects. #617

Closed crnormand closed 3 years ago

crnormand commented 3 years ago

@cefasheli / Boifubá showed me a macro that he is using. "this code is a frankestein, it's not mine" the idea is great!

I am thinking of a system of chat commands (and system properties) to allow the user to define certain visual or sound effects and trigger them using a chat command, so it could be used in an OtF button. Of course, this would require a 3rd party module.

Maybe something like:

[/if [S:Fireball] /show "Fireball"]

Where "Fireball" has been defined elsewhere (system setting). To make it most effective, it would prompt the user to click on a location (we would read the mouse), and it would display the effect there.

This would do damage (and show the fireball) [/r [2d+2 burn]\/show Fireball]

Or maybe we could enhance the damage parsing to allow:

[2d+2 burn /show Fireball]

//Requires and Target to be Targetted
if(game.user.targets.size == 0) ui.notifications.error('You must target at least one token');
//Requires the originating token to be selected
if(canvas.tokens.controlled.length == 0) ui.notifications.error("Please select your token");
//Requires FX Master Module
if (!canvas.fxmaster) ui.notifications.error("This macro depends on the FXMaster module. Make sure it is installed and enabled");

const sleepNow = (delay) => new Promise((resolve) => setTimeout(resolve, delay))

async function Cast() {

// Scaled globally for consistency across scenes. Change divisor for size of animation
let Scale = canvas.scene.data.grid/175;
var plusOrMinus = Math.random() < 0.5 ? -1 : 1;
// Uses FX Master's Draw Towards function
function castSpell(effect) {
  const tokens = canvas.tokens.controlled;
  game.user.targets.forEach((i, t) => {
    canvas.fxmaster.drawSpecialToward(effect, tokens[0], t);

  });
}
//File path for the animated asset.
let file = "modules/jb2a_patreon/Library/Generic/Weapon_Attacks/Melee/";

castSpell({
//Animated file
  file: `${file}Sword01_Fire_Regular_Blue_800x600.webm`,
  anchor: {
    x: 0.4,
    y: 0.5,
  },
  speed: 0,
  angle: 0,
  scale: {
    x: Scale,
    y: (Scale * plusOrMinus),
  },
});

// Add some sound to the effects
/*
let soundFile = `sound path here`;
AudioHelper.play({src: soundFile, volume: 1.0, autoplay: true, loop: false}, true);
*/

// Delete comments to activate token Magic FX. Requires the Token Magic FX Modules to be installed
/*
let params =
[{
    filterType: "images",
    filterId: "myMirrorImages",
    time: 0,
    nbImage: 2,
    alphaImg: 1.0,
    alphaChr: 0.0,
    autoDestroy: true,
    blend: 4,
    ampX: 0.03,
    ampY: 0.03,
    zOrder: 20,
    animated :
    {
      time: 
      { 
        active: true, 
        speed: 0.070, 
        animType: "move", 
        loopDuration: 200,
        loops: 2
      },
       anchorX:
       {
          animType: "chaoticOscillation",
          loopDuration : 100,
          val1: 0.40,
          val2: 0.60,
          loops:4
       } 
}}];
await sleepNow(900);
TokenMagic.addUpdateFiltersOnTargeted(params);
*/
}
Cast ()
GURPS.SetLastActor(game.actors.get('PvpdXORKNNnHatrh'))
GURPS.executeOTF(`A:"Bastard Sword (Swing - One Handed)"`)
Boifuba commented 3 years ago

About the Third Part modules, i suggest look theses.

Jb2a - have several effects for free Otigons Animation Macros - have lots of macro who work together with JB2M TokenFX Furnace

Actually with Furnace Module we can call any macro what we want! You just need to send a GURPS.executeOTF to a chat with {{macro:"macro name"}} to chat. Furnace recognize the line and execute the macro. So we have theses effects... another way is using Otigons+JB2M with the usual OTF.