1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-20 04:47:54 +03:00

Fixed liquid turrets not targeting closest fire

This commit is contained in:
Anuken 2021-06-28 11:35:46 -04:00
parent a5c44e7998
commit fcdbd4b117
2 changed files with 16 additions and 6 deletions

View File

@ -581,7 +581,7 @@ public class UnitTypes implements ContentList{
}};
atrax = new UnitType("atrax"){{
speed = 0.5f;
speed = 0.54f;
drag = 0.4f;
hitSize = 13f;
rotateSpeed = 3f;
@ -621,7 +621,7 @@ public class UnitTypes implements ContentList{
}};
spiroct = new UnitType("spiroct"){{
speed = 0.45f;
speed = 0.48f;
drag = 0.4f;
hitSize = 15f;
rotateSpeed = 3f;

View File

@ -100,17 +100,27 @@ public class LiquidTurret extends Turret{
@Override
protected void findTarget(){
if(extinguish && liquids.current().canExtinguish()){
Fire result = null;
float mindst = 0f;
int tr = (int)(range / tilesize);
for(int x = -tr; x <= tr; x++){
for(int y = -tr; y <= tr; y++){
Tile other = world.tileWorld(x + tile.x, y + tile.y);
Tile other = world.tile(x + tile.x, y + tile.y);
var fire = Fires.get(x + tile.x, y + tile.y);
float dst = fire == null ? 0 : dst2(fire);
//do not extinguish fires on other team blocks
if(other != null && Fires.has(x + tile.x, y + tile.y) && (other.build == null || other.team() == team)){
target = Fires.get(x + tile.x, y + tile.y);
return;
if(other != null && fire != null && dst <= range * range && (result == null || dst < mindst) && (other.build == null || other.team() == team)){
result = fire;
mindst = dst;
}
}
}
if(result != null){
target = result;
//don't run standard targeting
return;
}
}
super.findTarget();