猫史档案馆


令人跑酷 代码

用户:./'./'查看:0 回复:1 评论:0 创建时间:2021-05-03T11:48:01


            今天为你们准备1份独家代码

            行数超多

            准备好了吗

            Go!

console.clear()

var Quat = new Box3Quaternion(0,0,0,1)
var w = 0
var x = 0
const COLOR = [new Box3RGBAColor(0,0,0,1),new Box3RGBAColor(1,1,1,1),new Box3RGBAColor(0.968,0.702,0.392,1)]

world.onPlayerJoin(async({ entity,tick }) => {
    console.log(entity.player.url.searchParams)
    user = entity.player.userKey
    while(true){
        await sleep(1000)

        var w = Quat.w
        var x = Quat.x
        if(x >= 10){
            x = 0
            w += 1
        }
        x ++

        Quat = new Box3Quaternion(w,x,0,0)
    }
})

for(const e of world.querySelectorAll('*')){
    if(e.id.startsWith('复活')){
        e.collides = true
        e.fixed = true
        e.meshColor.set(0,1,0)
        e.meshScale = e.meshScale.scale(2)
        e.onEntityContact(({ other }) => {
            if(other.isPlayer){
                if(e.position !== other.player.spawnPoint){
                    other.player.directMessage(`存档成功!`)
                    other.player.spawnPoint = e.position
                }
            }
        })
    }
}

/* 按下左键时,在控制台输入记录 */
world.onPress(({ button, entity }) => {
    if(button === 'action0'){
       entity.player.directMessage(` ${entity.player.name} 按下了左键`);
    }
})

world.onPlayerJoin(({ entity }) => {
    entity.enableInteract = true
    entity.interactRadius = 4
    entity.interactHint = 'HP:100'
    entity.interactColor.set(0,0,1)

    entity.onInteract(({targetEntity,entity}) => {
        targetEntity.player.forceRespawn()
        TEXT(entity,`成功复活${entity.player.name}!`,false,'系统')
        entity.hp += 10
    })

    entity.onTakeDamage(() => {
        entity.interactHint = `HP:${entity.hp}`
    })

    entity.player.crouchButton = false
    entity.enableDamage = true

    entity.onVoxelSeparate(({ voxel }) => {
        if(voxel === voxels.id('lava02')){
            entity.hurt(5)
        }
    })

    entity.onVoxelContact(async({ x,y,z,voxel }) => {
        if(voxel===voxels.id('stripe_04')){
            await sleep(2000)
            voxels.setVoxel(x,y,z,'')
            await sleep(2000)
            voxels.setVoxel(x,y,z,'stripe_04')
        }
    })

    entity.onFluidEnter(({voxel}) => {
        if(voxel===voxels.id('water')){
            entity.position.copy(entity.player.spawnPoint)
            entity.position.y += 4
        }
    })
})

function TEXT(entity,content,hasArrow,title){
    return entity.player.dialog({
        type: Box3DialogType.TEXT,
        contentTextColor: COLOR[1],
        contentBackgroundColor: COLOR[2],
        content,
        titleTextColor: COLOR[1],
        titleBackgroundColor: COLOR[3],
        title,
        hasArrow,
    })
}

for(const s of world.querySelectorAll('.S')){
    s.enableInteract = true
    s.interactRadius = 4.5
    s.interactHint = s.id
    s.interactColor.set(1,0,0,1)

    s.onInteract(({ entity }) => {
        if(s.id === '告示牌'){
            TEXT(entity,'后面的几关都是模型跑酷,小心哟!',undefined,s.id)
        }else if(s.id === 'NPC'){
            TEXT(entity,'不错,不错,你完成了1.6半跑酷!',undefined,s.id)
        }else{
            entity.player.sound('audio/goal.mp3')
            TEXT(entity,'你成功了!奖励:飞行+穿墙+变色',undefined,s.id)
            world.say(`${entity.player.name}用时${Quat.w}${Quat.x}秒`)
            entity.player.canFly = true
            entity.player.spectator = true
            entity.player.color.set(1,0,1)
        }
    })
}

