Skip to content

Commit

Permalink
Fix point defense weapons ignore damage multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
nanmenyangde committed Aug 12, 2023
1 parent 585104a commit e5a9efb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions core/src/mindustry/type/weapons/PointDefenseWeapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import mindustry.gen.*;
import mindustry.type.*;

import static mindustry.Vars.*;

/**
* Note that this requires several things:
* - A bullet with positive maxRange
Expand Down Expand Up @@ -49,8 +51,10 @@ protected boolean checkTarget(Unit unit, Teamc target, float x, float y, float r
protected void shoot(Unit unit, WeaponMount mount, float shootX, float shootY, float rotation){
if(!(mount.target instanceof Bullet target)) return;

if(target.damage() > bullet.damage){
target.damage(target.damage() - bullet.damage);
// not sure whether it should multiply by the damageMultiplier of the unit
float bulletDamage = bullet.damage * unit.damageMultiplier() * state.rules.unitDamage(unit.team);
if(target.damage() > bulletDamage){
target.damage(target.damage() - bulletDamage);
}else{
target.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import mindustry.graphics.*;
import mindustry.world.meta.*;

import static mindustry.Vars.*;

public class PointDefenseTurret extends ReloadTurret{
public final int timerTarget = timers++;
public float retargetTime = 5f;
Expand Down Expand Up @@ -80,8 +82,9 @@ public void updateTile(){

//shoot when possible
if(Angles.within(rotation, dest, shootCone) && reloadCounter >= reload){
if(target.damage() > bulletDamage){
target.damage(target.damage() - bulletDamage);
float realDamage = bulletDamage * state.rules.blockDamage(team);
if(target.damage() > realDamage){
target.damage(target.damage() - realDamage);
}else{
target.remove();
}
Expand Down

0 comments on commit e5a9efb

Please sign in to comment.