diff --git a/README.md b/README.md index 7c24b90b..44129845 100644 --- a/README.md +++ b/README.md @@ -532,6 +532,8 @@ Many thanks to: * Jules and Ben's Witch Bolt effect is from [JB2A] and is licensed under [CC BY-NC-SA-4.0]. * The Seagull sprites used in the Birds weather effect are from [whtdragon]. * The control and tool icons are from [Font Awesome], licensed under the [CC BY-4.0]. +* The rats icon is a derivative work of “Rat” by DataBase Center for Life Science (DBCLS) (https://togotv.dbcls.jp/en/togopic.2021.006.html), used under [CC BY-4.0], and licensed under [CC BY-4.0]. +* The rat sprites used in the Rats weather effects by crymoonster are licensed under [CC BY-4.0]. [Foundry Virtual Tabletop]: https://foundryvtt.com/ [JB2A]: https://github.com/Jules-Bens-Aa/JB2A_DnD5e diff --git a/assets/weatherEffects/effects/rat/rat_0.png b/assets/weatherEffects/effects/rat/rat_0.png new file mode 100644 index 00000000..0dbd1551 Binary files /dev/null and b/assets/weatherEffects/effects/rat/rat_0.png differ diff --git a/assets/weatherEffects/effects/rat/rat_1.png b/assets/weatherEffects/effects/rat/rat_1.png new file mode 100644 index 00000000..ff55d351 Binary files /dev/null and b/assets/weatherEffects/effects/rat/rat_1.png differ diff --git a/assets/weatherEffects/effects/rat/rat_2.png b/assets/weatherEffects/effects/rat/rat_2.png new file mode 100644 index 00000000..c0f6129d Binary files /dev/null and b/assets/weatherEffects/effects/rat/rat_2.png differ diff --git a/assets/weatherEffects/effects/rat/rat_3.png b/assets/weatherEffects/effects/rat/rat_3.png new file mode 100644 index 00000000..b0667bb6 Binary files /dev/null and b/assets/weatherEffects/effects/rat/rat_3.png differ diff --git a/assets/weatherEffects/effects/rat/rat_4.png b/assets/weatherEffects/effects/rat/rat_4.png new file mode 100644 index 00000000..a8c2b349 Binary files /dev/null and b/assets/weatherEffects/effects/rat/rat_4.png differ diff --git a/assets/weatherEffects/icons/rats.png b/assets/weatherEffects/icons/rats.png new file mode 100644 index 00000000..cf6809df Binary files /dev/null and b/assets/weatherEffects/icons/rats.png differ diff --git a/assets/weatherEffects/icons/rats.png.license b/assets/weatherEffects/icons/rats.png.license new file mode 100644 index 00000000..3b7ab1e0 --- /dev/null +++ b/assets/weatherEffects/icons/rats.png.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2022 Johannes Loher (www.johannesloher.com/) + +SPDX-License-Identifier: CC-BY-4.0 diff --git a/src/weatherEffects/effects/RatsWeatherEffect.js b/src/weatherEffects/effects/RatsWeatherEffect.js new file mode 100644 index 00000000..99d8052f --- /dev/null +++ b/src/weatherEffects/effects/RatsWeatherEffect.js @@ -0,0 +1,98 @@ +import { AbstractWeatherEffect } from "./AbstractWeatherEffect.js"; + +export class RatsWeatherEffect extends AbstractWeatherEffect { + static get label() { + return "Rats"; + } + + static get icon() { + return "modules/fxmaster/assets/weatherEffects/icons/rats.png"; + } + + static get parameters() { + return foundry.utils.mergeObject(super.parameters, { + density: { min: 0.001, value: 0.006, max: 0.1, step: 0.001, decimals: 3 }, + "-=direction": undefined, + }); + } + + getParticleEmitters() { + return [this._getEmitter(this.parent)]; + } + + _getEmitter(parent) { + const d = canvas.dimensions; + const p = (d.width / d.size) * (d.height / d.size) * this.options.density.value; + const config = foundry.utils.mergeObject( + this.constructor.CONFIG, + { + spawnRect: { + x: d.sceneRect.x, + y: d.sceneRect.y, + w: d.sceneRect.width, + h: d.sceneRect.height, + }, + maxParticles: p, + frequency: this.constructor.CONFIG.lifetime.min / p, + }, + { inplace: false }, + ); + this.applyOptionsToConfig(config); + + const anim_sheet = { + framerate: "10", + textures: Array.fromRange(5).map( + (index) => `modules/fxmaster/assets/weatherEffects/effects/rat/rat_${index}.png`, + ), + loop: true, + }; + const emitter = new PIXI.particles.Emitter(parent, anim_sheet, config); + emitter.particleConstructor = PIXI.particles.AnimatedParticle; + return emitter; + } + + /** + * Configuration for the Rats particle effect + * @type {Object} + */ + static CONFIG = foundry.utils.mergeObject( + SpecialEffect.DEFAULT_CONFIG, + { + alpha: { + list: [ + { value: 0, time: 0 }, + { value: 1, time: 0.02 }, + { value: 1, time: 0.98 }, + { value: 0, time: 1 }, + ], + isStepped: false, + }, + scale: { + list: [ + { value: 0.03, time: 0 }, + { value: 0.125, time: 0.1 }, + { value: 0.125, time: 0.9 }, + { value: 0.03, time: 1 }, + ], + isStepped: false, + minimumScaleMultiplier: 0.5, + }, + speed: { + start: 200, + end: 200, + minimumSpeedMultiplier: 0.6, + }, + startRotation: { + min: 0, + max: 360, + }, + lifetime: { + min: 20, + max: 40, + }, + blendMode: "normal", + emitterLifetime: -1, + }, + { inplace: false }, + ); +} diff --git a/src/weatherEffects/weatherDB.js b/src/weatherEffects/weatherDB.js index 10a129db..35d0ca16 100644 --- a/src/weatherEffects/weatherDB.js +++ b/src/weatherEffects/weatherDB.js @@ -14,6 +14,7 @@ import { SnowWeatherEffect } from "./effects/SnowWeatherEffect.js"; import { AutumnLeavesWeatherEffect } from "./effects/AutumnLeavesWeatherEffect.js"; import { SpiderWeatherEffect } from "./effects/SpiderWeatherEffect.js"; import { EaglesWeatherEffect } from "./effects/EaglesWeatherEffect.js"; +import { RatsWeatherEffect } from "./effects/RatsWeatherEffect.js"; export const weatherDB = { snowstorm: SnowstormWeatherEffect, @@ -32,4 +33,5 @@ export const weatherDB = { rain: RainWeatherEffect, snow: SnowWeatherEffect, eagles: EaglesWeatherEffect, + rats: RatsWeatherEffect, };