world.onDie(async({ entity,tick }) => {
    if(entity.isPlayer){
        TEXT(entity,'你喵了,15秒后显示复活选项',true,'阵亡')

        for(var i=15;i>0;i-=1){
            await sleep(1000)

            entity.player.directMessage(`还剩${i}秒`)
        }

        const amount = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            contentTextColor: COLOR[1],
            contentBackgroundColor: COLOR[2],
            content: '请选择复活选项(自行复活血量初始值为20)',
            titleTextColor: COLOR[1],
            titleBackgroundColor: COLOR[3],
            title: '阵亡',
            options: ['自行复活','等待支援'],
        })

        if(amount){
            if(amount.index === 0){
                TEXT(entity,'OK',true,'阵亡')
                entity.player.forceRespawn()
                entity.hp = 20
            }
        }
    }
})

world.onPress(({ button,entity }) => {
    if(button === Box3ButtonType.ACTION1){
        TEXT(entity,`name:${entity.player.name},userKey:${entity.player.userKey}\nHP:${entity.hp}`,undefined,`${entity.player.name}的状态`)
    }
})

world.onChat(({ entity,message }) => {
    if(message === '复活'){
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
        entity.hp = 100
    }
})

world.onPlayerJoin(({ entity }) => {
    TEXT(entity,`嗨!\n${entity.player.name}\n这是一个小小的跑酷\n功能等你来探索!`,undefined,entity.player.name)
})

for(const v of world.querySelectorAll('.V')){
    v.enableInteract = true
    v.interactRadius = 6
    v.interactColor = new Box3RGBAColor(0,1,0)
    v.enableDamage = true

    v.onDie(() => {
        v.destroy()
    })

    v.onInteract(async({ entity }) => {
        if(v.id === '密码门'){
            const amount = await entity.player.dialog({
                type: Box3DialogType.INPUT,
                titleTextColor: COLOR[1],
                titleBackgroundColor: COLOR[3],
                title: '密码门',
                contentTextColor: COLOR[1],
                contentBackgroundColor: COLOR[2],
                content: '输入密码(你可别告诉我你不知道密码)',
                placeholder: '在此处输入密码',
            })
            if(amount){
                if(Number(amount) === 148526){
                    v.hurt(20)
                    TEXT(entity,`密码正确,再输入正确密码${v.hp / 20}次`,undefined,v.id)
                }else{
                    TEXT(entity,'密码错误',v.id)
                }
            }
        }

        if(v.id === '纸'){
            TEXT(entity,'你发现了1张纸',true,v.id)
            TEXT(entity,'上面写着:148526',v.id)
        }

        if(v.id === '小箱子'){
            entity.hp *= 300
            world.say(`${entity.player.name}触发了最后一关的苹果!`)
        }
    })
}

world.addCollisionFilter('player','player');

function bubble_sort(list){
    var i,j,temp;
    for(i=0;i<list.length - 1;i++){
        for(j=0;j<list.length - 1 - i;j++){
            if(list[j] > list[j+1]){
                temp = list[j]
                list[j] = list[j + 1]
                list[j + 1] = temp
            }
        }
    }

    return list
}

bubble_sort([喵])

const pad = world.querySelector('#弹射跳板-1')
pad.onEntityContact(({ other, axis }) => {
    if (axis.y === -1) { // 如果是往下踩
        other.velocity.y = 2 // 设置玩家的瞬时y轴速度为2
    }
})

world.onPlayerJoin(({ entity:e }) => {
    e.onVoxelContact(async({x,y,z,voxel})=>{
        if(voxel===voxels.id('A')){
            voxels.setVoxel(x,y,z,'')

            await sleep(1000)

            voxels.setVoxel(x,y,z,'A')
        }
    })
})

//一个简单的射击PvP
world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true;
    entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
        if (button !== 'action0' || !hitEntity) {
            return;
        }
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += 0.5;
        hitEntity.velocity.z += direction.z;
        hitEntity.hurt(20 * Math.random() + 5, {
            attacker: entity,
        });
    });
});


回复

