Closed revilowaldow closed 2 months ago
This one's def in need of dedicated player walls. All sorts of funky stuff going on like significant crops, 90° rotations etc.
Rotate walls 90°, taken from Foundry discord https://discord.com/channels/170995199584108546/699750150674972743/1153310497765081180
let centerPoint = canvas.walls.controlled.reduce((acc, wall) => {
let wallX = wall.document.c[0];
let wallY = wall.document.c[1];
acc.x += wallX;
acc.y += wallY;
return acc;
},{x: 0, y:0})
centerPoint.x = centerPoint.x / canvas.walls.controlled.length;
centerPoint.y = centerPoint.y / canvas.walls.controlled.length;
const walls = canvas.walls.controlled.map(wall => {
let w = duplicate(wall.document);
const mid_offset_0 = w.c[0] - centerPoint.x;
const mid_offset_1 = w.c[1] - centerPoint.y;
const mid_offset_2 = w.c[2] - centerPoint.x;
const mid_offset_3 = w.c[3] - centerPoint.y;
w.c[0] = centerPoint.x - mid_offset_1;
w.c[1] = centerPoint.y + mid_offset_0;
w.c[2] = centerPoint.x - mid_offset_3;
w.c[3] = centerPoint.y + mid_offset_2;
return {_id: w._id, c: w.c};
});
canvas.scene.updateEmbeddedDocuments("Wall", walls);
interesting that they use the first point of the wall to calculate the center, rather than e.g. the midpoint of the wall
wonder if it works any better if you swap that first statement out for:
let centerPoint = canvas.walls.controlled.reduce((acc, wall) => {
const [x0, y0, x1, y1] = wall.document.c;
let wallX = x0 + ((x1 - x0) / 2);
let wallY = y0 + ((y1 - y0) / 2);
acc.x += wallX;
acc.y += wallY;
return acc;
},{x: 0, y:0})
not that I imagine it matters for this use-case
Add walls for maps in
HWAitW
Should be 11, maps need setting up + grid data in advance