WIP bullet shotgun for T4 tank

This commit is contained in:
Anuken
2022-05-02 22:24:45 -04:00
parent de9a41159f
commit 78f3e23f0b
13 changed files with 48 additions and 14 deletions
@@ -138,6 +138,8 @@ public class BulletType extends Content implements Cloneable{
public boolean makeFire = false;
/** Whether to create hit effects on despawn. Forced to true if this bullet has any special effects like splash damage. */
public boolean despawnHit = false;
/** If true, this bullet will create bullets when it hits anything, not just when it despawns. */
public boolean fragOnHit = true;
/** If true, unit armor is ignored in damage calculations. Ignored for building armor. */
public boolean pierceArmor = false;
@@ -146,7 +148,8 @@ public class BulletType extends Content implements Cloneable{
/** Whether status and despawnHit should automatically be set. */
public boolean setDefaults = true;
public float fragCone = 360f;
public float fragRandomSpread = 360f;
public float fragSpread = 0f;
public float fragAngle = 0f;
public int fragBullets = 9;
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f, fragLifeMin = 1f, fragLifeMax = 1f;
@@ -308,12 +311,11 @@ public class BulletType extends Content implements Cloneable{
Effect.shake(hitShake, hitShake, b);
createFrags(b, x, y);
createPuddles(b, x, y);
if(incendChance > 0 && Mathf.chance(incendChance)){
Damage.createIncend(x, y, incendSpread, incendAmount);
if(fragOnHit){
createFrags(b, x, y);
}
createPuddles(b, x, y);
createIncend(b, x, y);
if(suppressionRange > 0){
//bullets are pooled, require separate Vec2 instance
@@ -327,6 +329,12 @@ public class BulletType extends Content implements Cloneable{
}
}
public void createIncend(Bullet b, float x, float y){
if(incendChance > 0 && Mathf.chance(incendChance)){
Damage.createIncend(x, y, incendSpread, incendAmount);
}
}
public void createPuddles(Bullet b, float x, float y){
if(puddleLiquid != null && puddles > 0){
for(int i = 0; i < puddles; i++){
@@ -361,7 +369,7 @@ public class BulletType extends Content implements Cloneable{
if(fragBullet != null){
for(int i = 0; i < fragBullets; i++){
float len = Mathf.random(1f, 7f);
float a = b.rotation() + Mathf.range(fragCone / 2) + fragAngle;
float a = b.rotation() + Mathf.range(fragRandomSpread / 2) + fragAngle + ((i - fragBullets/2) * fragSpread);
fragBullet.create(b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax), Mathf.random(fragLifeMin, fragLifeMax));
}
}
@@ -373,6 +381,11 @@ public class BulletType extends Content implements Cloneable{
if(despawnHit){
hit(b);
}
if(!fragOnHit){
createFrags(b, b.x, b.y);
}
despawnEffect.at(b.x, b.y, b.rotation(), hitColor);
despawnSound.at(b);
@@ -85,7 +85,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
transient float efficiency;
/** Same as efficiency, but for optional consumers only. */
transient float optionalEfficiency;
/** The efficiency this block would have if consValid() / productionValid() returned true. */
/** The efficiency this block *would* have if shouldConsume() returned true. */
transient float potentialEfficiency;
transient float healSuppressionTime = -1f;
@@ -187,7 +187,6 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
type.collideFloor && (tile == null || tile.floor().hasSurface() || tile.block() != Blocks.air) ||
type.collideTerrain && tile != null && tile.block() instanceof StaticWall
){
type.despawned(self());
remove();
hit = true;
return;