上一页1 页 / 共 1下一页
AB骉AlobokAB骉Alobok

console.clear()

var Quat = new Box3Quaternion(0,0,0,1)
var w = 0
var x = 0
const COLOR = [new Box3RGBAColor(0,0,0,1),new Box3RGBAColor(1,1,1,1),new Box3RGBAColor(0.968,0.702,0.392,1)]

world.onPlayerJoin(async({ entity,tick }) => {
    console.log(entity.player.url.searchParams)
    user = entity.player.userKey
    while(true){
        await sleep(1000)

        var w = Quat.w
        var x = Quat.x
        if(x >= 10){
            x = 0
            w += 1
        }
        x ++

        Quat = new Box3Quaternion(w,x,0,0)
    }
})

for(const e of world.querySelectorAll('*')){
    if(e.id.startsWith('复活')){
        e.collides = true
        e.fixed = true
        e.meshColor.set(0,1,0)
        e.meshScale = e.meshScale.scale(2)
        e.onEntityContact(({ other }) => {
            if(other.isPlayer){
                if(e.position !== other.player.spawnPoint){
                    other.player.directMessage(`存档成功!`)
                    other.player.spawnPoint = e.position
                }
            }
        })
    }
}

/* 按下左键时,在控制台输入记录 */
world.onPress(({ button, entity }) => {
    if(button === 'action0'){
       entity.player.directMessage(` ${entity.player.name} 按下了左键`);
    }
})

world.onPlayerJoin(({ entity }) => {
    entity.enableInteract = true
    entity.interactRadius = 4
    entity.interactHint = 'HP:100'
    entity.interactColor.set(0,0,1)

    entity.onInteract(({targetEntity,entity}) => {
        targetEntity.player.forceRespawn()
        TEXT(entity,`成功复活${entity.player.name}!`,false,'系统')
        entity.hp += 10
    })

    entity.onTakeDamage(() => {
        entity.interactHint = `HP:${entity.hp}`
    })

    entity.player.crouchButton = false
    entity.enableDamage = true

    entity.onVoxelSeparate(({ voxel }) => {
        if(voxel === voxels.id('lava02')){
            entity.hurt(5)
        }
    })

    entity.onVoxelContact(async({ x,y,z,voxel }) => {
        if(voxel===voxels.id('stripe_04')){
            await sleep(2000)
            voxels.setVoxel(x,y,z,'')
            await sleep(2000)
            voxels.setVoxel(x,y,z,'stripe_04')
        }
    })

    entity.onFluidEnter(({voxel}) => {
        if(voxel===voxels.id('water')){
            entity.position.copy(entity.player.spawnPoint)
            entity.position.y += 4
        }
    })
})

function TEXT(entity,content,hasArrow,title){
    return entity.player.dialog({
        type: Box3DialogType.TEXT,
        contentTextColor: COLOR[1],
        contentBackgroundColor: COLOR[2],
        content,
        titleTextColor: COLOR[1],
        titleBackgroundColor: COLOR[3],
        title,
        hasArrow,
    })
}

for(const s of world.querySelectorAll('.S')){
    s.enableInteract = true
    s.interactRadius = 4.5
    s.interactHint = s.id
    s.interactColor.set(1,0,0,1)

    s.onInteract(({ entity }) => {
        if(s.id === '告示牌'){
            TEXT(entity,'后面的几关都是模型跑酷,小心哟!',undefined,s.id)
        }else if(s.id === 'NPC'){
            TEXT(entity,'不错,不错,你完成了1.6半跑酷!',undefined,s.id)
        }else{
            entity.player.sound('audio/goal.mp3')
            TEXT(entity,'你成功了!奖励:飞行+穿墙+变色',undefined,s.id)
            world.say(`${entity.player.name}用时${Quat.w}${Quat.x}秒`)
            entity.player.canFly = true
            entity.player.spectator = true
            entity.player.color.set(1,0,1)
        }
    })
}

