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

Method moveToAndCollect

JDJRValidator_Pure.js:459–491  ·  view source on GitHub ↗
({x, y, duration})

Source from the content-addressed store, hash-verified

457 }
458
459 moveToAndCollect({x, y, duration}) {
460 let movedX = 0;
461 let movedY = 0;
462 let movedT = 0;
463 const times = duration / this.minDuration;
464 let perX = x / times;
465 let perY = y / times;
466 let padDuration = 0;
467
468 if (Math.abs(perX) < 1) {
469 padDuration = duration / Math.abs(x) - this.minDuration;
470 perX = 1;
471 perY = y / Math.abs(x);
472 }
473
474 while (Math.abs(movedX) < Math.abs(x)) {
475 const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10);
476
477 movedX += perX + Math.random() * 2 - 1;
478 movedY += perY;
479 movedT += this.minDuration + rDuration;
480
481 const currX = parseInt(this.x + movedX, 10);
482 const currY = parseInt(this.y + movedY, 10);
483 const currT = this.t + movedT;
484
485 this.pos.push([currX, currY, currT]);
486 }
487
488 this.x += x;
489 this.y += y;
490 this.t += Math.max(duration, movedT);
491 }
492}
493
494function injectToRequest(fn,scene = 'cww') {

Callers 2

stepPosMethod · 0.95
fixPosMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected