用户:
幻境孤影查看:6 回复:5 评论:6 创建时间:2023-02-16T19:13:27
console.clear()
var door = world.querySelector('#传送门')
door.enableInteract = true
door.interactRadius = 2
door.interactHint = '传送到房顶上面'
door.onInteract(({ entity }) => {
entity.position.set(79,26,73)
})
console.clear()
var door = world.querySelector('#单')
door.enableInteract = true
door.interactRadius = 2
door.interactHint = '传送到亭子上面'
door.onInteract(({ entity }) => {
entity.position.set(97,25,208)
})
for (let i = 0; i < 254; i++) {
for (let j = 9; j < 19; j++) {
for (let k = 0; k < 1; k++) {
voxels.setVoxel(i, j, k, 'light_grey_stone_brick')
}
}
}
for (let i = 0; i < 1; i++) {
for (let j = 9; j < 19; j++) {
for (let k = 0; k < 254; k++) {
voxels.setVoxel(i, j, k, 'light_grey_stone_brick')
}
}
}
for (let i = 0; i < 254; i++) {
for (let j = 9; j < 19; j++) {
for (let k = 252; k < 253; k++) {
voxels.setVoxel(i, j, k, 'light_grey_stone_brick')
}
}
}
for (let i = 252; i < 253; i++) {
for (let j = 9; j < 19; j++) {
for (let k = 0; k < 254; k++) {
voxels.setVoxel(i, j, k, 'light_grey_stone_brick')
} }
}
(async function(){
while(true){
world.querySelectorAll("#金字塔").forEach((e)=>{
e.meshOrientation.copy(e.meshOrientation.rotateY(Math.PI/250))
});
await sleep(10);
}
})()
world.onPlayerJoin(({ entity }) => {
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/金箍棒.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(1, 1, 1),
emissive: number = 1
});
});
//将可伤害开启
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
});
//摔落伤害
world.onVoxelContact(async ({ entity, x, y, z, voxel }) => {
if (!entity.isPlayer) return;
let i = entity.player.fall - y
if (entity.player.fall - y > 10) {
entity.hurt(i * 3)
entity.player.directMessage('你受到了' + i * 3 + '点摔落伤害,目前血量是:' + entity.hp)
}
entity.player.fall = y
});
//处理特殊情况:水方块
world.onFluidEnter(async({entity,voxel})=>{
if(!entity.isPlayer){return;}
entity.player.fall=0
})
function cylinder(cx, cy, cz, vox, radius, height) {
var xend = cx + radius;
var yend = cy + height;
var zend = cz + radius;
for (var x = cx - radius; x <= xend; x++) {
for (var z = cz - radius; z <= zend; z++) {
var dx = x - cx;
var dz = z - cz;
if (Math.round(Math.sqrt(dx * dx + dz * dz)) <= radius) {
for (var y = cy; y < yend; y++) {
voxels.setVoxel(x, y, z, vox);
}
}
}
}
}
for (var i = 0; i < 10800; i++) { /* 300个随机圆柱体构成场景 */
let x = Math.random() * 1005; /* x坐标 */
let z = Math.random() * 1005; /* z坐标 */
let h = Math.random() * 5; /* 高 0~3.9999 */
let r = 2 + Math.random() * 5; /* 半径 2~6.9999 */
cylinder(x, 9, z, 'dirt', r, h);
}
for (var y = 8; y < 14; y++) { /* 扫描9~12层的格子 */
for (var x = 0; x < 10800; x++) {
for (var z = 0; z < 10800; z++) {
/* 如果当前格子不为空而它上面那格是空的, 则表示它是复杂地形的表面 */
if (voxels.getVoxel(x, y, z) != 0 && voxels.getVoxel(x, y + 1, z) == 0) {
voxels.setVoxel(x, y, z, 'white_grass'); /* 土块替换成喵地 */
}
}
}
}
for (let i = 0; i < 128; ++i) {
for (let j = 0; j < 128; ++j) {
voxels.setVoxel(i, 8, j, 'white_grass')
}
}
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.hurt(60 * Math.random() + 5, {
attacker: entity,
});
});
});
const shake = () => {
world.onPress(({ button, entity })=>{
if(button == Box3ButtonType.CROUCH){
const name = entity.player.name;
const dianyao = world.addZone({
selector: 'entity',
bounds: {
hi: entity.position.add(new Box3Vector3(5,2,5)),
lo: entity.position.sub(new Box3Vector3(5,2,5))
}
});
dianyao.onEnter(({ entity })=>{
if(entity.player.name !== name){
entity.enableDamage = true;
entity.hurt(2);
}
world.removeZone(dianyao);
});
};
});
};
shake();
world.onDie(({ entity, attacker }) => {
if (attacker) {
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}
});
world.onPlayerJoin(({ entity }) => {//初始化信息
entity.item = []//az
//entity.pvpitem = ['喵炮', '双龙炮', '百鬼夜行', '龙骨炮(骨头版)', '回旋镖']
entity.item = ['1类','2类','3类']//, '龙骨炮'
entity.qiangitem=['金箍棒']//1类自变量
entity.qita=['三叉戟']//2自变量
entity.aoyi=['黑暗之矛','龙骨炮','黄金龙首', '急冻之刃', '阴阳剑','地狱之火','闪电法杖','骨龙喵']//3自变量
entity.zt = 1
entity.coin = 50
entity.bag = 1
entity.zhushou = '无'
entity.player.onPress(async ({ button }) => {//右键显示状态栏
if (entity.player.walkState == Box喵layerWalkState.CROUCH && button == Box3ButtonType.ACTION1) {
const selpvp = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `个人信息:
昵称:${entity.player.name}
金币:${entity.coin}`,
options: ['切换武器', '取消'],
})
if (!selpvp || selpvp === null) {
return;
}
if (selpvp) {
if (selpvp.value == '切换武器') {
const selpvp2 = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `请选择您要切换的武器`,
options: entity.item,
})
if (selpvp2) {
if (selpvp2.value == '1类') {
const qiangxielei = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `请选择您要切换的武器`,
options: entity.qiangitem,
})
if (qiangxielei.value == '金箍棒') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/金箍棒.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(1, 1, 1),
emissive: number = 3
});
entity.zhushou = '金箍棒';//这个是技能用的,等下会用到
}
}
}
if (selpvp2.value == '2类') {
const qita = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `请选择您要切换的武器`,
options: entity.qita,
})
if (qita.value == '三叉戟') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/三叉戟.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(1, 1, 1),
//emissive: number = 1
});
entity.zhushou = '回旋镖';//这个是技能用的,等下会用到
}
}
}
if (selpvp2.value == '3类') {
const aoyi = await entity.player.dialog({
type: Box3DialogType.SELECT,
content: `请选择您要切换的武器`,
options: entity.aoyi,
})
if (aoyi.value == '黑暗之矛') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/长矛.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(1, 1, 1),
emissive: number = 1
});
entity.zhushou = '矛';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '急冻之刃') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/浪潮之刃.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(1, 1, 1),
// emissive: number = 1
});
entity.zhushou = '寒冰法杖';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '龙骨炮') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/龙骨炮.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(0.35, 0.7, 0.35),
emissive: number = 1
});
entity.zhushou = '龙骨炮(骨头版)';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '地狱之火') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/火系神剑.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(0.35, 0.7, 0.35),
emissive: number = 1
});
entity.zhushou = '火';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '阴阳剑') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/黄金龙首.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(0.35, 0.7, 0.35),
emissive: number = 1
});
entity.zhushou = '龙';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '闪电法杖') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/闪电法杖.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(0.35, 0.7, 0.35),
emissive: number = 1
});
entity.zhushou = '电';//这个是技能用的,等下会用到
}
}
if (aoyi.value == '骨龙喵') {
const pvprpg = await entity.player.dialog({
type: Box3DialogType.SELECT,
options: ['装备', '取消'],
})
if (pvprpg.value == '装备') {
const allWearables = entity.player.wearables();
allWearables.forEach((item) => {
item.remove();
});
entity.player.addWearable({
bodyPart: Box3BodyPart.RIGHT_HAND,
mesh: 'mesh/骨龙喵.vb',
orientation: new Box3Quaternion(1, 0, 1.5, -1).rotateY(Math.PI / 2),
scale: new Box3Vector3(0.35, 0.7, 0.35),
emissive: number = 1
});
entity.zhushou = '骨龙喵';//这个是技能用的,等下会用到
}
}
}
}
}
}
}
}
)
})
//这里的复活代码@吉吉喵
world.onDie(async({ entity }) => {
if (!entity.isPlayer) return;
for (let t = 0; t <= 1; t++) {
entity.player.directMessage(`倒计时 ${String(1 - t)} 秒后复活`);
await sleep(1000);
}
entity.player.forceRespawn();
});
world.onPress(async ({ entity, button, raycast: { direction } }) => {
if (button === 'action0' && entity.zhushou == '回旋镖' && entity.player.cool == 0&&entity.hp>0) {
entity.player.helper = false;
entity.player.cool = 3
const MeshScale = [1 / 16, 1 / 16, 1 / 16] //正常的模型缩放比例
const Quat = new Box3Quaternion(0, 0, 0, 1) //默认的旋转状态
const RED = new Box3RGBColor(1, 0, 0) //发光的红色
const d = entity.player.facingDirection //玩家的朝向
const knife = world.createEntity({
meshScale: MeshScale,
mesh: 'mesh/回旋镖-1.vb',
collides: true, // 开启碰撞
gravity: false, // 不受重力影响
position: entity.position, // 在玩家的位置生成飞刀
meshOrientation: Quat.rotateY(Math.atan2(d.z, d.x)), // 刀头指向玩家的朝向
particleRate: 40, //每秒发出80个粒子
particleLifetime: 1.1, //每个粒子存活2秒
particleSize: [1, 4, 3, 2, 4], //粒子在5个阶段的大小都是2
particleColor: [RED, RED, RED, RED, RED], //粒子在5个阶段的颜色都是红色
particleVelocity: d.scale(-2),
bounds: [0.5, 0.5, 0.5],// 子弹实体0.2个方块大小
})
knife.id = entity.player.userKey
knife.onEntityContact(async ({ other }) => {
if (!other.isPlayer) { return }
other.hurt(40, { attacker: entity, damageType: '回旋镖', })
})
for (let i = 0; i < 2; i++) {
for (let q = 0; q < 30; q++) {
await sleep(10)
knife.velocity.x += direction.x * 0.2
knife.velocity.z += direction.z * 0.2
knife.meshOrientation = knife.meshOrientation.rotateY(Math.PI / 2)
}
for (let q = 0; q < 30; q++) {
await sleep(5)
knife.meshOrientation = knife.meshOrientation.rotateY(Math.PI / 2)
}
for (let q = 0; q < 30; q++) {
await sleep(10)
knife.velocity.x -= direction.x * 0.2
knife.velocity.z -= direction.z * 0.2
knife.meshOrientation = knife.meshOrientation.rotateY(Math.PI / 2)
}
for (let q = 0; q < 30; q++) {
await sleep(5)
knife.meshOrientation = knife.meshOrientation.rotateY(Math.PI / 2)
}
}
if (knife) {
knife.destroy()//清除飞刀, 防止飞刀数量太多超过服务器负载
}
await sleep(4000)
entity.player.cool = 0
}
})
world.onPress(async ({ entity, button, raycast: { direction } }) => {
if (button === 'action0' && entity.zhushou == '风鹰剑'&&entity.hp>0) {
const MeshScale = [1 / 16, 1 / 16, 1 / 16] //正常的模型缩放比例
const Quat = new Box3Quaternion(0, 0, 0, 1) //默认的旋转状态
const d = entity.player.facingDirection //玩家的朝向
const knife = world.createEntity({
mesh: 'mesh/剑气-蓝.vb',
position: entity.position,
gravity: false,
fixed: 1,
velocity: d.scale(0.5 + Math.random()),
meshScale: [0.05, 0.05, 0.05],
meshOrientation: Quat.rotateZ(Math.random() * Math.PI).rotateX(Math.atan2(d.y, Math.sqrt(d.x ** 2 + d.z ** 2))).rotateY(Math.atan2(d.z, d.x)),
meshColor: [0, 0.5, 1],
meshemissive: (0.05),
})
knife.addTag(entity.player.userKey);
knife.onEntityContact(({ other }) => {
other.hurt(20, {
attacker: entity,
damageType: '风鹰剑',
})
})
await sleep(2000)
knife.removeTag(entity.player.userKey);
knife.destroy()
}
})
world.onPress(async ({ entity, button, raycast: { direction,hitPosition } }) => {
if (button === 'action1' && entity.zhushou == '风鹰剑'&&entity.hp>0&& !entity.jllengque) {
entity.jllengque = true
sleep(10000).then(() => {
entity.jllengque = false
})
entity.wait = true;
const d = direction;
const light = world.createEntity({
mesh: 'mesh/【喵】风鹰剑.vb',
position: hitPosition.add({ x: 0, y: 100, z: 0 }),
meshScale: [0.2, 0.2, 0.2],
mass: 256,
velocity: [0, -2, 0],
})
light.onEntityContact(({ other }) => {
if(other !== entity)
other.hurt(29, {
attacker: entity,
damageType: '风鹰剑',
})
})
await sleep(5000);
light.destroy();
entity.wait = false;
}
})
world.onPress(async({entity,button})=>{
if(button == 'action0' && entity.zhushou == '骨龙喵'&& !entity.jllengque &&entity.hp>0){
if (entity.player.walkState == Box喵layerWalkState.CROUCH) return;
entity.jllengque = true
sleep(10000).then(() => {
entity.jllengque = false
})
const e = world.createEntity({
mesh: 'mesh/光轮特效.vb',
meshScale: new Box3Vector3(1 / 10, 1 / 10, 1 / 10),
position: entity.position,
gravity: false,
collides: false,
fixed: true
})
e.addTag('骨龙喵')
e.addTag(entity.player.name)
e.point = {
lo: new Box3Vector3(e.position.x - 3, e.position.y - 3, e.position.z - 3), //最低坐标
hi: new Box3Vector3(e.position.x + 3, e.position.y + 3, e.position.z + 3), //最高坐标
}
sleep(6000).then(() => {
e.destroy()
e.destroyed = true
})
while (e.destroyed == false) {
e.position.copy(entity.position)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI / 2 / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(-Math.PI / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(-Math.PI / 2 / 2)
await sleep(10)
if (entity.hp <= 0) {
e.destroy()
}
}
}
})
world.onPress(async({entity,button})=>{
if(entity.player.walkState == Box喵layerWalkState.CROUCH && button == Box3ButtonType.ACTION0&& entity.zhushou == '骨龙喵'&& !entity.jllengque1 &&entity.hp>0){
if (!entity.jllengque1) {
entity.jllengque1 = true //设置玩家冷却成立
sleep(6000).then(() => {
entity.jllengque1 = false //再次恢复未冷却状态
})
const e = world.createEntity({
mesh: 'mesh/光轮特效.vb',
meshScale: new Box3Vector3(1 / 16, 1 / 16, 1 / 16),
position: entity.position,
gravity: false,
collides: false,
fixed: true
})
e.addTag('骨龙喵-0')
e.addTag(entity.player.name)
e.point = { //设置伤害区域
lo: new Box3Vector3(e.position.x - e.meshScale.x * 16 / 4, e.position.y - e.meshScale.y * 16 / 4, e.position.z - e.meshScale.z * 16 / 4), //最低坐标
hi: new Box3Vector3(e.position.x + e.meshScale.x * 16 / 4, e.position.y + e.meshScale.y * 16 / 4, e.position.z + e.meshScale.z * 16 / 4), //最高坐标
}
sleep(3000).then(() => {
e.destroy()
e.destroyed = true
})
while (e.destroyed == false) {
e.meshScale = new Box3Vector3(e.meshScale.x * 1.1, 1 / 16, e.meshScale.z * 1.1)
await sleep(1 / 24 * 1000)
}
}
}
})
async function shandian(position, entity) {
for (let i = -2; i < 3; i++) {
for (let p = -2; p < 3; p++) {
world.onPress(async({entity,button})=>{
if(button == 'action0' && entity.zhushou == '骨龙喵'&& !entity.jllengque &&entity.hp>0){
if (entity.player.walkState == Box喵layerWalkState.CROUCH) return;
entity.jllengque = true
sleep(10000).then(() => {
entity.jllengque = false
})
const e = world.createEntity({
mesh: 'mesh/光轮特效.vb',
meshScale: new Box3Vector3(1 / 10, 1 / 10, 1 / 10),
position: entity.position,
gravity: false,
collides: false,
fixed: true
})
e.addTag('骨龙喵')
e.addTag(entity.player.name)
e.point = {
lo: new Box3Vector3(e.position.x - 3, e.position.y - 3, e.position.z - 3), //最低坐标
hi: new Box3Vector3(e.position.x + 3, e.position.y + 3, e.position.z + 3), //最高坐标
}
sleep(6000).then(() => {
e.destroy()
e.destroyed = true
})
while (e.destroyed == false) {
e.position.copy(entity.position)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI / 2 / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(Math.PI)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(-Math.PI / 2)
await sleep(10)
e.meshOrientation = new Box3Quaternion(0, 0, 0, 1).rotateY(-Math.PI / 2 / 2)
await sleep(10)
if (entity.hp <= 0) {
e.destroy()
}
}
}
})
world.onPress(async({entity,button})=>{
if(entity.player.walkState == Box喵layerWalkState.CROUCH && button == Box3ButtonType.ACTION0&& entity.zhushou == '骨龙喵'&& !entity.jllengque1 &&entity.hp>0){
if (!entity.jllengque1) {
entity.jllengque1 = true //设置玩家冷却成立
sleep(6000).then(() => {
entity.jllengque1 = false //再次恢复未冷却状态
})
const e = world.createEntity({
mesh: 'mesh/光轮特效.vb',
meshScale: new Box3Vector3(1 / 16, 1 / 16, 1 / 16),
position: entity.position,
gravity: false,
collides: false,
fixed: true
})
e.addTag('骨龙喵-0')
e.addTag(entity.player.name)
e.point = { //设置伤害区域
lo: new Box3Vector3(e.position.x - e.meshScale.x * 16 / 4, e.position.y - e.meshScale.y * 16 / 4, e.position.z - e.meshScale.z * 16 / 4), //最低坐标
hi: new Box3Vector3(e.position.x + e.meshScale.x * 16 / 4, e.position.y + e.meshScale.y * 16 / 4, e.position.z + e.meshScale.z * 16 / 4), //最高坐标
}
sleep(3000).then(() => {
e.destroy()
e.destroyed = true
})
while (e.destroyed == false) {
e.meshScale = new Box3Vector3(e.meshScale.x * 1.1, 1 / 16, e.meshScale.z * 1.1)
await sleep(1 / 24 * 1000)
}
}
}
})
//先在地图放置模型:单元方块
var dot = world.createEntity({
mesh: 'mesh/单元方块.vb',
position: new Box3Vector3(position.x + i, position.y + 21, position.z + p),
gravity: 0,
fixed: 1,
collides: 0,
meshScale: new Box3Vector3(0, 0, 0)
});
var dot1 = world.createEntity({
mesh: dot.mesh,
position: new Box3Vector3(position.x + i, position.y, position.z + p),
gravity: 0,
fixed: 1,
collides: 0,
meshScale: dot.meshScale
});
Object.assign(dot, {
particleRate: 2000,
particleColor: new Box3RGBColor(1, 10, 10),
particleTarget: dot1,
particleSize: 4,
particleVelocity: [0, -50, 0],
particleNoise: 2.5, //数值越大频率越高
particleNoiseFrequency: Infinity
})
dot.addTag('电')
dot1.addTag('电')
dot.addTag(entity.player.name)
dot1.addTag(entity.player.name)
var e = dot
e.point = {
lo: new Box3Vector3(e.position.x - 1, e.position.y - 20, e.position.z - 1), //最低坐标
hi: new Box3Vector3(e.position.x + 1, e.position.y + 20, e.position.z + 1), //最高坐标
}
e = dot1
e.point = {
lo: new Box3Vector3(e.position.x - 1, e.position.y - 20, e.position.z - 1), //最低坐标
hi: new Box3Vector3(e.position.x + 1, e.position.y + 20, e.position.z + 1), //最高坐标
}
}
}
await sleep(10000)
world.querySelectorAll('.电').forEach((x) => {
if (x.hasTag(entity.player.name)) {
x.destroy()
}
})
}
world.onPress(async({entity,button})=>{
if(button == 'action1' && entity.zhushou == '骨龙喵' &&entity.hp>0){
}
})
world.onPress(async({entity,button})=>{
if(button == 'action1' && entity.zhushou == '闪电法杖' &&entity.hp>0&& !entity.jllengque){
if (!entity.jllengque) {
entity.jllengque = true //设置玩家冷却成立
sleep(15000).then(() => {
entity.jllengque = false //再次恢复未冷却状态
})
shandian(entity.position, entity)
}
}
})
const zdQuat = new Box3Quaternion(0, 0, 0, 1)
async function shootGJ(entity, speed) {
var e = world.createEntity({
mesh: 'mesh/光球.vb',
position: entity.position.add(new Box3Vector3(0, 1, 0)),
collides: true,
meshScale: new Box3Vector3(0.01, 0.01, 0.01),
})
e.addTag('弓箭')
e.zhongli = 0.1;
var angle = Math.atan2(entity.player.facingDirection.z, entity.player.facingDirection.x)
e.velocity.x = Math.cos(angle) * Math.cos(-entity.player.cameraPitch) * speed
e.velocity.y = 0.1
e.velocity.z = Math.sin(angle) * Math.cos(-entity.player.cameraPitch) * speed
var orientation = zdQuat.rotateY(Math.atan2(e.velocity.z, e.velocity.x)).rotateX(-entity.player.cameraPitch)
e.meshOrientation.copy(orientation)
Object.assign(e, {
particleRate: 10,
particleLifetime: 1.2,
})
e.onEntityContact(async({ other }) => {
if(other == entity)return;
other.hurt(30,{
attacker:entity,
damageType: '闪电法杖',
})
e.destroy();
})
await sleep(3000);
e.destroy()
}
(async function(){
for(let i = 0; i < Infinity; i++) {
world.querySelectorAll('.弓箭').forEach((e) => {
e.velocity.y -= e.zhongli
})
await sleep(100)
}
})()
world.onPress(async ({ entity, button }) => {
if (entity.player.dead) return;
if (button == Box3ButtonType.ACTION0 && entity.zhushou == '闪电法杖' && entity.hp > 0) {
var speed = 1
entity.player.walkState *= 0.5;
entity.player.walkAcceleration *= 0.5;
entity.player.runSpeed *= 0.5;
entity.player.runAcceleration *= 0.5;
while (entity.player.action0Button) {
if (speed < 10) {
speed++
}
await sleep(500);
}
shootGJ(entity, speed)
entity.player.walkState *= 2;
entity.player.walkAcceleration *= 2;
entity.player.runSpeed *= 2;
entity.player.runAcceleration *= 2;
}
})
setInterval(async function () {
world.querySelectorAll('.骨龙喵').forEach((jiguang) => {
jiguang.point = { //设置伤害区域
lo: new Box3Vector3(jiguang.position.x - 3, jiguang.position.y - 3, jiguang.position.z - 3), //最低坐标
hi: new Box3Vector3(jiguang.position.x + 3, jiguang.position.y + 3, jiguang.position.z + 3), //最高坐标
}
world.searchBox(jiguang.point).forEach((e) => {
if (e.isPlayer) {
if (jiguang.tags().includes(e.player.name)) return
world.querySelectorAll('player').forEach((x) => {
if (x.player.name == jiguang.tags()[1]) {
var attack = x
e.hurt(10, { attacker: attack,
damageType: '骨龙喵',
})
}
})
return
}
})
})
world.querySelectorAll('.骨龙喵-0').forEach((jiguang) => {
jiguang.point = { //设置伤害区域
lo: new Box3Vector3(jiguang.position.x - jiguang.meshScale.x * 16 / 4, jiguang.position.y - jiguang.meshScale.y * 16 / 4, jiguang.position.z - jiguang.meshScale.z * 16 / 4), //最低坐标
hi: new Box3Vector3(jiguang.position.x + jiguang.meshScale.x * 16 / 4, jiguang.position.y + jiguang.meshScale.y * 16 / 4, jiguang.position.z + jiguang.meshScale.z * 16 / 4), //最高坐标
}
world.searchBox(jiguang.point).forEach((e) => { //获取伤害区域内的所有实体
if (e.isPlayer) {
if (jiguang.tags().includes(e.player.name)) return
world.querySelectorAll('player').forEach((x) => {
if (x.player.name == jiguang.tags()[1]) {
var attack = x
e.hurt(30, { attacker: attack,
damageType: '骨龙喵',
})
}
})
return;
}
})
})
}, 600)
world.querySelectorAll('.闪电').forEach((jiguang) => {
world.searchBox(jiguang.point).forEach((e) => { //获取伤害区域内的所有实体
if (e.isPlayer) {
world.querySelectorAll('player').forEach((x) => {
if (x.player.name == jiguang.tags()[1] && x != e) {
var attack = x
e.hurt(20, { attacker: attack })
}
})
return;
}
})
})
world.onPress(async ({ entity, button }) => {
entity.player.onPress(async ({ button, raycast}) => {
if(entity.player.dead) return;
if (button == Box3ButtonType.ACTION0 && entity.zhushou == '寒冰法杖' && entity.hp > 0) {
if (world.currentTick - entity.time < 5) {
return;
}
entity.time = world.currentTick;
const MeshScale = [1 / 30, 1 / 30, 1 / 30];
const x = raycast.direction.x * 7.5;
const y = raycast.direction.y * 7.5;
const z = raycast.direction.z * 7.5;
const uuu = Math.sqrt(10);
const hq = world.createEntity({
mesh: 'mesh/光球.vb',
meshScale: MeshScale,
collides: false,
gravity: false,
position: entity.position,
velocity: new Box3Vector3(x, y, z),
meshEmissive: Infinity,
meshShininess: Infinity,
particleRate: 50,
particleSize: [uuu, 3 * uuu, 5 * uuu, 3 * uuu, uuu],
particleColor: [
new Box3RGBColor(1, 3, 7),
new Box3RGBColor(1, 3, 7),
new Box3RGBColor(1, 3, 7),
new Box3RGBColor(1, 3, 7),
],
particleLifetime: 0.4,
particleVelocitySpread: new Box3Vector3(2, 2, 2),
})
hq.id = entity.player.name;
hq.kk = 0;
world.onTick(({ }) => {
const x1 = hq.position.x;
const y1 = hq.position.y;
const z1 = hq.position.z;
if (hq.kk) return;
world.querySelectorAll('player').forEach((p) => {
const x2 = p.position.x;
const y2 = p.position.y;
const z2 = p.position.z;
if (((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1)) < 8) {
if (hq.id != p.player.name) {
p.hurt(25, {
attacker: entity,
damageType: '寒冰法杖',
})
hq.destroy();
hq.kk = 1;
}
}
});
if (x1 < -5 || y1 < -5 || z1 < -5 || x1 > 260 || y1 > 172 || z1 > 260) {
hq.destroy();
return;
}
})
}
})
})
world.onPress(async ({ entity, button }) => {
if (button == Box3ButtonType.ACTION0 && entity.zhushou == '火' && entity.hp > 0) {
}
})
world.onPress(async ({ entity, button }) => {
entity.player.onPress(async ({ button, raycast}) => {
if(entity.player.dead) return;
if (button == Box3ButtonType.ACTION0 && entity.zhushou == '火' && entity.hp > 0) {
if (world.currentTick - entity.time < 5) {
return;
}
entity.time = world.currentTick;
const MeshScale = [1 / 30, 1 / 30, 1 / 30];
const x = raycast.direction.x * 7.5;
const y = raycast.direction.y * 7.5;
const z = raycast.direction.z * 7.5;
const uuu = Math.sqrt(10);
const hq = world.createEntity({
mesh: 'mesh/光球.vb',
meshScale: MeshScale,
collides: false,
gravity: false,
position: entity.position,
velocity: new Box3Vector3(x, y, z),
meshEmissive: Infinity,
meshShininess: Infinity,
particleRate:100,
particleSize: [uuu, 3 * uuu, 5 * uuu, 3 * uuu, uuu],
particleColor: [
new Box3RGBColor(1, 0, 0),
new Box3RGBColor(1, 0, 0),
new Box3RGBColor(1, 0, 0),
new Box3RGBColor(1, 0, 0),
],
particleLifetime: 0.4,
particleVelocitySpread: new Box3Vector3(2, 2, 2),
})
hq.id = entity.player.name;
hq.kk = 0;
world.onTick(({ }) => {
const x1 = hq.position.x;
const y1 = hq.position.y;
const z1 = hq.position.z;
if (hq.kk) return;
world.querySelectorAll('player').forEach((p) => {
const x2 = p.position.x;
const y2 = p.position.y;
const z2 = p.position.z;
if (((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1)) < 8) {
if (hq.id != p.player.name) {
p.hurt(25, {
attacker: entity,
damageType: '火',
})
hq.destroy();
hq.kk = 1;
}
}
});
if (x1 < -5 || y1 < -5 || z1 < -5 || x1 > 260 || y1 > 172 || z1 > 260) {
hq.destroy();
return;
}
})
}
})
})
world.onPress(async ({ entity, button }) => {
if (button == Box3ButtonType.ACTION0 && entity.zhushou == '火' && entity.hp > 0) {
}
})
function cylinder(cx,cy,cz,vox,radius,height){
var xend = cx+radius
var yend = cy+height
var zend = cz+radius
for(var x=cx-radius;x<=xend;x++){
for(var z=cz-radius;z<=zend;z++){
var dx = x-cx;
var dz = z-cz;
if(Math.round(Math.sqrt(dx*dx+dz*dz))<=radius){
for(var y=cy;y<yend;y++){
voxels.setVoxel(x,y,z,vox)
}
}
}
}
}
function cylinder(cx,cy,cz,vox,radius,height){
var xend = cx+radius
var yend = cy+height
var zend = cz+radius
for(var x=cx-radius;x<=xend;x++){
for(var z=cz-radius;z<=zend;z++){
var dx = x-cx;
var dz = z-cz;
if(Math.round(Math.sqrt(dx*dx+dz*dz))<=radius){
for(var y=cy;y<yend;y++){
voxels.setVoxel(x,y,z,vox)
}
}
}
}
}