Skip to content

Commit

Permalink
Merge branch 'Viscious-Mockery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Faizan Ahmad committed Apr 15, 2022
2 parents 7d1fca9 + 5f4c8bc commit 4015861
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 4 deletions.
30 changes: 29 additions & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ASE.LightningBolt": "Lightning Bolt",
"ASE.ChainLightning": "Chain Lightning",
"ASE.MirrorImage": "Mirror Image",
"ASE.ViciousMockery": "Vicious Mockery",

"ASE.SummonAberration": "Summon Aberration",
"ASE.SummonBeast": "Summon Beast",
Expand Down Expand Up @@ -471,5 +472,32 @@
"ASE.ThunderShatterEffectSoundDelayLabel": "Thunder Shatter Effect Sound Delay: ",
"ASE.ThunderShatterEffectSoundDelayTooltip": "Delay before playing the Thunder Shatter effect sound relative to the Thunder Shatter effect",
"ASE.ThunderShatterEffectSoundVolumeLabel": "Thunder Shatter Effect Volume: ",
"ASE.ThunderShatterEffectSoundVolumeTooltip": "Volume of the Thunder Shatter effect sound"
"ASE.ThunderShatterEffectSoundVolumeTooltip": "Volume of the Thunder Shatter effect sound",

"ASE.EffectSpeedLabel": "Effect Speed: ",
"ASE.EffectSpeedTooltip": "Relative speed of the words flying towards the target, 1 is default, 2 is twice as fast",
"ASE.EffectFontLabel": "Font Family: ",
"ASE.EffectFontTooltip": "Font used for the effect",
"ASE.FontSizeLabel": "Font Size: ",
"ASE.FontSizeTooltip": "Font size used for the effect",
"ASE.EffectFillColorALabel": "Fill Color A: ",
"ASE.EffectFillColorATooltip": "First fill color used for the effect",
"ASE.EffectFillColorBLabel": "Fill Color B: ",
"ASE.EffectFillColorBTooltip": "Second fill color used for the effect",
"ASE.RandomGlowLabel": "Random Glow: ",
"ASE.RandomGlowTooltip": "Randomly select a glow color for the effect",
"ASE.EffectGlowColorLabel": "Glow Color: ",
"ASE.EffectGlowColorTooltip": "Glow color used for the effect",
"ASE.EffectGlowDistanceLabel": "Glow Distance: ",
"ASE.EffectGlowDistanceTooltip": "Distance of the glow from the effect",
"ASE.EffectGlowOuterStrengthLabel": "Glow Outer Strength: ",
"ASE.EffectGlowOuterStrengthTooltip": "Strength of the outer glow",
"ASE.EffectGlowInnerStrengthLabel": "Glow Inner Strength: ",
"ASE.EffectGlowInnerStrengthTooltip": "Strength of the inner glow",
"ASE.ViscousMockerySoundLabel": "Effect Sound: ",
"ASE.ViscousMockerySoundTooltip": "Sound played when the effect is triggered",
"ASE.ViscousMockerySoundDelayLabel": "Effect Sound Delay: ",
"ASE.ViscousMockerySoundDelayTooltip": "Delay before playing the effect sound relative to the effect",
"ASE.ViscousMockerySoundVolumeLabel": "Effect Volume: ",
"ASE.ViscousMockerySoundVolumeTooltip": "Volume of the effect sound"
}
5 changes: 5 additions & 0 deletions scripts/ASEHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { chainLightning } from "./spells/chainLightning.js";
import { mirrorImage } from "./spells/mirrorImage.js";
import { wallOfForce } from "./spells/wallOfForce.js";
import { detectStuff } from "./spells/detectStuff.js";
import { viciousMockery } from "./spells/viciousMockery.js";

