Air/ground bullet cleanup

This commit is contained in:
Anuken 2020-07-02 15:52:21 -04:00
parent ee3aedc75f
commit d59aab1a7d
4 changed files with 29 additions and 14 deletions

View File

@ -20,7 +20,7 @@ public class Bullets implements ContentList{
artilleryDense, artilleryPlastic, artilleryPlasticFrag, artilleryHoming, artilleryIncendiary, artilleryExplosive,
//flak
flakScrap, flakLead, flakPlastic, flakExplosive, flakSurge, flakGlass, glassFrag,
flakScrap, flakLead, flakPlastic, flakExplosive, flakSurge, flakGlass, flakGlassFrag, flakPlasticFrag,
//missiles
missileExplosive, missileIncendiary, missileSurge, missileJavelin, missileSwarm,
@ -62,6 +62,7 @@ public class Bullets implements ContentList{
backColor = Pal.plastaniumBack;
frontColor = Pal.plastaniumFront;
despawnEffect = Fx.none;
collidesAir = false;
}};
artilleryPlastic = new ArtilleryBulletType(3.4f, 12, "shell"){{
@ -122,7 +123,7 @@ public class Bullets implements ContentList{
statusDuration = 60f;
}};
glassFrag = new BasicBulletType(3f, 5, "bullet"){{
flakGlassFrag = new BasicBulletType(3f, 5, "bullet"){{
width = 5f;
height = 12f;
shrinkY = 1f;
@ -130,6 +131,7 @@ public class Bullets implements ContentList{
backColor = Pal.gray;
frontColor = Color.white;
despawnEffect = Fx.none;
collidesGround = false;
}};
flakLead = new FlakBulletType(4.2f, 3){{
@ -165,14 +167,25 @@ public class Bullets implements ContentList{
hitEffect = Fx.flakExplosion;
splashDamage = 20f;
splashDamageRadius = 20f;
fragBullet = glassFrag;
fragBullet = flakGlassFrag;
fragBullets = 5;
}};
flakPlasticFrag = new BasicBulletType(2.5f, 10, "bullet"){{
width = 10f;
height = 12f;
shrinkY = 1f;
lifetime = 15f;
backColor = Pal.plastaniumBack;
frontColor = Pal.plastaniumFront;
despawnEffect = Fx.none;
collidesGround = false;
}};
flakPlastic = new FlakBulletType(4f, 6){{
splashDamageRadius = 50f;
splashDamage = 25f;
fragBullet = artilleryPlasticFrag;
fragBullet = flakPlasticFrag;
fragBullets = 6;
hitEffect = Fx.plasticExplosion;
frontColor = Pal.plastaniumFront;

View File

@ -225,14 +225,16 @@ public class Damage{
Units.nearby(rect, cons);
}
if(!complete){
int trad = (int)(radius / tilesize);
Tile tile = world.tileWorld(x, y);
if(tile != null){
tileDamage(team, tile.x, tile.y, trad, damage);
if(ground){
if(!complete){
int trad = (int)(radius / tilesize);
Tile tile = world.tileWorld(x, y);
if(tile != null){
tileDamage(team, tile.x, tile.y, trad, damage);
}
}else{
completeDamage(team, x, y, radius, damage);
}
}else{
completeDamage(team, x, y, radius, damage);
}
}

View File

@ -29,7 +29,7 @@ public class FlakBulletType extends BasicBulletType{
if(b.timer(2, 6)){
Units.nearbyEnemies(b.team(), Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x(), b.y()), unit -> {
if(b.data() instanceof Float || (unit.isFlying() && !collidesAir) || (unit.isGrounded() && !collidesGround)) return;
if(b.data() instanceof Float || !unit.checkTarget(collidesAir, collidesGround)) return;
if(unit.dst(b) < explodeRange){
b.data(0);

View File

@ -75,7 +75,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override
public boolean collides(Hitboxc other){
return type.collides && (other instanceof Teamc && ((Teamc)other).team() != team)
&& !(other instanceof Flyingc && ((((Flyingc)other).isFlying() && !type.collidesAir) || (((Flyingc)other).isGrounded() && !type.collidesGround)))
&& !(other instanceof Flyingc && !((Flyingc)other).checkTarget(type.collidesAir, type.collidesGround))
&& !(type.pierce && collided.contains(other.id())); //prevent multiple collisions
}
@ -107,7 +107,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
public void update(){
type.update(base());
if(type.collidesTiles && type.collides){
if(type.collidesTiles && type.collides && type.collidesGround){
world.raycastEach(world.toTile(lastX()), world.toTile(lastY()), tileX(), tileY(), (x, y) -> {
Building tile = world.ent(x, y);