world.onDie(async({ entity,tick }) => {
    if(entity.isPlayer){
        TEXT(entity,'你喵了,15秒后显示复活选项',true,'阵亡')

        for(var i=15;i>0;i-=1){
            await sleep(1000)

            entity.player.directMessage(`还剩${i}秒`)
        }

        const amount = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            contentTextColor: COLOR[1],
            contentBackgroundColor: COLOR[2],
            content: '请选择复活选项(自行复活血量初始值为20)',
            titleTextColor: COLOR[1],
            titleBackgroundColor: COLOR[3],
            title: '阵亡',
            options: ['自行复活','等待支援'],
        })

        if(amount){
            if(amount.index === 0){
                TEXT(entity,'OK',true,'阵亡')
                entity.player.forceRespawn()
                entity.hp = 20
            }
        }
    }
})

world.onPress(({ button,entity }) => {
    if(button === Box3ButtonType.ACTION1){
        TEXT(entity,`name:${entity.player.name},userKey:${entity.player.userKey}\nHP:${entity.hp}`,undefined,`${entity.player.name}的状态`)
    }
})

world.onChat(({ entity,message }) => {
    if(message === '复活'){
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
        entity.hp = 100
    }
})

world.onPlayerJoin(({ entity }) => {
    TEXT(entity,`嗨!\n${entity.player.name}\n这是一个小小的跑酷\n功能等你来探索!`,undefined,entity.player.name)
})

for(const v of world.querySelectorAll('.V')){
    v.enableInteract = true
    v.interactRadius = 6
    v.interactColor = new Box3RGBAColor(0,1,0)
    v.enableDamage = true

    v.onDie(() => {
        v.destroy()
    })

    v.onInteract(async({ entity }) => {
        if(v.id === '密码门'){
            const amount = await entity.player.dialog({
                type: Box3DialogType.INPUT,
                titleTextColor: COLOR[1],
                titleBackgroundColor: COLOR[3],
                title: '密码门',
                contentTextColor: COLOR[1],
                contentBackgroundColor: COLOR[2],
                content: '输入密码(你可别告诉我你不知道密码)',
                placeholder: '在此处输入密码',
            })
            if(amount){
                if(Number(amount) === 148526){
                    v.hurt(20)
                    TEXT(entity,`密码正确,再输入正确密码${v.hp / 20}次`,undefined,v.id)
                }else{
                    TEXT(entity,'密码错误',v.id)
                }
            }
        }

        if(v.id === '纸'){
            TEXT(entity,'你发现了1张纸',true,v.id)
            TEXT(entity,'上面写着:148526',v.id)
        }

        if(v.id === '小箱子'){
            entity.hp *= 300
            world.say(`${entity.player.name}触发了最后一关的苹果!`)
        }
    })
}

world.addCollisionFilter('player','player');

function bubble_sort(list){
    var i,j,temp;
    for(i=0;i<list.length - 1;i++){
        for(j=0;j<list.length - 1 - i;j++){
            if(list[j] > list[j+1]){
                temp = list[j]
                list[j] = list[j + 1]
                list[j + 1] = temp
            }
        }
    }

    return list
}

bubble_sort([喵])

const pad = world.querySelector('#弹射跳板-1')
pad.onEntityContact(({ other, axis }) => {
    if (axis.y === -1) { // 如果是往下踩
        other.velocity.y = 2 // 设置玩家的瞬时y轴速度为2
    }
})

world.onPlayerJoin(({ entity:e }) => {
    e.onVoxelContact(async({x,y,z,voxel})=>{
        if(voxel===voxels.id('A')){
            voxels.setVoxel(x,y,z,'')

            await sleep(1000)

            voxels.setVoxel(x,y,z,'A')
        }
    })
})

//一个简单的射击PvP
world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true;
    entity.player.onPress(({ button, raycast:{ hitEntity, direction } }) => {
        if (button !== 'action0' || !hitEntity) {
            return;
        }
        hitEntity.velocity.x += direction.x;
        hitEntity.velocity.y += 0.5;
        hitEntity.velocity.z += direction.z;
        hitEntity.hurt(20 * Math.random() + 5, {
            attacker: entity,
        });
    });
});

点赞0


评论