用户:
两个小八路查看:0 回复:1 评论:0 创建时间:2020-04-27T09:07:06
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
world.rainColor = new Box3RGBColor(1, 1, 1);
world.rainDensity = 50;
world.rainInterference = 0.1;
world.rainPhi = Math.PI/6;
world.rainSizeHi = 3;
world.rainSizeLo = 1;
world.rainSpeed = 1.5;
world.sunFrequency = 1/24/60/60;
var a, b, c, rain, x, y, z;
a = 250;
b = 0;
c = 0;
let d = ['不知名帅哥', '逢考必过加油', '孙冬野', '两个小八路', '无人区知晓', '张允旭', '蓝buff', 'Eason12', '33工作', '人工智能AI','PX侠客行'];
rain = Math.floor(world.rainDensity);world.rainSpeed = 1.5;
world.sunFrequency = 1/24/60/60;
world.rainSpeed = 1.5;
setInterval(() => {
world.rainDensity = 100 - a/5;
if(world.rainDensity <= 0){
world.rainDensity = 0;
}
if(b == 1){
a -= 50 * Math.random();
if (rain != Math.floor(world.rainDensity && a < 500)){
world.say('雨越来越大,降水量变成了' + Math.floor(world.rainDensity) );
rain = Math.floor(world.rainDensity);
}
}
if(b == 0){
a += 50 * Math.random();
if (rain != Math.floor(world.rainDensity)){
if(Math.ceil(world.rainDensity) == 100){
world.say('雨小了下来,现在降雨量: 99' );
}else{
world.say('雨小了下来,现在降雨量:' + Math.ceil(world.rainDensity) );
}
rain = Math.ceil(world.rainDensity);
}
}
if(a >= 500){
b = 2;
if (c == 0){
c = 1;
world.say('雨停了!');
}
b -= Math.random() / 4;
if (b <= 1){
c = 0;
b = 1;
}
}
if(a <= 0){
b = 0;
}
}, 10000);
var m;
world.onEntityContact(({ entity }) =>{
if (entity.position == (73, 121, 75)) {
entity.player.scale *= 0.75;
entity.player.walkSpeed *= 0.75;
entity.player.runSpeed *= 0.75;
entity.player.crouchSpeed *= 0.75;
}
})
world.onPlayerJoin(({ entity }) => {
entity.maxHp = 100;
entity.player.swimSpeed = 10;
entity.player.scale = 0.5;
entity.enableDamage = true;
if(d.includes(entity.player.name)){
entity.player.canFly = true;
entity.player.emissive = 0.2;
}
entity.player.onPress(({ entity, button, raycast:{ hitEntity, direction } }) => {
if (button === 'crouch' ){
if(entity.player.moveState == 'fly'){return;}
entity.player.color=new Box3RGBColor(0,1,0);
entity.hp += 5;
if(entity.hp > 100){
entity.hp = 100;
}
}
else {
if(entity.player.spawnPoint.toString() == z){
entity.player.color=new Box3RGBColor(1,1,0);
}else{
entity.player.color=new Box3RGBColor(0,0,1);
}
if (button !== 'action0' || !hitEntity || !hitEntity.isPlayer) {
return ;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += 0.5;
hitEntity.velocity.z += direction.z;
hitEntity.hurt(20 * Math.random() + 5, {
attacker: entity,
})
if(hitEntity.isPlayer){
hitEntity.player.color=new Box3RGBColor(1,0,0);
sleep(500).then(()=>{
if(hitEntity.player.spawnPoint.toString() == z){
hitEntity.player.color=new Box3RGBColor(1,1,0);
}else{
hitEntity.player.color=new Box3RGBColor(0,0,1);
}
})
}
}
})
entity.player.onRelease(({ entity, button, raycast:{ hitEntity, direction } }) => {
if(entity.player.spawnPoint.toString() == z){
entity.player.color=new Box3RGBColor(1,1,0);
}else{
entity.player.color=new Box3RGBColor(0,0,1);
}
})
})
world.onDie(({ entity, attacker }) => {
if (attacker) {
if(attacker.player.color !== entity.player.color){
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}else{
world.say(attacker.player.name + ' 误杀了自己的队友 ' + entity.player.name)
}
}
entity.player.forceRespawn();
});
world.onChat(({ entity, message }) => {
if ( entity && entity.isPlayer ) {
if( entity.player.name == ' ' ){
m = message;
}
if(message == m){
if (entity.player.invisible == false){
entity.player.invisible = true;
}else {
entity.player.invisible = false;
}
}
if(d.includes(entity.player.name)){
if(message == '大'){
entity.player.scale *= 2;
entity.player.walkSpeed *= 2;
entity.player.runSpeed *= 2;
entity.player.crouchSpeed *= 2;
}
if(message == '小'){
entity.player.scale /= 2;
entity.player.walkSpeed /= 2;
entity.player.runSpeed /= 2;
entity.player.crouchSpeed /= 2;
}
if(message == '隐身'){
entity.player.invisible = true;
}
if(message == '现身'){
entity.player.invisible = false;
}
if(message == '还原'){
entity.player.invisible = false;
entity.player.scale = 1;
entity.player.walkSpeed = 0.22;
entity.player.runSpeed = 0.4;
entity.player.crouchSpeed = 0.1;
}
}
}
})
world.onTick(()=>{
world.querySelectorAll('player').forEach((e)=>{
if(e.position.y < -10){
if(Math.round(e.hp/3)===0){
e.hurt(1);
} else{
e.hurt(Math.round(e.hp/3));
}
if(e.hp<=0){
world.say(e.player.name + '掉下了虚空');
}
}
})
})
var m, n;
m = 0;
n = 0;
world.onPlayerJoin(async ({entity})=>{
entity.player.directMessage(entity.player.name + ',欢迎来到星球大战')
if (m == n) {
entity.position.set(114, 20 , 8);//玩家进来的时候,将ta传送到指定的坐标
entity.player.spawnPoint.copy(entity.position);//将玩家复活点复制为上面的坐标
entity.position=new Box3Vector3(114,10 * Math.random() + 20,8);
entity.player.directMessage('你加入了蓝队,你需要守住下面的麦当劳!');
n = (typeof n == 'number' ? n : 0) + 1;
entity.player.color=new Box3RGBColor(0,0,1);
}
else {
entity.position.set(18, 17 , 107);//玩家进来的时候,将ta传送到指定的坐标
entity.player.spawnPoint.copy(entity.position);//将玩家复活点复制为上面的坐标
entity.position=new Box3Vector3(18,10 * Math.random() + 17,107);
z = entity.player.spawnPoint.toString();
entity.player.directMessage('你加入了黄队,快去找队友攻击麦当劳吧!');
m = (typeof m == 'number' ? m : 0) + 1;
entity.player.color=new Box3RGBColor(1,1,0);
}
});
world.querySelectorAll('.跑车').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
if(!other.isPlayer){return}
other.meshScale=entity.meshScale;//设置玩家的大小
other.player.invisible=true;//隐身
other.mesh=entity.mesh;//设置玩家的外观
other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//设置跑车的旋转角度,没有反不要这个代码
world.say(other.player.name+" 开走了水上飞机");//广播消息
other.player.runSpeed = 2;//设置跑步的速度
other.player.walkSpeed = 1.5;//设置走路的速度
other.player.scale =0.6;//因为实体比较小,设置玩家的大小小一些
other.player.jumpPower = 1;//关闭跳跃能力
other.player.canFly = true;
other.player.forceRespawn();
jumpPower: number = 3
});
});
world.querySelectorAll('.1').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
if(!other.isPlayer){return}
hithp = true;
other.meshScale=entity.meshScale;//设置玩家的大小
other.player.invisible=true;//隐身
other.mesh=entity.mesh;//设置玩家的外观
other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//设置跑车的旋转角度,没有反不要这个代码
world.say(other.player.name+" 碰到了僵尸,自己也变成了僵尸");//广播消息
other.player.runSpeed = 0.5;//设置跑步的速度
other.player.walkSpeed = 0.2;//设置走路的速度
other.player.scale =0.6;//因为实体比较小,设置玩家的大小小一些
other.player.jumpPower = 0.6;//关闭跳跃能力
other.player.canFly = true;
other.player.hp = 100;
other.player.forceRespawn();
jumpPower: number = 3;
});
});
world.querySelectorAll('.11').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
if(other.player.invisible == false){
other.player.invisible = true;
world.say("恭喜"+other.player.name + "到达跑酷终点,并获得隐身1分钟的奖励!!");
start.splice(find(start,entity.player.name),1);
world.PVP = true;
while (true) {
}
}
})})
world.querySelectorAll('.蓝队').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
//if(other.player.spawnPoint.toString() == z){
e.collides = true;
//}
})})
world.querySelectorAll('.5').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
if(!other.isPlayer){return}
other.mesh=entity.mesh;//设置玩家的外观
other.meshScale=entity.meshScale;//设置玩家的大小
other.player.invisible=true;//隐身
other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//这段代码没法左右旋转!!!!!!!!
world.say(other.player.name+" 开走了敞篷跑车");//广播消息
other.player.runSpeed = 2;//设置跑步的速度
other.player.walkSpeed = 1.5;//设置走路的速度
other.player.scale =0.6;//因为实体比较小,设置玩家的大小小一些
other.player.jumpPower = 1;
other.player.forceRespawn();
});
});