Skip to content

Commit

Permalink
Revert "Properly handle missile units shooting more missile units (#8359
Browse files Browse the repository at this point in the history
)" (#8585)

This reverts commit 1373381.
  • Loading branch information
MEEPofFaith authored May 12, 2023
1 parent 0496d21 commit 688b5b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions core/src/mindustry/entities/bullet/BulletType.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public void drawLight(Bullet b){

public void init(Bullet b){

if(killShooter && b.owner() instanceof Healthc h && !h.dead()){
if(killShooter && b.owner() instanceof Healthc h){
h.kill();
}

Expand Down Expand Up @@ -700,6 +700,7 @@ public ContentType getContentType(){
return create(owner, team, x, y, angle, -1, velocityScl, lifetimeScl, null);
}


public @Nullable Bullet create(Entityc owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Mover mover){
return create(owner, team, x, y, angle, -1, velocityScl, lifetimeScl, null, mover);
}
Expand Down Expand Up @@ -731,27 +732,24 @@ public ContentType getContentType(){
Unit spawned = spawnUnit.create(team);
spawned.set(x, y);
spawned.rotation = angle;

//immediately spawn at top speed, since it was launched
if(spawnUnit.missileAccelTime <= 0f){
spawned.vel.trns(angle, spawnUnit.speed);
}

//assign unit owner
if(spawned.controller() instanceof MissileAI ai){
if(owner instanceof Unit unit){
ai.shooter = unit;
}

if(owner instanceof ControlBlock control){
ai.shooter = control.unit();
}

}
spawned.add();
}

//Since bullet init is never called, handle killing shooter here
if(killShooter && owner instanceof Healthc h && !h.dead()) h.kill();

//no bullet returned
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions core/src/mindustry/type/Weapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*;
import mindustry.audio.*;
import mindustry.content.*;
Expand Down Expand Up @@ -457,8 +456,7 @@ protected void bullet(Unit unit, WeaponMount mount, float xOffset, float yOffset
lifeScl = bullet.scaleLife ? Mathf.clamp(Mathf.dst(bulletX, bulletY, mount.aimX, mount.aimY) / bullet.range) : 1f,
angle = angleOffset + shootAngle + Mathf.range(inaccuracy + bullet.inaccuracy);

Entityc shooter = unit.controller() instanceof MissileAI ai ? ai.shooter : unit; //Pass the missile's shooter down to its bullets
mount.bullet = bullet.create(shooter, unit.team, bulletX, bulletY, angle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, mount.aimX, mount.aimY);
mount.bullet = bullet.create(unit, unit.team, bulletX, bulletY, angle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, mount.aimX, mount.aimY);
handleBullet(unit, mount, mount.bullet);

if(!continuous){
Expand Down

0 comments on commit 688b5b9

Please sign in to comment.