Skip to content

Instantly share code, notes, and snippets.

@Core-commits
Created July 11, 2020 16:06
Show Gist options
  • Select an option

  • Save Core-commits/6730688c3ee4c1f7a0d3ce0e95368c94 to your computer and use it in GitHub Desktop.

Select an option

Save Core-commits/6730688c3ee4c1f7a0d3ce0e95368c94 to your computer and use it in GitHub Desktop.
Game.on("initialSpawn", (player) => {
let zombie = new Bot("Zombie")
let outfit = new Outfit(zombie)
.body("#0d9436")
.torso("#694813")
.rightLeg("#694813")
.leftLeg("#694813")
Game.newBot(zombie)
// We use bot.setinterval so that when the zombie is destroyed, the loop clears.
// It's good practice to do this to avoid memory leaks.
zombie.setInterval(() => {
let target = zombie.findClosestPlayer(20)
if (!target) return zombie.setSpeech("")
zombie.setSpeech("BRAAINNNSSS!")
zombie.moveTowardsPlayer(target, 8)
}, 10)
let touchEvent = zombie.touching((p) => {
Game.messageAll(`[#ff0000]${p.username} was eaten by a zombie!`)
p.kill()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment