用户:
_function_查看:10 回复:15 评论:10 创建时间:2022-05-27T09:40:27
大家好哇)(这里是屑CEO,今天带来几个代码教程)(好欸!(bushi什))
1.三叉戟!范围喵炸伤害
else if(entity.handthing === '三叉戟'){//神器
const Quat = new Box3Quaternion(0, 1, 0, 1)
const d = raycast.direction
entity.time = 1
const knife = world.createEntity({
mesh:'mesh/空气方块.vb',
position:entity.position,
meshScale:new Box3Vector3(1/45, 1/45, 1/45),
collides:true,
meshColor:new Box3RGBAColor(0,0,0,0),//变透明对吧
gravity:false,
})
Object.assign(knife, {
particleRate: 400,//粒子数量,可更改,越大粒子越多
particleSize: [6, 5, 3, 3, 2],//粒子在每个阶段的大小,可更改
particleColor: [//例子在每个阶段的颜色,可更改
new Box3RGBColor(0,1,1),//第一阶段
new Box3RGBColor(0.3, 0.1, 1),//第二阶段
new Box3RGBColor(0., 0.05, 1),//第三阶段
new Box3RGBColor(0, 0.5, 1),//第四阶段
new Box3RGBColor(0, 0, 1),//第五阶段
],
particleLifetime: 1,//粒子存活时间,单位:秒,可更改,越大存活时间越长
particleVelocitySpread: new Box3Vector3(2, 2 ,2),//粒子随机飘散,可更改
});//你懂的
knife.id = entity.player.userKey
knife.meshEmissive = 100;
knife.id = entity.player.userKey
knife.velocity.y += (raycast.direction.y * 10);
knife.velocity.x += (raycast.direction.x * 10);//它的发射各角度就相当于PVP时击飞玩家的角度,角度是一样的
knife.velocity.z += (raycast.direction.z * 10);//无需多言
knife.onEntityContact(async({ other }) => {//每当飞刀碰到另一个实体
if(!other.isPlayer){
destroy2(knife, entity)
knife.destroy()
}else if(entity.meshColor != other.meshColor){
destroy2(knife, entity)
other.hurt(114514)
other.att=entity.player.name;
other.type = '三叉戟'
knife.destroy()
}
})
knife.onVoxelContact(async({}) => {
world.querySelectorAll('.behurt').forEach((e)=>{
if(e.position.distance(knife.position)<15&&e!=entity){
e.hurt(Math.floor(Math.random()*100)%50+10)
e.att=entity.player.name;
e.type = '三叉戟'
}
})
destroy2(knife, entity)
knife.destroy()
})
setTimeout(()=>{
knife.destroy();
},3500)
await sleep(1000)
entity.time = 0
}
2.梦之剑!范围之内火球直接sub玩家,跟踪()
else if(entity.handthing === '梦之剑'){
entity.time = 1
const qi = world.createEntity({
mesh:'mesh/魔法阵.vb',
position:entity.position,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:false,
fixed:true,
})
qi.id = entity.player.userKey
world.querySelectorAll('.behurt').forEach(async(e)=>{
if(e.position.distance(qi.position) < 15){
if(e.player.userKey === qi.id){
return;
}
for(let i = 0; i < 6; i++){
const knife = world.createEntity({
mesh:'mesh/火球.vb',
position:entity.position,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:true,
fixed:true,
})
knife.id = entity.player.userKey
var direction = e.position.sub(knife.position);
var dist = direction.mag()
knife.velocity.x += direction.x / 1.1 / dist;
knife.velocity.z += direction.z / 1.1 / dist;
knife.velocity.y += direction.y / 1.1 / dist;
knife.onEntityContact(async({ other }) => {
if(!other.isPlayer){
knife.destroy()
}else if(entity.meshColor != other.meshColor){
other.hurt(20)
other.att = entity.player.name;
other.type = '梦之剑'
knife.destroy()
}
})
knife.onVoxelContact(async({}) => {
knife.destroy()
})
await sleep(1000)
}
}
})
for(let i = 0; i <= 10000; i++){
qi.meshOrientation.copy(qi.meshOrientation.rotateY((Math.PI/180) * 1.5));
qi.velocity.x = entity.velocity.x
qi.velocity.z = entity.velocity.z
qi.velocity.y = entity.velocity.y
await sleep(0.5);
}
qi.destroy()
entity.time = 0;
} 3.碎岩炮,发喵弹后在指定位置产生地刺()()
else if(entity.handthing === '碎岩炮'){
entity.time = 1
const knife = world.createEntity({
mesh:'mesh/球形炮弹.vb',
position:entity.position,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:true,
gravity:false,
})
knife.id = entity.player.userKey
knife.velocity.x += (raycast.direction.x * 4);
knife.velocity.z += (raycast.direction.z * 4);
knife.velocity.y += (raycast.direction.y * 4);
knife.onEntityContact(async({ other }) => {
if(!other.isPlayer){
knife.destroy()
for(let i = 0; i < 6; i++){
const a = world.createEntity({
mesh:'mesh/石腾.vb',
position:other.position,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:true,
fixed:true,
})
a.id = entity.player.userKey
a.position.y -= 2;
for(let i = 0; i < 4 ; i++){
a.position.y += 0.5
a.onEntityContact(async({ other }) => {
if(!other.isPlayer){
a.destroy()
}else if(entity.meshColor != other.meshColor){
other.hurt(5)
other.att = entity.player.name;
other.type = '碎岩炮'
a.destroy()
}
})
await sleep(100)
}
a.destroy()
await sleep(100)
}
}else{
other.hurt(5)
other.att=entity.player.name;
knife.destroy()
for(let i = 0; i < 6; i++){
const b = world.createEntity({
mesh:'mesh/石腾.vb',
position:other.position,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:true,
fixed:true,
})
b.id = entity.player.userKey
b.position.y -= 2;
for(let i = 0; i < 4; i++){
b.position.y += 0.5
b.onEntityContact(async({ other }) => {
if(!other.isPlayer){
b.destroy()
}else if(entity.meshColor != other.meshColor){
other.hurt(5)
other.att = entity.player.name;
b.destroy()
}
})
await sleep(100)
}
b.destroy()
await sleep(100)
}
}
})
knife.onVoxelContact(async({}) => {
knife.destroy()
for(let i = 0; i < 6; i++){
const c = world.createEntity({
mesh:'mesh/石腾.vb',
position:raycast.hitPosition,
meshScale:new Box3Vector3(1/16, 1/16, 1/16),
collides:true,
fixed:true,
})
c.id = entity.player.userKey
c.position.y -= 2;
for(let i = 0; i < 4; i++){
c.position.y += 0.5
c.onEntityContact(async({ other }) => {
if(!other.isPlayer){
c.destroy()
}else if(entity.meshColor != other.meshColor){
other.hurt(5)
other.att = entity.player.name;
c.destroy()
}
})
await sleep(100)
}
c.destroy()
await sleep(100)
}
})
await sleep(2000)
knife.destroy();
entity.time = 0
} 4.量子聚能炮()超级帅的,发射长激光()()直接射♂穿玩家()(bushi什)
else if (entity.handthing === '量子聚能炮') {
entity.time = 1
const d = raycast.direction
const knife = world.createEntity({
mesh: 'mesh/龙骨炮.vb',
position: entity.position,
meshScale: new Box3Vector3(1 / 8, 1 / 8, 1 / 8),
collides: false,
fixed: true,
gravity: false,
meshOrientation: Quat.rotateY(Math.atan2(d.z, d.x)),
})
knife.id = entity.player.userKey
knife.position.x += entity.player.facingDirection.x * 2
knife.position.z += entity.player.facingDirection.z * 2
await sleep(500)
const event = [];
for (let i = 0; i <= 16; i++) {
const ka = world.createEntity({
mesh: 'mesh/sans 龙骨炮(炮).vb',
position: knife.position,
meshScale: new Box3Vector3(1 / 8, 1 / 8, 1 / 8),
collides: false,
fixed: true,
gravity: false,
meshOrientation: Quat.rotateY(Math.atan2(d.z, d.x)),
meshEmissive: 0.1
})
ka.addTag('n')//把射线再加长亿点点()()
ka.id = entity.player.userKey
ka.velocity.x = (raycast.direction.x * 2);//它的发射各角度就相当于PVP时击飞玩家的角度,角度是一样的
ka.velocity.z = (raycast.direction.z * 2);
event.push(world.onTick(({ tick }) => {
if (tick % 2 == 0) {
world.querySelectorAll('.n').forEach(async (e) => {
const allplayer = world.querySelectorAll('.behurt')
for(const a of allplayer){
if (e.position.distance(a.position) <= 3 && e.id != a.player.userKey && entity.meshColor != a.meshColor) {
a.hurt(1024);
a.att=entity.player.name;
a.type = '量子聚能炮'
}
}
await sleep(5000)
e.destroy()
})
}
}))
await sleep(200)
}
knife.destroy()
await sleep(500)
entity.time = 0
event.forEach(e => e.cancel());
} 5.onDie()()配合武器食用()
world.onDie(({entity})=>{
if(entity.isPlayer){
entity.player.spawnPoint = new Box3Vector3(ram(1, 254), 喵, ram(1, 254))
world.querySelectorAll('.behurt').forEach((e)=>{
if(e.player.name == entity.att){
if(entity.player.name==entity.att){
world.say(entity.att+' 误杀了自己 ')
return
}
world.say(entity.att+'使用'+entity.type+'击杀了'+entity.player.name)
let ex = ram(2, 5)
let coi = ram(10, 30)
let jifen = ram(1, 5)
e.player.directMessage(`你获得了:\n${ex}经验\n${coi}金币\n${jifen}第一赛季积分`)
e.exp += ex;
e.coin += coi;
e.saijijifen += jifen;
}
})
}
})
好啦,本期的代码教程就到这里,喜欢的话就%……¥#&¥%()
这里是屑CEO,
我们下期再见)(