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

View File

@@ -100,17 +100,27 @@ public class LiquidTurret extends Turret{
@Override @Override
protected void findTarget(){ protected void findTarget(){
if(extinguish && liquids.current().canExtinguish()){ if(extinguish && liquids.current().canExtinguish()){
Fire result = null;
float mindst = 0f;
int tr = (int)(range / tilesize); int tr = (int)(range / tilesize);
for(int x = -tr; x <= tr; x++){ for(int x = -tr; x <= tr; x++){
for(int y = -tr; y <= tr; y++){ 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 //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)){ if(other != null && fire != null && dst <= range * range && (result == null || dst < mindst) && (other.build == null || other.team() == team)){
target = Fires.get(x + tile.x, y + tile.y); result = fire;
return; mindst = dst;
} }
} }
} }
if(result != null){
target = result;
//don't run standard targeting
return;
}
} }
super.findTarget(); super.findTarget();