export class ASEHandler {
static async handleASE(data) {
Expand Down Expand Up @@ -133,6 +134,10 @@ export class ASEHandler {
case game.i18n.localize('ASE.WallOfForce'):
wallOfForce.createWallOfForce(data);
return;
case game.i18n.localize('ASE.ViciousMockery'):
const viciousMockerySpell = new viciousMockery(data);
viciousMockerySpell.cast();
return;
}
if (item.name.includes(game.i18n.localize("ASE.Summon")) || aseFlags.spellEffect.includes(game.i18n.localize("ASE.Summon"))) {
await summonCreature.doSummon(data);
Expand Down
11 changes: 11 additions & 0 deletions scripts/apps/aseSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { mirrorImage } from "../spells/mirrorImage.js";
import { wallOfForce } from "../spells/wallOfForce.js";
import { chaosBolt } from "../spells/chaosBolt.js";
import { detectStuff } from "../spells/detectStuff.js";
import { viciousMockery } from "../spells/viciousMockery.js";

export class ASESettings extends FormApplication {
constructor() {
super(...arguments);
Expand Down Expand Up @@ -50,6 +52,7 @@ export class ASESettings extends FormApplication {
this.spellList[game.i18n.localize("ASE.Summon")] = summonCreature;
this.spellList[game.i18n.localize("ASE.WallOfForce")] = wallOfForce;
this.spellList[game.i18n.localize("ASE.DetectStuff")] = detectStuff;
this.spellList[game.i18n.localize("ASE.ViciousMockery")] = viciousMockery;
}

static get defaultOptions() {
Expand Down Expand Up @@ -142,6 +145,14 @@ export class ASESettings extends FormApplication {
data.save = { ability: "dex", dc: null, scaling: "spell" };
data.target = { value: 1, width: null, units: "", type: "creature" };
break;
case game.i18n.localize("ASE.ViciousMockery"):
data.level = 0;
data.actionType = "save";
data.damage.parts.push(["1d4", "psychic"]);
data.save = { ability: "wis", dc: null, scaling: "spell" };
data.target = { value: 1, width: null, units: "", type: "creature" };
data.scaling = { mode: "cantrip", formula: "1d4" };
break;
}
let updates = { data };
await item.update(updates);
Expand Down
252 changes: 252 additions & 0 deletions scripts/spells/viciousMockery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import { aseSocket } from "../aseSockets.js";
import * as utilFunctions from "../utilityFunctions.js";

export class viciousMockery {

constructor(data) {
this.params = data;
this.actor = game.actors.get(this.params.actor.id);
this.token = canvas.tokens.get(this.params.tokenId);
this.item = this.params.item;
this.effectOptions = this.item.getFlag("advancedspelleffects", "effectOptions");
this.isMidiActive = utilFunctions.isMidiActive();
this.target = Array.from(this.params.targets)[0];
this.cussVault = ['!', '@', '#', '$', '%', '&'];
}

static registerHooks() {
return;
}

async cast() {
await this.playSequence();

}

async playSequence() {
const caster = this.token;
const target = this.target;
const useRandomGlow = this.effectOptions.randomGlow;
const glowColor = useRandomGlow ? utilFunctions.getRandomColor("0x") : utilFunctions.convertColorHexTo0x(this.effectOptions?.glowColor ?? "#f01414");
const glowDistance = this.effectOptions?.glowDistance ?? 30;
const glowOuterStrength = this.effectOptions?.glowOuterStrength ?? 2;
const glowInnerStrength = this.effectOptions?.glowInnerStrength ?? 0.25;
const fontFamily = this.effectOptions?.font ?? "Impact";
const fontSize = this.effectOptions?.size ?? 38;
const fontFillColorA = this.effectOptions?.fillColorA ?? "#f01414";
const fontFillColorB = this.effectOptions?.fillColorB ?? "#931a1a";
const soundFile = this.effectOptions?.sound ?? "";
const soundDelay = this.effectOptions?.soundDelay ?? 0;
const soundVolume = this.effectOptions?.soundVolume ?? 0.5;
const textOptions = {
"dropShadowAngle": 7.6,
"fontFamily": fontFamily,
"fontSize": fontSize,
"fontStyle": "oblique",
"fontVariant": "small-caps",
"fontWeight": "bolder",
"fill": [
fontFillColorA,
fontFillColorB
],
};
const distance = utilFunctions.getDistanceClassic({ x: caster.x, y: caster.y }, { x: target.x, y: target.y });
let viciousMockerySeq = new Sequence();
viciousMockerySeq
.sound()
.file(soundFile)
.delay(soundDelay)
.volume(soundVolume)
.playIf(soundFile && soundFile !== "");

for (let i = 0; i < utilFunctions.getRandomInt(5, 8); i++) {
viciousMockerySeq.effect()
.moveTowards(target, { ease: "easeInOutElastic" })
.moveSpeed(distance / 2.5)
.atLocation(caster)
.text(this.makeCussWord(), textOptions)
.animateProperty("sprite", "rotation", { from: 0, to: 720, duration: 1200, ease: "easeInOutCubic" })
.animateProperty("sprite", "scale.x", { from: 0, to: 1, duration: 1200, ease: "easeInOutCubic" })
.animateProperty("sprite", "scale.y", { from: 0, to: 1, duration: 1200, ease: "easeInOutCubic" })
.randomOffset()
.animateProperty("sprite", "scale.x", { from: 1, to: 0, delay: 1250, duration: 600, ease: "easeInOutCubic" })
.animateProperty("sprite", "scale.y", { from: 1, to: 0, delay: 1250, duration: 600, ease: "easeInOutCubic" })
.filter("Glow", { color: glowColor, distance: glowDistance, outerStrength: glowOuterStrength, innerStrength: glowInnerStrength })
.wait(utilFunctions.getRandomInt(50, 75))
}
viciousMockerySeq.play();
}

makeCussWord() {
let cussWordList = [];
for (let i = 0; i < utilFunctions.getRandomInt(4, 10); i++) {
cussWordList.push(this.cussVault[utilFunctions.getRandomInt(0, this.cussVault.length - 1)]);
}
let cussWord = cussWordList.join("");
return cussWord;
}

static async getRequiredSettings(currFlags) {
if (!currFlags) currFlags = {};
let spellOptions = [];
let animOptions = [];
let soundOptions = [];

const effectFontOptions = {
"serif": "Serif",
"Georgia serif": "Georgia",
"Palatino": "Palatino",
"Times New Roman": "Times New Roman",
"Times": "Times",
"sans-serif": "Sans-Serif",
"Arial": "Arial",
"Helvetica": "Helvetica",
"Arial Black": "Arial Black",
"Gadget": "Gadget",
"Comic Sans MS": "Comic Sans MS",
"cursive": "Cursive",
"Impact": "Impact",
"Charcoal": "Charcoal",
"Lucida Sans Unicode": "Lucida Sans Unicode",
"Lucida Grande": "Lucida Grande",
"Tahoma": "Tahoma",
"Geneva": "Geneva",
"Trebuchet MS": "Trebuchet MS",
"Verdana": "Verdana",
"Courier New, monospace": "Courier New",
"Courier": "Courier",
"Monaco": "Monaco",
"MS PGothic": "MS PGothic",
"Indie Flower": "Indie Flower",
};

/* animOptions.push({
label: game.i18n.localize("ASE.EffectSpeedLabel"),
tooltip: game.i18n.localize("ASE.EffectSpeedTooltip"),
type: 'rangeInput',
name: 'flags.advancedspelleffects.effectOptions.speedModifier',
flagName: 'speedModifier',
flagValue: currFlags.speedModifier ?? 1,
min: 0.1,
max: 2,
step: 0.1,
});*/

animOptions.push({
label: game.i18n.localize("ASE.EffectFontLabel"),
tooltip: game.i18n.localize("ASE.EffectFontTooltip"),
type: 'dropdown',
options: effectFontOptions,
name: 'flags.advancedspelleffects.effectOptions.font',
flagName: 'font',
flagValue: currFlags.font ?? 'Impact',
});

animOptions.push({
label: game.i18n.localize("ASE.FontSizeLabel"),
tooltip: game.i18n.localize("ASE.FontSizeTooltip"),
type: 'numberInput',
name: 'flags.advancedspelleffects.effectOptions.size',
flagName: 'size',
flagValue: currFlags.size ?? 38,
});

animOptions.push({
label: game.i18n.localize("ASE.EffectFillColorALabel"),
tooltip: game.i18n.localize("ASE.EffectFillColorATooltip"),
type: 'colorPicker',
name: 'flags.advancedspelleffects.effectOptions.fillColorA',
flagName: 'fillColorA',
flagValue: currFlags.fillColorA ?? '#f01414',
});

animOptions.push({
label: game.i18n.localize("ASE.EffectFillColorBLabel"),
tooltip: game.i18n.localize("ASE.EffectFillColorBTooltip"),
type: 'colorPicker',
name: 'flags.advancedspelleffects.effectOptions.fillColorB',
flagName: 'fillColorB',
flagValue: currFlags.fillColorB ?? '#931a1a',
});

animOptions.push({
label: game.i18n.localize("ASE.RandomGlowLabel"),
tooltip: game.i18n.localize("ASE.RandomGlowTooltip"),
type: 'checkbox',
name: 'flags.advancedspelleffects.effectOptions.randomGlow',
flagName: 'randomGlow',
flagValue: currFlags.randomGlow ?? true,
});

animOptions.push({
label: game.i18n.localize("ASE.EffectGlowColorLabel"),
tooltip: game.i18n.localize("ASE.EffectGlowColorTooltip"),
type: 'colorPicker',
name: 'flags.advancedspelleffects.effectOptions.glowColor',
flagName: 'glowColor',
flagValue: currFlags.glowColor ?? '#f01414',
});

animOptions.push({
label: game.i18n.localize("ASE.EffectGlowDistanceLabel"),
tooltip: game.i18n.localize("ASE.EffectGlowDistanceTooltip"),
type: 'numberInput',
name: 'flags.advancedspelleffects.effectOptions.glowDistance',
flagName: 'glowDistance',
flagValue: currFlags.glowDistance ?? 30,
});

animOptions.push({
label: game.i18n.localize("ASE.EffectGlowOuterStrengthLabel"),
tooltip: game.i18n.localize("ASE.EffectGlowOuterStrengthTooltip"),
type: 'numberInput',
name: 'flags.advancedspelleffects.effectOptions.glowOuterStrength',
flagName: 'glowOuterStrength',
flagValue: currFlags.glowOuterStrength ?? 2,
});

animOptions.push({
label: game.i18n.localize("ASE.EffectGlowInnerStrengthLabel"),
tooltip: game.i18n.localize("ASE.EffectGlowInnerStrengthTooltip"),
type: 'numberInput',
name: 'flags.advancedspelleffects.effectOptions.glowInnerStrength',
flagName: 'glowInnerStrength',
flagValue: currFlags.glowInnerStrength ?? 0.25,
});

soundOptions.push({
label: game.i18n.localize("ASE.ViscousMockerySoundLabel"),
tooltip: game.i18n.localize("ASE.ViscousMockerySoundTooltip"),
type: 'fileInput',
name: 'flags.advancedspelleffects.effectOptions.sound',
flagName: 'sound',
flagValue: currFlags.sound ?? '',
});
soundOptions.push({
label: game.i18n.localize("ASE.ViscousMockerySoundDelayLabel"),
tooltip: game.i18n.localize("ASE.ViscousMockerySoundDelayTooltip"),
type: 'numberInput',
name: 'flags.advancedspelleffects.effectOptions.soundDelay',
flagName: 'soundDelay',
flagValue: currFlags.soundDelay ?? 0,
});
soundOptions.push({
label: game.i18n.localize("ASE.ViscousMockerySoundVolumeLabel"),
tooltip: game.i18n.localize("ASE.ViscousMockerySoundVolumeTooltip"),
type: 'rangeInput',
name: 'flags.advancedspelleffects.effectOptions.soundVolume',
flagName: 'soundVolume',
flagValue: currFlags.soundVolume ?? 0.5,
min: 0,
max: 1,
step: 0.01,
});

return {
spellOptions: spellOptions,
animOptions: animOptions,
soundOptions: soundOptions
}

}
}
15 changes: 12 additions & 3 deletions scripts/templates/ase-settings-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@
{{/ifCondASE}}
{{#ifCondASE this.type '==' 'rangeInput'}}
<input type="range" min="{{this.min}}" max="{{this.max}}"
step="{{this.step}}" name="{{this.name}}" value={{this.flagValue}}>
step="{{this.step}}"
oninput="this.nextElementSibling.value = this.value"
name="{{this.name}}" value={{this.flagValue}}>
<output style="font-weight: bold;">{{this.flagValue}}</output>
{{/ifCondASE}}
{{#ifCondASE this.type '==' 'textInput'}}
<input type="text" name="{{this.name}}" value={{this.flagValue}}>
Expand Down Expand Up @@ -220,7 +223,10 @@
{{/ifCondASE}}
{{#ifCondASE this.type '==' 'rangeInput'}}
<input type="range" min="{{this.min}}" max="{{this.max}}"
step="{{this.step}}" name="{{this.name}}" value={{this.flagValue}}>
step="{{this.step}}"
oninput="this.nextElementSibling.value = this.value"
name="{{this.name}}" value={{this.flagValue}}>
<output style="font-weight: bold;">{{this.flagValue}}</output>
{{/ifCondASE}}
{{#ifCondASE this.type '==' 'colorPicker'}}
<input type="color" name="{{this.name}}" value={{this.flagValue}}>
Expand Down Expand Up @@ -263,7 +269,10 @@
{{#ifCondASE this.type '==' 'rangeInput'}}
<td colspan="2">
<input type="range" min="{{this.min}}" max="{{this.max}}"
step="{{this.step}}" name="{{this.name}}" value={{this.flagValue}}>
step="{{this.step}}"
oninput="this.nextElementSibling.value = this.value"
name="{{this.name}}" value={{this.flagValue}}>
<output style="font-weight: bold;">{{this.flagValue}}</output>
</td>
{{/ifCondASE}}
{{#ifCondASE this.type '==' 'checkbox'}}
Expand Down
Loading

0 comments on commit 4015861

Please sign in to comment.