Skip to content

Instantly share code, notes, and snippets.

@jasontbradshaw
Created December 18, 2015 22:59
Show Gist options
  • Save jasontbradshaw/32e60e041bb767d3c862 to your computer and use it in GitHub Desktop.
Save jasontbradshaw/32e60e041bb767d3c862 to your computer and use it in GitHub Desktop.
How to win at ZType (http://zty.pe).
clearInterval(window.shootInterval);
var targetComparator = function (a, b) {
var aDist = ig.game.player.distanceTo(a);
var bDist = ig.game.player.distanceTo(b);
return aDist - bDist;
};
shootInterval = setInterval(function () {
if (!ig.game) { return; }
var targetArrayKeys = Object.keys(ig.game.targets);
var targets = [];
for (var i = 0, iLen = targetArrayKeys.length; i < iLen; i++) {
var targetArray = ig.game.targets[targetArrayKeys[i]];
targets.push.apply(targets, targetArray);
}
// Sort by distance to player, closest first.
targets.sort(targetComparator);
for (var j = 0, jLen = targets.length; j < jLen; j++) {
var target = targets[j];
if (!target.cheatKilled) {
console.log(`Die, '${target.word}'!`);
for (var k = 0, kLen = target.word.length; k < kLen; k++) {
ig.game.shoot(target.word[k]);
}
target.cheatKilled = true;
}
}
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment