Created
December 18, 2015 22:59
-
-
Save jasontbradshaw/32e60e041bb767d3c862 to your computer and use it in GitHub Desktop.
How to win at ZType (http://zty.pe).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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