forked from GitHub-Mirrors/foundry-sw5e
Super VJ Update
This commit is contained in:
parent
442212bdea
commit
1983b74bde
59 changed files with 4640 additions and 2462 deletions
|
@ -1,32 +1,40 @@
|
|||
/**
|
||||
* Measure the distance between two pixel coordinates
|
||||
* See BaseGrid.measureDistance for more details
|
||||
*
|
||||
* @param {Object} p0 The origin coordinate {x, y}
|
||||
* @param {Object} p1 The destination coordinate {x, y}
|
||||
* @param {boolean} gridSpaces Enforce grid distance (if true) vs. direct point-to-point (if false)
|
||||
* @return {number} The distance between p1 and p0
|
||||
*/
|
||||
export const measureDistance = function(p0, p1, {gridSpaces=true}={}) {
|
||||
if ( !gridSpaces ) return BaseGrid.prototype.measureDistance.bind(this)(p0, p1, {gridSpaces});
|
||||
let gs = canvas.dimensions.size,
|
||||
ray = new Ray(p0, p1),
|
||||
nx = Math.abs(Math.ceil(ray.dx / gs)),
|
||||
ny = Math.abs(Math.ceil(ray.dy / gs));
|
||||
/** @override */
|
||||
export const measureDistances = function(segments, options={}) {
|
||||
if ( !options.gridSpaces ) return BaseGrid.prototype.measureDistances.call(this, segments, options);
|
||||
|
||||
// Get the number of straight and diagonal moves
|
||||
let nDiagonal = Math.min(nx, ny),
|
||||
nStraight = Math.abs(ny - nx);
|
||||
// Track the total number of diagonals
|
||||
let nDiagonal = 0;
|
||||
const rule = this.parent.diagonalRule;
|
||||
const d = canvas.dimensions;
|
||||
|
||||
// Alternative DMG Movement
|
||||
if ( this.parent.diagonalRule === "5105" ) {
|
||||
let nd10 = Math.floor(nDiagonal / 2);
|
||||
let spaces = (nd10 * 2) + (nDiagonal - nd10) + nStraight;
|
||||
return spaces * canvas.dimensions.distance;
|
||||
}
|
||||
// Iterate over measured segments
|
||||
return segments.map(s => {
|
||||
let r = s.ray;
|
||||
|
||||
// Standard PHB Movement
|
||||
else return (nStraight + nDiagonal) * canvas.scene.data.gridDistance;
|
||||
// Determine the total distance traveled
|
||||
let nx = Math.abs(Math.ceil(r.dx / d.size));
|
||||
let ny = Math.abs(Math.ceil(r.dy / d.size));
|
||||
|
||||
// Determine the number of straight and diagonal moves
|
||||
let nd = Math.min(nx, ny);
|
||||
let ns = Math.abs(ny - nx);
|
||||
nDiagonal += nd;
|
||||
|
||||
// Alternative DMG Movement
|
||||
if (rule === "5105") {
|
||||
let nd10 = Math.floor(nDiagonal / 2) - Math.floor((nDiagonal - nd) / 2);
|
||||
let spaces = (nd10 * 2) + (nd - nd10) + ns;
|
||||
return spaces * canvas.dimensions.distance;
|
||||
}
|
||||
|
||||
// Euclidean Measurement
|
||||
else if (rule === "EUCL") {
|
||||
return Math.round(Math.hypot(nx, ny) * canvas.scene.data.gridDistance);
|
||||
}
|
||||
|
||||
// Standard PHB Movement
|
||||
else return (ns + nd) * canvas.scene.data.gridDistance;
|
||||
});
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -39,8 +47,8 @@ const _TokenGetBarAttribute = Token.prototype.getBarAttribute;
|
|||
export const getBarAttribute = function(...args) {
|
||||
const data = _TokenGetBarAttribute.bind(this)(...args);
|
||||
if ( data && (data.attribute === "attributes.hp") ) {
|
||||
data.value += parseInt(data['temp'] || 0);
|
||||
data.max += parseInt(data['tempmax'] || 0);
|
||||
data.value += parseInt(getProperty(this.actor.data, "data.attributes.hp.temp") || 0);
|
||||
data.max += parseInt(getProperty(this.actor.data, "data.attributes.hp.tempmax") || 0);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue