用户:
神秘蟑螂zl查看:7 回复:9 评论:7 创建时间:2022-10-16T17:57:51
神秘蟑螂zl代码注释版(大佬勿喷):
(async function main() {//不加用不了await
while(1){ //一直监测
world.querySelectorAll('player').forEach((x)=>{//遍历所有玩家
if(["必有用"].includes(x.player.name)&&x.player.walkState=='crouch'){//[]里面填写使用连点的人,当玩家可以用连点并且玩家蹲下
var raycast=world.raycast(x.position,new Box3Vector3(x.player.facingDirection.x,x.player.cameraPitch*-1,x.player.facingDirection.z),{ignoreSelector:`.${x.player.name}`})//记住就行了,就是创建射线
if(raycast.hit&&raycast.hitEntity){ //如果射线射到人
var hitEntity=raycast.hitEntity//不用管
var direction=raycast.direction//不用管
var 喵 = 2;//伤害保留小数
var damage=Math.ceil(Math.random()*(10**喵))/(10**喵)//不用管
hitEntity.hurt(damage,{attacker:x})//给予玩家伤害
if(x.player.walkState!='crouch'){//如果要打的玩家没用下蹲
hitEntity.velocity.x+=direction.x*1.5
hitEntity.velocity.y+=0.2
hitEntity.velocity.z+=direction.z*1.5//以上为击退代码
}else{//否则
hitEntity.velocity.x+=direction.x
hitEntity.velocity.y+=0.1
hitEntity.velocity.z+=direction.z//以上为击退代码
}
}
}
})
await sleep(100);//等待100毫秒继续下一轮监测
}
})();点赞0
评论