feat: ✨ update guard
This commit is contained in:
parent
4f1e510386
commit
b1f27f455d
|
@ -6,10 +6,12 @@ let cfg = {}
|
|||
let bot = {}
|
||||
let guardPos
|
||||
|
||||
const filterallMobs = e => e.type === 'mob'
|
||||
// const filterPlayers = e => e.type === 'player' && e.username !== 'Applezaus'
|
||||
const filterAllMobs = e => e.type === 'mob'
|
||||
const filterPlayers = e => e.type === 'player'
|
||||
const filterMods = e => e.type === 'player' && [cfg.mods].includes(e.username)
|
||||
// const filterPassiveMobs = e => e.kind === 'Passive mobs'
|
||||
const filterCreeper = e => e.mobType === 'Creeper'
|
||||
// const filterCreeperOrEndermen = e => ['Creeper', 'EndderMen'].includes(e.mobType) //TODO endmen hostile by default?
|
||||
const filterHostileMobs = e => e.kind === 'Hostile mobs'
|
||||
// // not needed if detecting by kind
|
||||
// && e.mobType !== 'Armor Stand' // Mojang classifies armor stands as mobs for some reason?
|
||||
|
@ -60,33 +62,56 @@ function lookForMobs() {
|
|||
const filter = e => e.position.distanceTo(bot.entity.position) < 16 && filterHostileMobs(e)
|
||||
|
||||
const entityEnemy = bot.nearestEntity(filter)
|
||||
if (entityEnemy) {
|
||||
if(filterCreeper(entityEnemy))
|
||||
if (entityEnemy && !filterCreeper(entityEnemy)) {
|
||||
// if(filterCreeper(entityEnemy))
|
||||
// Start attacking
|
||||
// bot.off('time', lookForMobs)
|
||||
// bot.on('physicTick', lookForMobs)
|
||||
bot.pvp.movements.canDig = !!cfg.move && cfg.move.canDig
|
||||
bot.pvp.attack(entityEnemy)
|
||||
} else if (entityEnemy) {
|
||||
bot.lookAt(
|
||||
// (new v.Vec3(0, 1, 0)).add(
|
||||
entityEnemy.position
|
||||
// )
|
||||
)
|
||||
cfg.quiet || bot.chat("AH! A creeper! They creep me out!")
|
||||
}
|
||||
}
|
||||
|
||||
function guardSelf(entity) {
|
||||
if (!cfg.guard.self || entity !== bot.entity || guardPos) return // Do nothing
|
||||
// bot.chat("")
|
||||
bot.chat((
|
||||
() => { const a = ["ouch!", "oww!", "help", "", "", ""]; return a[Math.floor(Math.random() * a.length)] }
|
||||
)())
|
||||
const hurtMessages = [
|
||||
"ouch!", "oww!", "help", "monster!"
|
||||
]
|
||||
const hurtMessagesPlayer = [
|
||||
"leave me alone!", "don't hurt me!", "bully!", "go away!", "stop", "no stop", "stop it", "murderer!",
|
||||
"what have i ever done to you? :(",
|
||||
]
|
||||
console.info(bot.nearestEntity(filterAllMobs))
|
||||
|
||||
console.info(bot.nearestEntity(filterallMobs))
|
||||
|
||||
// Only look for mobs within 10 blocks
|
||||
const filter = e => e.position.distanceTo(bot.entity.position) < 10 && filterHostileMobs(e)
|
||||
// Only look for mobs within 5 blocks
|
||||
// const filter = e => e.position.distanceTo(bot.entity.position) < 5 && filterHostileMobs(e) || filterPlayers(e) && !filterMods(e)//anarchy
|
||||
const filter = e => e.position.distanceTo(bot.entity.position) < 5 && filterHostileMobs(e)
|
||||
|
||||
const entityEnemy = bot.nearestEntity(filter)
|
||||
|
||||
cfg.quiet || 0.2 < Math.random() && entityEnemy && bot.chat(
|
||||
// TODO use fuzzy message function
|
||||
filterPlayers(entityEnemy) ?
|
||||
hurtMessagesPlayer[Math.floor(Math.random() * hurtMessagesPlayer.length)]
|
||||
:
|
||||
hurtMessages[Math.floor(Math.random() * hurtMessages.length)]
|
||||
|
||||
)
|
||||
|
||||
if (entityEnemy && !filterCreeper(entityEnemy)) {
|
||||
// Start attacking
|
||||
// bot.off('time', lookForMobs)
|
||||
// bot.on('physicTick', lookForMobs)
|
||||
bot.pvp.attack(entityEnemy)
|
||||
bot.pvp.movements.canDig = !!cfg.move && cfg.move.canDig
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user