猫史档案馆


【代码】飞镖发射代码教程,附代码注释

用户:星星上的雪花星星上的雪花查看:12 回复:20 评论:12 创建时间:2022-08-04T01:16:21



回复

上一页1 页 / 共 1下一页
星星上的雪花星星上的雪花

自古沙发归作者

点赞0


评论


清瞑月风GUI清瞑月风GUI

针不戳,Very厉害的,我曾研究,但最终不知道

点赞0


评论


星星上的雪花星星上的雪花

顶啊顶

点赞0


评论


呵呵0486呵呵0486

电脑太菜显示不出来图片()

点赞1


评论


星星上的雪花星星上的雪花

顶上去啊

点赞0


评论


星星上的雪花星星上的雪花

再顶!

点赞0


评论


busterbuster

贝 宁 大 战 乌 鸡

点赞0


评论


果冻橙本人果冻橙本人

bushi

点赞0


评论


AokenAoken

dddd

点赞0


评论


BOSS不爱吃鱼的小鱼BOSS不爱吃鱼的小鱼

好家伙,厉害厉害

点赞0


评论


浮生awa浮生awa

为什么我看不到啊

点赞0


评论


星星上的雪花星星上的雪花

如果不能正常显示或看不到 请访问【bcmcreator.cn/edit/examples/yll.php?xjm=1804620410&k=3】 查看代码!

点赞0


评论


原坏三老旅长原坏三老旅长

center_image

扔了点好玩的东西

点赞1


评论


星辰_零柒星辰_零柒

被封号是个什么情况()()

点赞0


评论


指令者指令者

怎么右键显示喵排行榜

点赞0


评论


睿策升华重生版睿策升华重生版

constModelDart=world.querySelector("#古代飞行器-1"),//发射的飞镖实体WearDart=world.querySelector("#古代飞行器-2");//穿戴的飞镖模型[ModelDart,WearDart].forEach(e=>e.destroy());//销毁这2个实体world.addCollisionFilter(".dart","*");//过滤飞镖和实体的碰撞world.onPlayerJoin(async({entity})=>{entity.sending=false;//设置玩家飞镖未发射entity.enableDamage=true;//支持受伤entity.hp=entity.maxHp=100;//设置血量entity.kill=0;//连斩数entity.dart=entity.player.addWearable({//穿戴的飞镖模型mesh:WearDart.mesh.valueOf(),scale:WearDart.meshScale.scale(16),orientation:WearDart.meshOrientation.clone(),bodyPart:"torso",offset:[-0.35,0.2,-0喵],emissive:0.01,});entity.enableInteract=true;entity.interactRadius=1024;entity.interactHint=`${entity.player.name}:连斩0人`;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);});world.onDie(async({entity,attacker})=>{if(!entity.isPlayer){//如果的实体不是玩家entity.destroy();//销毁return;};entity.kill=0;//因为玩家逝逝,所以该玩家的连斩数清零entity.interactHint=`${entity.player.name}:连斩0人`;entity.player.directMessage("你被击杀了\n将在5秒钟后复活");setTimeout(()=>{entity.hp=+entity.maxHp;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);},5e3);//等待5秒钟后复活if(!attacker)return;//世界广播(因为只斩1人不算连续击杀,所以只有连斩数大于1时才播报连斩数)world.say(`${attacker.player.name}击杀了${entity.player.name}${(++attacker.kill)>1?`\n连斩${attacker.kill}人`:""}`);attacker.interactHint=`${attacker.player.name}:连斩${attacker.kill}人`;});world.onPress(async({entity,button,raycast:{hit,hitEntity:target,hitPosition,hitVoxel,direction}})=>{//如果飞镖已经发射、或按键不是鼠标左键,就不执行后面的代码if(entity.sending||button!="action0"||entity.player.dead)return;entity.sending=true;//设置飞镖已经发射entity.dart.mesh="";//隐藏玩家身上的飞镖模型constdart=world.createEntity(ModelDart);//创建新飞镖实体dart.addTag("dart");//添加标签,以过滤碰撞dart.position.copy(hitVoxel?hitPosition.sub(direction.scale(5)):entity.position);if(target){if(target.hasTag("dart"))target=null;};while((entity.player.action0Button||target)&&!entity.destroyed&&!entity.player.dead){dart.meshOrientation=dart.meshOrientation.rotateY(0.5);if(hit){if(target){dart.fixed=true;target.velocity.y=0.3;target.hurt(5+Math.random()*5,{attacker:entity});dart.position=target.position.clone();if(target.hp<=0)break;}elseif(hitVoxel){dart.velocity=direction.scale(2);};}else{dart.velocity=direction.scale(2);};awaitsleep(64);};dart.fixed=false;while(!entity.destroyed&&!entity.player.dead&&dart.position.distance(entity.position)>2){dart.meshOrientation=dart.meshOrientation.rotateY(-(entity.player.crouchButton?0.8:0.5));dart.velocity=dart.position.towards(entity.position).scale((entity.player.crouchButton?3:2)/dart.position.distance(entity.position));awaitsleep(64);};entity.sending=false;dart.destroy();entity.dart.mesh=ModelDart.mesh.valueOf();});world.onVoxelContact(async({entity,x,y,z,voxel:type})=>{if(!entity.hasTag("dart"))return;voxels.setVoxelId(x,y,z,0);awaitsleep(2e3+Math.random()*0.5e3);voxels.setVoxelId(x,y,z,type);});world.querySelectorAll("*").forEach(e=>{e.collides=true;e.gravity=true;e.fixed=false;e.enableDamage=true;e.hp=e.maxHp=100;});

