MCPcopy Create free account
hub / github.com/Semporia/Scripts / moveToAndCollect

Method moveToAndCollect

jd_validate.js:389–421  ·  view source on GitHub ↗
({x, y, duration})

Source from the content-addressed store, hash-verified

387 }
388
389 moveToAndCollect({x, y, duration}) {
390 let movedX = 0;
391 let movedY = 0;
392 let movedT = 0;
393 const times = duration / this.minDuration;
394 let perX = x / times;
395 let perY = y / times;
396 let padDuration = 0;
397
398 if (Math.abs(perX) < 1) {
399 padDuration = duration / Math.abs(x) - this.minDuration;
400 perX = 1;
401 perY = y / Math.abs(x);
402 }
403
404 while (Math.abs(movedX) < Math.abs(x)) {
405 const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10);
406
407 movedX += perX + Math.random() * 2 - 1;
408 movedY += perY;
409 movedT += this.minDuration + rDuration;
410
411 const currX = parseInt(this.x + movedX, 10);
412 const currY = parseInt(this.y + movedY, 10);
413 const currT = this.t + movedT;
414
415 this.pos.push([currX, currY, currT]);
416 }
417
418 this.x += x;
419 this.y += y;
420 this.t += Math.max(duration, movedT);
421 }
422}
423
424Date.prototype.Format = function (fmt) {

Callers 2

stepPosMethod · 0.95
fixPosMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected