Browse Source

feat: enhancements to lighting builder

tags/v0.12.0
Shaun 1 year ago
parent
commit
3bf7ac8c80
3 changed files with 26 additions and 17 deletions
  1. +5
    -3
      src/client/js/rendering/lightningBuilder.js
  2. +20
    -13
      src/server/clientComponents/lightningEffect.js
  3. +1
    -1
      src/server/items/generators/spellbook.js

+ 5
- 3
src/client/js/rendering/lightningBuilder.js View File

@@ -17,9 +17,11 @@ define([
let tx = config.toX * scale;
let ty = config.toY * scale;

const linkSize = config.linkSize ?? 3;

let angle = Math.atan2(ty - fy, tx - fx);
let distance = Math.sqrt(Math.pow(tx - fx, 2) + Math.pow(ty - fy, 2));
let divDistance = Math.min(20, distance);
let divDistance = config.divDistance ?? Math.min(20, distance);
let divisions = config.divisions || Math.max(1, distance / divDistance);

let x = fx;
@@ -75,8 +77,8 @@ define([
lightPatch.tint = '0xffffff';
lightPatch.x = ~~((xx - scaleMult) / scaleMult) * scaleMult;
lightPatch.y = ~~((yy - scaleMult) / scaleMult) * scaleMult;
lightPatch.width = scaleMult * 3;
lightPatch.height = scaleMult * 3;
lightPatch.width = scaleMult * linkSize;
lightPatch.height = scaleMult * linkSize;

lightPatch.blendMode = PIXI.BLEND_MODES.ADD;



+ 20
- 13
src/server/clientComponents/lightningEffect.js View File

@@ -25,13 +25,13 @@ define([
init: function () {
effects.register(this);

let xOffset = (this.toX >= this.obj.x) ? 1 : 0;
let { toX = this.target.x, toY = this.target.y } = this;

let fromX = this.obj.x + xOffset;
let fromY = this.obj.y + 0.5;
const fromX = this.obj.x + ((toX >= this.obj.x) ? 1 : 0);
const fromY = this.obj.y + 0.5;

let toX = this.lineGrow ? fromX : this.toX + 0.5;
let toY = this.lineGrow ? fromY : this.toY + 0.5;
toX = this.lineGrow ? fromX : toX + 0.5;
toY = this.lineGrow ? fromY : toY + 0.5;

this.effect = lightningBuilder.build({
fromX: fromX,
@@ -40,7 +40,9 @@ define([
toY: toY,
divisions: this.divisions,
colors: this.colors,
maxDeviate: this.maxDeviate
maxDeviate: this.maxDeviate,
divDistance: this.divDistance,
linkSize: this.linkSize
});
},

@@ -58,8 +60,10 @@ define([

this.cd = cdMax;

lightningBuilder.destroy(this.effect);
this.effect = null;
if (this.effect) {
lightningBuilder.destroy(this.effect);
this.effect = null;
}

if (!this.shrinking) {
this.ttl--;
@@ -69,14 +73,15 @@ define([
}
}

let xOffset = (this.toX >= this.obj.x) ? 1 : 0;
let { toX = this.target.x, toY = this.target.y } = this;
toX += 0.5;
toY += 0.5;

let xOffset = (toX >= this.obj.x) ? 1 : 0;

let fromX = this.obj.x + xOffset;
let fromY = this.obj.y + 0.5;

let toX = this.toX + 0.5;
let toY = this.toY + 0.5;

let changeTo = (
(
(this.lineGrow) &&
@@ -110,7 +115,9 @@ define([
toY: toY,
divisions: this.divisions,
colors: this.colors,
maxDeviate: this.maxDeviate
maxDeviate: this.maxDeviate,
divDistance: this.divDistance,
linkSize: this.linkSize
});

if ((this.shrinking) && (linePercentage < 0.1))


+ 1
- 1
src/server/items/generators/spellbook.js View File

@@ -47,7 +47,7 @@ module.exports = {
generate: function (item, blueprint) {
blueprint = blueprint || {};
let spellQuality = blueprint ? blueprint.spellQuality : '';
let spellName = blueprint.spellName;
let spellName = blueprint.spellName?.replaceAll('_', ' ');

if (!spellName) {
let spellList = Object.keys(spellsConfig.spells).filter(s => !spellsConfig.spells[s].auto && !spellsConfig.spells[s].noDrop);


Loading…
Cancel
Save