mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Pierce damage decay (#8416)
This commit is contained in:
parent
9c3ddc398c
commit
0122b735a0
@ -46,6 +46,8 @@ public class BulletType extends Content implements Cloneable{
|
||||
public boolean pierceBuilding;
|
||||
/** Maximum # of pierced objects. */
|
||||
public int pierceCap = -1;
|
||||
/** Multiplier of damage decreased per health pierced. */
|
||||
public float pierceDamageFactor = 0f;
|
||||
/** If false, this bullet isn't removed after pierceCap is exceeded. Expert usage only. */
|
||||
public boolean removeAfterPierce = true;
|
||||
/** For piercing lasers, setting this to true makes it get absorbed by plastanium walls. */
|
||||
@ -360,6 +362,8 @@ public class BulletType extends Content implements Cloneable{
|
||||
}else if(build.team != b.team && direct){
|
||||
hit(b);
|
||||
}
|
||||
|
||||
handlePierce(b, initialHealth, x, y);
|
||||
}
|
||||
|
||||
public void hitEntity(Bullet b, Hitboxc entity, float health){
|
||||
@ -385,6 +389,19 @@ public class BulletType extends Content implements Cloneable{
|
||||
if(!wasDead && entity instanceof Unit unit && unit.dead){
|
||||
Events.fire(new UnitBulletDestroyEvent(unit, b));
|
||||
}
|
||||
|
||||
handlePierce(b, health, entity.x(), entity.y());
|
||||
}
|
||||
|
||||
public void handlePierce(Bullet b, float initialHealth, float x, float y){
|
||||
float sub = Math.max(initialHealth*pierceDamageFactor, 0);
|
||||
//subtract health from each consecutive pierce
|
||||
b.damage -= Math.min(b.damage, sub);
|
||||
|
||||
if(removeAfterPierce && b.damage <= 0){
|
||||
b.hit = true;
|
||||
b.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public float damageMultiplier(Bullet b){
|
||||
|
@ -13,8 +13,6 @@ public class RailBulletType extends BulletType{
|
||||
|
||||
public Effect pierceEffect = Fx.hitBulletSmall, pointEffect = Fx.none, lineEffect = Fx.none;
|
||||
public Effect endEffect = Fx.none;
|
||||
/** Multiplier of damage decreased per health pierced. */
|
||||
public float pierceDamageFactor = 1f;
|
||||
|
||||
public float length = 100f;
|
||||
|
||||
@ -37,8 +35,9 @@ public class RailBulletType extends BulletType{
|
||||
return length;
|
||||
}
|
||||
|
||||
void handle(Bullet b, float initialHealth, float x, float y){
|
||||
float sub = Math.max(initialHealth*pierceDamageFactor, 0);
|
||||
@Override
|
||||
public void handlePierce(Bullet b, float initialHealth, float x, float y){
|
||||
float sub = Math.max(initialHealth * pierceDamageFactor, 0);
|
||||
|
||||
if(b.damage <= 0){
|
||||
b.fdata = Math.min(b.fdata, b.dst(x, y));
|
||||
@ -93,14 +92,8 @@ public class RailBulletType extends BulletType{
|
||||
return bullet.team != tile.team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitEntity(Bullet b, Hitboxc entity, float health){
|
||||
super.hitEntity(b, entity, health);
|
||||
handle(b, health, entity.getX(), entity.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitTile(Bullet b, Building build, float x, float y, float initialHealth, boolean direct){
|
||||
handle(b, initialHealth, x, y);
|
||||
handlePierce(b, initialHealth, x, y);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user