Browse Source

more conflict fixes

tags/v0.3.0
Big Bad Waffle 5 years ago
parent
commit
b4a4606a2f
12 changed files with 279 additions and 1719 deletions
  1. +0
    -10
      src/client/js/components/projectile.js
  2. +1
    -1
      src/client/js/components/sound.js
  3. +10
    -10
      src/client/js/misc/distanceToPolygon.js
  4. +13
    -421
      src/client/js/misc/physics.js
  5. +7
    -27
      src/client/js/rendering/particles.js
  6. +144
    -934
      src/client/js/rendering/renderer.js
  7. +1
    -1
      src/client/js/sound/sound.js
  8. +2
    -2
      src/client/ui/templates/middleHud/middleHud.js
  9. +4
    -5
      src/client/ui/templates/target/target.js
  10. +10
    -47
      src/server/components/chest.js
  11. +5
    -25
      src/server/components/effects.js
  12. +82
    -236
      src/server/config/maps/fjolarok/map.json

+ 0
- 10
src/client/js/components/projectile.js View File

@@ -82,13 +82,8 @@ define([
},

renderManual: function () {
<<<<<<< HEAD
let source = this.obj;
let target = this.target;
=======
var source = this.obj;
var target = this.target;
>>>>>>> 555-new-dungeon

let dx = target.x - this.x;
let dy = target.y - this.y;
@@ -100,13 +95,8 @@ define([
source.y = target.y;
this.particles.emitter.emit = false;
if (!this.noExplosion)
<<<<<<< HEAD
source.explosion.explode();
source.destroyed = true;
=======
this.obj.explosion.explode();
this.obj.destroyed = true;
>>>>>>> 555-new-dungeon
} else {
dx /= ticksLeft;
dy /= ticksLeft;


+ 1
- 1
src/client/js/components/sound.js View File

@@ -10,7 +10,7 @@ define([
volume: 0,

init: function () {
var obj = this.obj;
let obj = this.obj;
sound.addSound(obj.zoneId, this.sound, this.volume, obj.x, obj.y, obj.width, obj.height, obj.area);
}
};


+ 10
- 10
src/client/js/misc/distanceToPolygon.js View File

@@ -9,12 +9,12 @@ define([
},

distanceToLine: function (p, la, lb) {
var xD = lb[0] - la[0];
var yD = lb[1] - la[1];
let xD = lb[0] - la[0];
let yD = lb[1] - la[1];

var u = (((p[0] - la[0]) * xD) + ((p[1] - la[1]) * yD)) / ((xD * xD) + (yD * yD));
let u = (((p[0] - la[0]) * xD) + ((p[1] - la[1]) * yD)) / ((xD * xD) + (yD * yD));

var closestLine;
let closestLine;
if (u < 0)
closestLine = [la[0], la[1]];
else if (u > 1)
@@ -26,14 +26,14 @@ define([
},

calculate: function (p, verts) {
var minDistance = 9999;
let minDistance = 9999;

var vLen = verts.length;
for (var i = 0, j = vLen - 1; i < vLen; j = i++) {
var vi = verts[i];
var vj = verts[j];
let vLen = verts.length;
for (let i = 0, j = vLen - 1; i < vLen; j = i++) {
let vi = verts[i];
let vj = verts[j];

var distance = this.distanceToLine(p, vi, vj);
let distance = this.distanceToLine(p, vi, vj);
if (distance < minDistance)
minDistance = distance;
}


+ 13
- 421
src/client/js/misc/physics.js View File

@@ -1,17 +1,11 @@
define([
'js/misc/pathfinder',
'js/misc/distanceToPolygon'

], function (
pathfinder,
distanceToPolygon
) {
<<<<<<< HEAD
let sqrt = Math.sqrt.bind(Math);
let ceil = Math.ceil.bind(Math);
let random = Math.random.bind(Math);

=======
>>>>>>> 555-new-dungeon
return {
graph: null,

@@ -33,234 +27,6 @@ define([
});
},

<<<<<<< HEAD
addRegion: function (obj) {
let lowX = obj.x;
let lowY = obj.y;
let highX = lowX + obj.width;
let highY = lowY + obj.height;
let cells = this.cells;

for (let i = lowX; i <= highX; i++) {
let row = cells[i];
for (let j = lowY; j <= highY; j++)
row[j].push(obj);
}
},

addObject: function (obj, x, y, fromX, fromY) {
let row = this.cells[x];

if (!row)
return;

let cell = row[y];

if (!cell)
return;

let cLen = cell.length;
for (let i = 0; i < cLen; i++) {
let c = cell[i];

//If we have fromX and fromY, check if the target cell doesn't contain the same obj (like a notice area)
if ((c.width) && (fromX)) {
if ((fromX < c.x) || (fromY < c.y) || (fromX >= c.x + c.width) || (fromY >= c.y + c.height)) {
c.collisionEnter(obj);
obj.collisionEnter(c);
}
} else {
c.collisionEnter(obj);
obj.collisionEnter(c);
}
}

cell.push(obj);
return true;
},
removeObject: function (obj, x, y, toX, toY) {
let row = this.cells[x];

if (!row)
return;

let cell = row[y];

if (!cell)
return;

let oId = obj.id;
let cLen = cell.length;
for (let i = 0; i < cLen; i++) {
let c = cell[i];

if (c.id !== oId) {
//If we have toX and toY, check if the target cell doesn't contain the same obj (like a notice area)
if ((c.width) && (toX)) {
if ((toX < c.x) || (toY < c.y) || (toX >= c.x + c.width) || (toY >= c.y + c.height)) {
c.collisionExit(obj);
obj.collisionExit(c);
}
} else {
c.collisionExit(obj);
obj.collisionExit(c);
}
} else {
cell.splice(i, 1);
i--;
cLen--;
}
}
},

isValid: function (x, y) {
let row = this.cells[x];

if ((!row) || (row.length <= y) || (!this.graph.grid[x][y]))
return false;
return true;
},

getCell: function (x, y) {
let row = this.cells[x];

if (!row)
return [];

let cell = row[y];

if (!cell)
return [];

return cell;
},
getArea: function (x1, y1, x2, y2, filter) {
let width = this.width;
let height = this.height;

x1 = ~~x1;
y1 = ~~y1;

x2 = ~~x2;
y2 = ~~y2;

if (x1 < 0)
x1 = 0;
else if (x2 >= width)
x2 = width - 1;
if (y1 < 0)
y1 = 0;
else if (y2 >= height)
y2 = height - 1;

let cells = this.cells;
let grid = this.graph.grid;

let result = [];
for (let i = x1; i <= x2; i++) {
let row = cells[i];
let gridRow = grid[i];
for (let j = y1; j <= y2; j++) {
if (!gridRow[j])
continue;

let cell = row[j];
let cLen = cell.length;
for (let k = 0; k < cLen; k++) {
let c = cell[k];

if (filter) {
if (filter(c))
result.push(c);
} else
result.push(c);
}
}
}

return result;
},

getOpenCellInArea: function (x1, y1, x2, y2) {
let width = this.width;
let height = this.height;

x1 = ~~x1;
y1 = ~~y1;

x2 = ~~x2;
y2 = ~~y2;

if (x1 < 0)
x1 = 0;
else if (x2 >= width)
x2 = width - 1;
if (y1 < 0)
y1 = 0;
else if (y2 >= height)
y2 = height - 1;

let cells = this.cells;
let grid = this.graph.grid;

let result = [];
for (let i = x1; i <= x2; i++) {
let row = cells[i];
let gridRow = grid[i];
for (let j = y1; j <= y2; j++) {
if (!gridRow[j])
continue;

let cell = row[j];
if (cell.length === 0) {
return {
x: i,
y: j
};
}
}
}

return result;
},

getPath: function (from, to) {
let graph = this.graph;
let grid = graph.grid;

if (!to) {
to = {
x: ~~(random() * grid.length),
y: ~~(random() * grid[0].length)
};
}

let fromX = ~~from.x;
let fromY = ~~from.y;

if ((!grid[fromX]) || (grid[fromX].length <= fromY) || (fromX < 0) || (fromY < 0))
return [];

let toX = ~~to.x;
let toY = ~~to.y;

if ((!grid[toX]) || (grid[toX].length <= toY) || (toX < 0) || (toY < 0))
return [];

let path = pathfinder.astar.search(graph, {
x: fromX,
y: fromY
}, {
x: toX,
y: toY
}, {
closest: true
});

return path;
},
=======
>>>>>>> 555-new-dungeon
isTileBlocking: function (x, y, mob, obj) {
if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height))
return true;
@@ -272,208 +38,34 @@ define([

return ((!node) || (node.weight === 0));
},
<<<<<<< HEAD
isCellOpen: function (x, y) {
if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height))
return true;

return (this.cells[x][y].length === 0);
},
hasLos: function (fromX, fromY, toX, toY) {
if ((fromX < 0) || (fromY < 0) || (fromX >= this.width) | (fromY >= this.height) || (toX < 0) || (toY < 0) || (toX >= this.width) | (toY >= this.height))
return false;

let graphGrid = this.graph.grid;

if ((!graphGrid[fromX][fromY]) || (!graphGrid[toX][toY]))
return false;

let dx = toX - fromX;
let dy = toY - fromY;

let distance = sqrt((dx * dx) + (dy * dy));

dx /= distance;
dy /= distance;

fromX += 0.5;
fromY += 0.5;
=======
>>>>>>> 555-new-dungeon

isInPolygon: function (x, y, verts) {
var inside = false;

<<<<<<< HEAD
let x = 0;
let y = 0;
let inside = false;

for (let i = 0; i < distance; i++) {
fromX += dx;
fromY += dy;
=======
var vLen = verts.length;
for (var i = 0, j = vLen - 1; i < vLen; j = i++) {
var vi = verts[i];
var vj = verts[j];
let vLen = verts.length;
for (let i = 0, j = vLen - 1; i < vLen; j = i++) {
let vi = verts[i];
let vj = verts[j];

var xi = vi[0];
var yi = vi[1];
var xj = vj[0];
var yj = vj[1];
>>>>>>> 555-new-dungeon
let xi = vi[0];
let yi = vi[1];
let xj = vj[0];
let yj = vj[1];

var doesIntersect = (
((yi > y) != (yj > y)) &&
let doesIntersect = (
((yi > y) !== (yj > y)) &&
(x < ((((xj - xi) * (y - yi)) / (yj - yi)) + xi))
);

<<<<<<< HEAD
if (!graphGrid[x][y])
return false;
else if ((x === toX) && (y === toY))
return true;
=======
if (doesIntersect)
inside = !inside
>>>>>>> 555-new-dungeon
inside = !inside;
}

return inside;
},

<<<<<<< HEAD
getClosestPos: function (fromX, fromY, toX, toY, target) {
let tried = {};

let hasLos = this.hasLos.bind(this, toX, toY);

let width = this.width;
let height = this.height;

let collisionMap = this.collisionMap;
let cells = this.cells;

let reverseX = (fromX > toX);
let reverseY = (fromY > toY);

for (let c = 1; c <= 10; c++) {
let x1 = toX - c;
let y1 = toY - c;
let x2 = toX + c;
let y2 = toY + c;

let lowX, lowY, highX, highY, incX, incY;

if (reverseX) {
incX = -1;
lowX = x2;
highX = x1 - 1;
} else {
incX = 1;
lowX = x1;
highX = x2 + 1;
}

if (reverseY) {
incY = -1;
lowY = y2;
highY = y1 - 1;
} else {
incY = 1;
lowY = y1;
highY = y2 + 1;
}

for (let i = lowX; i !== highX; i += incX) {
if ((i < 0) || (i >= width))
continue;

let row = collisionMap[i];
let cellRow = cells[i];

let t = tried[i];
if (!t)
t = tried[i] = {};

for (let j = lowY; j !== highY; j += incY) {
if (t[j])
continue;

t[j] = 1;

if (
((i === toX) && (j === toY)) ||
((j < 0) || (j >= height)) ||
(row[j])
)
continue;

let cell = cellRow[j];
let cLen = cell.length;
let blocking = false;
for (let k = 0; k < cLen; k++) {
let aggro = cell[k].aggro;
if (aggro) {
blocking = aggro.list.some(a => a.obj === target);
if (blocking)
break;
}
}
if (blocking)
continue;
else if (!hasLos(i, j))
continue;

return {
x: i,
y: j
};
}
}
}
},

mobsCollide: function (x, y, obj) {
if ((x < 0) || (y < 0) || (x >= this.width) | (y >= this.height))
return true;

let cell = this.cells[x][y];
let cLen = cell.length;

if (cLen === 1)
return false;

let found = false;
for (let i = 0; i < cLen; i++) {
let c = cell[i];
if (c.aggro) {
if ((!found) && (c === obj))
found = true;
else
return true;
}
}

return false;
},

setCollision: function (config) {
const x = config.x;
const y = config.y;
const collides = config.collides;

const grid = this.graph.grid;

let node = grid[x][y];
if (!node)
node = grid[x][y] = new pathfinder.gridNode(x, y, collides ? 0 : 1);

node.weight = collides ? 0 : 1;
=======
distanceToPolygon: function (p, verts) {
return distanceToPolygon.calculate(p, verts);
>>>>>>> 555-new-dungeon
}
};
});

+ 7
- 27
src/client/js/rendering/particles.js View File

@@ -23,18 +23,13 @@ define([
},

buildEmitter: function (config) {
<<<<<<< HEAD
let obj = config.obj;
delete config.obj;

let options = $.extend(true, {}, particleDefaults, config);

let emitter = new PIXI.particles.Emitter(this.r.layers.particles, ['images/particles.png'], options);
=======
var obj = config.obj;
delete config.obj;
var options = $.extend(true, {}, particleDefaults, config);

var emitter = new PIXI.particles.Emitter(this.r.layers.particles, ['images/particles.png'], options);
emitter.obj = obj;
>>>>>>> 555-new-dungeon
emitter.emit = true;

this.emitters.push(emitter);
@@ -47,33 +42,24 @@ define([
},

update: function () {
<<<<<<< HEAD
let renderer = this.r;
let now = Date.now();
=======
var renderer = this.r;
var now = Date.now();
>>>>>>> 555-new-dungeon

let emitters = this.emitters;
let eLen = emitters.length;
for (let i = 0; i < eLen; i++) {
let e = emitters[i];

<<<<<<< HEAD
let visible = null;
let destroy = !e.emit;
=======
var visible = null;
var destroy = (
let destroy = (
(!e.emit) &&
(e.obj.destroyed)
);
>>>>>>> 555-new-dungeon
if (destroy) {
if (e.particleCount > 0) {
visible = renderer.isVisible(e.spawnPos.x, e.spawnPos.y);
if (visible)
if (visible)
destroy = false;
}
}
@@ -86,22 +72,16 @@ define([
i--;
eLen--;
continue;
}
}

if (visible === null)
visible = renderer.isVisible(e.spawnPos.x, e.spawnPos.y);
if (!visible)
continue;

<<<<<<< HEAD
let r = e.update((now - this.lastTick) * 0.001);
r.forEach(function (rr) {
if (e.blendMode === 'overlay')
=======
var r = e.update((now - this.lastTick) * 0.001);
r.forEach(function (rr) {
if (e.blendMode == 'overlay')
>>>>>>> 555-new-dungeon
rr.pluginName = 'picture';
}, this);
}


+ 144
- 934
src/client/js/rendering/renderer.js
File diff suppressed because it is too large
View File


+ 1
- 1
src/client/js/sound/sound.js View File

@@ -14,7 +14,7 @@ define([

unload: function (zoneId) {
this.sounds.forEach(function (s) {
if ((s.sound) && (s.zoneId != zoneId))
if ((s.sound) && (s.zoneId !== zoneId))
s.sound.unload();
});



+ 2
- 2
src/client/ui/templates/middleHud/middleHud.js View File

@@ -15,9 +15,9 @@ define([
},

onGetCasting: function (casting) {
var el = this.find('.casting');
let el = this.find('.casting');

if ((casting == 0) || (casting == 1))
if ((casting === 0) || (casting === 1))
el.hide();
else {
el


+ 4
- 5
src/client/ui/templates/target/target.js View File

@@ -22,16 +22,15 @@ define([
},

onGetCasting: function (casting) {
var box = this.el.find('.statBox')
let box = this.el.find('.statBox')
.eq(2);

if ((casting == 0) || (casting == 1)) {
if ((casting === 0) || (casting === 1)) {
box.hide();
return;
} else
box.show();
} box.show();

var w = ~~(casting * 100);
let w = ~~(casting * 100);
box.find('[class^="stat"]').css('width', w + '%');
},



+ 10
- 47
src/server/components/chest.js View File

@@ -1,81 +1,44 @@
module.exports = {
type: 'chest',

ownerId: -1,
ownerName: null,

ttl: -1,

<<<<<<< HEAD
init: function (blueprint) {
if (blueprint.ownerId)
this.ownerId = blueprint.ownerId;
=======
ownerName: null,
>>>>>>> 555-new-dungeon
if (blueprint.ownerName != null)
this.ownerName = blueprint.ownerName;

if (blueprint.ttl)
this.ttl = blueprint.ttl;
},

<<<<<<< HEAD
simplify: function (self) {
return {
type: 'chest',
ownerId: this.ownerId
ownerName: this.ownerName
};
},
=======
init: function (blueprint) {
if (blueprint.ownerName != null)
this.ownerName = blueprint.ownerName;
>>>>>>> 555-new-dungeon

update: function () {
if (this.ttl > 0) {
this.ttl--;

<<<<<<< HEAD
if (this.ttl === 0)
if (this.ttl == 0)
this.obj.destroyed = true;
}
},
=======
simplify: function (self) {
return {
type: 'chest',
ownerName: this.ownerName
};
},

update: function () {
if (this.ttl > 0) {
this.ttl--;

if (this.ttl == 0)
this.obj.destroyed = true;
}
},
>>>>>>> 555-new-dungeon

collisionEnter: function (obj) {
if (!obj.player)
return;

<<<<<<< HEAD
let ownerId = this.ownerId;
if (ownerId !== -1) {
if (ownerId instanceof Array) {
if (ownerId.indexOf(obj.serverId) === -1)
=======
var ownerName = this.ownerName;
if (ownerName) {
if (ownerName instanceof Array) {
if (ownerName.indexOf(obj.name) == -1)
return;
} else if (ownerName != obj.name)
>>>>>>> 555-new-dungeon
let ownerName = this.ownerName;
if (ownerName) {
if (ownerName instanceof Array) {
if (ownerName.indexOf(obj.name) === -1)
return;
} else if (ownerId !== obj.serverId)
} else if (ownerName !== obj.name)
return;
}



+ 5
- 25
src/server/components/effects.js View File

@@ -113,33 +113,8 @@ module.exports = {
eLen--;
i--;
}
<<<<<<< HEAD
}
},
=======
},

canApplyEffect: function (type) {
if (this.ccResistances[type] == null)
return true;

var ccResistances = this.ccResistances;
if ((100 - ccResistances[type]) >= 50) {
ccResistances[type] += 50;
return true;
} else
return false;
},

addEffect: function (options, source) {
if ((options.ttl != null) && (options.ttl == 0))
return;

options.caster = options.caster || source;

if (!this.canApplyEffect(options.type))
return;
>>>>>>> 555-new-dungeon

canApplyEffect: function (type) {
if (!this.ccResistances[type])
@@ -153,6 +128,11 @@ module.exports = {
},

addEffect: function (options) {
if ((options.ttl != null) && (options.ttl == 0))
return;

options.caster = options.caster || source;

if (!this.canApplyEffect(options.type))
return;



+ 82
- 236
src/server/config/maps/fjolarok/map.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save