
Lv.1
在 求攻击到实体(玩家、模型)、方块后有爆炸粒子特效 中回复
console.clear()
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true //允许这个实体 受伤/喵亡/复活
entity.hurt(50) //去掉玩家半管血
console.log('hp:'+entity.hp) //现在受伤后只剩50了
console.log('maxHp:'+entity.maxHp) //生命值上限, box3里所有实体默认maxHp是100
})
console.clear()
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true //允许这个实体 受伤/喵亡/复活
entity.hp -= 100 //让玩家受100点伤害当场去世
})
world.onChat(({ entity }) => {
entity.hp = entity.maxHp * 0.5 //复活至一半最大生命值
})
for (const e of world.querySelectorAll('*')) { //遍历每个实体
e.enableDamage = true //允许这个实体 受伤/喵亡/复活
e.hurt(50) //把实体打剩半条命
}
for (const e of world.querySelectorAll('*')) { //遍历每个实体
e.enableDamage = true //允许这个实体 受伤/喵亡/复活
}
// 利用点击事件对点中的实体造成伤害
world.onClick(({ entity, clicker }) => { //entity是被点击的实体, clicker是点击了这个实体的玩家
if (entity.isPlayer) { //如果被点击的是个玩家实体
world.say(`${clicker.player.name} 击中 ${entity.player.name}`) //显示玩家的名字
} else {
world.say(`${clicker.player.name} 击中 ${entity.id}`) //显示实体的id
}
entity.hurt(20)
})
// 碰到岩浆受伤, 碰到字母H恢复生命
world.onVoxelContact(({ entity, voxel, x, y, z }) => { //当触碰方块
if (voxel === voxels.id('lava02')) { //如果方块类型是岩浆
entity.hurt(20) //受伤
} else if (voxel === voxels.id('H')) { //如果方块类型是H字母
entity.hp = entity.maxHp //恢复满血
voxels.setVoxel(x, y, z, '') //消掉H方块
}
})
for (const e of world.querySelectorAll('*')) { //遍历每个实体
e.enableDamage = true //允许这个实体 受伤/喵亡/复活
e.collides = true //允许实体被碰撞
e.gravity = true //开启重力, 这样实体才不会一碰就飘走
}
// 碰到僵尸受伤, 碰到急救包恢复生命
world.onEntityContact(({ entity, other }) => { //other是被触碰的实体
if (other.hasTag('僵尸')) { //当被碰实体有僵尸标签
entity.hurt(20) //受伤
} else if (other.hasTag('急救包')) { //当被碰实体有急救包标签
entity.hp = entity.maxHp //恢复满血
other.destroy() // 把急救包从地图删除, destroy()只能删除非玩家实体
}
})
for (const e of world.querySelectorAll('.僵尸')) { //遍历每个僵尸实体
e.enableDamage = true //允许这个实体 受伤/喵亡/复活
e.collides = true //允许实体被碰撞
e.gravity = true //开启重力, 这样实体才不会一碰就飘走
}
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true //允许这个实体 受伤/喵亡/复活
entity.id = entity.player.name //喵家名字赋值到id, 以便和其它实体一样可以统一通过entity.id获取名字
})
world.onEntityContact(({ entity, other }) => {
if (other.hasTag('僵尸')) { //如果被碰实体有僵尸标签
entity.hurt(30, {
damageType: '病毒', //伤害类型为病毒
attacker: other, //告诉引擎攻击者是被碰到的这个实体
})
}
})
world.onClick(({ entity, clicker }) => {// entity是被点击的实体, clicker是点击了这个实体的玩家
entity.hurt(20, {
damageType: '喵击', //伤害类型为喵击
attacker: clicker, //告诉引擎攻击者是触发点击的这个玩家实体
})
})
world.onTakeDamage(({ entity, attacker, damage, damageType }) => { //每次地图里有实体受伤
world.say(`${attacker.id} 对 ${entity.id} 造成${damage}点${damageType}伤害`)
})
world.onDie(({ entity, attacker, damageType }) => { //每次地图里有实体喵亡
if (entity.isPlayer) { //如果是玩家实体
if (damageType === '病毒') { //如果是病毒致喵
entity.player.color.set(0, 1, 0) //玩家实体颜色变绿
}
} else { //如果非玩家实体
if (damageType === '喵击') { //如果是喵击致喵
entity.destroy() //从地图上消失
}
}
})2021-04-18T11:26:41 点赞:1
在 【岛3老活新整创作节】官方地图《赤碧城》限时送,报名时间已截止! 中回复
我要报名参赛,我的地图编辑链接是:https://box3.codemao.cn/e/4a429喵3喵b11672喵13
2021-04-25T21:31:18 点赞:0
在 【老活新整创作节答疑帖】你分得清“有效报名”和“无效报名”吗? 中回复
来来来!!!!!
链接:https://box3.codemao.cn/e/4a429喵3喵b11672喵13
(会在这周内通过)
2021-04-25T21:40:45 点赞:0
在 有没有人知道一些好用的代码? 中回复
第二期代码教程:https://shequ.codemao.cn/community/374024
第一期代码教程:https://shequ.codemao.cn/community/3735喵
2021-04-28T19:09:43 点赞:0
在 【Python作品分享】【去太空,趣编程】watch the stars【作品秀】 中回复
热烈欢迎大家加入“皮卡丘工作室”! 加入链接喵o.cn/work_shop/6836
2021-05-04T10:46:25 点赞:0
在 一个喵小透明,想要与大神合作在岛三做一个赛博朋克风的游戏 中回复
热烈欢迎大家加入“皮卡丘工作室”! 加入链接喵o.cn/work_shop/6836
2021-05-04T10:49:51 点赞:0
在 *so,Do you wanna have a bad Tom!!! 中回复
热烈欢迎大家加入“皮卡丘工作室”! 加入链接:https://shequ.codemao.cn/work_shop/6836
2021-05-04T11:21:33 点赞:0
在 会python可否加入工作室 中回复
热烈欢迎大家加入“皮卡丘工作室”! 加入链接:https://shequ.codemao.cn/work_shop/6836
2021-05-04T11:21:51 点赞:0