Skip to content

Commit

Permalink
feat: add rats weather effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost91- committed Mar 24, 2022
1 parent 58fff22 commit 7a0a68e
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added assets/weatherEffects/effects/rat/rat_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weatherEffects/effects/rat/rat_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weatherEffects/effects/rat/rat_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weatherEffects/effects/rat/rat_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weatherEffects/effects/rat/rat_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weatherEffects/icons/rats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/weatherEffects/icons/rats.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2022 Johannes Loher (www.johannesloher.com/)

SPDX-License-Identifier: CC-BY-4.0
98 changes: 98 additions & 0 deletions src/weatherEffects/effects/RatsWeatherEffect.js
Original file line number Diff line number Diff line change
@@ -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 },
);
}
2 changes: 2 additions & 0 deletions src/weatherEffects/weatherDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,4 +33,5 @@ export const weatherDB = {
rain: RainWeatherEffect,
snow: SnowWeatherEffect,
eagles: EaglesWeatherEffect,
rats: RatsWeatherEffect,
};

0 comments on commit 7a0a68e

Please sign in to comment.