点赞0


评论


AokenAoken

ddd

点赞0


评论


天冷记得盖被子天冷记得盖被子

厉害厉害

点赞0


评论


yee剑走天下yee剑走天下

sc

点赞0


评论


༿༺闪ོ༒电ོ༻༾༿༺闪ོ༒电ོ༻༾

constModelDart=world.querySelector("#古代飞行器-1"),//发射的飞镖实体WearDart=world.querySelector("#古代飞行器-2");//穿戴的飞镖模型[ModelDart,WearDart].forEach(e=>e.destroy());//销毁这2个实体world.a喵CollisionFilter(".dart","*");//过滤飞镖和实体的碰撞world.onPlayerJoin(async({entity})=>{entity.sending=false;//设置玩家飞镖未发射entity.enableDamage=true;//支持受伤entity.hp=entity.maxHp=100;//设置血量entity.kill=0;//连斩数entity.dart=entity.player.a喵Wearable({//穿戴的飞镖模型mesh:WearDart.mesh.valueOf(),scale:WearDart.meshScale.scale(16),orientation:WearDart.meshOrientation.clone(),bodyPart:"torso",offset:[-0.35,0.2,-0喵],emissive:0.01,});entity.enableInteract=true;entity.interactRadius=1024;entity.interactHint=`${entity.player.name}:连斩0人`;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);});world.onDie(async({entity,attacker})=>{if(!entity.isPlayer){//如果的实体不是玩家entity.destroy();//销毁return;};entity.kill=0;//因为玩家逝逝,所以该玩家的连斩数清零entity.interactHint=`${entity.player.name}:连斩0人`;entity.player.directMessage("你被击杀了\n将在5秒钟后复活");setTimeout(()=>{entity.hp=+entity.maxHp;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);},5e3);//等待5秒钟后复活if(!attacker)return;//世界广播(因为只斩1人不算连续击杀,所以只有连斩数大于1时才播报连斩数)world.say(`${attacker.player.name}击杀了${entity.player.name}${(++attacker.kill)>1?`\n连斩${attacker.kill}人`:""}`);attacker.interactHint=`${attacker.player.name}:连斩${attacker.kill}人`;});world.onPress(async({entity,button,raycast:{hit,hitEntity:target,hitPosition,hitVoxel,direction}})=>{//如果飞镖已经发射、或按键不是鼠标左键,就不执行后面的代码if(entity.sending||button!="action0"||entity.player.dead)return;entity.sending=true;//设置飞镖已经发射entity.dart.mesh="";//隐藏玩家身上的飞镖模型constdart=world.createEntity(ModelDart);//创建新飞镖实体dart.a喵Tag("dart");//添加标签,以过滤碰撞dart.position.copy(hitVoxel?hitPosition.sub(direction.scale(5)):entity.position);if(target){if(target.hasTag("dart"))target=null;};while((entity.player.action0Button||target)&&!entity.destroyed&&!entity.player.dead){dart.meshOrientation=dart.meshOrientation.rotateY(0.5);if(hit){if(target){dart.fixed=true;target.velocity.y=0.3;target.hurt(5+Math.random()*5,{attacker:entity});dart.position=target.position.clone();if(target.hp<=0)break;}elseif(hitVoxel){dart.velocity=direction.scale(2);};}else{dart.velocity=direction.scale(2);};awaitsleep(64);};dart.fixed=false;while(!entity.destroyed&&!entity.player.dead&&dart.position.distance(entity.position)>2){dart.meshOrientation=dart.meshOrientation.rotateY(-(entity.player.crouchButton?0.8:0.5));dart.velocity=dart.position.towards(entity.position).scale((entity.player.crouchButton?3:2)/dart.position.distance(entity.position));awaitsleep(64);};entity.sending=false;dart.destroy();entity.dart.mesh=ModelDart.mesh.valueOf();});world.onVoxelContact(async({entity,x,y,z,voxel:type})=>{if(!entity.hasTag("dart"))return;voxels.setVoxelId(x,y,z,0);awaitsleep(2e3+Math.random()*0.5e3);voxels.setVoxelId(x,y,z,type);});world.querySelectorAll("*").forEach(e=>{e.collides=true;e.gravity=true;e.fixed=false;e.enableDamage=true;e.hp=e.maxHp=100;});

点赞0


评论