@lewismoten/gamemaker-sandbox-tools 3.1.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/NOTICE.md +105 -3
- package/README.md +301 -15
- package/dist/audio-files.js +82 -0
- package/dist/audio.js +23 -138
- package/dist/block-merge.js +43 -0
- package/dist/color-reduce.js +44 -0
- package/dist/colors.js +87 -0
- package/dist/delta.js +75 -0
- package/dist/disk-diff.js +220 -0
- package/dist/drawing.js +83 -869
- package/dist/embroidery/compile.js +85 -0
- package/dist/embroidery/dst.js +79 -0
- package/dist/embroidery/exp.js +26 -0
- package/dist/embroidery/fill.js +49 -0
- package/dist/embroidery/geom.js +82 -0
- package/dist/embroidery/pes.js +79 -0
- package/dist/embroidery/satin.js +29 -0
- package/dist/embroidery/simulate.js +30 -0
- package/dist/embroidery/strokeFont.js +253 -0
- package/dist/embroidery/svg.js +24 -0
- package/dist/embroidery/types.js +13 -0
- package/dist/embroidery/units.js +26 -0
- package/dist/embroidery/validate.js +15 -0
- package/dist/formats/blocks.js +1 -103
- package/dist/formats/character.js +1 -83
- package/dist/formats/cmf.js +1 -37
- package/dist/formats/fli.js +1 -296
- package/dist/formats/fliLimits.js +1 -54
- package/dist/formats/game.js +1 -193
- package/dist/formats/gif.js +1 -125
- package/dist/formats/graphicScripts.js +1 -44
- package/dist/formats/map.js +1 -38
- package/dist/formats/monster.js +1 -69
- package/dist/formats/palette.js +1 -58
- package/dist/formats/recording.js +1 -17
- package/dist/formats/sound.js +1 -44
- package/dist/formats/voc.js +1 -303
- package/dist/gif-shrink.js +56 -0
- package/dist/image/png.js +42 -0
- package/dist/images.js +81 -43
- package/dist/kit/actors.js +19 -0
- package/dist/kit/align.js +204 -0
- package/dist/kit/blit.js +45 -0
- package/dist/kit/blockRoles.js +97 -0
- package/dist/kit/clips.js +40 -0
- package/dist/kit/coverPaint.js +18 -0
- package/dist/kit/disk.js +76 -0
- package/dist/kit/fadeOut.js +13 -0
- package/dist/kit/fliClips.js +133 -0
- package/dist/kit/fliShrink.js +277 -0
- package/dist/kit/gameSim.js +235 -0
- package/dist/kit/hopBot.js +142 -0
- package/dist/kit/levelGen.js +1423 -0
- package/dist/kit/levelGrid.js +33 -0
- package/dist/kit/levelPicture.js +27 -0
- package/dist/kit/menuVersion.js +19 -0
- package/dist/kit/microText.js +35 -0
- package/dist/kit/mumble.js +74 -0
- package/dist/kit/music.js +8 -0
- package/dist/kit/palRamps.js +32 -0
- package/dist/kit/palette.js +49 -0
- package/dist/kit/pcText.js +72 -0
- package/dist/kit/photo.js +150 -0
- package/dist/kit/pixels.js +79 -0
- package/dist/kit/png.js +40 -0
- package/dist/kit/quantize.js +72 -0
- package/dist/kit/raytrace.js +379 -0
- package/dist/kit/recordedDemo.js +10 -0
- package/dist/kit/reel.js +77 -0
- package/dist/kit/road3d.js +67 -0
- package/dist/kit/routeChecks.js +8 -0
- package/dist/kit/saveSlots.js +11 -0
- package/dist/kit/sceneInit.js +13 -0
- package/dist/kit/sceneSim.js +112 -0
- package/dist/kit/screenText.js +15 -0
- package/dist/kit/sdftext.js +237 -0
- package/dist/kit/shading.js +69 -0
- package/dist/kit/song.js +251 -0
- package/dist/kit/songFx.js +179 -0
- package/dist/kit/sound.js +52 -0
- package/dist/kit/synthParts.js +20 -0
- package/dist/kit/tar.js +53 -0
- package/dist/kit/textBounds.js +84 -0
- package/dist/kit/textfit.js +246 -0
- package/dist/kit/transforms.js +57 -0
- package/dist/kit/tune.js +21 -0
- package/dist/look-alike.js +50 -0
- package/dist/menu-version.js +4 -0
- package/dist/mesh/colorBodies.js +137 -0
- package/dist/mesh/decimate.js +207 -0
- package/dist/mesh/meshCheck.js +51 -0
- package/dist/mesh/overhang.js +41 -0
- package/dist/mesh/sampledField.js +12 -0
- package/dist/mesh/stl.js +36 -0
- package/dist/mesh/surfaceNets.js +79 -0
- package/dist/mesh/tetraMesh.js +62 -0
- package/dist/mesh/threeMf.js +58 -0
- package/dist/mesh/zipFile.js +52 -0
- package/dist/microFont.js +101 -0
- package/dist/music/compose.js +72 -0
- package/dist/pack/meshPack.js +198 -0
- package/dist/pack/threeMfPack.js +92 -0
- package/dist/palette-reserve.js +116 -0
- package/dist/palettes.js +138 -0
- package/dist/release-notes.js +40 -0
- package/dist/simulation.js +16 -2774
- package/dist/text.js +74 -0
- package/dist/types/audio.d.ts +4 -0
- package/dist/types/audioFiles.d.ts +22 -0
- package/dist/types/audioWav.d.ts +4 -0
- package/dist/types/blockMerge.d.ts +24 -0
- package/dist/types/colorReduce.d.ts +23 -0
- package/dist/types/{web/packages/tools/src/colors.d.ts → colors.d.ts} +6 -0
- package/dist/types/delta.d.ts +32 -0
- package/dist/types/diskDiff.d.ts +47 -0
- package/dist/types/drawing.d.ts +15 -0
- package/dist/types/embroidery/compile.d.ts +3 -0
- package/dist/types/embroidery/dst.d.ts +13 -0
- package/dist/types/embroidery/exp.d.ts +8 -0
- package/dist/types/embroidery/fill.d.ts +6 -0
- package/dist/types/embroidery/geom.d.ts +19 -0
- package/dist/types/embroidery/pes.d.ts +10 -0
- package/dist/types/embroidery/satin.d.ts +11 -0
- package/dist/types/embroidery/simulate.d.ts +19 -0
- package/dist/types/embroidery/strokeFont.d.ts +20 -0
- package/dist/types/embroidery/svg.d.ts +3 -0
- package/dist/types/embroidery/types.d.ts +70 -0
- package/dist/types/embroidery/units.d.ts +10 -0
- package/dist/types/embroidery/validate.d.ts +22 -0
- package/dist/types/formats/blocks.d.ts +1 -0
- package/dist/types/formats/character.d.ts +1 -0
- package/dist/types/formats/cmf.d.ts +1 -0
- package/dist/types/formats/fli.d.ts +1 -0
- package/dist/types/formats/fliLimits.d.ts +1 -0
- package/dist/types/formats/game.d.ts +1 -0
- package/dist/types/formats/gif.d.ts +1 -0
- package/dist/types/formats/graphicScripts.d.ts +1 -0
- package/dist/types/formats/map.d.ts +1 -0
- package/dist/types/formats/monster.d.ts +1 -0
- package/dist/types/formats/palette.d.ts +1 -0
- package/dist/types/formats/recording.d.ts +1 -0
- package/dist/types/formats/sound.d.ts +1 -0
- package/dist/types/formats/voc.d.ts +1 -0
- package/dist/types/gifShrink.d.ts +8 -0
- package/dist/types/image/animatedGif.d.ts +9 -0
- package/dist/types/image/surface.d.ts +26 -0
- package/dist/types/images.d.ts +13 -0
- package/dist/types/kit/actors.d.ts +7 -0
- package/dist/types/kit/align.d.ts +93 -0
- package/dist/types/kit/audioEvents.d.ts +26 -0
- package/dist/types/kit/blit.d.ts +20 -0
- package/dist/types/kit/blockRoles.d.ts +243 -0
- package/dist/types/{games/kit → kit}/clips.d.ts +1 -1
- package/dist/types/kit/coverPaint.d.ts +7 -0
- package/dist/types/kit/disk.d.ts +15 -0
- package/dist/types/kit/fadeOut.d.ts +12 -0
- package/dist/types/kit/fliClips.d.ts +32 -0
- package/dist/types/kit/fliShrink.d.ts +149 -0
- package/dist/types/{games/kit → kit}/gameSim.d.ts +9 -5
- package/dist/types/kit/hopBot.d.ts +72 -0
- package/dist/types/kit/laserClearance.d.ts +16 -0
- package/dist/types/kit/laserJoints.d.ts +39 -0
- package/dist/types/kit/laserLayout.d.ts +54 -0
- package/dist/types/kit/laserPixels.d.ts +52 -0
- package/dist/types/kit/laserPreview.d.ts +9 -0
- package/dist/types/kit/laserSvg.d.ts +35 -0
- package/dist/types/kit/levelGen/castle.d.ts +17 -0
- package/dist/types/kit/levelGen/dungeon.d.ts +11 -0
- package/dist/types/kit/levelGen/forest.d.ts +17 -0
- package/dist/types/kit/levelGen/furnish.d.ts +31 -0
- package/dist/types/kit/levelGen/grid.d.ts +46 -0
- package/dist/types/kit/levelGen/index.d.ts +138 -0
- package/dist/types/kit/levelGen/interior.d.ts +18 -0
- package/dist/types/kit/levelGen/jumpModel.d.ts +78 -0
- package/dist/types/kit/levelGen/needs.d.ts +44 -0
- package/dist/types/kit/levelGen/overworld.d.ts +21 -0
- package/dist/types/kit/levelGen/platform.d.ts +59 -0
- package/dist/types/kit/levelGen/platformCap.d.ts +13 -0
- package/dist/types/kit/levelGen/platformReach.d.ts +37 -0
- package/dist/types/kit/levelGen/props.d.ts +37 -0
- package/dist/types/kit/levelGen/town.d.ts +24 -0
- package/dist/types/kit/levelGrid.d.ts +16 -0
- package/dist/types/kit/levelPicture.d.ts +9 -0
- package/dist/types/kit/menuVersion.d.ts +7 -0
- package/dist/types/kit/microText.d.ts +18 -0
- package/dist/types/kit/mumble.d.ts +41 -0
- package/dist/types/kit/music.d.ts +1 -0
- package/dist/types/kit/palMerge.d.ts +10 -0
- package/dist/types/kit/palRamps.d.ts +28 -0
- package/dist/types/kit/pcText.d.ts +19 -0
- package/dist/types/kit/photo.d.ts +69 -0
- package/dist/types/kit/png.d.ts +7 -0
- package/dist/types/kit/quantize.d.ts +20 -0
- package/dist/types/kit/raytrace.d.ts +169 -0
- package/dist/types/kit/recordedDemo.d.ts +1 -0
- package/dist/types/kit/road3d.d.ts +71 -0
- package/dist/types/kit/routeChecks.d.ts +6 -0
- package/dist/types/kit/saveSlots.d.ts +17 -0
- package/dist/types/kit/sceneInit.d.ts +11 -0
- package/dist/types/{games/kit → kit}/sceneSim.d.ts +5 -5
- package/dist/types/kit/screenText.d.ts +3 -0
- package/dist/types/kit/sdftext.d.ts +34 -0
- package/dist/types/kit/shading.d.ts +23 -0
- package/dist/types/kit/shareBlocks.d.ts +20 -0
- package/dist/types/kit/song.d.ts +89 -0
- package/dist/types/kit/songFx.d.ts +99 -0
- package/dist/types/kit/synthParts.d.ts +7 -0
- package/dist/types/kit/tar.d.ts +13 -0
- package/dist/types/kit/textfit.d.ts +74 -0
- package/dist/types/kit/transforms.d.ts +8 -0
- package/dist/types/lookAlike.d.ts +31 -0
- package/dist/types/menuVersionEntry.d.ts +1 -0
- package/dist/types/mesh/colorBodies.d.ts +18 -0
- package/dist/types/mesh/decimate.d.ts +10 -0
- package/dist/types/mesh/fieldTrinket.d.ts +40 -0
- package/dist/types/mesh/figureShapes.d.ts +24 -0
- package/dist/types/mesh/mesh.d.ts +9 -0
- package/dist/types/mesh/meshCheck.d.ts +22 -0
- package/dist/types/mesh/overhang.d.ts +24 -0
- package/dist/types/mesh/pixelFigure.d.ts +41 -0
- package/dist/types/mesh/sampledField.d.ts +3 -0
- package/dist/types/mesh/sdfShapes.d.ts +20 -0
- package/dist/types/mesh/stl.d.ts +9 -0
- package/dist/types/mesh/strokeText.d.ts +8 -0
- package/dist/types/mesh/surfaceNets.d.ts +14 -0
- package/dist/types/mesh/tetraMesh.d.ts +4 -0
- package/dist/types/mesh/threeMf.d.ts +12 -0
- package/dist/types/mesh/trinketKinds.d.ts +72 -0
- package/dist/types/mesh/trinketTool.d.ts +26 -0
- package/dist/types/mesh/voxel.d.ts +10 -0
- package/dist/types/mesh/zipFile.d.ts +13 -0
- package/dist/types/microFont.d.ts +6 -0
- package/dist/types/pack/meshPack.d.ts +26 -0
- package/dist/types/pack/threeMfPack.d.ts +11 -0
- package/dist/types/palettePresetData.d.ts +4 -0
- package/dist/types/palettePresets.d.ts +12 -0
- package/dist/types/paletteReserve.d.ts +52 -0
- package/dist/types/palettes.d.ts +4 -0
- package/dist/types/releaseNotes.d.ts +3 -0
- package/dist/types/simulation.d.ts +6 -0
- package/dist/types/{web/packages/tools/src/text.d.ts → text.d.ts} +6 -6
- package/package.json +145 -15
- package/dist/binary-D7wuaC5g.js +0 -120
- package/dist/pixels-DzfIIUOl.js +0 -76
- package/dist/types/games/kit/blit.d.ts +0 -10
- package/dist/types/games/kit/music.d.ts +0 -1
- package/dist/types/games/kit/pcText.d.ts +0 -8
- package/dist/types/games/kit/shading.d.ts +0 -11
- package/dist/types/web/packages/tools/src/audio.d.ts +0 -3
- package/dist/types/web/packages/tools/src/drawing.d.ts +0 -10
- package/dist/types/web/packages/tools/src/images.d.ts +0 -2
- package/dist/types/web/packages/tools/src/microFont.d.ts +0 -1
- package/dist/types/web/packages/tools/src/simulation.d.ts +0 -3
- package/dist/types/web/scripts/cdGames.d.ts +0 -103
- package/dist/types/web/scripts/gameShots.d.ts +0 -12
- package/dist/types/web/scripts/ogImage.d.ts +0 -21
- package/dist/types/web/src/audio/cmfLoad.d.ts +0 -7
- package/dist/types/web/src/audio/cmfPlayer.d.ts +0 -69
- package/dist/types/web/src/audio/context.d.ts +0 -12
- package/dist/types/web/src/audio/engine.d.ts +0 -39
- package/dist/types/web/src/audio/music.worklet.d.ts +0 -14
- package/dist/types/web/src/audio/opl.d.ts +0 -37
- package/dist/types/web/src/audio/output.d.ts +0 -13
- package/dist/types/web/src/desk/boxes/boxFacts.d.ts +0 -85
- package/dist/types/web/src/dosPlayer/fileExtensions.d.ts +0 -44
- package/dist/types/web/src/dosPlayer/patchRules.d.ts +0 -24
- package/dist/types/web/src/dosPlayer/patchTable.d.ts +0 -80
- package/dist/types/web/src/edition.d.ts +0 -6
- package/dist/types/web/src/eggs/eggState.d.ts +0 -26
- package/dist/types/web/src/eggs/eggs.d.ts +0 -31
- package/dist/types/web/src/engine/character.d.ts +0 -30
- package/dist/types/web/src/engine/funcKeys.d.ts +0 -33
- package/dist/types/web/src/engine/game.d.ts +0 -52
- package/dist/types/web/src/engine/keys.d.ts +0 -17
- package/dist/types/web/src/engine/machine.d.ts +0 -99
- package/dist/types/web/src/engine/menus.d.ts +0 -46
- package/dist/types/web/src/engine/monsters.d.ts +0 -19
- package/dist/types/web/src/engine/playGain.d.ts +0 -11
- package/dist/types/web/src/engine/playerLook.d.ts +0 -26
- package/dist/types/web/src/engine/recorder.d.ts +0 -60
- package/dist/types/web/src/engine/render.d.ts +0 -8
- package/dist/types/web/src/engine/scene.d.ts +0 -156
- package/dist/types/web/src/engine/scroll.d.ts +0 -16
- package/dist/types/web/src/engine/showGraphic.d.ts +0 -39
- package/dist/types/web/src/engine/slowPc.d.ts +0 -62
- package/dist/types/web/src/engine/touch.d.ts +0 -33
- package/dist/types/web/src/engine/world.d.ts +0 -215
- package/dist/types/web/src/export/gameAbout.d.ts +0 -15
- package/dist/types/web/src/formats/binary.d.ts +0 -44
- package/dist/types/web/src/formats/blocks.d.ts +0 -52
- package/dist/types/web/src/formats/character.d.ts +0 -65
- package/dist/types/web/src/formats/cmf.d.ts +0 -33
- package/dist/types/web/src/formats/fli.d.ts +0 -45
- package/dist/types/web/src/formats/fliLimits.d.ts +0 -13
- package/dist/types/web/src/formats/game.d.ts +0 -72
- package/dist/types/web/src/formats/gif.d.ts +0 -15
- package/dist/types/web/src/formats/graphicScripts.d.ts +0 -18
- package/dist/types/web/src/formats/highscore.d.ts +0 -10
- package/dist/types/web/src/formats/map.d.ts +0 -24
- package/dist/types/web/src/formats/monster.d.ts +0 -48
- package/dist/types/web/src/formats/palette.d.ts +0 -15
- package/dist/types/web/src/formats/recording.d.ts +0 -7
- package/dist/types/web/src/formats/sound.d.ts +0 -13
- package/dist/types/web/src/formats/voc.d.ts +0 -13
- package/dist/types/web/src/gfx/cp437Glyphs.d.ts +0 -2
- package/dist/types/web/src/gfx/font8x8.d.ts +0 -2
- package/dist/types/web/src/gfx/levelPicture.d.ts +0 -81
- package/dist/types/web/src/gfx/screen.d.ts +0 -46
- package/dist/types/web/src/gfx/titlePicture.d.ts +0 -21
- package/dist/types/web/src/input/chords.d.ts +0 -22
- package/dist/types/web/src/input/deskMouse.d.ts +0 -14
- package/dist/types/web/src/input/keyboard.d.ts +0 -39
- package/dist/types/web/src/input/scancodes.d.ts +0 -3
- package/dist/types/web/src/manual/printables/types.d.ts +0 -277
- package/dist/types/web/src/project/bizarre.d.ts +0 -28
- package/dist/types/web/src/project/companion.d.ts +0 -35
- package/dist/types/web/src/project/diskFacts.d.ts +0 -30
- package/dist/types/web/src/project/files.d.ts +0 -124
- package/dist/types/web/src/project/gameFiles.d.ts +0 -49
- package/dist/types/web/src/project/gamePack.d.ts +0 -17
- package/dist/types/web/src/project/health.d.ts +0 -30
- package/dist/types/web/src/project/secretGames.d.ts +0 -19
- package/dist/types/web/src/project/storage.d.ts +0 -46
- package/dist/types/web/src/project/streamGame.d.ts +0 -38
- package/dist/types/web/src/project/zip.d.ts +0 -33
- package/dist/types/web/src/retro/dos/disks.d.ts +0 -33
- package/dist/types/web/src/retro/text/cp437.d.ts +0 -4
- package/dist/types/web/src/seededRandom.d.ts +0 -6
- package/dist/types/web/src/tinHearts/deskHearts.d.ts +0 -33
- package/dist/types/web/src/tinHearts/manifest.d.ts +0 -30
- package/dist/types/web/src/tinHearts/tinHearts.d.ts +0 -84
- package/dist/types/web/src/walkthrough/format.d.ts +0 -92
- package/dist/types/web/src/walkthrough/madeUpScores.d.ts +0 -6
- package/dist/types/web/src/walkthrough/runtime.d.ts +0 -134
- /package/dist/types/{web/src/assistant → image}/png.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/palette.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/pixels.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/reel.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/sound.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/textBounds.d.ts +0 -0
- /package/dist/types/{games/kit → kit}/tune.d.ts +0 -0
- /package/dist/types/{web/src/audio → music}/compose.d.ts +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
class d {
|
|
2
|
+
constructor(s, t) {
|
|
3
|
+
this.sim = s, this.scan = t.scan, this.origin = t.origin, this.meterShown = t.meter, this.traced = t.traced ?? [72, 75, 77, 80, 16, 18];
|
|
4
|
+
}
|
|
5
|
+
sim;
|
|
6
|
+
log = [];
|
|
7
|
+
scan;
|
|
8
|
+
origin;
|
|
9
|
+
meterShown;
|
|
10
|
+
traced;
|
|
11
|
+
snapshot() {
|
|
12
|
+
return { sim: this.sim.snapshot(), log: this.log.length };
|
|
13
|
+
}
|
|
14
|
+
restore(s) {
|
|
15
|
+
this.sim.restore(s.sim), this.log.length = s.log;
|
|
16
|
+
}
|
|
17
|
+
/** The hero's position in level pixels (left/top of its bottom block). */
|
|
18
|
+
get px() {
|
|
19
|
+
const s = this.sim.pos;
|
|
20
|
+
return { x: (s.x - this.origin) * 20 + s.sx, y: (s.y - this.origin) * 20 + s.sy };
|
|
21
|
+
}
|
|
22
|
+
/** Its block (level coordinates), rounded to the nearest. */
|
|
23
|
+
get at() {
|
|
24
|
+
const s = this.px;
|
|
25
|
+
return { x: Math.round(s.x / 20), y: Math.round(s.y / 20) };
|
|
26
|
+
}
|
|
27
|
+
say(s) {
|
|
28
|
+
const t = this.px;
|
|
29
|
+
this.log.push(`[${this.sim.scene}] ${s} @${(t.x / 20).toFixed(2)},${(t.y / 20).toFixed(2)} t${this.sim.ticks} hp ${this.sim.ci.hitpts}`);
|
|
30
|
+
}
|
|
31
|
+
async tick() {
|
|
32
|
+
const s = this.sim.ci.hitpts, t = await this.sim.tick() ?? void 0;
|
|
33
|
+
if (process.env.BOT_HURT && this.sim.ci.hitpts < s) {
|
|
34
|
+
const e = this.sim.w, h = e.mi.map((r, o) => ({ mi: r, n: e.mm[o].monnum })).filter(({ mi: r, n: o }) => o < 64 && Math.abs(r.curx[0] - this.sim.pos.x) <= 1 && Math.abs(r.cury[0] - this.sim.pos.y) <= 1), i = this.meterShown;
|
|
35
|
+
this.say(
|
|
36
|
+
` hurt ${s - this.sim.ci.hitpts}: monsters ${h.map((r) => r.n).join(",")} block ${this.sim.blockAt(this.sim.pos.x + 1, this.sim.pos.y)} ${i.name} ${this.sim.meter(i.n) - 1}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return process.env.BOT_TRACE && this.say(` keys ${this.traced.filter((e) => this.sim.isHeld(e)).join(",")} gy ${this.sim.ci.gravy}${t ? " " + t : ""}`), t;
|
|
40
|
+
}
|
|
41
|
+
async wait(s) {
|
|
42
|
+
for (let t = 0; t < s; t++) {
|
|
43
|
+
const e = await this.tick();
|
|
44
|
+
if (e) return e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Waits until the hero stops moving up or down (standing, or holding on to something). */
|
|
48
|
+
async land(s = 80) {
|
|
49
|
+
let t = this.px.y, e = 0;
|
|
50
|
+
for (let h = 0; h < s; h++) {
|
|
51
|
+
const i = await this.tick();
|
|
52
|
+
if (i) return i;
|
|
53
|
+
const r = this.px.y;
|
|
54
|
+
if (e = r === t ? e + 1 : 0, t = r, e >= 3) return;
|
|
55
|
+
}
|
|
56
|
+
return "never landed";
|
|
57
|
+
}
|
|
58
|
+
/** Before each step of a walk: a game's chance to stop for something (keys still held). */
|
|
59
|
+
async beforeStep(s) {
|
|
60
|
+
}
|
|
61
|
+
/** Before a hop (and before a walk hops what blocks it, `dir` still held): a game's chance to wait. */
|
|
62
|
+
async beforeHop(s) {
|
|
63
|
+
}
|
|
64
|
+
/** Walks to level column `bx` (its left edge at bx * 20 px), hopping over whatever stops it. */
|
|
65
|
+
async walk(s, t = "", e = 900) {
|
|
66
|
+
const h = this.scan, i = s * 20, r = i > this.px.x ? "right" : "left", o = () => r === "right" ? this.px.x >= i : this.px.x <= i;
|
|
67
|
+
this.sim.press(h[r]);
|
|
68
|
+
let n = 0, a = this.px.x;
|
|
69
|
+
for (let l = 0; l < e && !o(); l++) {
|
|
70
|
+
const p = await this.beforeStep(r);
|
|
71
|
+
if (p) return this.sim.releaseAll(), p;
|
|
72
|
+
const m = await this.tick();
|
|
73
|
+
if (m) return this.sim.releaseAll(), m;
|
|
74
|
+
if (n = this.px.x === a ? n + 1 : 0, a = this.px.x, n >= 3) {
|
|
75
|
+
const x = await this.beforeHop(r);
|
|
76
|
+
if (x) return this.sim.releaseAll(), x;
|
|
77
|
+
this.sim.press(h.up);
|
|
78
|
+
const f = await this.wait(10);
|
|
79
|
+
if (this.sim.release(h.up), f) return this.sim.releaseAll(), f;
|
|
80
|
+
n = -12;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.sim.release(h[r]);
|
|
84
|
+
const c = await this.land();
|
|
85
|
+
if (c) return c;
|
|
86
|
+
if (Math.abs(this.px.x - i) > 3) {
|
|
87
|
+
const l = this.px.x > i ? "left" : "right";
|
|
88
|
+
this.sim.press(h[l]);
|
|
89
|
+
for (let p = 0; p < 10 && Math.abs(this.px.x - i) > 2; p++) {
|
|
90
|
+
const m = await this.tick();
|
|
91
|
+
if (m) return this.sim.releaseAll(), m;
|
|
92
|
+
}
|
|
93
|
+
this.sim.release(h[l]);
|
|
94
|
+
}
|
|
95
|
+
return Math.abs(this.px.x - i) > 6 ? `walk to ${s} ${t} stopped at ${(this.px.x / 20).toFixed(2)}` : (t && this.say(`at ${t}`), this.land());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A hop: Up (or Q/E sideways) held `hold` ticks; then `steer` held while it falls, until it
|
|
99
|
+
* lands or has gone `steerTo` columns (level block x).
|
|
100
|
+
*/
|
|
101
|
+
async hop(s, t = 12, e, h) {
|
|
102
|
+
const i = this.scan, r = s === "up" ? i.up : s === "left" ? i.q : i.e, o = await this.beforeHop();
|
|
103
|
+
if (o) return o;
|
|
104
|
+
this.sim.press(r);
|
|
105
|
+
let n = await this.wait(t);
|
|
106
|
+
if (this.sim.release(r), n) return this.sim.releaseAll(), n;
|
|
107
|
+
if (e) {
|
|
108
|
+
this.sim.press(i[e]);
|
|
109
|
+
const a = h !== void 0 ? h * 20 : void 0;
|
|
110
|
+
for (let c = 0; c < 60 && !(a !== void 0 && (e === "right" ? this.px.x >= a : this.px.x <= a)); c++)
|
|
111
|
+
if (n = await this.tick(), n) return this.sim.releaseAll(), n;
|
|
112
|
+
this.sim.release(i[e]);
|
|
113
|
+
}
|
|
114
|
+
return n = await this.land(), this.say(`hopped ${s}${e ? " then " + e : ""}`), n;
|
|
115
|
+
}
|
|
116
|
+
/** Holds a key for `ticks` (Down to climb down, Up to climb up, Space for the game's action). */
|
|
117
|
+
async hold(s, t) {
|
|
118
|
+
const e = this.scan[s];
|
|
119
|
+
this.sim.press(e);
|
|
120
|
+
const h = await this.wait(t);
|
|
121
|
+
return this.sim.release(e), h;
|
|
122
|
+
}
|
|
123
|
+
/** Climbs (or walks) along one axis until the hero reaches level column/row `to`. */
|
|
124
|
+
async dig(s, t, e = "", h = 400) {
|
|
125
|
+
const i = t * 20, r = () => s === "left" ? this.px.x <= i : s === "right" ? this.px.x >= i : s === "up" ? this.px.y <= i : this.px.y >= i;
|
|
126
|
+
return this.until(s, r, e || `dug ${s} to ${t}`, h);
|
|
127
|
+
}
|
|
128
|
+
/** Holds `key` until `check` says so (or `max` ticks: then it fails). */
|
|
129
|
+
async until(s, t, e, h = 300) {
|
|
130
|
+
const i = s === void 0 ? void 0 : this.scan[s];
|
|
131
|
+
i !== void 0 && this.sim.press(i);
|
|
132
|
+
for (let r = 0; r < h && !t(); r++) {
|
|
133
|
+
const o = await this.tick();
|
|
134
|
+
if (o) return this.sim.releaseAll(), o;
|
|
135
|
+
}
|
|
136
|
+
if (i !== void 0 && this.sim.release(i), !t()) return `never ${e}`;
|
|
137
|
+
this.say(e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
d as HopBot
|
|
142
|
+
};
|