Skip to content

Commit

Permalink
Merge pull request #33 from koiboi-dev/31-anti-missile-fix
Browse files Browse the repository at this point in the history
31 anti missile fix
  • Loading branch information
ColonelKai committed Aug 6, 2022
2 parents 97e7559 + 85b3b51 commit a683354
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.kaiyan.missilewarfare</groupId>
<artifactId>MissileWarfare</artifactId>
<version>1.6.17</version>
<version>1.6.18-preRelease1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion pom/pom-j8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.kaiyan.missilewarfare</groupId>
<artifactId>MissileWarfare</artifactId>
<version>1.6.17</version>
<version>1.6.18-preRelease1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public MissileController(boolean isgroundmissile, Vector startpos, Vector target
launched = false;
this.type = type;


armourStand = world.spawnEntity(pos.toLocation(world), EntityType.ARMOR_STAND);
armourStand.setPersistent(true);
((LivingEntity) armourStand).getEquipment().setHelmet(new ItemStack(Material.RED_CONCRETE));
armourStand.setGravity(false);
((LivingEntity) armourStand).setInvisible(true);
armourStand.setCustomName("MissileHolder");

target = target.add(new Vector((Math.random()-0.5)*accuracy, 0, (Math.random()-0.5)*accuracy));

this.target = target;
Expand Down Expand Up @@ -210,10 +218,13 @@ public void Update(BukkitRunnable run, MissileController other){
this.target = other.pos;
Vector velocity = getVelocityIgnoreY();
pos.add(velocity);
armourStand.teleport(pos.toLocation(world).clone().subtract(new Vector(0, 1.75, 0)));
world.spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, pos.toLocation(world), 0, 0, 0, 0, 0.1, null, true);
world.spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, (pos.toLocation(world).subtract(velocity.divide(new Vector(2,2,2)))), 0, 0, 0, 0, 0.1, null, true);
world.spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE, (pos.toLocation(world)), 0, 0, 0, 0, 0.1, null, true);
world.spawnParticle(Particle.FLAME, pos.toLocation(world), 0, -dir.getX()+(Math.random() - 0.5), -dir.getY()+(Math.random() - 0.5), -dir.getZ()+(Math.random() - 0.5), 0.1);

if (target.distanceSquared(pos) < (speed*speed)*1.1){
if (Math.random()>0.1){
if (Math.random()>0.1){ // chance of failure to detonate?
run.cancel();
return;
}
Expand All @@ -222,7 +233,7 @@ public void Update(BukkitRunnable run, MissileController other){
world.spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, pos.toLocation(world), 0, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5, 0.1, null, true);
world.spawnParticle(Particle.FLAME, pos.toLocation(world), 0, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5, 0.1, null,true);
}
if (other.update != null) {
if (other.update != null && !other.update.isCancelled()) {
other.explode(other.update);
run.cancel();
}
Expand Down Expand Up @@ -376,6 +387,8 @@ public Vector getVelocity(){
velocity.setZ(velocity.getZ());
return velocity;
}


public Vector getVelocityIgnoreY(){
Vector velocity = new Vector(0, 0, 0);

Expand Down

0 comments on commit a683354

Please sign in to comment.