Fix point defense weapons ignore damage multiplier (#8922)

This commit is contained in:
南门阳德
2023-08-12 23:40:25 +08:00
committed by GitHub
parent 7999eb4c4d
commit a7e8dd126e
2 changed files with 11 additions and 4 deletions

View File

@@ -9,6 +9,8 @@ import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.type.*; import mindustry.type.*;
import static mindustry.Vars.*;
/** /**
* Note that this requires several things: * Note that this requires several things:
* - A bullet with positive maxRange * - A bullet with positive maxRange
@@ -49,8 +51,10 @@ public class PointDefenseWeapon extends Weapon{
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){ protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){
if(!(mount.target instanceof Bullet target)) return; if(!(mount.target instanceof Bullet target)) return;
if(target.damage() > bullet.damage){ // not sure whether it should multiply by the damageMultiplier of the unit
target.damage(target.damage() - bullet.damage); float bulletDamage = bullet.damage * unit.damageMultiplier() * state.rules.unitDamage(unit.team);
if(target.damage() > bulletDamage){
target.damage(target.damage() - bulletDamage);
}else{ }else{
target.remove(); target.remove();
} }

View File

@@ -14,6 +14,8 @@ import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class PointDefenseTurret extends ReloadTurret{ public class PointDefenseTurret extends ReloadTurret{
public final int timerTarget = timers++; public final int timerTarget = timers++;
public float retargetTime = 5f; public float retargetTime = 5f;
@@ -80,8 +82,9 @@ public class PointDefenseTurret extends ReloadTurret{
//shoot when possible //shoot when possible
if(Angles.within(rotation, dest, shootCone) && reloadCounter >= reload){ if(Angles.within(rotation, dest, shootCone) && reloadCounter >= reload){
if(target.damage() > bulletDamage){ float realDamage = bulletDamage * state.rules.blockDamage(team);
target.damage(target.damage() - bulletDamage); if(target.damage() > realDamage){
target.damage(target.damage() - realDamage);
}else{ }else{
target.remove(); target.remove();
} }