大佬教你在游戏中制作非常牛逼的导弹防御塔

2021-08-25 16:30:04

  当然也能防空

  如图所示,一个导弹防御塔

  下面来说说怎么做到的呢......

  首先你需要搭建一个塔(废话)样式随意,自己觉得不难看就行。

  然后就需要做导弹部分了。

  玩过一段时间mc的玩家都知道,火球在mc是呈直线运动的,但是明显图里的火球拐了弯。

  那么怎么才能让火球锁定目标并作出轨迹的改变呢,那就先从空间直角坐标系说起吧

  空间直角坐标系(此图来源于百度)

  上过高中的人都学过这个,上过初中的也学过平面直角坐标系,可以类推。

  由此图可见坐标系被三个平面分为了8个部分,3个平面又被三条轴细分成12个小平面,三条轴又被原点细分成6条射线,那么加起来一共就有8+12+6=26个区域

  假设目标位置就是原点O,那我们只要穷举出火球在26个区域内的可能,并更改火球的运动方向,那么火球就会不断的向原点O靠近。

  如图:

  箭头所示,如果火球在1区域内,会先斜向下运动,直到到达yoz平面再斜向下运动,直到到达x轴,之后沿着x轴运动到达原点。

  至此原理部分就说完了,相信有数学基础的人都能理解。

  之后给出指令(以下指令基于1.8版本【ps因为作者偷懒没在高版本做】,高版本只需把其中实体名称换掉,如ArmorStand→armor_stand)

  首先创建攻击目标的计分板:

  /scoreboard objectives add attack dummy

  然后是穷举26个方位:(以下指令需要高频/循环)

  分为8个区域,12个小平面,6条单向轴/execute @e[score_attack_min=1] ~1 ~2 ~-101 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[-0.81,-0.81,0.81]}

  /execute @e[score_attack_min=1] ~1 ~-100 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[-0.81,0.81,-0.81]}

  /execute @e[score_attack_min=1] ~1 ~2 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[-0.81,-0.81,-0.81]}

  /execute @e[score_attack_min=1] ~1 ~-100 ~-101 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[-0.81,0.81,0.81]}

  /execute @e[score_attack_min=1] ~-101 ~2 ~-101 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[0.81,-0.81,0.81]}

  /execute @e[score_attack_min=1] ~-101 ~2 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[0.81,-0.81,-0.81]}

  /execute @e[score_attack_min=1] ~-101 ~-100 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[0.81,0.81,-0.81]}

  /execute @e[score_attack_min=1] ~-101 ~-100 ~-101 /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=100] {direction:[0.81,0.81,0.81]}

  /execute @e[score_attack_min=1] ~-101 ~1 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=100] {direction:[0.99,0.0,-0.99]}

  /execute @e[score_attack_min=1] ~1 ~1 ~1 /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=100] {direction:[-0.99,0.0,-0.99]}

  /execute @e[score_attack_min=1] ~1 ~1 ~-1 /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=100] {direction:[-0.99,0.0,0.99]}

  /execute @e[score_attack_min=1] ~-101 ~1 ~-101 /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=100] {direction:[0.99,0.0,0.99]}

  /execute @e[score_attack_min=1] ~-101 ~2 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=0] {direction:[0.99,-0.99,0.0]}

  /execute @e[score_attack_min=1] ~1 ~-100 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=0] {direction:[-0.99,0.99,0.0]}

  /execute @e[score_attack_min=1] ~1 ~2 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=0] {direction:[-0.99,-0.99,0.0]}

  /execute @e[score_attack_min=1] ~-101 ~-100 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=100,dz=0] {direction:[0.99,0.99,0.0]}

  /execute @e[score_attack_min=1] ~ ~-100 ~1 /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=100] {direction:[0.0,0.99,-0.99]}

  /execute @e[score_attack_min=1] ~ ~2 ~-101 /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=100] {direction:[0.0,-0.99,0.99]}

  /execute @e[score_attack_min=1] ~ ~2 ~1 /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=100] {direction:[0.0,-0.99,-0.99]}

  /execute @e[score_attack_min=1] ~ ~-100 ~-101 /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=100] {direction:[0.0,0.99,0.99]}

  /execute @e[score_attack_min=1] ~ ~2 ~ /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=0] {direction:[0.0,-1.4,0.0]}

  /execute @e[score_attack_min=1] ~1 ~1 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=0] {direction:[-1.4,0.0,0.0]}

  /execute @e[score_attack_min=1] ~-101 ~1 ~ /entitydata @e[type=Fireball,name=233,dx=100,dy=0,dz=0] {direction:[1.4,0.0,0.0]}

  /execute @e[score_attack_min=1] ~ ~-100 ~ /entitydata @e[type=Fireball,name=233,dx=0,dy=100,dz=0] {direction:[0.0,1.4,0.0]}

  /execute @e[score_attack_min=1] ~ ~1 ~1 /entitydata @e[type=Fireball,name=233,dx=0,dy=0,dz=100] {direction:[0.0,0.0,-1.4]}

  /execute @e[score_attack_min=1] ~ ~1 ~-101 /entitydata @e[type=Fireball,name=233,dx=0,dy=0,dz=100] {direction:[0.0,0.0,1.4]}

  这样就能做到一个名为233的火球无限靠近目标了

  之后为了提高命中率,让火球靠近目标即爆炸:

  /execute @e[score_attack_min=1] ~ ~ ~ /execute @e[type=Fireball,name=233,r=2] ~ ~ ~ /summon Creeper ~ ~ ~ {ExplosionRadius:2,Fuse:-1,ActiveEffects:[{Id:14,Duration:99999}],CustomName:导弹}

  /execute @e[score_attack_min=1] ~ ~ ~ /execute @e[type=Fireball,name=233,r=2] ~ ~ ~ /kill @e[type=Fireball,r=2]

  为了好看我们加点特效:

  /execute @e[type=Fireball] ~ ~ ~ /particle flame ~ ~ ~ 0.01 0.01 0.01 0.06 8 force

  到此为止追踪及命中部分

  就搞定了,下面来说发射部分,由上述指令可知,只要召唤一个名字为233的火球,这个火球就会追着计分板attack至少为1的玩家跑。

  首先我们在防御塔里面放一个盔甲架:

  /summon ArmorStand ~ ~ ~ {CustomName:"2333",CustomNameVisible:0b,NoGravity:0,Invisible:1}

  之后可用低频脉冲顺序激活下列指令:(如五秒激活一次)

  /execute @e[type=ArmorStand,name=2333] ~ ~ ~ /scoreboard players set @e[r=70] attack 0

  /execute @e[type=ArmorStand,name=2333] ~ ~ ~ /scoreboard players set @e[name=!233,c=1,r=50,rm=1] attack 1

  /execute @e[score_attack_min=1] ~ ~ ~ /execute @e[type=ArmorStand,name=2333] ~ ~ ~ /summon Fireball ~ ~20 ~ {CustomName:"233",CustomNameVisible:0b,direction:[0.0,2.0,0.0],ExplosionPower:2}

  /execute @e[type=ArmorStand,name=2333] ~ ~ ~ /execute @e[type=Fireball,name=233,r=60] ~ ~ ~ /playsound fireworks.launch @a[r=60] ~ ~ ~ 100 0 0

  这样就会自动检测2333盔甲架周围50格的最近玩家并锁定,每激活一次发射一次导弹。

  然后导弹防御塔就大功告成了!

特色标签

精彩合集,奇葩无下限 更多

最新游戏

更多

最新专题

更多

相关文章