mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Fixed #3037
This commit is contained in:
parent
c27251cfb0
commit
9060a9518a
@ -185,14 +185,18 @@ public class SectorDamage{
|
||||
}
|
||||
|
||||
//create sparse tile array for fast range query
|
||||
int sparseSkip = 6;
|
||||
int sparseSkip = 5, sparseSkip2 = 3;
|
||||
//TODO if this is slow, use a quadtree
|
||||
Seq<Tile> sparse = new Seq<>(path.size / sparseSkip + 1);
|
||||
Seq<Tile> sparse2 = new Seq<>(path.size / sparseSkip2 + 1);
|
||||
|
||||
for(int i = 0; i < path.size; i++){
|
||||
if(i % sparseSkip == 0){
|
||||
sparse.add(path.get(i));
|
||||
}
|
||||
if(i % sparseSkip2 == 0){
|
||||
sparse2.add(path.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
//regen is in health per second
|
||||
@ -202,8 +206,11 @@ public class SectorDamage{
|
||||
|
||||
//first, calculate the total health of blocks in the path
|
||||
|
||||
for(Tile t : path){
|
||||
int radius = 2;
|
||||
//radius around the path that gets counted
|
||||
int radius = 7;
|
||||
IntSet counted = new IntSet();
|
||||
|
||||
for(Tile t : sparse2){
|
||||
|
||||
//radius is square.
|
||||
for(int dx = -radius; dx <= radius; dx++){
|
||||
@ -212,7 +219,7 @@ public class SectorDamage{
|
||||
if(wx >= 0 && wy >= 0 && wx < world.width() && wy < world.height()){
|
||||
Tile tile = world.rawTile(wx, wy);
|
||||
|
||||
if(tile.build != null && tile.team() == state.rules.defaultTeam){
|
||||
if(tile.build != null && tile.team() == state.rules.defaultTeam && counted.add(tile.pos())){
|
||||
//health is divided by block size, because multiblocks are counted multiple times.
|
||||
sumHealth += tile.build.health / tile.block().size;
|
||||
totalPathBuild += 1f / tile.block().size;
|
||||
@ -228,7 +235,7 @@ public class SectorDamage{
|
||||
for(Building build : Groups.build){
|
||||
float e = build.efficiency();
|
||||
if(e > 0.08f){
|
||||
if(build.team == state.rules.defaultTeam && build instanceof Ranged ranged && sparse.contains(t -> t.within(build, ranged.range()))){
|
||||
if(build.team == state.rules.defaultTeam && build instanceof Ranged ranged && sparse.contains(t -> t.within(build, ranged.range() + radius*tilesize))){
|
||||
if(build.block instanceof Turret t && build instanceof TurretBuild b && b.hasAmmo()){
|
||||
sumDps += t.shots / t.reloadTime * 60f * b.peekAmmo().estimateDPS() * e;
|
||||
}
|
||||
@ -304,7 +311,7 @@ public class SectorDamage{
|
||||
//enemy units like to aim for a lot of non-essential things, so increase resulting health slightly
|
||||
info.sumHealth = sumHealth * 1.2f;
|
||||
//players tend to have longer range units/turrets, so assume DPS is higher
|
||||
info.sumDps = sumDps * 1.2f;
|
||||
info.sumDps = sumDps * 1.5f;
|
||||
info.sumRps = sumRps;
|
||||
|
||||
//finally, find an equation to put it all together and produce a 0-1 number
|
||||
|
@ -83,7 +83,7 @@ public class ItemTurret extends Turret{
|
||||
public void displayBars(Table bars){
|
||||
super.displayBars(bars);
|
||||
|
||||
bars.add(new Bar("blocks.ammo", Pal.ammo, () -> (float)totalAmmo / maxAmmo)).growX();
|
||||
bars.add(new Bar("stat.ammo", Pal.ammo, () -> (float)totalAmmo / maxAmmo)).growX();
|
||||
bars.row();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user