mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-09-22 13:01:12 +03:00
Shield absorption support for flame/point laser bullets
This commit is contained in:
@@ -298,7 +298,7 @@ public class Damage{
|
||||
* If the shields only absorb part of the damage, the bullet's damage is reduced accordingly.
|
||||
* @return the length of the laser, cut short if a shield absorbed it.
|
||||
*/
|
||||
private static float findShieldLength(Bullet b, float length, boolean laser, boolean absorb){
|
||||
public static float findShieldLength(Bullet b, float length, boolean laser, boolean absorb){
|
||||
float damage = b.type.shieldDamage(b);
|
||||
if(!(laser || b.type.shieldAbsorb) || length <= 0f || damage <= 0f) return length;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ContinuousFlameBulletType extends ContinuousBulletType{
|
||||
hitColor = colors[1].cpy().a(1f);
|
||||
lightColor = hitColor;
|
||||
lightOpacity = 0.7f;
|
||||
laserAbsorb = false;
|
||||
laserAbsorb = true;
|
||||
ammoMultiplier = 1f;
|
||||
pierceArmor = true;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,14 @@ public class PointLaserBulletType extends BulletType{
|
||||
updateTrailEffects(b);
|
||||
updateBulletInterval(b);
|
||||
|
||||
float dst = b.dst(b.aimX, b.aimY);
|
||||
float length = Damage.findShieldLength(b, dst, true, laserAbsorb);
|
||||
if(length < dst){
|
||||
Tmp.v1.set(b.aimX - b.x, b.aimY - b.y).setLength(length);
|
||||
b.aimX = Tmp.v1.x + b.x;
|
||||
b.aimY = Tmp.v1.y + b.y;
|
||||
}
|
||||
|
||||
if(b.timer.get(0, damageInterval)){
|
||||
Damage.collidePoint(b, b.team, hitEffect, b.aimX, b.aimY);
|
||||
}
|
||||
@@ -92,6 +100,11 @@ public class PointLaserBulletType extends BulletType{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float shieldDamage(Bullet b){
|
||||
return b.damage / damageInterval * Time.delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTrailEffects(Bullet b){
|
||||
if(trailChance > 0){
|
||||
|
||||
Reference in New Issue
Block a user